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; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 38 | import from Native_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 39 | import from Osmocom_CTRL_Adapter all; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 40 | import from Osmocom_CTRL_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 41 | |
| 42 | import from RSL_Types all; |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 43 | import from RTP_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 44 | import from IPA_Types all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 45 | import from IPA_Emulation all; |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 46 | import from IPA_Testing all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 47 | import from RSL_Emulation all; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 48 | import from RTP_Emulation all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 49 | |
| 50 | import from IPL4asp_Types all; |
| 51 | import from TRXC_Types all; |
| 52 | import from TRXC_CodecPort all; |
| 53 | import from TRXC_CodecPort_CtrlFunct all; |
| 54 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 55 | import from PCUIF_Types all; |
| 56 | import from PCUIF_CodecPort all; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 57 | import from UD_Types all; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 58 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 59 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 60 | import from MobileL3_RRM_Types all; |
| 61 | import from MobileL3_Types all; |
| 62 | import from L3_Templates all; |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 63 | import from L3_Common all; |
| 64 | import from MobileL3_GMM_SM_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 65 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 66 | import from Osmocom_VTY_Functions all; |
| 67 | import from TELNETasp_PortType all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 68 | import from BTS_Tests_LAPDm all; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 69 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 70 | friend module BTS_Tests_SMSCB; |
Vadim Yanitskiy | 7387813 | 2021-05-05 02:22:45 +0200 | [diff] [blame] | 71 | friend module BTS_Tests_VAMOS; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 72 | friend module BTS_Tests_virtphy; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 73 | friend module BTS_Tests_LAPDm; |
Pau Espin Pedrol | 5a012ee | 2020-02-06 19:33:22 +0100 | [diff] [blame] | 74 | friend module BTS_Tests_perf; |
Pau Espin Pedrol | 65d712e | 2021-06-25 13:55:38 +0200 | [diff] [blame] | 75 | friend module BTS_Tests_OML; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 76 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 77 | /* The tests assume a BTS with the following timeslot configuration: |
| 78 | * TS0 : Combined CCCH + SDCCH/4 |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 79 | * TS1 : TCH/F |
| 80 | * TS2 : TCH/F |
| 81 | * TS3 : TCH/F_PDCH (IPA Style) |
| 82 | * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 83 | * TS5 : TCH/H |
| 84 | * TS6 : SDCCH/8 |
| 85 | * TS7 : PDCH |
| 86 | */ |
| 87 | |
| 88 | modulepar { |
| 89 | charstring mp_rsl_ip := "127.0.0.2"; |
| 90 | integer mp_rsl_port := 3003; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 91 | charstring mp_bts_trxc_ip := "127.0.0.1"; |
| 92 | integer mp_bts_trxc_port := 5701; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 93 | charstring mp_pcu_socket := PCU_SOCK_DEFAULT; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 94 | charstring mp_ctrl_ip := "127.0.0.1"; |
| 95 | integer mp_ctrl_port := 4238; |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 96 | charstring mp_bsc_ctrl_ip := "127.0.0.1"; |
| 97 | integer mp_bsc_ctrl_port := 4249; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 98 | charstring mp_rtpem_bind_ip := "127.0.0.1"; |
| 99 | integer mp_rtpem_bind_port := 6766; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 100 | integer mp_tolerance_rxqual := 1; |
| 101 | integer mp_tolerance_rxlev := 3; |
| 102 | integer mp_tolerance_timing_offset_256syms := 0; |
Pau Espin Pedrol | 752ffd5 | 2018-06-07 13:55:45 +0200 | [diff] [blame] | 103 | integer mp_rxlev_exp := 57; |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 104 | integer mp_ul_rxlev_exp := 10; |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 105 | integer mp_ms_power_level_exp := 7; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 106 | integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */ |
| 107 | integer mp_bts_tx_pwr_att_exp := 20; /* Expected Tx Power attenuation wrt to Tx Nominal Output Power, in dB */ |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 108 | integer mp_ms_actual_ta_exp := 0; |
| 109 | integer mp_timing_offset_256syms_exp := 512; |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 110 | integer mp_uplink_power_target := -75; |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 111 | integer mp_uplink_power_hysteresis := 8; /* -83 .. -67 */ |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 112 | /* Time to wait for RSL conn from BTS during startup of test */ |
Philipp Maier | 12567e4 | 2019-04-17 14:10:05 +0200 | [diff] [blame] | 113 | float mp_ipa_up_timeout := 15.0; |
Philipp Maier | e63229e | 2019-04-26 12:21:37 +0200 | [diff] [blame] | 114 | float mp_ipa_up_delay := 0.0; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 115 | /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */ |
| 116 | boolean mp_l1_supports_gprs := false; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 117 | /* how many transceivers do we expect to connect */ |
| 118 | integer mp_transceiver_num := 1; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 119 | /* frequency hopping status */ |
| 120 | boolean mp_freq_hop_enabled := false; |
| 121 | /* frequency hopping parameters */ |
| 122 | FreqHopConfig mp_fh_config; |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 123 | /* configuration for each individual transceiver */ |
| 124 | TrxPars mp_trx_pars; /* see BTS_Tests.default */ |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 125 | /* default Training Sequence Code */ |
| 126 | GsmTsc mp_tsc_def := 7; |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 127 | /* Default interference boundaries in osmo-bsc (in dBm): |
| 128 | * 0(-85) X1(-91) X2(-97) X3(-103) X4(-109) X5(-115) |
| 129 | * Default interference level reported by fake_trx.py: |
| 130 | * 0: -109 >= -85 dBm (no) |
| 131 | * X1: -109 >= -91 dBm (no) |
| 132 | * X2: -109 >= -97 dBm (no) |
| 133 | * X3: -109 >= -103 dBm (no) |
| 134 | * X4: -109 >= -109 dBm (yes) |
| 135 | * X5: -109 >= -115 dBm (no) |
| 136 | * So all channels should be in band 4. */ |
| 137 | uint3_t mp_interf_band := 4; |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 138 | /* T3105 timer (see 3GPP TS 44.018, section 11.1.2) */ |
| 139 | integer mp_ho_t3105_ms := 100; |
| 140 | /* Ny1 counter (see 3GPP TS 44.018, section 11.1.3) */ |
| 141 | integer mp_ho_ny1 := 10; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 142 | } |
| 143 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 144 | type record of RslChannelNr ChannelNrs; |
| 145 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 146 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 147 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 148 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 149 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 150 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 151 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 152 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 153 | |
| 154 | /* L1CTL port (for classic tests) */ |
| 155 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 156 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 157 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 158 | port TRXC_CODEC_PT BTS_TRXC; |
| 159 | var integer g_bts_trxc_conn_id; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 160 | |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 161 | /* VTY connections to both BTS and BSC */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 162 | port TELNETasp_PT BTSVTY; |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 163 | port TELNETasp_PT BSCVTY; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 164 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 165 | /* PCU Interface of BTS */ |
| 166 | port PCUIF_CODEC_PT PCU; |
| 167 | var integer g_pcu_conn_id; |
| 168 | /* Last PCU INFO IND we received */ |
| 169 | var PCUIF_Message g_pcu_last_info; |
| 170 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 171 | /* SI configuration */ |
| 172 | var SystemInformationConfig si_cfg := { |
| 173 | bcch_extended := false, |
| 174 | si1_present := false, |
| 175 | si2bis_present := false, |
| 176 | si2ter_present := false, |
| 177 | si2quater_present := false, |
| 178 | si7_present := false, |
| 179 | si8_present := false, |
| 180 | si9_present := false, |
| 181 | si13_present := false, |
| 182 | si13alt_present := false, |
| 183 | si15_present := false, |
| 184 | si16_present := false, |
| 185 | si17_present := false, |
| 186 | si2n_present := false, |
| 187 | si21_present := false, |
| 188 | si22_present := false |
| 189 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 190 | |
| 191 | /* all logical channels available on the BTS */ |
| 192 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 193 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | /* an individual call / channel */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 197 | type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 198 | port L1CTL_PT L1CTL; |
| 199 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 200 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 201 | port TRXC_CODEC_PT BTS_TRXC; |
| 202 | var integer g_bts_trxc_conn_id; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 203 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 204 | /* port to be initialized optionally to access BSC VTY */ |
| 205 | port TELNETasp_PT BSCVTY; |
| 206 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 207 | timer g_Tguard; |
| 208 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 209 | |
| 210 | var ConnHdlrPars g_pars; |
| 211 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 212 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 213 | |
| 214 | /* PCU Interface of BTS */ |
| 215 | port PCUIF_CODEC_PT PCU; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 216 | |
| 217 | var RTP_Emulation_CT vc_RTPEM; |
| 218 | port RTPEM_CTRL_PT RTPEM_CTRL; |
| 219 | port RTPEM_DATA_PT RTPEM_DATA; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 220 | } |
| 221 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 222 | private function f_init_rsl(charstring id) runs on test_CT { |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 223 | var bitstring trx_mask := '00000000'B; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 224 | var bitstring rfind_mask := '00000000'B; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 225 | var integer trx_count := 0; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 226 | var integer rfind_count := 0; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 227 | var RSLEm_Event ev; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 228 | var ASP_RSL_Unitdata rx_ud; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 229 | timer T; |
| 230 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 231 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 232 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 233 | |
| 234 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 235 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 236 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 237 | |
| 238 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 239 | vc_RSL.start(RSL_Emulation.main(false)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 240 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 241 | /* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here. |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 242 | * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 243 | T.start(mp_ipa_up_timeout); |
| 244 | alt { |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 245 | /* These events are sent by the RSL_Emulation_CT */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 246 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev { |
| 247 | /* Make sure that all transceivers use unique stream ID */ |
| 248 | if (trx_mask[enum2int(ev.sid)] == '1'B) { |
| 249 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 250 | log2str("Duplicate RSL stream ID (", ev.sid, ")")); |
| 251 | } |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 252 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 253 | trx_mask[enum2int(ev.sid)] := '1'B; |
| 254 | trx_count := trx_count + 1; |
| 255 | |
| 256 | log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected"); |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 257 | repeat; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 258 | } |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 259 | /* This message (RF RESource INDication) is sent by the IUT itself */ |
| 260 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ?)) -> value rx_ud { |
| 261 | if (trx_mask[enum2int(rx_ud.streamId)] == '0'B) { |
| 262 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 263 | log2str("Got RF Resource Indication before RSLEM_EV_TRX_UP (", rx_ud.streamId, ")")); |
| 264 | } |
| 265 | if (rfind_mask[enum2int(rx_ud.streamId)] == '1'B) { |
| 266 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 267 | log2str("Duplicate RF Resource Indication ID (", rx_ud.streamId, ")")); |
| 268 | } |
| 269 | |
| 270 | rfind_mask[enum2int(rx_ud.streamId)] := '1'B; |
| 271 | rfind_count := rfind_count + 1; |
| 272 | log(rfind_count, "/", mp_transceiver_num, " RF Resource Indication(s) received"); |
| 273 | if (rfind_count < mp_transceiver_num) { repeat; } |
| 274 | } |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 275 | /* osmo-bts may send us CCCH LOAD INDication or whatever else */ |
| 276 | [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; } |
| 277 | [] T.timeout { |
| 278 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 279 | "Timeout waiting for RSL bring up"); |
| 280 | } |
| 281 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 282 | } |
| 283 | |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 284 | friend type record length(1 .. 256) of TrxParsItem TrxPars; |
| 285 | friend type record TrxParsItem { |
| 286 | GsmArfcn arfcn, |
| 287 | TrxTsPars ts |
| 288 | }; |
| 289 | |
| 290 | friend type record length(8) of TrxTsParsItem TrxTsPars; |
| 291 | friend type record TrxTsParsItem { |
| 292 | PchanConfig config |
| 293 | }; |
| 294 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 295 | friend type record FreqHopPars { |
| 296 | /* Whether frequency hopping is in use */ |
| 297 | boolean enabled, |
| 298 | /* Mobile Allocation Index Offset / Hopping Sequence Number */ |
| 299 | MaioHsn maio_hsn, |
| 300 | /* MA bitmap to be indicated in RR Immediate Assignment */ |
| 301 | MobileAllocationLV ma_map, |
| 302 | /* The actual Mobile Allocation (ARFCN list) to be used */ |
| 303 | L1ctlMA ma |
| 304 | }; |
| 305 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 306 | type record ConnHdlrPars { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 307 | uint8_t trx_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 308 | RslChannelNr chan_nr, |
| 309 | RSL_IE_ChannelMode chan_mode, |
| 310 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 311 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 312 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 313 | RSL_IE_EncryptionInfo encr optional, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 314 | BtsBand bts0_band optional, |
| 315 | |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 316 | /* Training Sequence Code */ |
| 317 | GsmTsc tsc, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 318 | /* Frequency hopping parameters */ |
| 319 | FreqHopPars fhp |
| 320 | }; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 321 | |
| 322 | /* Test-specific parameters */ |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 323 | friend type union TestSpecUnion { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 324 | RllTestCase rll, |
| 325 | TopTestCase top |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 326 | } |
| 327 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 328 | private template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 329 | max_retrans := RACH_MAX_RETRANS_7, |
| 330 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 331 | cell_barr_access := false, |
| 332 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 333 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 334 | }; |
| 335 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 336 | private template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 337 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 338 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 339 | acs := '0'B, |
| 340 | neci := true, |
| 341 | rxlev_access_min := 0 |
| 342 | } |
| 343 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 344 | private template (value) LocationAreaIdentification ts_LAI_default := { |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 345 | mcc_mnc := '262F42'H, |
| 346 | lac := 42 |
| 347 | } |
| 348 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 349 | private template (value) GPRSIndicator ts_GPRSIndicator_def := { |
| 350 | ra_colour := 0, |
| 351 | si13_pos := '0'B |
| 352 | } |
| 353 | |
| 354 | private template (value) SI3RestOctets ts_SI3RestOctets_def |
| 355 | modifies ts_SI3RestOctets := { |
| 356 | gprs_ind := { |
| 357 | presence := CSN1_H, |
| 358 | ind := ts_GPRSIndicator_def |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | private template (value) SI4RestOctets ts_SI4RestOctets_def |
| 363 | modifies ts_SI4RestOctets := { |
| 364 | gprs_ind := { |
Vadim Yanitskiy | ab5363f | 2020-05-05 00:30:22 +0700 | [diff] [blame] | 365 | presence := CSN1_H, |
| 366 | ind := ts_GPRSIndicator_def |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 367 | } |
| 368 | } |
| 369 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 370 | /* Default SYSTEM INFORMATION 3 */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 371 | private template (value) SystemInformation ts_SI3_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 372 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 373 | payload := { |
| 374 | si3 := { |
| 375 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 376 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 377 | ctrl_chan_desc := { |
| 378 | msc_r99 := true, |
| 379 | att := true, |
| 380 | bs_ag_blks_res := 1, |
| 381 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 382 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 383 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 384 | spare := '00'B, |
| 385 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 386 | t3212 := 1 /* 6 minutes */ |
| 387 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 388 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 389 | dn_ind := false, |
| 390 | pwrc := false, |
| 391 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 392 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 393 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 394 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 395 | rach_control := ts_RachCtrl_default, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 396 | rest_octets := valueof(ts_SI3RestOctets_def) |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 397 | } |
| 398 | } |
| 399 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 400 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 401 | private template (value) SystemInformation ts_SI2_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 402 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 403 | payload := { |
| 404 | si2 := { |
| 405 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 406 | ncc_permitted := '11111111'B, |
| 407 | rach_control := ts_RachCtrl_default |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 412 | private template (value) SystemInformation ts_SI4_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 413 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 414 | payload := { |
| 415 | si4 := { |
| 416 | lai := ts_LAI_default, |
| 417 | cell_sel_par := ts_CellSelPar_default, |
| 418 | rach_control := ts_RachCtrl_default, |
| 419 | cbch_chan_desc := omit, |
| 420 | cbch_mobile_alloc := omit, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 421 | rest_octets := valueof(ts_SI4RestOctets_def) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | } |
| 425 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 426 | private function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 427 | runs on test_CT { |
| 428 | log("Setting ", rsl_si_type, ": ", si_enc); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 429 | 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] | 430 | } |
| 431 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 432 | private function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 433 | runs on test_CT { |
| 434 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 435 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 436 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 437 | } |
| 438 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 439 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 440 | map(self:BTSVTY, system:BTSVTY); |
| 441 | f_vty_set_prompts(BTSVTY); |
| 442 | f_vty_transceive(BTSVTY, "enable"); |
| 443 | } |
| 444 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 445 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 446 | map(self:BSCVTY, system:BSCVTY); |
| 447 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 448 | f_vty_transceive(BSCVTY, "enable"); |
| 449 | } |
| 450 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 451 | friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr { |
| 452 | map(self:BSCVTY, system:BSCVTY); |
| 453 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 454 | f_vty_transceive(BSCVTY, "enable"); |
| 455 | } |
| 456 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 457 | /* PCU socket may at any time receive a new INFO.ind */ |
Pau Espin Pedrol | 65d712e | 2021-06-25 13:55:38 +0200 | [diff] [blame] | 458 | friend altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id, |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 459 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 460 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 461 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 462 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 463 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 464 | [] 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] | 465 | 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] | 466 | } |
| 467 | } |
| 468 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 469 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 470 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 471 | timer T := 2.0; |
| 472 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 473 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 474 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 475 | return; |
| 476 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 477 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 478 | |
| 479 | T.start; |
| 480 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 481 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 482 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 483 | 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] | 484 | } |
| 485 | } |
| 486 | } |
| 487 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 488 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 489 | out integer trxc_conn_id) { |
| 490 | var Result res; |
| 491 | |
| 492 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 493 | "", -1, -1, { udp := {} }, {}); |
| 494 | if (not ispresent(res.connId)) { |
| 495 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 496 | "Could not connect to the control (TRXC) interface " & |
| 497 | "of FakeTRX, check your configuration"); |
| 498 | } |
| 499 | trxc_conn_id := res.connId; |
| 500 | } |
| 501 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 502 | /* global init function (without PCUIF connection) */ |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 503 | friend function f_init(uint8_t trx_nr := 0) |
| 504 | runs on test_CT |
| 505 | { |
| 506 | var TrxParsItem trx_pars := mp_trx_pars[trx_nr]; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 507 | var charstring id := testcasename(); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 508 | |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 509 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653. |
| 510 | * TODO: also generate this list dynamically from module parameters. */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 511 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 512 | g_AllChanTypes := { |
| 513 | /* TS 1..4: TCH/F */ |
| 514 | valueof(ts_RslChanNr_Bm(1)), |
| 515 | /* TS 5: TCH/H */ |
| 516 | valueof(ts_RslChanNr_Lm(5,1)), |
| 517 | /* TS 0: SDCCH/4 */ |
| 518 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 519 | /* TS 6: SDCCH/8 */ |
| 520 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 521 | }; |
| 522 | } else { |
| 523 | g_AllChanTypes := { |
| 524 | /* TS 1..4: TCH/F */ |
| 525 | valueof(ts_RslChanNr_Bm(1)), |
| 526 | /* TS 0: SDCCH/4 */ |
| 527 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 528 | /* TS 6: SDCCH/8 */ |
| 529 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 530 | }; |
| 531 | } |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 532 | |
| 533 | g_AllChannels := { }; |
| 534 | |
| 535 | /* Generate list of all logical channels from module parameters */ |
| 536 | for (var integer tn := 0; tn < lengthof(trx_pars.ts); tn := tn + 1) { |
| 537 | select (trx_pars.ts[tn].config) { |
| 538 | case (GSM_PCHAN_CCCH_SDCCH4) { |
| 539 | g_AllChannels := g_AllChannels & |
| 540 | { valueof(ts_RslChanNr_SDCCH4(tn, 0)), |
| 541 | valueof(ts_RslChanNr_SDCCH4(tn, 1)), |
| 542 | valueof(ts_RslChanNr_SDCCH4(tn, 2)), |
| 543 | valueof(ts_RslChanNr_SDCCH4(tn, 3)) }; |
| 544 | } |
| 545 | case (GSM_PCHAN_SDCCH8) { |
| 546 | g_AllChannels := g_AllChannels & |
| 547 | { valueof(ts_RslChanNr_SDCCH8(tn, 0)), |
| 548 | valueof(ts_RslChanNr_SDCCH8(tn, 1)), |
| 549 | valueof(ts_RslChanNr_SDCCH8(tn, 2)), |
| 550 | valueof(ts_RslChanNr_SDCCH8(tn, 3)), |
| 551 | valueof(ts_RslChanNr_SDCCH8(tn, 4)), |
| 552 | valueof(ts_RslChanNr_SDCCH8(tn, 5)), |
| 553 | valueof(ts_RslChanNr_SDCCH8(tn, 6)), |
| 554 | valueof(ts_RslChanNr_SDCCH8(tn, 7)) }; |
| 555 | } |
| 556 | case (GSM_PCHAN_TCHH_TCHF_PDCH) { |
| 557 | g_AllChannels := g_AllChannels & |
| 558 | { valueof(ts_RslChanNr_Lm(tn, 0)), |
| 559 | valueof(ts_RslChanNr_Lm(tn, 1)), |
| 560 | valueof(ts_RslChanNr_Bm(tn)) }; |
| 561 | } |
| 562 | case (GSM_PCHAN_TCHH) { |
| 563 | g_AllChannels := g_AllChannels & |
| 564 | { valueof(ts_RslChanNr_Lm(tn, 0)), |
| 565 | valueof(ts_RslChanNr_Lm(tn, 1)) }; |
| 566 | } |
| 567 | case (GSM_PCHAN_TCHF, GSM_PCHAN_TCHF_PDCH) { |
| 568 | g_AllChannels := g_AllChannels & |
| 569 | { valueof(ts_RslChanNr_Bm(tn)) }; |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 574 | f_init_rsl(id); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 575 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 576 | f_init_vty(id); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 577 | f_ipa_ctrl_start_client(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 578 | |
| 579 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 580 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 581 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 582 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 583 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 584 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 585 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 586 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 587 | |
| 588 | /* Init TRXC interface to FakeTRX */ |
| 589 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 590 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 591 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 592 | /* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */ |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 593 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(2*256)); |
| 594 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_RSSI(-60)); |
Vadim Yanitskiy | de535e0 | 2019-07-26 16:29:27 +0700 | [diff] [blame] | 595 | /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */ |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 596 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_CI(60)); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 597 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 598 | |
| 599 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 600 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 601 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 602 | } |
| 603 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 604 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 605 | friend function f_init_l1ctl() runs on test_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 606 | map(self:L1CTL, system:L1CTL); |
| 607 | f_connect_reset(L1CTL); |
| 608 | } |
| 609 | |
Vadim Yanitskiy | 7387813 | 2021-05-05 02:22:45 +0200 | [diff] [blame] | 610 | friend type function void_fn(charstring id) runs on ConnHdlr; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 611 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 612 | private type record length(8) of FreqHopGroups FreqHopConfig; |
| 613 | |
| 614 | private type record of FreqHopGroup FreqHopGroups; |
| 615 | private type record FreqHopGroup { |
| 616 | uint6_t hsn, |
| 617 | FreqHopGroupItems trx_maio |
| 618 | }; |
| 619 | |
| 620 | private type record of FreqHopGroupItem FreqHopGroupItems; |
| 621 | private type record FreqHopGroupItem { |
| 622 | uint8_t trx_nr, |
| 623 | uint6_t maio |
| 624 | }; |
| 625 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 626 | friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn, |
| 627 | uint8_t trx_nr := 0) |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 628 | { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 629 | var FreqHopGroups groups := mp_fh_config[tn]; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 630 | var integer i, j; |
| 631 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 632 | fhp.enabled := false; |
| 633 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 634 | for (i := 0; i < lengthof(groups); i := i + 1) { |
| 635 | var FreqHopGroup g := groups[i]; |
| 636 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 637 | var FreqHopGroupItem gi := g.trx_maio[j]; |
| 638 | if (gi.trx_nr == trx_nr) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 639 | fhp.maio_hsn.maio := gi.maio; |
| 640 | fhp.maio_hsn.hsn := g.hsn; |
| 641 | fhp.enabled := true; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 642 | break; |
| 643 | } |
| 644 | } |
| 645 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 646 | if (fhp.enabled) { |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 647 | /* Prepare the Mobile Allocation bitmask (length & padding) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 648 | fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */ |
| 649 | fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B); |
| 650 | fhp.ma := { }; /* to be composed below */ |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 651 | |
| 652 | /* Compose the actual Mobile Allocation and the bitmask */ |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 653 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 654 | var FreqHopGroupItem gi := g.trx_maio[j]; |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 655 | var GsmArfcn arfcn := mp_trx_pars[gi.trx_nr].arfcn; |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 656 | fhp.ma := fhp.ma & { valueof(ts_GsmBandArfcn(arfcn)) }; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 657 | fhp.ma_map.ma[gi.trx_nr] := '1'B; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 658 | } |
| 659 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 660 | log("Freq. hopping parameters: ", fhp); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 661 | break; /* We're done */ |
| 662 | } |
| 663 | } |
| 664 | } |
| 665 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 666 | /* create a new test component */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 667 | friend function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 668 | boolean pcu_comp := false, |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 669 | boolean trxc_comp := false, |
| 670 | boolean l1ctl := true) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 671 | runs on test_CT return ConnHdlr { |
| 672 | var charstring id := testcasename(); |
| 673 | var ConnHdlr vc_conn; |
| 674 | |
| 675 | vc_conn := ConnHdlr.create(id); |
| 676 | /* connect to RSL Emulation main component */ |
| 677 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 678 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 679 | |
| 680 | /* The ConnHdlr component may want to talk to some ports directly, |
| 681 | * so we disconnect it from the test_CT and connect it to the component. |
| 682 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 683 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 684 | unmap(self:PCU, system:PCU); |
| 685 | map(vc_conn:PCU, system:PCU); |
| 686 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 687 | if (trxc_comp) { |
| 688 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 689 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 690 | } |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 691 | if (l1ctl) { |
| 692 | map(vc_conn:L1CTL, system:L1CTL); |
| 693 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 694 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 695 | /* Obtain frequency hopping parameters for a given timeslot */ |
| 696 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 697 | f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 698 | } |
| 699 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 700 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 701 | return vc_conn; |
| 702 | } |
| 703 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 704 | private altstep as_Tguard() runs on ConnHdlr { |
| 705 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 706 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 707 | } |
| 708 | } |
| 709 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 710 | friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) { |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 711 | var GsmBandArfcn arfcn := valueof(ts_GsmBandArfcn(mp_trx_pars[0].arfcn)); |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 712 | f_L1CTL_FBSB(L1CTL, arfcn, ccch_mode, mp_rxlev_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 713 | } |
| 714 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 715 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 716 | var TrxcMessage ret; |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 717 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_RSSI(rssi)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 718 | } |
| 719 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 720 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 721 | var TrxcMessage ret; |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 722 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | /* first function started in ConnHdlr component */ |
| 726 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 727 | runs on ConnHdlr { |
| 728 | g_pars := pars; |
| 729 | g_chan_nr := pars.chan_nr; |
| 730 | |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 731 | if (L1CTL.checkstate("Mapped")) { |
| 732 | f_connect_reset(L1CTL); |
| 733 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 734 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 735 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 736 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 737 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 738 | |
| 739 | g_Tguard.start(pars.t_guard); |
| 740 | activate(as_Tguard()); |
| 741 | |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 742 | f_rslem_register(pars.trx_nr, pars.chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 743 | |
| 744 | /* call the user-supplied test case function */ |
| 745 | fn.apply(id); |
| 746 | } |
| 747 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 748 | private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, |
| 749 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 750 | runs on ConnHdlr return RSL_Message { |
| 751 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 752 | timer T := 3.0; |
| 753 | RSL.send(tx); |
| 754 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 755 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 756 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 757 | T.stop; |
| 758 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 759 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 760 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 761 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 762 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 763 | [not ignore_other] as_l1_sacch(); |
| 764 | [not ignore_other] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 765 | [not ignore_other] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 766 | [not ignore_other] as_l1_tch_loop(); |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 767 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 768 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 769 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 770 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 771 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 772 | return rx; |
| 773 | } |
| 774 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 775 | friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, |
| 776 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 777 | runs on ConnHdlr { |
| 778 | 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] | 779 | } |
| 780 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 781 | /* Send the given measurement results to the IUT over the Um interface, |
| 782 | * wait for the IUT to receive then and forward over the A-bis/RSL interface. */ |
| 783 | friend function f_transceive_meas_rep(template (value) MeasurementResults meas_res) |
| 784 | runs on ConnHdlr { |
| 785 | var template (value) SacchL1Header l1h; |
| 786 | var octetstring l2, l3; |
| 787 | timer T; |
| 788 | |
| 789 | /* RR Measurement Report to be sent */ |
| 790 | var GsmRrL3Message meas_rep := { |
| 791 | header := valueof(t_RrL3Header(MEASUREMENT_REPORT)), |
| 792 | payload := { meas_rep := { meas_res := valueof(meas_res) } } |
| 793 | }; |
| 794 | |
| 795 | /* TITAN has weird (and often unusable) padding model, so we pad here manaully */ |
| 796 | l3 := f_pad_oct(enc_GsmRrL3Message(meas_rep), 18, '00'O); |
| 797 | l2 := f_pad_oct(enc_LapdmFrameAB(valueof(ts_LAPDm_AB(0, meas_rep))), 21, '00'O); |
| 798 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, |
| 799 | g_pars.l1_pars.ms_actual_ta); |
| 800 | |
| 801 | /* Send RR Measurement Report over the Um interface */ |
| 802 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2)); |
| 803 | |
| 804 | /* Expect MEASurement RESult on the A-bis/RSL interface */ |
| 805 | T.start(2.0); |
| 806 | alt { |
| 807 | [] RSL.receive(tr_RSL_MEAS_RES_OSMO(g_chan_nr, l3_info := l3)) { |
| 808 | setverdict(pass); |
| 809 | } |
| 810 | [] RSL.receive { repeat; } |
| 811 | [] T.timeout { |
| 812 | setverdict(fail, "Timeout waiting for RSL MEASurement RESult"); |
| 813 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 814 | } |
| 815 | } |
| 816 | } |
| 817 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 818 | friend function f_rsl_chan_act(RSL_IE_ChannelMode mode, |
| 819 | boolean encr_enable := false, |
| 820 | RSL_IE_List more_ies := {}, |
| 821 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) |
| 822 | runs on ConnHdlr { |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 823 | 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] | 824 | if (encr_enable) { |
| 825 | /* append encryption related IEs, if requested */ |
| 826 | var RSL_IE_EncryptionInfo encr_info; |
| 827 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 828 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 829 | encr_info})) }; |
| 830 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 831 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 832 | 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] | 833 | } |
| 834 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 835 | friend function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 836 | 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] | 837 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 838 | } |
| 839 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 840 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Vadim Yanitskiy | e6c1755 | 2021-06-01 01:20:55 +0200 | [diff] [blame] | 841 | template RSL_IE_ChannelMode chan_mode, |
| 842 | template (omit) TestSpecUnion spec := omit, |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 843 | uint8_t trx_nr := 0, float t_guard := 20.0) := { |
| 844 | trx_nr := trx_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 845 | chan_nr := valueof(chan_nr), |
| 846 | chan_mode := valueof(chan_mode), |
| 847 | t_guard := t_guard, |
| 848 | l1_pars := { |
| 849 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 850 | toa256_enabled := false, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 851 | meas_valid := true, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 852 | meas_ul := { |
| 853 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 854 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 855 | rxqual := 0 |
| 856 | }, |
| 857 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 858 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 859 | rxqual := 0 |
| 860 | } |
| 861 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 862 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 863 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 864 | ms_power_level := mp_ms_power_level_exp, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 865 | ms_actual_ta := mp_ms_actual_ta_exp, |
| 866 | facch_enabled := false |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 867 | }, |
Vadim Yanitskiy | e6c1755 | 2021-06-01 01:20:55 +0200 | [diff] [blame] | 868 | spec := spec, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 869 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 870 | bts0_band := omit, |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 871 | tsc := mp_tsc_def, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 872 | fhp := { |
| 873 | enabled := false, |
| 874 | maio_hsn := ts_HsnMaio(0, 0), |
| 875 | ma_map := c_MA_null, |
Vadim Yanitskiy | 2b991b6 | 2020-11-14 21:40:41 +0700 | [diff] [blame] | 876 | ma := { } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 877 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 878 | } |
| 879 | |
Vadim Yanitskiy | f8a9df5 | 2022-03-12 13:29:26 +0300 | [diff] [blame] | 880 | /* This altstep triggers on receipt of a L1CTL DATA.ind matching the given |
| 881 | * RSL chan_nr/link_id and data templates. Used as a base for other altsteps. */ |
| 882 | private altstep as_l1ctl_dl_msg(out L1ctlDlMessage msg, |
| 883 | template (present) octetstring tr_data := ?, |
| 884 | template (present) RslChannelNr chan_nr := ?, |
| 885 | template (present) RslLinkId link_id := ?) |
| 886 | runs on ConnHdlr { |
| 887 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr, link_id, tr_data)) -> value msg; |
| 888 | } |
| 889 | |
| 890 | /* This altstep is built on top of as_l1ctl_dl_msg(), and triggers on receipt |
| 891 | * of dummy LAPDm func=UI frames with empty payload. Repeats by default. */ |
| 892 | private altstep as_dl_lapdm_dummy(template (present) RslChannelNr chan_nr := ?, |
| 893 | template (present) RslLinkId link_id := ?, |
| 894 | template (present) LapdmSapi sapi := ?, |
| 895 | boolean do_repeat := true) |
| 896 | runs on ConnHdlr { |
| 897 | template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, ''O); |
| 898 | var L1ctlDlMessage dl_msg; |
| 899 | |
| 900 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, chan_nr, link_id) { |
| 901 | if (do_repeat) { |
| 902 | repeat; |
| 903 | } |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | /* This altstep triggers on receipt of a Downlink DCCH containing a L2 payload |
| 908 | * that matches the given LAPDm frame. The L2 is treated as LapdmFrameAB. */ |
| 909 | private altstep as_dl_dcch_lapdm_ab(out LapdmFrameAB frame, |
| 910 | template (present) LapdmFrameAB tr_frame := ?, |
| 911 | template (present) RslLinkId link_id := ?) |
| 912 | runs on ConnHdlr { |
| 913 | var L1ctlDlMessage dl_msg; |
| 914 | |
| 915 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, g_chan_nr, link_id) { |
| 916 | frame := dec_LapdmFrameAB(dl_msg.payload.data_ind.payload); |
| 917 | } |
| 918 | } |
| 919 | |
Vadim Yanitskiy | a144e3c | 2022-03-14 23:56:40 +0300 | [diff] [blame] | 920 | /* This altstep triggers on receipt of a Downlink SACCH containing a L2 payload |
| 921 | * that matches the given LAPDm frame, as well as the given SACCH L1 header. */ |
| 922 | private altstep as_dl_sacch_lapdm_ab(out SacchL1Header l1h, out LapdmFrameAB frame, |
| 923 | template (present) LapdmFrameAB tr_frame := ?, |
| 924 | template (present) SacchL1Header tr_l1h := ?, |
| 925 | template (present) GsmSapi sapi := ?) |
| 926 | runs on ConnHdlr { |
| 927 | var L1ctlDlMessage dl_msg; |
| 928 | template (present) RslLinkId link_id := tr_RslLinkID_SACCH(sapi); |
| 929 | template (present) L1ctlDataReq tr_data := { |
| 930 | l1header := tr_l1h, |
| 931 | l2_payload := decmatch tr_frame |
| 932 | }; |
| 933 | |
| 934 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_data, g_chan_nr, link_id) { |
| 935 | var octetstring data := dl_msg.payload.data_ind.payload; |
| 936 | l1h := dec_SacchL1Header(substr(data, 0, 2)); |
| 937 | frame := dec_LapdmFrameAB(substr(data, 2, lengthof(data) - 2)); |
| 938 | } |
| 939 | } |
| 940 | |
Vadim Yanitskiy | f8a9df5 | 2022-03-12 13:29:26 +0300 | [diff] [blame] | 941 | /* This altstep is built on top of as_dl_dcch_lapdm_ab(), and triggers on receipt |
| 942 | * of a LAPDm AB frame with a L3 payload matching the given template. The L3 |
| 943 | * payload is treated as PDU_ML3_NW_MS. */ |
| 944 | private altstep as_dl_dcch_pdu(out PDU_ML3_NW_MS pdu, |
| 945 | template (present) PDU_ML3_NW_MS tr_pdu := ?, |
| 946 | template (present) GsmSapi sapi := 0) |
| 947 | runs on ConnHdlr { |
| 948 | template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, decmatch tr_pdu); |
| 949 | template (present) RslLinkId link_id := tr_RslLinkID_DCCH(sapi); |
| 950 | var LapdmFrameAB lapdm_frame; |
| 951 | |
| 952 | [] as_dl_dcch_lapdm_ab(lapdm_frame, tr_frame.ab, link_id) { |
| 953 | pdu := dec_PDU_ML3_NW_MS(lapdm_frame.payload); |
| 954 | } |
| 955 | } |
| 956 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 957 | /*********************************************************************** |
| 958 | * Channel Activation / Deactivation |
| 959 | ***********************************************************************/ |
| 960 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 961 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 962 | private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 963 | for (var integer i := 0; i < 500; i := i+1) { |
| 964 | f_rsl_chan_act(g_pars.chan_mode); |
| 965 | f_rsl_chan_deact(); |
| 966 | } |
| 967 | setverdict(pass); |
| 968 | } |
| 969 | testcase TC_chan_act_stress() runs on test_CT { |
| 970 | var ConnHdlr vc_conn; |
| 971 | 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] | 972 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 973 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 974 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 975 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 976 | } |
| 977 | |
| 978 | /* Test if re-activation of an already active channel fails as expected */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 979 | private function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 980 | f_rsl_chan_act(g_pars.chan_mode); |
| 981 | /* attempt to activate the same lchan again -> expect reject */ |
| 982 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 983 | alt { |
| 984 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 985 | 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] | 986 | } |
| 987 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 988 | setverdict(pass); |
| 989 | } |
| 990 | } |
| 991 | f_rsl_chan_deact(); |
| 992 | } |
| 993 | testcase TC_chan_act_react() runs on test_CT { |
| 994 | var ConnHdlr vc_conn; |
| 995 | 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] | 996 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 997 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 998 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 999 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | /* Attempt to de-activate a channel that's not active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1003 | private function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1004 | timer T := 3.0; |
| 1005 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 1006 | T.start; |
| 1007 | alt { |
| 1008 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 1009 | setverdict(pass); |
| 1010 | } |
| 1011 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1012 | 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] | 1013 | } |
| 1014 | } |
| 1015 | } |
| 1016 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 1017 | 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] | 1018 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1019 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 1020 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1021 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1022 | } |
| 1023 | |
| 1024 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1025 | private function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1026 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 1027 | alt { |
| 1028 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1029 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1030 | } |
| 1031 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 1032 | setverdict(pass); |
| 1033 | } |
| 1034 | } |
| 1035 | } |
| 1036 | private type record WrongChanNrCase { |
| 1037 | RslChannelNr chan_nr, |
| 1038 | charstring description |
| 1039 | } |
| 1040 | private type record of WrongChanNrCase WrongChanNrCases; |
| 1041 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 1042 | chan_nr := chan_nr, |
| 1043 | description := desc |
| 1044 | } |
| 1045 | |
| 1046 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 1047 | var ConnHdlr vc_conn; |
| 1048 | var ConnHdlrPars pars; |
| 1049 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1050 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1051 | |
| 1052 | var WrongChanNrCases wrong := { |
| 1053 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 1054 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 1055 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 1056 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 1057 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 1058 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 1059 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 1060 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 1061 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 1062 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 1063 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 1064 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 1065 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 1066 | }; |
| 1067 | |
| 1068 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 1069 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 1070 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 1071 | vc_conn.done; |
| 1072 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1073 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1074 | } |
| 1075 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1076 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 1077 | 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] | 1078 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1079 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1080 | |
| 1081 | /* test on each of the channels we have */ |
| 1082 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1083 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 1084 | |
| 1085 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 1086 | vc_conn := f_start_handler(fn, pars); |
| 1087 | vc_conn.done; |
| 1088 | } |
| 1089 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1090 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1091 | } |
| 1092 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1093 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1094 | * SACCH handling |
| 1095 | ***********************************************************************/ |
| 1096 | |
| 1097 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 1098 | timer T_sacch := 3.0; |
| 1099 | T_sacch.start; |
| 1100 | alt { |
| 1101 | [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] | 1102 | 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] | 1103 | } |
| 1104 | [not exp] T_sacch.timeout { |
| 1105 | setverdict(pass); |
| 1106 | } |
| 1107 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 1108 | setverdict(pass); |
| 1109 | } |
| 1110 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1111 | 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] | 1112 | } |
| 1113 | [] L1CTL.receive { repeat; } |
| 1114 | [] RSL.receive { repeat; } |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 1119 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 1120 | f_l1_tune(L1CTL); |
| 1121 | RSL.clear; |
| 1122 | |
| 1123 | /* activate the logical channel */ |
| 1124 | f_est_dchan(); |
| 1125 | L1CTL.clear; |
| 1126 | |
| 1127 | /* check that SACCH actually are received as expected */ |
| 1128 | f_exp_sacch(true); |
| 1129 | |
| 1130 | /* deactivate SACCH on the logical channel */ |
| 1131 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 1132 | f_sleep(1.0); |
| 1133 | L1CTL.clear; |
| 1134 | |
| 1135 | /* check that no SACCH are received anymore */ |
| 1136 | f_exp_sacch(false); |
| 1137 | |
| 1138 | /* release the channel */ |
| 1139 | f_rsl_chan_deact(); |
| 1140 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1141 | } |
| 1142 | testcase TC_deact_sacch() runs on test_CT { |
| 1143 | var ConnHdlr vc_conn; |
| 1144 | var ConnHdlrPars pars; |
| 1145 | f_init(); |
| 1146 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1147 | //for (var integer i := 0; i < 1; i := i+1) { |
| 1148 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1149 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1150 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 1151 | vc_conn.done; |
| 1152 | } |
| 1153 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1154 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1155 | } |
| 1156 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1157 | /* verify that given SACCH payload is present */ |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1158 | private function f_sacch_present(template octetstring l3_exp, |
| 1159 | boolean do_fail := true) |
| 1160 | runs on ConnHdlr { |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1161 | var L1ctlDlMessage dl; |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1162 | timer T_sacch := 3.0; |
| 1163 | L1CTL.clear; |
| 1164 | T_sacch.start; |
| 1165 | alt { |
| 1166 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1167 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1168 | if (match(l3, l3_exp)) { |
| 1169 | setverdict(pass); |
| 1170 | } else { |
| 1171 | repeat; |
| 1172 | } |
| 1173 | } |
| 1174 | [] L1CTL.receive { repeat; } |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1175 | [not do_fail] T_sacch.timeout { |
| 1176 | log("Timeout waiting for SACCH ", l3_exp); |
| 1177 | } |
| 1178 | [do_fail] T_sacch.timeout { |
Vadim Yanitskiy | 77a65f8 | 2022-03-11 12:34:47 +0300 | [diff] [blame] | 1179 | setverdict(fail, "Timeout waiting for SACCH ", l3_exp); |
| 1180 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1181 | } |
| 1182 | } |
| 1183 | } |
| 1184 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1185 | /* verify that given SACCH payload is not present */ |
| 1186 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 1187 | var L1ctlDlMessage dl; |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1188 | timer T_sacch := 3.0; |
| 1189 | L1CTL.clear; |
| 1190 | T_sacch.start; |
| 1191 | alt { |
| 1192 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1193 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1194 | if (match(l3, l3_exp)) { |
Vadim Yanitskiy | 77a65f8 | 2022-03-11 12:34:47 +0300 | [diff] [blame] | 1195 | setverdict(fail, "Received unexpected SACCH ", dl); |
| 1196 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1197 | } else { |
| 1198 | repeat; |
| 1199 | } |
| 1200 | } |
| 1201 | [] L1CTL.receive { repeat; } |
| 1202 | [] T_sacch.timeout { |
| 1203 | setverdict(pass); |
| 1204 | } |
| 1205 | } |
| 1206 | } |
| 1207 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1208 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1209 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 1210 | /* Set a known default SACCH filling for SI5 */ |
| 1211 | var octetstring si5 := f_rnd_octstring(19); |
| 1212 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1213 | |
| 1214 | f_l1_tune(L1CTL); |
| 1215 | RSL.clear; |
| 1216 | |
| 1217 | /* activate the logical channel */ |
| 1218 | f_est_dchan(); |
| 1219 | |
| 1220 | /* check that the specified SI5 value is actually sent */ |
| 1221 | f_sacch_present(si5); |
| 1222 | |
| 1223 | /* release the channel */ |
| 1224 | RSL.clear; |
| 1225 | f_rsl_chan_deact(); |
| 1226 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1227 | } |
| 1228 | testcase TC_sacch_filling() runs on test_CT { |
| 1229 | var ConnHdlr vc_conn; |
| 1230 | var ConnHdlrPars pars; |
| 1231 | f_init(); |
| 1232 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1233 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1234 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1235 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 1236 | vc_conn.done; |
| 1237 | } |
| 1238 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1239 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1240 | } |
| 1241 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1242 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1243 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 1244 | /* Set a known default SACCH filling for SI5 */ |
| 1245 | var octetstring si5 := f_rnd_octstring(19); |
| 1246 | var octetstring si5_diff := f_rnd_octstring(19); |
| 1247 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1248 | |
| 1249 | f_l1_tune(L1CTL); |
| 1250 | RSL.clear; |
| 1251 | |
| 1252 | log("Activating channel, expecting standard SI5"); |
| 1253 | /* activate the logical channel */ |
| 1254 | f_est_dchan(); |
| 1255 | /* check that the specified SI5 value is actually sent */ |
| 1256 | f_sacch_present(si5); |
| 1257 | |
| 1258 | /* set channel-specific different SI5 */ |
| 1259 | log("Setting channel specific SACCH INFO, expecting it"); |
| 1260 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 1261 | /* check that the specified lchan-specific value is now used */ |
| 1262 | f_sacch_present(si5_diff); |
| 1263 | |
| 1264 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 1265 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 1266 | f_rsl_chan_deact(); |
| 1267 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 1268 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 1269 | f_sacch_present(si5); |
| 1270 | |
| 1271 | /* release the channel */ |
| 1272 | RSL.clear; |
| 1273 | f_rsl_chan_deact(); |
| 1274 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1275 | } |
| 1276 | testcase TC_sacch_info_mod() runs on test_CT { |
| 1277 | var ConnHdlr vc_conn; |
| 1278 | var ConnHdlrPars pars; |
| 1279 | f_init(); |
| 1280 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1281 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1282 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1283 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 1284 | vc_conn.done; |
| 1285 | } |
| 1286 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1287 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1288 | } |
| 1289 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1290 | /* Test SACCH scheduling of multiple different SI message types */ |
| 1291 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 1292 | var octetstring si5 := f_rnd_octstring(19); |
| 1293 | var octetstring si5bis := f_rnd_octstring(19); |
| 1294 | var octetstring si5ter := f_rnd_octstring(19); |
| 1295 | var octetstring si6 := f_rnd_octstring(19); |
| 1296 | |
| 1297 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1298 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 1299 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 1300 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1301 | |
| 1302 | f_l1_tune(L1CTL); |
| 1303 | RSL.clear; |
| 1304 | |
| 1305 | /* activate the logical channel */ |
| 1306 | f_est_dchan(); |
| 1307 | L1CTL.clear; |
| 1308 | |
| 1309 | /* check that SACCH actually are received as expected */ |
| 1310 | f_sacch_present(si5); |
| 1311 | f_sacch_present(si5bis); |
| 1312 | f_sacch_present(si5ter); |
| 1313 | f_sacch_present(si6); |
| 1314 | |
| 1315 | /* release the channel */ |
| 1316 | f_rsl_chan_deact(); |
| 1317 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1318 | } |
| 1319 | testcase TC_sacch_multi() runs on test_CT { |
| 1320 | var ConnHdlr vc_conn; |
| 1321 | var ConnHdlrPars pars; |
| 1322 | f_init(); |
| 1323 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1324 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1325 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1326 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 1327 | vc_conn.done; |
| 1328 | } |
| 1329 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1330 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1331 | } |
| 1332 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1333 | /* Test if SACH information is modified as expected */ |
| 1334 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1335 | var octetstring si5 := f_rnd_octstring(19); |
| 1336 | var octetstring si6 := f_rnd_octstring(19); |
| 1337 | |
| 1338 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1339 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1340 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1341 | |
| 1342 | f_l1_tune(L1CTL); |
| 1343 | RSL.clear; |
| 1344 | |
| 1345 | /* activate the logical channel */ |
| 1346 | f_est_dchan(); |
| 1347 | L1CTL.clear; |
| 1348 | |
| 1349 | /* check that SACCH actually are received as expected */ |
| 1350 | f_sacch_present(si5); |
| 1351 | f_sacch_present(si6); |
| 1352 | |
| 1353 | /* disable SI6 */ |
| 1354 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1355 | |
| 1356 | /* check that SI5 is still transmitted */ |
| 1357 | f_sacch_present(si5); |
| 1358 | /* check if SI6 is now gone */ |
| 1359 | f_sacch_missing(si6); |
| 1360 | |
| 1361 | /* release the channel */ |
| 1362 | f_rsl_chan_deact(); |
| 1363 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1364 | } |
| 1365 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1366 | var ConnHdlr vc_conn; |
| 1367 | var ConnHdlrPars pars; |
| 1368 | f_init(); |
| 1369 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1370 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1371 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1372 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1373 | vc_conn.done; |
| 1374 | } |
| 1375 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1376 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1377 | } |
| 1378 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1379 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1380 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1381 | var octetstring si5 := f_rnd_octstring(19); |
| 1382 | var octetstring si6 := f_rnd_octstring(19); |
| 1383 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1384 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1385 | |
| 1386 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1387 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1388 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1389 | |
| 1390 | f_l1_tune(L1CTL); |
| 1391 | RSL.clear; |
| 1392 | |
| 1393 | /* activate channel with different SACCH filling */ |
| 1394 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1395 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1396 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1397 | })); |
| 1398 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1399 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1400 | f_est_dchan(more_ies := addl_ies); |
| 1401 | |
| 1402 | /* check that SACCH actually are received as expected */ |
| 1403 | f_sacch_present(si5_specific); |
| 1404 | f_sacch_present(si6_specific); |
| 1405 | |
| 1406 | /* release the channel */ |
| 1407 | f_rsl_chan_deact(); |
| 1408 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1409 | } |
| 1410 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1411 | var ConnHdlr vc_conn; |
| 1412 | var ConnHdlrPars pars; |
| 1413 | f_init(); |
| 1414 | |
| 1415 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1416 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1417 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1418 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1419 | vc_conn.done; |
| 1420 | } |
| 1421 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1422 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1423 | } |
| 1424 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1425 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1426 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1427 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1428 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1429 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1430 | |
| 1431 | f_l1_tune(L1CTL); |
| 1432 | RSL.clear; |
| 1433 | |
| 1434 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1435 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1436 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1437 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1438 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1439 | var RSL_IE_List addl_ies := { |
| 1440 | ho_ref_ie |
| 1441 | }; |
| 1442 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1443 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1444 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1445 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1446 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1447 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1448 | |
| 1449 | /* Verify that no DL SACCH is being received */ |
| 1450 | f_sacch_missing(?); |
| 1451 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1452 | /* Send handover Access Burst and expect SACCH to start */ |
| 1453 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1454 | |
| 1455 | f_sacch_present(si5); |
| 1456 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1457 | f_rsl_chan_deact(); |
| 1458 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1459 | |
| 1460 | |
| 1461 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1462 | |
| 1463 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1464 | addl_ies := { |
| 1465 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1466 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1467 | }; |
| 1468 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1469 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1470 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1471 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1472 | |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1473 | /* 4.1.3 "If the MS Power IE is present the BTS *may* start transmission |
| 1474 | * also on the SACCH". "May" does not mean "shall", so osmo-bts does not. */ |
| 1475 | f_sacch_present(si5, do_fail := false); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1476 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1477 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1478 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1479 | |
| 1480 | f_sacch_present(si5); |
| 1481 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1482 | f_rsl_chan_deact(); |
| 1483 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1484 | } |
| 1485 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1486 | var ConnHdlr vc_conn; |
| 1487 | var ConnHdlrPars pars; |
| 1488 | f_init(); |
| 1489 | |
Vadim Yanitskiy | ce96d35 | 2022-03-11 15:32:07 +0300 | [diff] [blame] | 1490 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1491 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 1492 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1493 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1494 | vc_conn.done; |
| 1495 | } |
| 1496 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1497 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1498 | } |
| 1499 | |
| 1500 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1501 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1502 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1503 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1504 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1505 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1506 | var RSL_IE_List addl_ies; |
| 1507 | |
| 1508 | f_l1_tune(L1CTL); |
| 1509 | RSL.clear; |
| 1510 | |
| 1511 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1512 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1513 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1514 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1515 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1516 | addl_ies := { |
| 1517 | ho_ref_ie |
| 1518 | }; |
| 1519 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1520 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1521 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1522 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1523 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1524 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1525 | |
| 1526 | /* Verify that no DL SACCH is being received */ |
| 1527 | f_sacch_missing(?); |
| 1528 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1529 | /* Send handover Access Burst and expect SACCH to start */ |
| 1530 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1531 | |
| 1532 | f_sacch_present(si5); |
| 1533 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1534 | f_rsl_chan_deact(); |
| 1535 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1536 | |
| 1537 | |
| 1538 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1539 | |
| 1540 | /* Activate channel on BTS side */ |
| 1541 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1542 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1543 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1544 | }; |
| 1545 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1546 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1547 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1548 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1549 | |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1550 | /* 4.1.4 "If only the MS Power IE is present the BTS *may* start transmission |
| 1551 | * also on the SACCH". "May" does not mean "shall", so osmo-bts does not. */ |
| 1552 | f_sacch_present(si5, do_fail := false); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1553 | |
Neels Hofmeyr | d55a3ac | 2020-11-09 00:54:34 +0000 | [diff] [blame] | 1554 | /* Send handover Access Burst and expect SACCH to remain present */ |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1555 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1556 | |
| 1557 | f_sacch_present(si5); |
| 1558 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1559 | f_rsl_chan_deact(); |
| 1560 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1561 | |
| 1562 | |
| 1563 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1564 | |
| 1565 | /* Activate channel on BTS side */ |
| 1566 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1567 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1568 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1569 | }; |
| 1570 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1571 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1572 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1573 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1574 | |
| 1575 | /* Verify that no DL SACCH is being received */ |
| 1576 | f_sacch_missing(?); |
| 1577 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1578 | /* Send handover Access Burst and expect SACCH to start */ |
| 1579 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1580 | |
| 1581 | f_sacch_present(si5); |
| 1582 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1583 | f_rsl_chan_deact(); |
| 1584 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1585 | |
| 1586 | |
| 1587 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1588 | |
| 1589 | /* Activate channel on BTS side */ |
| 1590 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1591 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1592 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1593 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1594 | }; |
| 1595 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1596 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1597 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1598 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1599 | |
| 1600 | /* Verify that DL SACCH is being received */ |
| 1601 | f_sacch_present(si5); |
| 1602 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1603 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1604 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1605 | |
| 1606 | f_sacch_present(si5); |
| 1607 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1608 | f_rsl_chan_deact(); |
| 1609 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1610 | } |
| 1611 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1612 | var ConnHdlr vc_conn; |
| 1613 | var ConnHdlrPars pars; |
| 1614 | f_init(); |
| 1615 | |
Vadim Yanitskiy | ce96d35 | 2022-03-11 15:32:07 +0300 | [diff] [blame] | 1616 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1617 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 1618 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1619 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1620 | vc_conn.done; |
| 1621 | } |
| 1622 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1623 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1624 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1625 | |
| 1626 | |
| 1627 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1628 | * RACH Handling |
| 1629 | ***********************************************************************/ |
| 1630 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1631 | /* Send 1000 RACH requests and check their RA+FN on the RSL side */ |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1632 | private function f_TC_rach_content(boolean emerg) runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1633 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1634 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1635 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1636 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1637 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1638 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1639 | for (var integer i := 0; i < 1000; i := i+1) { |
Neels Hofmeyr | c897cfb | 2020-11-09 00:06:01 +0000 | [diff] [blame] | 1640 | var OCT1 ra; |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1641 | if (emerg == true) { |
| 1642 | ra := f_rnd_ra_emerg(); |
| 1643 | } else { |
| 1644 | ra := f_rnd_ra_cs(); |
| 1645 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1646 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1647 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1648 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1649 | } |
| 1650 | fn_last := fn; |
| 1651 | |
| 1652 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1653 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1654 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1655 | [] 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] | 1656 | T.stop; |
| 1657 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1658 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1659 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1660 | } |
| 1661 | [] RSL_CCHAN.receive { repeat; } |
| 1662 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1663 | test_failed := true; |
| 1664 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1665 | } |
| 1666 | } |
| 1667 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1668 | if (test_failed) { |
| 1669 | 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] | 1670 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1671 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1672 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1673 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1674 | |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1675 | /* Normal variant */ |
| 1676 | testcase TC_rach_content() runs on test_CT { |
| 1677 | f_TC_rach_content(emerg := false); |
| 1678 | } |
| 1679 | |
| 1680 | /* Emergency call variant */ |
| 1681 | testcase TC_rach_content_emerg() runs on test_CT { |
| 1682 | f_TC_rach_content(emerg := true); |
| 1683 | } |
| 1684 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1685 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1686 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1687 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1688 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1689 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1690 | f_l1_tune(L1CTL); |
| 1691 | |
| 1692 | var GsmFrameNumber fn_last := 0; |
| 1693 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1694 | var OCT1 ra := f_rnd_ra_cs(); |
| 1695 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1696 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1697 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1698 | } |
| 1699 | fn_last := fn; |
| 1700 | } |
| 1701 | var integer rsl_chrqd := 0; |
| 1702 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1703 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1704 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1705 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1706 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1707 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1708 | repeat; |
| 1709 | } |
| 1710 | [] RSL_CCHAN.receive { repeat; } |
| 1711 | [] T.timeout { } |
| 1712 | } |
| 1713 | if (rsl_chrqd == 1000) { |
| 1714 | setverdict(pass); |
| 1715 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1716 | 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] | 1717 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1718 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1719 | } |
| 1720 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1721 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1722 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1723 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1724 | } |
| 1725 | |
| 1726 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1727 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1728 | |
| 1729 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1730 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1731 | var ASP_RSL_Unitdata rx_ud; |
| 1732 | |
| 1733 | f_init_vty_bsc(); |
| 1734 | /* send load indications even at 0% load */ |
| 1735 | f_vty_load_ind_thresh(0); |
| 1736 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1737 | f_sleep(2.0); |
| 1738 | |
| 1739 | f_init(); |
| 1740 | |
Harald Welte | e37f9a5 | 2020-10-11 20:45:23 +0200 | [diff] [blame] | 1741 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1742 | alt { |
| 1743 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1744 | [] RSL_CCHAN.receive { repeat } |
| 1745 | } |
| 1746 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1747 | timer T := 5.0; |
| 1748 | T.start; |
| 1749 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1750 | [] 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] | 1751 | setverdict(pass); |
| 1752 | repeat; |
| 1753 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1754 | [] 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] | 1755 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1756 | repeat; |
| 1757 | } |
| 1758 | [] RSL_CCHAN.receive { |
| 1759 | repeat; |
| 1760 | } |
| 1761 | [] T.timeout { } |
| 1762 | } |
| 1763 | |
| 1764 | f_vty_load_ind_thresh(10); |
| 1765 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1766 | } |
| 1767 | |
| 1768 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1769 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1770 | var ASP_RSL_Unitdata rx_ud; |
| 1771 | |
| 1772 | f_init_vty_bsc(); |
| 1773 | f_init(); |
| 1774 | |
| 1775 | timer T := 5.0; |
| 1776 | T.start; |
| 1777 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1778 | [] 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] | 1779 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1780 | repeat; |
| 1781 | } |
| 1782 | [] RSL_CCHAN.receive { |
| 1783 | repeat; |
| 1784 | } |
| 1785 | [] T.timeout { |
| 1786 | setverdict(pass); |
| 1787 | } |
| 1788 | } |
| 1789 | |
| 1790 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1791 | } |
| 1792 | |
| 1793 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1794 | testcase TC_rach_load_count() runs on test_CT { |
| 1795 | var ASP_RSL_Unitdata rx_ud; |
| 1796 | var integer load_access_count := 0; |
| 1797 | |
| 1798 | f_init_vty_bsc(); |
| 1799 | /* send load indications even at 0% load */ |
| 1800 | f_vty_load_ind_thresh(0); |
| 1801 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1802 | f_sleep(2.0); |
| 1803 | f_init(); |
| 1804 | |
| 1805 | f_init_l1ctl(); |
| 1806 | f_sleep(1.0); |
| 1807 | f_l1_tune(L1CTL); |
| 1808 | |
Harald Welte | 52ae168 | 2020-10-11 20:45:55 +0200 | [diff] [blame] | 1809 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1810 | alt { |
| 1811 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1812 | [] RSL_CCHAN.receive { repeat } |
| 1813 | } |
| 1814 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1815 | var GsmFrameNumber fn_last := 0; |
| 1816 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1817 | var OCT1 ra := f_rnd_ra_cs(); |
| 1818 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1819 | if (fn == fn_last) { |
| 1820 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1821 | } |
| 1822 | fn_last := fn; |
| 1823 | } |
| 1824 | |
| 1825 | timer T := 5.0; |
| 1826 | T.start; |
| 1827 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1828 | [] 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] | 1829 | -> value rx_ud { |
| 1830 | var RSL_IE_Body ie; |
| 1831 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1832 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1833 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1834 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1835 | } |
| 1836 | repeat; |
| 1837 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1838 | [] 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] | 1839 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1840 | repeat; |
| 1841 | } |
| 1842 | [] RSL_CCHAN.receive { |
| 1843 | repeat; |
| 1844 | } |
| 1845 | [] T.timeout { } |
| 1846 | } |
| 1847 | if (load_access_count == 1000) { |
| 1848 | setverdict(pass); |
| 1849 | } else { |
| 1850 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1851 | } |
| 1852 | |
| 1853 | f_vty_load_ind_thresh(10); |
| 1854 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1855 | } |
| 1856 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1857 | 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] | 1858 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1859 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 1860 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256)); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1861 | f_sleep(0.5); |
| 1862 | |
| 1863 | /* Transmit RACH request + wait for confirmation */ |
| 1864 | var OCT1 ra := f_rnd_ra_cs(); |
| 1865 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1866 | |
| 1867 | /* Check for expected result */ |
| 1868 | timer T := 1.5; |
| 1869 | T.start; |
| 1870 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1871 | [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] | 1872 | setverdict(pass); |
| 1873 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1874 | [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] | 1875 | 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] | 1876 | } |
| 1877 | [] RSL_CCHAN.receive { repeat; } |
| 1878 | [not expect_pass] T.timeout { |
| 1879 | setverdict(pass); |
| 1880 | } |
| 1881 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1882 | 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] | 1883 | } |
| 1884 | } |
| 1885 | } |
| 1886 | |
| 1887 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1888 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1889 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1890 | f_init_l1ctl(); |
| 1891 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1892 | f_sleep(1.0); |
| 1893 | |
| 1894 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1895 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1896 | /* We allow early arrival up to 2 symbols */ |
| 1897 | f_rach_toffs(-1*256, true); |
| 1898 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1899 | f_rach_toffs(-10*256, false); |
| 1900 | |
| 1901 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1902 | f_rach_toffs(0, true); |
| 1903 | f_rach_toffs(32*256, true); |
| 1904 | f_rach_toffs(63*256, true); |
| 1905 | |
| 1906 | /* more than 63 bits is not legal / permitted */ |
| 1907 | f_rach_toffs(64*256, false); |
| 1908 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1909 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1910 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1911 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1912 | private function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1913 | var GsmFrameNumber fn; |
| 1914 | var RSL_Message rm; |
| 1915 | |
| 1916 | f_l1_tune(L1CTL); |
| 1917 | RSL.clear; |
| 1918 | |
| 1919 | /* Generate a random Handover Reference */ |
| 1920 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1921 | |
| 1922 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1923 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1924 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1925 | |
| 1926 | /* Activate a channel on the BTS side (no encryption) */ |
| 1927 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1928 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1929 | |
| 1930 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1931 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1932 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1933 | |
| 1934 | /* Send handover Access Burst */ |
| 1935 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1936 | |
| 1937 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1938 | |
| 1939 | /* Wait for handover detection */ |
| 1940 | timer T := 3.0; |
| 1941 | T.start; |
| 1942 | alt { |
| 1943 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1944 | log("Handover RACH has been detected: ", rm); |
| 1945 | setverdict(pass); |
| 1946 | } |
| 1947 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1948 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1949 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1950 | } |
| 1951 | [] RSL.receive { repeat; } |
| 1952 | [] T.timeout { |
| 1953 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1954 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1955 | } |
| 1956 | } |
| 1957 | |
| 1958 | /* Release the channel */ |
| 1959 | f_rsl_chan_deact(); |
| 1960 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1961 | } |
| 1962 | |
| 1963 | /* Test handover RACH detection */ |
| 1964 | testcase TC_ho_rach() runs on test_CT { |
| 1965 | var ConnHdlrPars pars; |
| 1966 | var ConnHdlr vc_conn; |
| 1967 | |
| 1968 | f_init(); |
| 1969 | |
| 1970 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 1971 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1972 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1973 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 1974 | vc_conn.done; |
| 1975 | } |
| 1976 | |
| 1977 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1978 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1979 | } |
| 1980 | |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 1981 | /* Test sending of the RR Physical Information message on DCCH */ |
| 1982 | private function f_TC_ho_physical_info(charstring id) runs on ConnHdlr { |
| 1983 | var PDU_ML3_NW_MS dcch_pdu; |
| 1984 | var integer count := 0; |
| 1985 | var L1ctlDlMessage dl; |
| 1986 | timer T; |
| 1987 | |
| 1988 | f_l1_tune(L1CTL); |
| 1989 | RSL.clear; |
| 1990 | |
| 1991 | /* Generate a random Handover Reference */ |
| 1992 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1993 | |
| 1994 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1995 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1996 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1997 | |
| 1998 | /* Activate a channel on the BTS side (no encryption) */ |
| 1999 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 2000 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 2001 | |
| 2002 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 2003 | * waiting for Immediate Assignment and sending of an Access Burst. */ |
| 2004 | f_l1ctl_est_dchan(L1CTL, g_pars); /* FIXME: disable Uplink Tx */ |
| 2005 | |
| 2006 | /* Expect nothing to be transmitted on Downlink DCCH. Nothing in this |
| 2007 | * context means any L2 frames, not only the RR Physical Information. */ |
| 2008 | T.start(2.0); |
| 2009 | L1CTL.clear; |
| 2010 | alt { |
| 2011 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value dl { |
| 2012 | setverdict(fail, "Rx unexpected Downlink DCCH (before handover RACH): ", dl); |
| 2013 | T.stop; |
| 2014 | } |
| 2015 | [] L1CTL.receive { repeat; } |
| 2016 | [] T.timeout { setverdict(pass); } |
| 2017 | } |
| 2018 | |
| 2019 | /* Send handover Access Burst */ |
| 2020 | log("Sending handover Access Burst"); |
| 2021 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 2022 | |
| 2023 | /* Expect RR Physical Information being sent on Downlink DCCH Ny1 times */ |
| 2024 | T.start(int2float(mp_ho_t3105_ms * mp_ho_ny1) / 1000.0 + 1.0); |
| 2025 | L1CTL.clear; |
| 2026 | alt { |
| 2027 | [] as_dl_lapdm_dummy(); /* Ignore empty LAPDm func=UI frames */ |
| 2028 | [] as_dl_dcch_pdu(dcch_pdu, tr_RRM_PhysicalInfo) { |
| 2029 | log("Rx RR Physical Information: ", dcch_pdu); |
| 2030 | /* Wait until the count reaches Ny1 */ |
| 2031 | count := count + 1; |
| 2032 | if (count < mp_ho_ny1) |
| 2033 | { repeat; } |
| 2034 | setverdict(pass); |
| 2035 | } |
| 2036 | [] as_dl_dcch_pdu(dcch_pdu, ?) { |
| 2037 | setverdict(fail, "Rx unexpected DCCH PDU: ", dcch_pdu); |
| 2038 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2039 | } |
| 2040 | [] L1CTL.receive { repeat; } |
| 2041 | [] T.timeout { |
| 2042 | setverdict(fail, "Timeout waiting for RR Physical Information"); |
| 2043 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2044 | } |
| 2045 | } |
| 2046 | |
| 2047 | /* Release the channel */ |
| 2048 | f_rsl_chan_deact(); |
| 2049 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2050 | } |
| 2051 | testcase TC_ho_physical_info() runs on test_CT { |
| 2052 | var ConnHdlrPars pars; |
| 2053 | var ConnHdlr vc_conn; |
| 2054 | |
| 2055 | f_init(); |
| 2056 | |
| 2057 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 2058 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 2059 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
| 2060 | vc_conn := f_start_handler(refers(f_TC_ho_physical_info), pars); |
| 2061 | vc_conn.done; |
| 2062 | } |
| 2063 | |
| 2064 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 2065 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2066 | } |
| 2067 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 2068 | /*********************************************************************** |
| 2069 | * Measurement Processing / Reporting |
| 2070 | ***********************************************************************/ |
| 2071 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2072 | private template (value) LapdmAddressField |
| 2073 | ts_LapdmAddr(template (value) LapdmSapi sapi, |
| 2074 | template (value) boolean c_r) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2075 | spare := '0'B, |
| 2076 | lpd := 0, |
| 2077 | sapi := sapi, |
| 2078 | c_r := c_r, |
| 2079 | ea := true |
| 2080 | } |
| 2081 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2082 | private template (value) LapdmFrameAB |
| 2083 | ts_LAPDm_AB(template (value) LapdmSapi sapi, |
| 2084 | template (value) GsmRrL3Message l3, |
| 2085 | template (value) boolean c_r := false, |
| 2086 | template (value) boolean p := false) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2087 | addr := ts_LapdmAddr(sapi, c_r), |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2088 | ctrl := ts_LapdmCtrlUI(valueof(p)), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2089 | len := 0, /* overwritten */ |
| 2090 | m := false, |
| 2091 | el := 1, |
Vadim Yanitskiy | 16e2991 | 2022-03-12 13:26:21 +0300 | [diff] [blame] | 2092 | payload := enc_GsmRrL3Message(valueof(l3)), |
| 2093 | padding := ''O |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2094 | } |
| 2095 | |
| 2096 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2097 | private altstep as_l1_sacch() runs on ConnHdlr { |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2098 | var template (value) LapdmFrameAB lb; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2099 | var L1ctlDlMessage l1_dl; |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2100 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2101 | [] 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] | 2102 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2103 | |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 2104 | lb := ts_LAPDm_AB(0, ts_MEAS_REP(g_pars.l1_pars.meas_valid, |
Vadim Yanitskiy | cb57c1b | 2020-11-11 20:57:15 +0700 | [diff] [blame] | 2105 | g_pars.l1_pars.meas_ul.full.rxlev, |
| 2106 | g_pars.l1_pars.meas_ul.sub.rxlev, |
| 2107 | g_pars.l1_pars.meas_ul.full.rxqual, |
| 2108 | g_pars.l1_pars.meas_ul.sub.rxqual)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2109 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 2110 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 2111 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
| 2112 | g_pars.l1_pars.ms_power_level, false, |
| 2113 | g_pars.l1_pars.ms_actual_ta); |
| 2114 | |
Vadim Yanitskiy | f105a5b | 2020-11-30 14:27:55 +0100 | [diff] [blame] | 2115 | /* According to 3GPP TS 44.018, section 10.5.2.20, we should pad with zeroes */ |
| 2116 | var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(valueof(lb)), 21, '00'O); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 2117 | |
| 2118 | log("Sending Measurement Report: ", l1h, l2); |
| 2119 | 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] | 2120 | repeat; |
| 2121 | } |
| 2122 | } |
| 2123 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2124 | /* handle incoming downlink SACCH, decode the L1 header into the given record */ |
| 2125 | private altstep as_l1_sacch_l1h(inout SacchL1Header l1h, |
| 2126 | boolean do_apply := true) |
| 2127 | runs on ConnHdlr |
| 2128 | { |
| 2129 | var L1ctlDlMessage l1_dl; |
| 2130 | |
| 2131 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2132 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 2133 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 2134 | log(%definitionId, "(): Rx SACCH L1 header: ", l1h); |
| 2135 | |
| 2136 | if (do_apply) { |
| 2137 | /* Update TA and MS power to follow what BTS requests */ |
| 2138 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 2139 | } |
| 2140 | } |
| 2141 | } |
| 2142 | |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2143 | private altstep as_l1_dcch_loop() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2144 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2145 | [] 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] | 2146 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 2147 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 2148 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 2149 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2150 | repeat; |
| 2151 | } |
| 2152 | } |
| 2153 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2154 | private altstep as_l1_tch_loop() runs on ConnHdlr { |
| 2155 | var L1ctlDlMessage l1_dl; |
| 2156 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl { |
| 2157 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 2158 | |
| 2159 | /* occasionaly inject FACCH frames into the uplink */ |
| 2160 | if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) { |
| 2161 | var octetstring pl := '010301'O; |
| 2162 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 2163 | f_pad_oct(pl, 23, '2B'O))); |
| 2164 | } else { |
| 2165 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 2166 | l1_dl.payload.traffic_ind.data)); |
| 2167 | } |
| 2168 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2169 | repeat; |
| 2170 | } |
| 2171 | } |
| 2172 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2173 | private type record MeasElem { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2174 | uint6_t rxlev, |
| 2175 | uint3_t rxqual |
| 2176 | } |
| 2177 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2178 | private type record MeasElemFS { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2179 | MeasElem full, |
| 2180 | MeasElem sub |
| 2181 | } |
| 2182 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2183 | private type record ConnL1Pars { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2184 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2185 | boolean toa256_enabled, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 2186 | boolean meas_valid, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2187 | MeasElemFS meas_ul, |
| 2188 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2189 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2190 | uint5_t ms_power_level, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 2191 | uint8_t ms_actual_ta, |
| 2192 | boolean facch_enabled |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2193 | } |
| 2194 | |
| 2195 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 2196 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 2197 | return 63 + (toffs256s/256); |
| 2198 | } |
| 2199 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2200 | private function f_max(integer a, integer b) return integer { |
| 2201 | if (a > b) { |
| 2202 | return a; |
| 2203 | } else { |
| 2204 | return b; |
| 2205 | } |
| 2206 | } |
| 2207 | |
| 2208 | private function f_min(integer a, integer b) return integer { |
| 2209 | if (a < b) { |
| 2210 | return a; |
| 2211 | } else { |
| 2212 | return b; |
| 2213 | } |
| 2214 | } |
| 2215 | |
| 2216 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 2217 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 2218 | val := val - tolerance; |
| 2219 | return f_max(val, min); |
| 2220 | } |
| 2221 | |
| 2222 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 2223 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 2224 | val := val + tolerance; |
| 2225 | return f_min(val, max); |
| 2226 | } |
| 2227 | |
| 2228 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 2229 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 2230 | return template integer { |
| 2231 | var template integer ret; |
| 2232 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 2233 | return ret; |
| 2234 | } |
| 2235 | |
| 2236 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2237 | /* build a template for matching measurement results against */ |
| 2238 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 2239 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2240 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2241 | len := 3, |
| 2242 | rfu := '0'B, |
| 2243 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2244 | 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] | 2245 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2246 | 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] | 2247 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2248 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 2249 | 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] | 2250 | supp_meas_info := omit |
| 2251 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2252 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 2253 | ul_meas.len := (3+8); |
| 2254 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2255 | 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] | 2256 | toa256_min := ?, |
| 2257 | toa256_max := ?, |
| 2258 | toa256_std_dev := ? |
| 2259 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2260 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2261 | var template RSL_IE_BS_Power bs_power := { |
| 2262 | reserved := 0, |
| 2263 | epc := false, |
| 2264 | fpc := false, |
| 2265 | power_level := l1p.bs_power_level |
| 2266 | }; |
| 2267 | var template RSL_IE_L1Info l1_info := { |
| 2268 | ms_power_lvl := l1p.ms_power_level, |
| 2269 | fpc := false, |
| 2270 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2271 | 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] | 2272 | }; |
| 2273 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2274 | 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] | 2275 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 2276 | ?, t_toffs); |
| 2277 | } |
| 2278 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2279 | /* build a template for matching measurement results that do not contain any |
| 2280 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 2281 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 2282 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2283 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2284 | len := 3, |
| 2285 | rfu := '0'B, |
| 2286 | dtx_d := l1p.dtx_enabled, |
| 2287 | rxlev_f_u := ?, |
| 2288 | reserved1 := '00'B, |
| 2289 | rxlev_s_u := ?, |
| 2290 | reserved2 := '00'B, |
| 2291 | rxq_f_u := ?, |
| 2292 | rxq_s_u := ?, |
| 2293 | supp_meas_info := omit |
| 2294 | }; |
| 2295 | if (l1p.toa256_enabled) { |
| 2296 | ul_meas.len := (3+8); |
| 2297 | ul_meas.supp_meas_info := { |
| 2298 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 2299 | toa256_min := ?, |
| 2300 | toa256_max := ?, |
| 2301 | toa256_std_dev := ? |
| 2302 | } |
| 2303 | } |
| 2304 | var template RSL_IE_BS_Power bs_power := { |
| 2305 | reserved := 0, |
| 2306 | epc := false, |
| 2307 | fpc := false, |
| 2308 | power_level := l1p.bs_power_level |
| 2309 | }; |
| 2310 | |
| 2311 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 2312 | } |
| 2313 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2314 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2315 | private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2316 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2317 | var boolean chan_est := false; |
| 2318 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 2319 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2320 | |
| 2321 | /* Receive osmocom specific measurement reports. This is the normal |
| 2322 | * case. Here we verify that the measurement reports we sent are |
| 2323 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2324 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 2325 | /* increment counter of next to-be-expected meas rep */ |
| 2326 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2327 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 2328 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2329 | |
| 2330 | /* The following two cases may only happen in the beginning |
| 2331 | * of the channel establishment phase. Once we have received |
| 2332 | * the "our" measurement report the first time, the channel |
| 2333 | * is established and empty or hardcoded TRXCON reports must |
| 2334 | * not occur anymore. */ |
| 2335 | chan_est := true; |
| 2336 | |
| 2337 | repeat; |
| 2338 | } |
| 2339 | |
| 2340 | /* When the BTS has established the channel, the MS might need slightly |
| 2341 | * more time to establish the channel and actually start sending. The |
| 2342 | * result is then a measurement report that just lacks the measurement |
| 2343 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 2344 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 2345 | /* increment counter of next to-be-expected meas rep */ |
| 2346 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2347 | /* Re-start the timer expecting the next MEAS RES */ |
| 2348 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2349 | repeat; |
| 2350 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2351 | |
| 2352 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 2353 | * measurements if the TTCN3 side does not supply measurement input in |
| 2354 | * time. In those cases TRXCON will either use a cached measurement |
| 2355 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 2356 | * report the templates above will not match. We tolerate this |
| 2357 | * behavior, but only once. */ |
| 2358 | [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] | 2359 | /* increment counter of next to-be-expected meas rep */ |
| 2360 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2361 | if (g_first_meas_res) { |
| 2362 | g_first_meas_res := false; |
| 2363 | repeat; |
| 2364 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2365 | 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] | 2366 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2367 | } |
| 2368 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2369 | 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] | 2370 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 2371 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2372 | 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] | 2373 | } |
| 2374 | } |
| 2375 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2376 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 2377 | select (rsl_alg_id) { |
| 2378 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 2379 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 2380 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 2381 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 2382 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 2383 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 2384 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 2385 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 2386 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2387 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2388 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2389 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2390 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2391 | } |
| 2392 | } |
| 2393 | } |
| 2394 | |
| 2395 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 2396 | select (rsl_alg_id) { |
| 2397 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 2398 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 2399 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 2400 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 2401 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 2402 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 2403 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 2404 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2405 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2406 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2407 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2408 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2409 | } |
| 2410 | } |
| 2411 | } |
| 2412 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2413 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 2414 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 2415 | var GsmFrameNumber fn; |
| 2416 | timer T := 8.0; |
| 2417 | |
| 2418 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 2419 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 2420 | |
| 2421 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 2422 | /* Send the actual RACH */ |
| 2423 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 2424 | |
| 2425 | T.start; |
| 2426 | alt { |
| 2427 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 2428 | [] T.timeout { |
| 2429 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 2430 | } |
| 2431 | } |
| 2432 | T.stop |
| 2433 | return fn; |
| 2434 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2435 | |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2436 | /* Tune to a dedicated channel: L1CTL only */ |
| 2437 | private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2438 | if (not pars.fhp.enabled) { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 2439 | var TrxParsItem trx_pars := mp_trx_pars[pars.trx_nr]; |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2440 | pt.send(ts_L1CTL_DM_EST_REQ_H0(pars.chan_nr, pars.tsc, |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 2441 | trx_pars.arfcn)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2442 | } else { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2443 | pt.send(ts_L1CTL_DM_EST_REQ_H1(pars.chan_nr, pars.tsc, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2444 | pars.fhp.maio_hsn.hsn, |
| 2445 | pars.fhp.maio_hsn.maio, |
| 2446 | pars.fhp.ma)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2447 | } |
| 2448 | } |
| 2449 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2450 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2451 | private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr { |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2452 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2453 | |
| 2454 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2455 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2456 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2457 | /* Craft channel description (with or without frequency hopping parameters) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2458 | if (g_pars.fhp.enabled) { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2459 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2460 | } else { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 2461 | var TrxParsItem trx_pars := mp_trx_pars[g_pars.trx_nr]; |
| 2462 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, trx_pars.arfcn, g_pars.tsc)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2463 | } |
| 2464 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2465 | /* enable dedicated mode */ |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 2466 | f_l1ctl_est_dchan(L1CTL, g_pars); |
| 2467 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2468 | /* enable encryption, if requested */ |
| 2469 | if (encr_enable) { |
| 2470 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 2471 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 2472 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2473 | |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2474 | /* Send TCH Mode Request to the L1 if needed */ |
| 2475 | if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) { |
| 2476 | var L1ctlTchMode tch_mode; |
| 2477 | |
| 2478 | select (g_pars.chan_mode.coding_alg_rate) { |
| 2479 | case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; } |
| 2480 | case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; } |
| 2481 | case (RSL_CMOD_SP_GSM2) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V2; } |
| 2482 | case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3; } |
| 2483 | case else { |
| 2484 | log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate, |
| 2485 | " is not supported by the L1, falling back to signalling"); |
| 2486 | tch_mode := L1CTL_CHAN_MODE_SIGN; |
| 2487 | } |
| 2488 | } |
| 2489 | |
| 2490 | f_L1CTL_TCH_MODE(L1CTL, tch_mode); |
| 2491 | } |
| 2492 | |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2493 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2494 | } |
| 2495 | |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2496 | /* Initialize and start the RTP emulation component for a ConnHdlr */ |
| 2497 | friend function f_rtpem_activate(inout octetstring payload, |
| 2498 | RtpemConfig cfg := c_RtpemDefaultCfg, |
| 2499 | RtpemMode mode := RTPEM_MODE_BIDIR) |
| 2500 | runs on ConnHdlr { |
| 2501 | /* Step 0: initialize, connect and start the emulation component */ |
| 2502 | vc_RTPEM := RTP_Emulation_CT.create(testcasename() & "-RTPEM"); |
| 2503 | map(vc_RTPEM:RTP, system:RTP); |
| 2504 | map(vc_RTPEM:RTCP, system:RTCP); |
| 2505 | connect(vc_RTPEM:CTRL, self:RTPEM_CTRL); |
| 2506 | connect(vc_RTPEM:DATA, self:RTPEM_DATA); |
| 2507 | vc_RTPEM.start(RTP_Emulation.f_main()); |
| 2508 | |
| 2509 | /* Step 1: configure the RTP parameters */ |
| 2510 | var integer payload_len := 0; |
| 2511 | var octetstring hdr := ''O; |
| 2512 | |
| 2513 | select (g_pars.chan_mode) { |
| 2514 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)) /* TCH/FS */ |
| 2515 | { payload_len := 33; hdr := 'D0'O; } |
| 2516 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)) /* TCH/HS */ |
| 2517 | { payload_len := 15; hdr := '00'O; } |
| 2518 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2)) /* TCH/EFS */ |
| 2519 | { payload_len := 31; hdr := 'C0'O; } |
| 2520 | case else { /* FIXME: also handle TCH/AFS and TCH/AHS */ |
| 2521 | setverdict(fail, "Unhandled RSL channel mode := ", g_pars.chan_mode); |
| 2522 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2523 | } |
| 2524 | } |
| 2525 | |
| 2526 | /* Pad the payload to conform the expected length */ |
| 2527 | payload := f_pad_oct(hdr & payload, payload_len, '00'O); |
| 2528 | cfg.tx_fixed_payload := payload; |
| 2529 | f_rtpem_configure(RTPEM_CTRL, cfg); |
| 2530 | |
| 2531 | /* Step 2: bind the RTP emulation to the configured address */ |
| 2532 | var PortNumber rtpem_bind_port := mp_rtpem_bind_port; |
| 2533 | f_rtpem_bind(RTPEM_CTRL, mp_rtpem_bind_ip, rtpem_bind_port); |
| 2534 | |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2535 | /* Step 3a: send CRCX to create an RTP connection at the IUT */ |
| 2536 | var RSL_Message crcx_ack := f_rsl_transceive_ret( |
| 2537 | /* FIXME (OS#5242): do not include Remote IP/Port IEs because |
| 2538 | * osmo-bts would respond with nonsense listen addr='0.0.0.0'. */ |
| 2539 | ts_RSL_IPA_CRCX(g_chan_nr, omit, omit), |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2540 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 2541 | "IPA CRCX ACK"); |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2542 | var uint16_t conn_id := crcx_ack.ies[1].body.ipa_conn_id; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2543 | |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2544 | /* Step 3b: send MDCX with the configured address/port to the IUT */ |
| 2545 | var RSL_Message mdcx_ack := f_rsl_transceive_ret( |
| 2546 | ts_RSL_IPA_MDCX(g_chan_nr, conn_id, |
| 2547 | remote_ip := f_inet_addr(mp_rtpem_bind_ip), |
| 2548 | remote_port := rtpem_bind_port, |
| 2549 | rtp_pt2 := 0), |
| 2550 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, conn_id, ?, ?, ?), |
| 2551 | "IPA MDCX ACK"); |
| 2552 | |
| 2553 | /* Step 4: connect to the IUT's address/port parsed from MDCX ACK */ |
| 2554 | var HostName bts_bind_ip := f_inet_ntoa(mdcx_ack.ies[2].body.ipa_local_ip); |
| 2555 | var PortNumber bts_bind_port := mdcx_ack.ies[3].body.ipa_local_port; |
| 2556 | f_rtpem_connect(RTPEM_CTRL, bts_bind_ip, bts_bind_port); |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2557 | |
| 2558 | /* Step 5: set the given RTP emulation mode */ |
| 2559 | f_rtpem_mode(RTPEM_CTRL, mode); |
| 2560 | } |
| 2561 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2562 | /* establish DChan, verify existance + contents of measurement reports */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2563 | private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2564 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2565 | RSL.clear; |
| 2566 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 2567 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 2568 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2569 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2570 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2571 | |
| 2572 | f_est_dchan(); |
| 2573 | |
| 2574 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2575 | * RSL measurement reports on Abis side */ |
| 2576 | timer T := 8.0; |
| 2577 | T.start; |
| 2578 | alt { |
| 2579 | [] as_l1_sacch(); |
| 2580 | [] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2581 | [] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2582 | [] as_l1_tch_loop(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2583 | [] L1CTL.receive { repeat; } |
| 2584 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2585 | /* 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] | 2586 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2587 | setverdict(pass); |
| 2588 | } |
| 2589 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2590 | 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] | 2591 | } |
| 2592 | } |
| 2593 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2594 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2595 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2596 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2597 | /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */ |
| 2598 | private function f_wait_ramp_up() runs on ConnHdlr return integer { |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2599 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2600 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2601 | timer Tup := 10.0; |
| 2602 | Tup.start; |
| 2603 | alt { |
| 2604 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2605 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2606 | log("Received rx_level=", rx_lvl); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2607 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2608 | if (rx_lvl != max_rx_lvl) { |
| 2609 | repeat; |
| 2610 | } |
| 2611 | Tup.stop; |
| 2612 | } |
| 2613 | [] L1CTL.receive { repeat; } |
| 2614 | [] Tup.timeout { |
| 2615 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2616 | log2str("Didn't reach full power ", max_rx_lvl)); |
| 2617 | } |
| 2618 | } |
| 2619 | return max_rx_lvl; |
| 2620 | } |
| 2621 | |
| 2622 | /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */ |
| 2623 | private function f_verify_ramp_up() runs on ConnHdlr { |
| 2624 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2625 | var integer initial_rx_lvl := -1; |
| 2626 | var integer last_rx_lvl := -1; |
| 2627 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2628 | |
| 2629 | timer T := 2.0; |
| 2630 | alt { |
| 2631 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2632 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2633 | log("Received rx_level=", rx_lvl); |
| 2634 | if (initial_rx_lvl == -1) { |
| 2635 | initial_rx_lvl := rx_lvl; |
| 2636 | last_rx_lvl := rx_lvl; |
| 2637 | |
| 2638 | /* Expect a somehow low value during first received messages */ |
| 2639 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2640 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2641 | log2str("Detected high initial tx power during ramp up: ", |
| 2642 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2643 | } |
| 2644 | } |
| 2645 | |
| 2646 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2647 | if (rx_lvl > max_rx_lvl) { |
| 2648 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2649 | log2str("Detected Tx power higher than full power: ", |
| 2650 | rx_lvl , " > ", max_rx_lvl)); |
| 2651 | } |
| 2652 | |
| 2653 | /* Make sure it never decreases, since we are rumping up */ |
| 2654 | if (last_rx_lvl > rx_lvl) { |
| 2655 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2656 | log2str("Detected Tx power decrease during ramp up: ", |
| 2657 | last_rx_lvl , " -> ", rx_lvl)); |
| 2658 | } |
| 2659 | |
| 2660 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2661 | /* We reached the maximum power, start timer and receive |
| 2662 | /* a few more to make sure we don't surpass it */ |
| 2663 | log("Reached full power, wating a bit more until success"); |
| 2664 | T.start; |
| 2665 | } |
| 2666 | |
| 2667 | last_rx_lvl := rx_lvl; |
| 2668 | repeat; |
| 2669 | } |
| 2670 | [] L1CTL.receive { repeat; } |
| 2671 | [] T.timeout { } |
| 2672 | } |
| 2673 | |
| 2674 | /* We didn't increase tx power during ramp up */ |
| 2675 | if (initial_rx_lvl < last_rx_lvl) { |
| 2676 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2677 | } else { |
| 2678 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2679 | log2str("No Tx power increase during whole ramp up: ", |
| 2680 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2681 | } |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2682 | } |
| 2683 | |
| 2684 | /* verify BTS ramps power down to rx_level 0 */ |
| 2685 | private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2686 | var L1ctlDlMessage l1_dl; |
| 2687 | var integer last_rx_lvl := max_rx_lvl; |
| 2688 | |
| 2689 | timer Tdown := 5.0; |
| 2690 | Tdown.start; |
| 2691 | alt { |
| 2692 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2693 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2694 | log("Received rx_level=", rx_lvl); |
| 2695 | |
| 2696 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2697 | if (rx_lvl > max_rx_lvl) { |
| 2698 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2699 | log2str("Detected Tx power higher than full power: ", |
| 2700 | rx_lvl , " > ", max_rx_lvl)); |
| 2701 | } |
| 2702 | |
| 2703 | /* Make sure it never increases, since we are rumping down */ |
| 2704 | if (last_rx_lvl < rx_lvl) { |
| 2705 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2706 | log2str("Detected Tx power increase during ramp up: ", |
| 2707 | last_rx_lvl , " -> ", rx_lvl)); |
| 2708 | } |
| 2709 | |
| 2710 | last_rx_lvl := rx_lvl; |
| 2711 | if (last_rx_lvl != 0) { |
| 2712 | repeat; |
| 2713 | } |
| 2714 | /* we reached power level 0, we are done */ |
| 2715 | Tdown.stop; |
| 2716 | } |
| 2717 | [] L1CTL.receive { repeat; } |
| 2718 | [] Tdown.timeout { } |
| 2719 | } |
| 2720 | |
| 2721 | /* We didn't increase tx power during ramp down */ |
| 2722 | if (max_rx_lvl > last_rx_lvl) { |
| 2723 | log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl); |
| 2724 | } else { |
| 2725 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2726 | log2str("No Tx power decrease during whole ramp down: ", |
| 2727 | max_rx_lvl , " -> ", last_rx_lvl)); |
| 2728 | } |
| 2729 | } |
| 2730 | |
| 2731 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2732 | private function f_TC_tx_power_start_ramp_up_bcch(charstring id) runs on ConnHdlr { |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2733 | f_l1_tune(L1CTL); |
| 2734 | RSL.clear; |
| 2735 | |
| 2736 | f_verify_ramp_up(); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2737 | |
| 2738 | setverdict(pass); |
| 2739 | } |
| 2740 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2741 | var ConnHdlr vc_conn; |
| 2742 | var ConnHdlrPars pars; |
| 2743 | f_init(); |
| 2744 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2745 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2746 | pcu_comp := false, trxc_comp := true); |
| 2747 | vc_conn.done; |
| 2748 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2749 | } |
| 2750 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2751 | /* Verify Tx power reduction and ramping downd uring BTS bring shutdown due to Abis link failure */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2752 | private function f_TC_tx_power_start_ramp_down_bcch(charstring id) runs on ConnHdlr { |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2753 | f_connhdlr_init_vty_bsc(); |
| 2754 | |
| 2755 | f_l1_tune(L1CTL); |
| 2756 | RSL.clear; |
| 2757 | |
| 2758 | /* Wait until BTS is started and at full power */ |
| 2759 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2760 | log("Reached nominal level ", max_rx_lvl, ", shutting down OML link"); |
| 2761 | |
| 2762 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 2763 | f_verify_ramp_down(max_rx_lvl); |
| 2764 | |
| 2765 | setverdict(pass); |
| 2766 | } |
| 2767 | testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT { |
| 2768 | var ConnHdlr vc_conn; |
| 2769 | var ConnHdlrPars pars; |
| 2770 | f_init(); |
| 2771 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2772 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars, |
| 2773 | pcu_comp := false, trxc_comp := true); |
| 2774 | vc_conn.done; |
| 2775 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2776 | } |
| 2777 | |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2778 | /* Verify Tx power: |
| 2779 | * + ramping down during ADM state UNLOCKED->LOCKED |
| 2780 | * + ramping up during ADM state LOCKED->UNLOCKED |
| 2781 | */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2782 | private function f_TC_tx_power_ramp_adm_state_change(charstring id) runs on ConnHdlr { |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2783 | var L1ctlDlMessage l1_dl; |
| 2784 | var integer last_rx_lvl; |
| 2785 | |
| 2786 | f_connhdlr_init_vty_bsc(); |
| 2787 | |
| 2788 | f_l1_tune(L1CTL); |
| 2789 | RSL.clear; |
| 2790 | |
| 2791 | /* Wait until BTS is started and at full power */ |
| 2792 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2793 | log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED"); |
| 2794 | |
| 2795 | log("ADM STATE UNLOCKED->LOCKED"); |
| 2796 | f_vty_enter_cfg_trx(BSCVTY); |
| 2797 | f_vty_transceive(BSCVTY, "rf_locked 1"); |
| 2798 | last_rx_lvl := max_rx_lvl; |
| 2799 | f_verify_ramp_down(max_rx_lvl); |
| 2800 | |
| 2801 | /* Let some time after we received 0dBm, then check we don't receive BCCH |
| 2802 | * anymore because scheduler has stopped after ramping down */ |
| 2803 | f_sleep(2.0); |
| 2804 | L1CTL.clear; |
| 2805 | timer Tlocked := 2.0; |
| 2806 | Tlocked.start; |
| 2807 | alt { |
| 2808 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2809 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2810 | log2str("Received data_ind during rf_locked: ", l1_dl)); |
| 2811 | } |
| 2812 | [] L1CTL.receive { repeat; } |
| 2813 | [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); } |
| 2814 | } |
| 2815 | |
| 2816 | log("ADM STATE LOCKED->UNLOCKED"); |
| 2817 | f_vty_transceive(BSCVTY, "rf_locked 0"); |
| 2818 | f_verify_ramp_up(); |
| 2819 | setverdict(pass); |
| 2820 | } |
| 2821 | testcase TC_tx_power_ramp_adm_state_change() runs on test_CT { |
| 2822 | var ConnHdlr vc_conn; |
| 2823 | var ConnHdlrPars pars; |
| 2824 | f_init(); |
| 2825 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2826 | vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars, |
| 2827 | pcu_comp := false, trxc_comp := true); |
| 2828 | vc_conn.done; |
| 2829 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2830 | } |
| 2831 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2832 | private function f_check_meas_bs_power_level(integer level) runs on ConnHdlr { |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2833 | timer T := 8.0; |
| 2834 | T.start; |
| 2835 | var RSL_Message rsl; |
| 2836 | alt { |
| 2837 | [] as_l1_sacch(); |
| 2838 | [] L1CTL.receive { repeat; } |
| 2839 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 2840 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 2841 | setverdict(pass) |
| 2842 | } else { |
| 2843 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 2844 | } |
| 2845 | } |
| 2846 | [] T.timeout { |
| 2847 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 2848 | } |
| 2849 | } |
| 2850 | } |
| 2851 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2852 | /* See if the RSL MEASurement RESult contains expeced BS power level |
| 2853 | * set _during_ the CHANnel ACTIVation procedure. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2854 | private function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr { |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2855 | f_l1_tune(L1CTL); |
| 2856 | RSL.clear; |
| 2857 | |
| 2858 | if (mp_bts_trxc_port != -1) { |
| 2859 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2860 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2861 | } |
| 2862 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2863 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2864 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2865 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 2866 | |
| 2867 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2868 | |
| 2869 | f_check_meas_bs_power_level(pwr_var); |
| 2870 | |
| 2871 | f_rsl_chan_deact(); |
| 2872 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2873 | } |
| 2874 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2875 | /* See if the RSL MEASurement RESult contains expeced BS power level |
| 2876 | * set _after_ the CHANnel ACTIVation procedure. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2877 | private function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr { |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2878 | f_l1_tune(L1CTL); |
| 2879 | RSL.clear; |
| 2880 | |
| 2881 | if (mp_bts_trxc_port != -1) { |
| 2882 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2883 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2884 | } |
| 2885 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2886 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2887 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2888 | |
| 2889 | f_est_dchan(); |
| 2890 | |
| 2891 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 2892 | |
| 2893 | f_check_meas_bs_power_level(pwr_var); |
| 2894 | |
| 2895 | f_rsl_chan_deact(); |
| 2896 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2897 | } |
| 2898 | |
| 2899 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 2900 | var ConnHdlr vc_conn; |
| 2901 | var ConnHdlrPars pars; |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 2902 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2903 | f_init(); |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 2904 | |
| 2905 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, trx_nr := 1)); |
| 2906 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 2907 | pcu_comp := false, trxc_comp := true); |
| 2908 | vc_conn.done; |
| 2909 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2910 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2911 | } |
| 2912 | |
| 2913 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 2914 | var ConnHdlr vc_conn; |
| 2915 | var ConnHdlrPars pars; |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 2916 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2917 | f_init(); |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 2918 | |
| 2919 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, trx_nr := 1)); |
| 2920 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 2921 | pcu_comp := false, trxc_comp := true); |
| 2922 | vc_conn.done; |
| 2923 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2924 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2925 | } |
| 2926 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2927 | /* Target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 2928 | * second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds. |
| 2929 | * These power levels are valid for all bands and require no special handling. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2930 | private function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2931 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2932 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2933 | |
| 2934 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2935 | f_l1_tune(L1CTL); |
| 2936 | RSL.clear; |
| 2937 | |
| 2938 | var RSL_IE_List addl_ies; |
| 2939 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2940 | |
| 2941 | addl_ies := { |
| 2942 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2943 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2944 | }; |
| 2945 | |
| 2946 | /* establish with power parameters */ |
| 2947 | f_est_dchan(more_ies := addl_ies); |
| 2948 | |
| 2949 | /* set a high value to ensure L1 power control level increases */ |
| 2950 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2951 | |
| 2952 | timer T2 := 6.0; |
| 2953 | T2.start; |
| 2954 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2955 | [] as_l1_sacch_l1h(l1h) { |
| 2956 | if (l1h.ms_power_lvl < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2957 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2958 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2959 | T2.stop; |
| 2960 | } |
| 2961 | [] L1CTL.receive { repeat; } |
| 2962 | [] T2.timeout { |
| 2963 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2964 | "Power Level in L1 header has not increased sufficiently"); |
| 2965 | } |
| 2966 | } |
| 2967 | |
| 2968 | /* set a low value to ensure L1 power control level decreases */ |
| 2969 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 2970 | |
| 2971 | timer T4 := 6.0; |
| 2972 | T4.start; |
| 2973 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2974 | [] as_l1_sacch_l1h(l1h) { |
| 2975 | if (l1h.ms_power_lvl > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2976 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2977 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2978 | T4.stop; |
| 2979 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 2980 | } |
| 2981 | [] L1CTL.receive { repeat; } |
| 2982 | [] T4.timeout { |
| 2983 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2984 | "Power Level in L1 header has not decreased sufficiently"); |
| 2985 | } |
| 2986 | } |
| 2987 | |
| 2988 | f_rsl_chan_deact(); |
| 2989 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2990 | |
| 2991 | } |
| 2992 | |
| 2993 | /* check that we do not exceed the max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2994 | private function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2995 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2996 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2997 | |
| 2998 | /* set a low value to ensure power increases */ |
| 2999 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 3000 | f_l1_tune(L1CTL); |
| 3001 | RSL.clear; |
| 3002 | |
| 3003 | var RSL_IE_List addl_ies; |
| 3004 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 3005 | |
| 3006 | addl_ies := { |
| 3007 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 3008 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 3009 | }; |
| 3010 | |
| 3011 | /* establish with power parameters */ |
| 3012 | f_est_dchan(more_ies := addl_ies); |
| 3013 | |
| 3014 | timer T1 := 10.0; |
| 3015 | T1.start; |
| 3016 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3017 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3018 | [] L1CTL.receive { repeat; } |
| 3019 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3020 | if (not isbound(l1h)) { |
| 3021 | setverdict(fail, "No SACCH blocks were received"); |
| 3022 | } else if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3023 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 3024 | } |
| 3025 | } |
| 3026 | } |
| 3027 | |
| 3028 | f_rsl_chan_deact(); |
| 3029 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3030 | |
| 3031 | } |
| 3032 | |
| 3033 | /* see if we reach the band max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3034 | private function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3035 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3036 | var uint5_t pwr_var := 15; |
| 3037 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 3038 | |
| 3039 | /* set a low value to ensure power increases */ |
| 3040 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 3041 | f_l1_tune(L1CTL); |
| 3042 | RSL.clear; |
| 3043 | |
| 3044 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3045 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3046 | |
| 3047 | /* establish with fixed power level */ |
| 3048 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3049 | |
| 3050 | /* check our initial power level */ |
| 3051 | f_wait_for_l1_power_level(pwr_var); |
| 3052 | |
| 3053 | /* update power param to enable power loop |
| 3054 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 3055 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 3056 | |
Vadim Yanitskiy | 93ad814 | 2022-04-08 01:52:13 +0300 | [diff] [blame] | 3057 | /* By default, the MS power loop gets triggered every 4th SACCH block (1.92s). |
| 3058 | * We need 9 * 4 dB steps to get from 0 dBm to 33 dBm, so 9 * 1.92s total. |
| 3059 | * Add an extra offset to avoid race conditions: +1.92s. */ |
| 3060 | timer T1 := 9.0 * 1.92 + 1.92; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3061 | T1.start; |
| 3062 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3063 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3064 | [] L1CTL.receive { repeat; } |
| 3065 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3066 | if (not isbound(l1h)) { |
| 3067 | setverdict(fail, "No SACCH blocks were received"); |
| 3068 | } else if (f_power_level_is_highest_dbm(l1h.ms_power_lvl)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3069 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 3070 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3071 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, " did not ", |
| 3072 | "reach the expected value := ", pwr_max_var); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3073 | } |
| 3074 | } |
| 3075 | } |
| 3076 | |
| 3077 | f_rsl_chan_deact(); |
| 3078 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3079 | |
| 3080 | } |
| 3081 | |
| 3082 | /* see if we reach the band min power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3083 | private function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3084 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3085 | |
| 3086 | /* set a high value to ensure power decreases */ |
| 3087 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3088 | f_l1_tune(L1CTL); |
| 3089 | RSL.clear; |
| 3090 | |
| 3091 | var uint5_t pwr_var := 5; |
| 3092 | var uint5_t pwr_target_val := 15; |
| 3093 | |
| 3094 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3095 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3096 | |
| 3097 | /* establish with fixed power level */ |
| 3098 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3099 | |
| 3100 | /* check our initial power level */ |
| 3101 | f_wait_for_l1_power_level(pwr_var); |
| 3102 | |
| 3103 | /* update power param to enable power loop |
| 3104 | 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] | 3105 | 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] | 3106 | |
| 3107 | /* wait, then check that our power level was increased */ |
| 3108 | timer T1 := 10.0; |
| 3109 | T1.start; |
| 3110 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3111 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3112 | [] L1CTL.receive { repeat; } |
| 3113 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3114 | if (not isbound(l1h)) { |
| 3115 | setverdict(fail, "No SACCH blocks were received"); |
| 3116 | } else if (f_power_level_is_lowest_dbm(l1h.ms_power_lvl)) { |
| 3117 | setverdict(pass, "Power level increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3118 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3119 | setverdict(fail, "Power level NOT increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3120 | } |
| 3121 | } |
| 3122 | } |
| 3123 | |
| 3124 | f_rsl_chan_deact(); |
| 3125 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3126 | |
| 3127 | } |
| 3128 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3129 | /* See if the power level remains constant when MS Power Parameters IE |
| 3130 | * is _absent_ in the CHANnel ACTIVation message. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3131 | private function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3132 | var SacchL1Header l1h; |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3133 | |
| 3134 | /* set a high value to ensure power decreases */ |
| 3135 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3136 | f_l1_tune(L1CTL); |
| 3137 | RSL.clear; |
| 3138 | |
| 3139 | var uint5_t pwr_var := 5; |
| 3140 | |
| 3141 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3142 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3143 | |
| 3144 | /* establish with fixed power level */ |
| 3145 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3146 | |
| 3147 | /* check our initial power level */ |
| 3148 | f_wait_for_l1_power_level(pwr_var); |
| 3149 | |
| 3150 | /* wait, then check that our power level did not change */ |
| 3151 | timer T1 := 10.0; |
| 3152 | T1.start; |
| 3153 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3154 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3155 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3156 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3157 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 3158 | } |
| 3159 | repeat; |
| 3160 | } |
| 3161 | [] L1CTL.receive { repeat; } |
| 3162 | [] T1.timeout { setverdict(pass); } |
| 3163 | } |
| 3164 | |
| 3165 | f_rsl_chan_deact(); |
| 3166 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3167 | |
| 3168 | } |
| 3169 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3170 | /* See if the power level remains constant when MS Power Parameters IE |
| 3171 | * is _absent_ in the CHANnel ACTIVation and MS Power Control messages. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3172 | private function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3173 | var SacchL1Header l1h; |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3174 | |
| 3175 | /* set a high value to ensure power decreases */ |
| 3176 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3177 | f_l1_tune(L1CTL); |
| 3178 | RSL.clear; |
| 3179 | |
| 3180 | var uint5_t pwr_var := 5; |
| 3181 | |
| 3182 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3183 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3184 | |
| 3185 | /* establish with fixed power level */ |
| 3186 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3187 | |
| 3188 | /* check our initial power level */ |
| 3189 | f_wait_for_l1_power_level(pwr_var); |
| 3190 | |
| 3191 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 3192 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3193 | |
| 3194 | /* wait, then check that our power level did not change */ |
| 3195 | timer T1 := 10.0; |
| 3196 | T1.start; |
| 3197 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3198 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3199 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3200 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3201 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 3202 | } |
| 3203 | repeat; |
| 3204 | } |
| 3205 | [] L1CTL.receive { repeat; } |
| 3206 | [] T1.timeout { setverdict(pass); } |
| 3207 | } |
| 3208 | |
| 3209 | f_rsl_chan_deact(); |
| 3210 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3211 | |
| 3212 | } |
| 3213 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3214 | private function f_wait_for_l1_power_level(integer level) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3215 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3216 | timer T0 := 10.0; |
| 3217 | T0.start; |
| 3218 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3219 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3220 | if (l1h.ms_power_lvl != level) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3221 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3222 | "Power level in L1 header != signaled (RSL) power level."); |
| 3223 | } |
| 3224 | } |
| 3225 | [] L1CTL.receive { repeat; } |
| 3226 | [] T0.timeout { |
| 3227 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3228 | "Timeout waiting for initial power level"); |
| 3229 | } |
| 3230 | } |
| 3231 | T0.stop; |
| 3232 | } |
| 3233 | |
| 3234 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 3235 | var IntegerRecord min_dbm_level; |
| 3236 | var IntegerRecord max_dbm_level; |
| 3237 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3238 | |
| 3239 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 3240 | if (min_dbm_level[i] == level) { |
| 3241 | return true; |
| 3242 | } |
| 3243 | } |
| 3244 | return false; |
| 3245 | } |
| 3246 | |
| 3247 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 3248 | var IntegerRecord min_dbm_level; |
| 3249 | var IntegerRecord max_dbm_level; |
| 3250 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3251 | |
| 3252 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 3253 | if (max_dbm_level[i] == level) { |
| 3254 | return true; |
| 3255 | } |
| 3256 | } |
| 3257 | return false; |
| 3258 | } |
| 3259 | |
| 3260 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 3261 | var IntegerRecord min_dbm_level; |
| 3262 | var IntegerRecord max_dbm_level; |
| 3263 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3264 | return max_dbm_level[0]; |
| 3265 | } |
| 3266 | |
| 3267 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3268 | private template charstring BtsBand_allGSM := pattern "GSM???"; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3269 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 3270 | // 45.005 4.1.1 |
| 3271 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 3272 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 3273 | 2, 1, 0}; |
| 3274 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 3275 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 3276 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 3277 | var IntegerRecord rv; |
| 3278 | |
| 3279 | select(band){ |
| 3280 | case (BtsBand_allGSM){ |
| 3281 | rv := gsm_power; |
| 3282 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 3283 | max_dbm_level := {2, 1, 0}; |
| 3284 | } |
| 3285 | case("DCS1800"){ |
| 3286 | rv := dcs_power; |
| 3287 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 3288 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 3289 | } |
| 3290 | case("PCS1900"){ |
| 3291 | rv := pcs_power; |
| 3292 | min_dbm_level := {15}; |
| 3293 | max_dbm_level := {30}; |
| 3294 | } |
Harald Welte | 194b691 | 2020-10-11 21:01:55 +0200 | [diff] [blame] | 3295 | case else { |
| 3296 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band); |
| 3297 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3298 | } |
| 3299 | |
| 3300 | return rv; |
| 3301 | } |
| 3302 | |
| 3303 | private function f_vty_get_bts0_band() runs on test_CT return BtsBand { |
Harald Welte | c935fad | 2020-10-11 21:02:54 +0200 | [diff] [blame] | 3304 | return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of*type* in band (\w+),*", 0); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3305 | } |
| 3306 | |
| 3307 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 3308 | var ConnHdlr vc_conn; |
| 3309 | var ConnHdlrPars pars; |
| 3310 | f_init(); |
| 3311 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3312 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3313 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3314 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3315 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 3316 | vc_conn.done; |
| 3317 | } |
| 3318 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3319 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3320 | } |
| 3321 | |
| 3322 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 3323 | var ConnHdlr vc_conn; |
| 3324 | var ConnHdlrPars pars; |
| 3325 | f_init(); |
| 3326 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3327 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3328 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3329 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3330 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 3331 | vc_conn.done; |
| 3332 | } |
| 3333 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3334 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3335 | } |
| 3336 | |
| 3337 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 3338 | var ConnHdlr vc_conn; |
| 3339 | var ConnHdlrPars pars; |
| 3340 | f_init(); |
| 3341 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3342 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3343 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3344 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3345 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 3346 | vc_conn.done; |
| 3347 | } |
| 3348 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3349 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3350 | } |
| 3351 | |
| 3352 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 3353 | var ConnHdlr vc_conn; |
| 3354 | var ConnHdlrPars pars; |
| 3355 | f_init(); |
| 3356 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3357 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3358 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3359 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3360 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 3361 | vc_conn.done; |
| 3362 | } |
| 3363 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3364 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3365 | } |
| 3366 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3367 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 3368 | var ConnHdlr vc_conn; |
| 3369 | var ConnHdlrPars pars; |
| 3370 | f_init(); |
| 3371 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3372 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3373 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3374 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3375 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 3376 | vc_conn.done; |
| 3377 | } |
| 3378 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3379 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3380 | } |
| 3381 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3382 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 3383 | var ConnHdlr vc_conn; |
| 3384 | var ConnHdlrPars pars; |
| 3385 | f_init(); |
| 3386 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3387 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3388 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3389 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3390 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 3391 | vc_conn.done; |
| 3392 | } |
| 3393 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3394 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3395 | } |
| 3396 | |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3397 | function f_TC_meas_res_speech_tchf(boolean facch_enabled) runs on test_CT { |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3398 | var template RSL_IE_ChannelMode ch_mode; |
| 3399 | var ConnHdlr vc_conn; |
| 3400 | var ConnHdlrPars pars; |
| 3401 | f_init(); |
| 3402 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3403 | for (var integer tn := 1; tn <= 1; tn := tn + 1) { |
| 3404 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3405 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3406 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3407 | pcu_comp := false, trxc_comp := true); |
| 3408 | vc_conn.done; |
| 3409 | } |
| 3410 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3411 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3412 | |
| 3413 | testcase TC_meas_res_speech_tchf() runs on test_CT { |
| 3414 | f_TC_meas_res_speech_tchf(false); |
| 3415 | } |
| 3416 | |
| 3417 | testcase TC_meas_res_speech_tchf_facch() runs on test_CT { |
| 3418 | f_TC_meas_res_speech_tchf(true); |
| 3419 | } |
| 3420 | |
| 3421 | function f_TC_meas_res_speech_tchh(boolean facch_enabled) runs on test_CT { |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3422 | var template RSL_IE_ChannelMode ch_mode; |
| 3423 | var ConnHdlr vc_conn; |
| 3424 | var ConnHdlrPars pars; |
| 3425 | f_init(); |
| 3426 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3427 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3428 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3429 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3430 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3431 | pcu_comp := false, trxc_comp := true); |
| 3432 | vc_conn.done; |
| 3433 | } |
| 3434 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3435 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3436 | |
| 3437 | testcase TC_meas_res_speech_tchh() runs on test_CT { |
| 3438 | f_TC_meas_res_speech_tchh(false) |
| 3439 | } |
| 3440 | |
| 3441 | testcase TC_meas_res_speech_tchh_facch() runs on test_CT { |
| 3442 | f_TC_meas_res_speech_tchh(true) |
| 3443 | } |
| 3444 | |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 3445 | testcase TC_meas_res_speech_tchh_toa256() runs on test_CT { |
| 3446 | var template RSL_IE_ChannelMode ch_mode; |
| 3447 | var ConnHdlr vc_conn; |
| 3448 | var ConnHdlrPars pars; |
| 3449 | f_init(); |
| 3450 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3451 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3452 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3453 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
| 3454 | pars.l1_pars.toa256_enabled := true; |
| 3455 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3456 | pcu_comp := false, trxc_comp := true); |
| 3457 | vc_conn.done; |
| 3458 | } |
| 3459 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3460 | } |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3461 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3462 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 3463 | var ConnHdlr vc_conn; |
| 3464 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3465 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3466 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3467 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3468 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_F))); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3469 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3470 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3471 | vc_conn.done; |
| 3472 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3473 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3474 | } |
| 3475 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 3476 | var ConnHdlr vc_conn; |
| 3477 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3478 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3479 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3480 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3481 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_H))); |
Eric Wild | 5b9ef14 | 2019-07-11 19:28:02 +0200 | [diff] [blame] | 3482 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3483 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3484 | vc_conn.done; |
| 3485 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3486 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3487 | } |
| 3488 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 3489 | var ConnHdlr vc_conn; |
| 3490 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3491 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3492 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3493 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 3494 | 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] | 3495 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3496 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3497 | vc_conn.done; |
| 3498 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3499 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3500 | } |
| 3501 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 3502 | var ConnHdlr vc_conn; |
| 3503 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3504 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3505 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3506 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 3507 | 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] | 3508 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3509 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3510 | vc_conn.done; |
| 3511 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3512 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3513 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3514 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 3515 | var ConnHdlr vc_conn; |
| 3516 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3517 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3518 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3519 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3520 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_H))); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3521 | pars.l1_pars.toa256_enabled := true; |
Vadim Yanitskiy | 0b65219 | 2020-10-20 02:39:02 +0700 | [diff] [blame] | 3522 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3523 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3524 | vc_conn.done; |
| 3525 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3526 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3527 | } |
| 3528 | |
Vadim Yanitskiy | 8f6eae0 | 2021-10-26 02:49:21 +0300 | [diff] [blame] | 3529 | /* Make sure that we always get RSL MEASurement RESult messages regardless |
| 3530 | * of what is sent on SACCH: (RR) Measurement Report or SAPI=3 data (SMS). */ |
| 3531 | private function f_TC_meas_res_sapi3(charstring id) runs on ConnHdlr { |
| 3532 | timer Texec := 8.0; |
| 3533 | timer Timpf := 2.0; |
| 3534 | timer Tmr; |
| 3535 | |
| 3536 | f_l1_tune(L1CTL); |
| 3537 | RSL.clear; |
| 3538 | |
| 3539 | f_est_dchan(); |
| 3540 | L1CTL.clear; |
| 3541 | |
| 3542 | /* Establish the main SAPI=0 link on DCCH first */ |
| 3543 | f_tx_lapdm(ts_LAPDm_SABM(0, cr_MO_CMD, true, ''O), ts_RslLinkID_DCCH(0)); |
| 3544 | |
| 3545 | /* Give more time for the first RSL MEASurement RESult */ |
| 3546 | Tmr.start(0.480 * 2.0); |
| 3547 | Texec.start; /* EXECution timer */ |
| 3548 | Timpf.start; /* IMPFung timer */ |
| 3549 | |
| 3550 | alt { |
| 3551 | /* We expect RSL MEASurement RESult messages every ~480ms (plus some guard) */ |
| 3552 | [] RSL.receive(tr_RSL_MEAS_RES(g_pars.chan_nr)) { |
| 3553 | /* Reschedule the MEAS RES timer */ |
| 3554 | Tmr.start(0.480 + 0.120); |
| 3555 | repeat; |
| 3556 | } |
| 3557 | [] RSL.receive { repeat; } |
| 3558 | [] Tmr.timeout { |
| 3559 | setverdict(fail, "Timeout waiting for RSL MEAS RES"); |
| 3560 | } |
| 3561 | /* Inject some SAPI=3 traffic on SACCH every 2 seconds */ |
| 3562 | [] Timpf.timeout { |
| 3563 | f_tx_lapdm(ts_LAPDm_SABM(3, cr_MO_CMD, true, ''O), ts_RslLinkID_SACCH(3)); |
| 3564 | log("Injected SAPI=3 traffic on SACCH"); |
| 3565 | Timpf.start; |
| 3566 | repeat; |
| 3567 | } |
| 3568 | /* We're good if survived so far */ |
| 3569 | [] Texec.timeout { |
| 3570 | setverdict(pass); |
| 3571 | } |
| 3572 | } |
| 3573 | |
| 3574 | f_rsl_chan_deact(); |
| 3575 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3576 | f_rslem_unregister(0, g_chan_nr); |
| 3577 | } |
| 3578 | testcase TC_meas_res_speech_tchf_sapi3() runs on test_CT { |
| 3579 | var template RSL_IE_ChannelMode ch_mode; |
| 3580 | var template ConnHdlrPars pars; |
| 3581 | var ConnHdlr vc_conn; |
| 3582 | |
| 3583 | f_init(); |
| 3584 | |
| 3585 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3586 | pars := t_Pars(t_RslChanNr_Bm(1), ch_mode); |
| 3587 | |
| 3588 | vc_conn := f_start_handler(refers(f_TC_meas_res_sapi3), valueof(pars)); |
| 3589 | vc_conn.done; |
| 3590 | |
| 3591 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3592 | } |
| 3593 | testcase TC_meas_res_speech_tchh_sapi3() runs on test_CT { |
| 3594 | var template RSL_IE_ChannelMode ch_mode; |
| 3595 | var template ConnHdlrPars pars; |
| 3596 | var ConnHdlr vc_conn; |
| 3597 | |
| 3598 | f_init(); |
| 3599 | |
| 3600 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3601 | pars := t_Pars(t_RslChanNr_Lm(5, 0), ch_mode); |
| 3602 | |
| 3603 | vc_conn := f_start_handler(refers(f_TC_meas_res_sapi3), valueof(pars)); |
| 3604 | vc_conn.done; |
| 3605 | |
| 3606 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3607 | } |
| 3608 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3609 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 3610 | * the BTS is forwarding those values to the MS via the SACCH L1 header. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3611 | private function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3612 | var SacchL1Header l1h; |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3613 | var RSL_IE_MS_Power ms_power; |
| 3614 | var RSL_Message rsl; |
| 3615 | var uint5_t power_level := 0; |
| 3616 | |
| 3617 | f_l1_tune(L1CTL); |
| 3618 | RSL.clear; |
| 3619 | |
| 3620 | f_est_dchan(); |
| 3621 | |
| 3622 | ms_power.reserved := 0; |
| 3623 | ms_power.fpc_epc := false; |
| 3624 | |
| 3625 | /* Send the first power control command. This will disable any BTS/TRX |
| 3626 | * internal power control and switch the MS (which is not in scope of |
| 3627 | * this test) to a constant power level. We start with a power level |
| 3628 | * of 0 */ |
| 3629 | ms_power.power_level := power_level; |
| 3630 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3631 | RSL.send(rsl); |
| 3632 | |
| 3633 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3634 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3635 | if (l1h.ms_power_lvl != power_level) { |
| 3636 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3637 | "match the signaled (RSL) power level := ", power_level); |
| 3638 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3639 | } |
| 3640 | |
| 3641 | /* Signal a new power level via RSL for the next turn. */ |
| 3642 | if (power_level < 31) { |
| 3643 | power_level := power_level + 1; |
| 3644 | ms_power.power_level := power_level; |
| 3645 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3646 | RSL.send(rsl); |
| 3647 | repeat; |
| 3648 | } |
| 3649 | |
| 3650 | } |
| 3651 | |
| 3652 | /* Ignore all other blocks */ |
| 3653 | [] L1CTL.receive { repeat; } |
| 3654 | |
| 3655 | } |
| 3656 | |
| 3657 | f_rsl_chan_deact(); |
| 3658 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3659 | |
| 3660 | setverdict(pass); |
| 3661 | } |
| 3662 | |
| 3663 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 3664 | var ConnHdlr vc_conn; |
| 3665 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3666 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3667 | |
| 3668 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 3669 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3670 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 3671 | vc_conn.done; |
| 3672 | } |
| 3673 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3674 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3675 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 3676 | /* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header. |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3677 | TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3678 | private function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr { |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3679 | var uint5_t ta_to_test := 16; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3680 | var SacchL1Header l1h; |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3681 | |
| 3682 | f_l1_tune(L1CTL); |
| 3683 | RSL.clear; |
| 3684 | |
| 3685 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 3686 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3687 | |
| 3688 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 3689 | |
| 3690 | |
| 3691 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3692 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3693 | if (l1h.actual_ta != ta_to_test) { |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3694 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 3695 | } |
| 3696 | |
| 3697 | } |
| 3698 | |
| 3699 | /* Ignore all other blocks */ |
| 3700 | [] L1CTL.receive { repeat; } |
| 3701 | |
| 3702 | } |
| 3703 | |
| 3704 | f_rsl_chan_deact(); |
| 3705 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3706 | |
| 3707 | setverdict(pass); |
| 3708 | } |
| 3709 | |
| 3710 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 3711 | var ConnHdlr vc_conn; |
| 3712 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3713 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3714 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3715 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 3716 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3717 | vc_conn.done; |
| 3718 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3719 | } |
| 3720 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3721 | /* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3722 | private function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr { |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3723 | var uint5_t ms_power_level := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3724 | var SacchL1Header l1h; |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3725 | |
| 3726 | var RSL_IE_MS_Power ms_power; |
| 3727 | ms_power.reserved := 0; |
| 3728 | ms_power.fpc_epc := false; |
| 3729 | ms_power.power_level := ms_power_level; |
| 3730 | |
| 3731 | f_l1_tune(L1CTL); |
| 3732 | RSL.clear; |
| 3733 | |
| 3734 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 3735 | |
| 3736 | timer T := 1.0; |
| 3737 | T.start; |
| 3738 | alt { |
| 3739 | /* Pick all SACCH blocks for checking */ |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3740 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3741 | if (l1h.ms_power_lvl != ms_power_level) { |
| 3742 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3743 | "match the signaled (RSL) power level := ", ms_power_level); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3744 | } |
| 3745 | } |
| 3746 | /* Ignore all other blocks */ |
| 3747 | [] L1CTL.receive { repeat; } |
| 3748 | [] T.timeout { |
| 3749 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3750 | } |
| 3751 | } |
| 3752 | |
| 3753 | f_rsl_chan_deact(); |
| 3754 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3755 | setverdict(pass); |
| 3756 | } |
| 3757 | |
| 3758 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 3759 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3760 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 3761 | } |
| 3762 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3763 | /* 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] | 3764 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3765 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3766 | RSL.clear; |
| 3767 | |
| 3768 | f_est_dchan(); |
| 3769 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3770 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3771 | |
| 3772 | timer T := 40.0; |
| 3773 | T.start; |
| 3774 | alt { |
| 3775 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 3776 | setverdict(pass) |
| 3777 | } |
| 3778 | [] RSL.receive { repeat }; |
| 3779 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3780 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3781 | } |
| 3782 | } |
| 3783 | f_rsl_chan_deact(); |
| 3784 | } |
| 3785 | testcase TC_conn_fail_crit() runs on test_CT { |
| 3786 | var ConnHdlr vc_conn; |
| 3787 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3788 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3789 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 3790 | pars.t_guard := 60.0; |
| 3791 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 3792 | vc_conn.done; |
| 3793 | } |
| 3794 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3795 | /*********************************************************************** |
| 3796 | * Paging |
| 3797 | ***********************************************************************/ |
| 3798 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3799 | private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3800 | if (tmsi == 'FFFFFFFF'O) { |
| 3801 | return true; |
| 3802 | } else { |
| 3803 | return false; |
| 3804 | } |
| 3805 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3806 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3807 | private type record allowedFn { integer frame_nr } |
| 3808 | private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 3809 | private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 3810 | private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 3811 | private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 3812 | private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 3813 | private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 3814 | private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 3815 | private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 3816 | private function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3817 | { |
| 3818 | var integer frame_nr_51; |
| 3819 | frame_nr_51 := frame_nr mod 51 |
| 3820 | |
| 3821 | var allowedFn fn_check; |
| 3822 | fn_check.frame_nr := frame_nr_51; |
| 3823 | |
| 3824 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3825 | 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] | 3826 | return; |
| 3827 | } |
| 3828 | |
| 3829 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 3830 | return; |
| 3831 | } |
| 3832 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 3833 | return; |
| 3834 | } |
| 3835 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 3836 | return; |
| 3837 | } |
| 3838 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 3839 | return; |
| 3840 | } |
| 3841 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 3842 | return; |
| 3843 | } |
| 3844 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 3845 | return; |
| 3846 | } |
| 3847 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 3848 | return; |
| 3849 | } |
| 3850 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 3851 | return; |
| 3852 | } |
| 3853 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3854 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3855 | return; |
| 3856 | } |
| 3857 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3858 | private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, |
| 3859 | inout integer num_paging_rcv_ids, |
| 3860 | PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3861 | runs on test_CT { |
| 3862 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3863 | [] 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] | 3864 | repeat; |
| 3865 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3866 | [] 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] | 3867 | var octetstring without_plen := |
| 3868 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 3869 | 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] | 3870 | |
| 3871 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 3872 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 3873 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 3874 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 3875 | * TODO: does it make sense to count them? */ |
| 3876 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3877 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3878 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3879 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3880 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3881 | } |
| 3882 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 3883 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3884 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 3885 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3886 | } |
| 3887 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 3888 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3889 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3890 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3891 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3892 | } |
| 3893 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 3894 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3895 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 3896 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3897 | } |
| 3898 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 3899 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3900 | } |
| 3901 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 3902 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3903 | } |
| 3904 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 3905 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3906 | } |
| 3907 | } |
| 3908 | repeat; |
| 3909 | } |
| 3910 | } |
| 3911 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3912 | private type record PagingTestCfg { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3913 | boolean combined_ccch, |
| 3914 | integer bs_ag_blks_res, |
| 3915 | float load_factor, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3916 | /* Mix in a paging request through the PCU socket for every Nth (ps_load_modulus) |
| 3917 | * paging command that is issued via RSL. */ |
| 3918 | integer ps_load_modulus, |
| 3919 | /* Wait until the paging queue inside the BTS is congested before starting to add |
| 3920 | * pagings via the PCU socket (0 = disabled) */ |
| 3921 | boolean ps_wait_cong, |
| 3922 | /* Maximum time to wait until the paging queue is drained at the end of the test. |
| 3923 | * This usually takes about 15s (size: 200, ~ 13 per s -> 15s), it is recommended |
| 3924 | * to set this value to 18s, however the draining process may take significantly |
| 3925 | * longer when the queue contains paging requests for PS as those are implemented |
| 3926 | * as immediate assignments and require an entire MAC block alone. */ |
| 3927 | float queue_drain_timeout, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3928 | boolean exp_load_ind, |
| 3929 | boolean exp_overload, |
| 3930 | boolean use_tmsi |
| 3931 | } |
| 3932 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3933 | private type record PagingTestState { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3934 | integer num_paging_sent, |
| 3935 | integer num_paging_rcv_msgs, |
| 3936 | integer num_paging_rcv_ids, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3937 | integer num_overload, |
| 3938 | /* When free space inside the paging queue reaches more than 2 thirds |
| 3939 | * of its capacity cong_detected is set to true. */ |
| 3940 | boolean cong_detected |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3941 | } |
| 3942 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3943 | /* Helper function for paging related testing */ |
| 3944 | private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3945 | /* Using the PCU socket affects the timing of the paging processing. We only |
| 3946 | * activate the PCU socket if we do paging load tests that include additional |
| 3947 | * paging load that is introduced through the PCU socket. */ |
| 3948 | if (cfg.ps_load_modulus > 0) { |
| 3949 | f_init_with_pcuif(); |
| 3950 | } else { |
| 3951 | f_init(); |
| 3952 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3953 | f_init_l1ctl(); |
| 3954 | f_l1_tune(L1CTL); |
| 3955 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3956 | var octetstring imm_ass := f_rnd_octstring(23); |
| 3957 | var ASP_RSL_Unitdata load_ind; |
| 3958 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3959 | var PagingTestState st := { |
| 3960 | num_paging_sent := 0, |
| 3961 | num_paging_rcv_msgs := 0, |
| 3962 | num_paging_rcv_ids := 0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3963 | num_overload := 0, |
| 3964 | cong_detected := false |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3965 | }; |
| 3966 | |
| 3967 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 3968 | var float max_pch_imsi_per_sec; |
| 3969 | if (cfg.use_tmsi) { |
| 3970 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 3971 | } else { |
| 3972 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 3973 | } |
| 3974 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 3975 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3976 | var float time_total := 20.0; |
| 3977 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 3978 | 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] | 3979 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3980 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 3981 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3982 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3983 | timer T_itv := 0.0; |
| 3984 | T_itv.start; |
| 3985 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3986 | alt { |
| 3987 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3988 | [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] | 3989 | st.num_overload := st.num_overload + 1; |
| 3990 | repeat; |
| 3991 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3992 | [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] | 3993 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3994 | } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3995 | [cfg.exp_load_ind] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) -> value load_ind { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3996 | log("Rx LOAD_IND"); |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3997 | |
| 3998 | /* Detect paging congestion: The logic inside the BTS will diagnose the |
| 3999 | * paging queue as congested when the fill state is more than 66% (which |
| 4000 | * is two thirds fill state, or approx. 66 of 200 paging slots. When a |
| 4001 | * paging congestion is detected pagings that are issued through the PCU |
| 4002 | * socket (PS) are dropped in order to prefer the CS related pagings. */ |
| 4003 | if (load_ind.rsl.ies[1].body.paging_load < 66) { |
| 4004 | st.cong_detected := true; |
| 4005 | } |
| 4006 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4007 | /* FIXME: analyze/verify interval + contents */ |
| 4008 | repeat; |
| 4009 | } |
Vadim Yanitskiy | 2372db6 | 2021-06-09 00:50:11 +0200 | [diff] [blame] | 4010 | /* ignore other RSL messages like RF RESource INDication */ |
| 4011 | [] RSL_CCHAN.receive { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4012 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 4013 | [] 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] | 4014 | [] L1CTL.receive { repeat; } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4015 | /* Only relevant when testing including with PCU sock connected */ |
| 4016 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4017 | [] T_itv.timeout { |
| 4018 | /* Send paging cmds based on elapsed time */ |
| 4019 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 4020 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4021 | var MobileIdentityV mi; |
| 4022 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4023 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4024 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4025 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4026 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4027 | 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] | 4028 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4029 | |
| 4030 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4031 | 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] | 4032 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4033 | /* Add additional pagings through the PCU socket interface. */ |
| 4034 | if (cfg.ps_load_modulus > 0 and st.num_paging_sent mod cfg.ps_load_modulus == 0) { |
| 4035 | if (st.cong_detected == true or cfg.ps_wait_cong == false) { |
| 4036 | f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H, wait_for_cnf := false); |
| 4037 | } |
| 4038 | } |
| 4039 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4040 | st.num_paging_sent := st.num_paging_sent + 1; |
| 4041 | } |
| 4042 | if (st.num_paging_sent < pkt_total) { |
| 4043 | /* Wait for interval to next PAGING COMMAND */ |
| 4044 | var float time_now := T_total.read; |
| 4045 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 4046 | if (next_sched > time_now) { |
| 4047 | T_itv.start(next_sched - time_now); |
| 4048 | } else { |
| 4049 | T_itv.start(0.0); |
| 4050 | } |
| 4051 | } else { |
| 4052 | /* We are done, no need to keep counting */ |
| 4053 | T_total.stop; |
| 4054 | } |
| 4055 | } |
| 4056 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4057 | } |
| 4058 | } |
| 4059 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4060 | timer T_wait := cfg.queue_drain_timeout |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4061 | T_wait.start; |
| 4062 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 4063 | [] 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] | 4064 | [] L1CTL.receive { repeat; } |
| 4065 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4066 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4067 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) -> value load_ind { repeat; } |
Vadim Yanitskiy | 2372db6 | 2021-06-09 00:50:11 +0200 | [diff] [blame] | 4068 | /* ignore other RSL messages like RF RESource INDication */ |
| 4069 | [] RSL_CCHAN.receive { repeat; } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4070 | /* Only relevant when testing including with PCU sock connected */ |
| 4071 | [] PCU.receive { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4072 | [] T_wait.timeout { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4073 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Waiting for paging queue, last detected fill state: ", load_ind.rsl.ies[1].body.paging_load)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4074 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4075 | } |
| 4076 | |
| 4077 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 4078 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 4079 | return st; |
| 4080 | } |
| 4081 | |
| 4082 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 4083 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 4084 | * - that CCCH LOAD IND (PCH) are being generated |
| 4085 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4086 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4087 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4088 | var PagingTestCfg cfg := { |
| 4089 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4090 | 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] | 4091 | load_factor := 0.8, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4092 | ps_load_modulus := 0, |
| 4093 | ps_wait_cong := false, |
| 4094 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4095 | exp_load_ind := true, |
| 4096 | exp_overload := false, |
| 4097 | use_tmsi := false |
| 4098 | }; |
| 4099 | var PagingTestState st := f_TC_paging(cfg); |
| 4100 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4101 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 4102 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4103 | } else { |
| 4104 | setverdict(pass); |
| 4105 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4106 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4107 | } |
| 4108 | |
| 4109 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 4110 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 4111 | * - that CCCH LOAD IND (PCH) are being generated |
| 4112 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4113 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4114 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4115 | var PagingTestCfg cfg := { |
| 4116 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4117 | 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] | 4118 | load_factor := 0.8, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4119 | ps_load_modulus := 0, |
| 4120 | ps_wait_cong := false, |
| 4121 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4122 | exp_load_ind := true, |
| 4123 | exp_overload := false, |
| 4124 | use_tmsi := true |
| 4125 | }; |
| 4126 | var PagingTestState st := f_TC_paging(cfg); |
| 4127 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4128 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 4129 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4130 | } else { |
| 4131 | setverdict(pass); |
| 4132 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4133 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4134 | } |
| 4135 | |
| 4136 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 4137 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 4138 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 4139 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4140 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4141 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4142 | var PagingTestCfg cfg := { |
| 4143 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4144 | 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] | 4145 | load_factor := 2.0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4146 | ps_load_modulus := 0, |
| 4147 | ps_wait_cong := false, |
| 4148 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4149 | exp_load_ind := true, |
| 4150 | exp_overload := true, |
| 4151 | use_tmsi := false |
| 4152 | }; |
| 4153 | var PagingTestState st := f_TC_paging(cfg); |
| 4154 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 4155 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4156 | 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] | 4157 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4158 | 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] | 4159 | } else { |
| 4160 | setverdict(pass); |
| 4161 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4162 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4163 | } |
| 4164 | |
| 4165 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 4166 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 4167 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 4168 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4169 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4170 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4171 | var PagingTestCfg cfg := { |
| 4172 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4173 | 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] | 4174 | load_factor := 2.0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4175 | ps_load_modulus := 0, |
| 4176 | ps_wait_cong := false, |
| 4177 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4178 | exp_load_ind := true, |
| 4179 | exp_overload := true, |
| 4180 | use_tmsi := true |
| 4181 | }; |
| 4182 | var PagingTestState st := f_TC_paging(cfg); |
| 4183 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 4184 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4185 | 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] | 4186 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4187 | 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] | 4188 | } else { |
| 4189 | setverdict(pass); |
| 4190 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4191 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4192 | } |
| 4193 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4194 | /* Same as above, but with additional paging load created by PS pagings that |
| 4195 | * are issued through the PCU socket. The additional load is introduced when |
| 4196 | * the paging queue is already two thirds full. Since the BTS implements a |
| 4197 | * prioritization logic that drops the pagings from the PCU under in those |
| 4198 | * congestive sitautions the behaviour on the PS side is expected to be |
| 4199 | * unaffected and match the behavior of TC_paging_imsi_200percent() */ |
| 4200 | testcase TC_paging_imsi_200percent_with_ps() runs on test_CT { |
| 4201 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 4202 | var PagingTestCfg cfg := { |
| 4203 | combined_ccch := true, |
| 4204 | bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res, |
| 4205 | load_factor := 2.0, |
| 4206 | ps_load_modulus := 16, |
| 4207 | ps_wait_cong := true, |
| 4208 | queue_drain_timeout := 18.0, |
| 4209 | exp_load_ind := true, |
| 4210 | exp_overload := true, |
| 4211 | use_tmsi := false |
| 4212 | }; |
| 4213 | var PagingTestState st := f_TC_paging(cfg); |
| 4214 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 4215 | * slots and will fully drain that buffer before returning */ |
| 4216 | var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100); |
| 4217 | if (not match(st.num_paging_rcv_ids, tpl)) { |
| 4218 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids)); |
| 4219 | } else { |
| 4220 | setverdict(pass); |
| 4221 | } |
| 4222 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4223 | } |
| 4224 | |
| 4225 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4226 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4227 | /*********************************************************************** |
| 4228 | * Immediate Assignment / AGCH |
| 4229 | ***********************************************************************/ |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 4230 | private const MobileAllocationLV c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4231 | len := 0, |
| 4232 | ma := ''B |
| 4233 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4234 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4235 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 4236 | return int2str(num_tx) & " sent, " |
| 4237 | & int2str(num_rx) & " received, " |
| 4238 | & int2str(num_del) & " deleted"; |
| 4239 | } |
| 4240 | |
| 4241 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 4242 | var L1ctlDlMessage l1_dl; |
| 4243 | timer T := 10.0; |
| 4244 | var integer num_tx := 0; |
| 4245 | var integer num_rx := 0; |
| 4246 | var integer num_del := 0; |
| 4247 | var charstring res_str; |
| 4248 | var float rx_ratio; |
| 4249 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4250 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4251 | f_init_l1ctl(); |
| 4252 | f_l1_tune(L1CTL); |
| 4253 | |
| 4254 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 4255 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0), |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 4256 | mp_trx_pars[0].arfcn, |
| 4257 | mp_tsc_def)); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4258 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 4259 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4260 | 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] | 4261 | num_tx := num_tx+1; |
| 4262 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4263 | } |
| 4264 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4265 | T.start; |
| 4266 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4267 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4268 | num_del := num_del+1; |
| 4269 | repeat; |
| 4270 | } |
| 4271 | [] RSL_CCHAN.receive { |
| 4272 | repeat; |
| 4273 | } |
| 4274 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4275 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 4276 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 4277 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4278 | //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] | 4279 | } else { |
| 4280 | num_rx := num_rx+1; |
| 4281 | } |
| 4282 | repeat; |
| 4283 | } |
| 4284 | [] L1CTL.receive { repeat; } |
| 4285 | [] T.timeout { } |
| 4286 | } |
| 4287 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 4288 | log("AGCH test: " & res_str); |
| 4289 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4290 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4291 | } |
| 4292 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 4293 | 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] | 4294 | 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] | 4295 | } else { |
| 4296 | setverdict(pass); |
| 4297 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4298 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4299 | } |
| 4300 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4301 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 4302 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 4303 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 4304 | } |
| 4305 | |
| 4306 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 4307 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 4308 | f_TC_imm_ass(200, 0.0, 0.05); |
| 4309 | } |
| 4310 | |
| 4311 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 4312 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 4313 | f_TC_imm_ass(150, 0.076, 1.00); |
| 4314 | } |
| 4315 | |
| 4316 | |
| 4317 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4318 | /*********************************************************************** |
| 4319 | * BCCH |
| 4320 | ***********************************************************************/ |
| 4321 | |
| 4322 | /* tuple of Frame Number + decoded SI */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4323 | private type record SystemInformationFn { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4324 | GsmFrameNumber frame_number, |
| 4325 | SystemInformation si |
| 4326 | } |
| 4327 | |
| 4328 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4329 | private type record of SystemInformationFn SystemInformationVector; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4330 | |
| 4331 | /* an array of SI-vectors indexed by TC value */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4332 | private type SystemInformationVector SystemInformationVectorPerTc[8]; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4333 | |
| 4334 | /* determine if a given SI vector contains given SI type at least once */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4335 | private function f_si_vecslot_contains(SystemInformationVector arr, |
| 4336 | RrMessageType key, |
| 4337 | boolean bcch_ext := false) |
| 4338 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4339 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 4340 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4341 | if (not bcch_ext and fn_mod51 == 2 or |
| 4342 | bcch_ext and fn_mod51 == 6) { |
| 4343 | if (arr[i].si.header.message_type == key) { |
| 4344 | return true; |
| 4345 | } |
| 4346 | } |
| 4347 | } |
| 4348 | return false; |
| 4349 | } |
| 4350 | |
| 4351 | /* ensure a given TC slot of the SI vector contains given SI type at least once at TC */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4352 | private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, |
| 4353 | integer tc, RrMessageType key, |
| 4354 | boolean ext_bcch := false) |
| 4355 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4356 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4357 | 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] | 4358 | } |
| 4359 | } |
| 4360 | |
| 4361 | /* check if a given SI vector contains given SI type at least once on any TC */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4362 | private function f_si_vec_contains(SystemInformationVectorPerTc arr, |
| 4363 | RrMessageType key) |
| 4364 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4365 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 4366 | if (f_si_vecslot_contains(arr[tc], key) or |
| 4367 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 4368 | return true; |
| 4369 | } |
| 4370 | } |
| 4371 | return false; |
| 4372 | } |
| 4373 | |
| 4374 | /* determine if a given SI vector contains given SI type at least N of M times */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4375 | private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, |
| 4376 | RrMessageType key, |
| 4377 | boolean bcch_ext := false, |
| 4378 | integer n := 1, integer m := 4) |
| 4379 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4380 | var integer count := 0; |
| 4381 | if (sizeof(arr) < m) { |
Harald Welte | a616ec9 | 2020-10-11 21:28:00 +0200 | [diff] [blame] | 4382 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: " |
| 4383 | & int2str(sizeof(arr)) & " < " & int2str(m)); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4384 | } |
| 4385 | for (var integer i:= 0; i < m; i := i + 1) { |
| 4386 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4387 | if (not bcch_ext and fn_mod51 == 2 or |
| 4388 | bcch_ext and fn_mod51 == 6) { |
| 4389 | if (arr[i].si.header.message_type == key) { |
| 4390 | count := count + 1; |
| 4391 | } |
| 4392 | } |
| 4393 | } |
| 4394 | if (count >= n) { |
| 4395 | return true; |
| 4396 | } else { |
| 4397 | return false; |
| 4398 | } |
| 4399 | } |
| 4400 | |
| 4401 | /* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4402 | private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, |
| 4403 | integer tc, RrMessageType key, |
| 4404 | boolean ext_bcch := false, |
| 4405 | integer n, integer m) |
| 4406 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4407 | 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] | 4408 | 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] | 4409 | } |
| 4410 | } |
| 4411 | |
| 4412 | /* determine if a given SI vector contains given SI type at least once */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4413 | private function f_si_vecslot_contains_only(SystemInformationVector arr, |
| 4414 | RrMessageType key, |
| 4415 | boolean bcch_ext := false) |
| 4416 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4417 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 4418 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4419 | if (not bcch_ext and fn_mod51 == 2 or |
| 4420 | bcch_ext and fn_mod51 == 6) { |
| 4421 | if (arr[i].si.header.message_type != key) { |
| 4422 | return false; |
| 4423 | } |
| 4424 | } |
| 4425 | } |
| 4426 | return true; |
| 4427 | } |
| 4428 | |
| 4429 | /* ensure a given TC slot of the SI vector contains only given SI type */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4430 | private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, |
| 4431 | integer tc, RrMessageType key, |
| 4432 | boolean ext_bcch := false) |
| 4433 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4434 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4435 | 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] | 4436 | } |
| 4437 | } |
| 4438 | |
| 4439 | /* SI configuration of cell, against which we validate actual SI messages */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4440 | private type set SystemInformationConfig { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4441 | boolean bcch_extended, |
| 4442 | boolean si1_present, |
| 4443 | boolean si2bis_present, |
| 4444 | boolean si2ter_present, |
| 4445 | boolean si2quater_present, |
| 4446 | boolean si7_present, |
| 4447 | boolean si8_present, |
| 4448 | boolean si9_present, |
| 4449 | boolean si13_present, |
| 4450 | boolean si13alt_present, |
| 4451 | boolean si15_present, |
| 4452 | boolean si16_present, |
| 4453 | boolean si17_present, |
| 4454 | boolean si2n_present, |
| 4455 | boolean si21_present, |
| 4456 | boolean si22_present |
| 4457 | } |
| 4458 | |
| 4459 | /* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4460 | private function f_validate_si_scheduling(SystemInformationConfig cfg, |
| 4461 | SystemInformationVectorPerTc si_per_tc) |
| 4462 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4463 | var integer i; |
| 4464 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 4465 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4466 | 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] | 4467 | } |
| 4468 | } |
| 4469 | if (cfg.si1_present) { |
| 4470 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 4471 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 4472 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 4473 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4474 | /* make sure *ALL* contain SI1 */ |
| 4475 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4476 | } |
| 4477 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 4478 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 4479 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 4480 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 4481 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 4482 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 4483 | |
| 4484 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 4485 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 4486 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 4487 | * consecutive occurrences of TC = 4. */ |
| 4488 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 4489 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4490 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 4491 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 4492 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 4493 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4494 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 4495 | } |
| 4496 | |
| 4497 | if (cfg.si7_present or cfg.si8_present) { |
| 4498 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 4499 | * if System Information type 4 does not contain all information needed for cell |
| 4500 | * selection and reselection. */ |
| 4501 | if (not cfg.bcch_extended) { |
| 4502 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 4503 | } |
| 4504 | if (cfg.si7_present) { |
| 4505 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 4506 | } |
| 4507 | if (cfg.si8_present) { |
| 4508 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 4509 | } |
| 4510 | } |
| 4511 | |
| 4512 | if (cfg.si2quater_present) { |
| 4513 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 4514 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 4515 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 4516 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 4517 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 4518 | if (not (cfg.bcch_extended)) { |
| 4519 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 4520 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 4521 | } else { |
| 4522 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 4523 | } |
| 4524 | } else { |
| 4525 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 4526 | } |
| 4527 | } |
| 4528 | if (cfg.si9_present) { |
| 4529 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 4530 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 4531 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 4532 | } |
| 4533 | if (cfg.si13_present) { |
| 4534 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 4535 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 4536 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 4537 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 4538 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 4539 | * within any of 4 consecutive occurrences of TC=4. */ |
| 4540 | if (not cfg.bcch_extended) { |
| 4541 | log("not-bccch-extended"); |
| 4542 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 4543 | } else { |
| 4544 | log("bccch-extended"); |
| 4545 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 4546 | } |
| 4547 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4548 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4549 | } |
| 4550 | } |
| 4551 | if (cfg.si16_present or cfg.si17_present) { |
| 4552 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 4553 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 4554 | if (cfg.si22_present) { |
| 4555 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4556 | } |
| 4557 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4558 | 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] | 4559 | } |
| 4560 | if (not cfg.bcch_extended) { |
| 4561 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 4562 | } |
| 4563 | if (cfg.si16_present) { |
| 4564 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 4565 | } |
| 4566 | if (cfg.si17_present) { |
| 4567 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 4568 | } |
| 4569 | } |
| 4570 | |
| 4571 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 4572 | * broadcast information. The frequency with which they are sent is determined by the |
| 4573 | * system operator. System Information type 9 identifies the scheduling of System |
| 4574 | * Information type 18 and 20 messages. */ |
| 4575 | |
| 4576 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 4577 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 4578 | * Information Type 9. */ |
| 4579 | |
| 4580 | if (cfg.si15_present) { |
| 4581 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 4582 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 4583 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 4584 | * 4 consecutive occurrences of TC = 1. */ |
| 4585 | if (not cfg.bcch_extended) { |
| 4586 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 4587 | } else { |
| 4588 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 4589 | } |
| 4590 | } |
| 4591 | if (cfg.si13alt_present) { |
| 4592 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 4593 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 4594 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 4595 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 4596 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 4597 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 4598 | * of TC = 4. */ |
| 4599 | if (cfg.si13_present) { |
| 4600 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 4601 | } |
| 4602 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4603 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4604 | } |
| 4605 | if (not cfg.bcch_extended) { |
| 4606 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 4607 | } else { |
| 4608 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 4609 | } |
| 4610 | } |
| 4611 | if (cfg.si2n_present) { |
| 4612 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 4613 | * as determined by the system operator. In the case that the message is sent on the |
| 4614 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 4615 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 4616 | * consecutive occurrences of TC = 4. */ |
| 4617 | if (not cfg.bcch_extended) { |
| 4618 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 4619 | } else { |
| 4620 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 4621 | } |
| 4622 | } |
| 4623 | if (cfg.si21_present) { |
| 4624 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 4625 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 4626 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 4627 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 4628 | * cell then this message shall only be sent on BCCH Ext. */ |
| 4629 | if (not cfg.bcch_extended) { |
| 4630 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 4631 | } else { |
| 4632 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 4633 | 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] | 4634 | 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] | 4635 | } |
| 4636 | } |
| 4637 | } |
| 4638 | if (cfg.si22_present) { |
| 4639 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 4640 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 4641 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 4642 | * =2 and TC=6. */ |
| 4643 | if (cfg.si16_present or cfg.si17_present) { |
| 4644 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4645 | } |
| 4646 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 4647 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4648 | 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] | 4649 | } |
| 4650 | if (not cfg.bcch_extended) { |
| 4651 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 4652 | } else { |
| 4653 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 4654 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 4655 | } |
| 4656 | } |
| 4657 | } |
| 4658 | |
| 4659 | /* sample Systme Information for specified duration via L1CTL */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4660 | private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) |
| 4661 | return SystemInformationVectorPerTc { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4662 | timer T := duration; |
| 4663 | var SystemInformationVectorPerTc si_per_tc; |
| 4664 | var L1ctlDlMessage l1_dl; |
| 4665 | |
| 4666 | /* initialize all per-TC vectors empty */ |
| 4667 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4668 | si_per_tc[i] := {}; |
| 4669 | } |
| 4670 | |
| 4671 | /* flush all previous L1 queued msgs */ |
| 4672 | pt.clear; |
| 4673 | |
| 4674 | T.start; |
| 4675 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4676 | [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 4677 | var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr }; |
| 4678 | if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) { |
| 4679 | log("Ignoring non-RR or invalid SI ", l1_dl); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4680 | repeat; |
| 4681 | } |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 4682 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4683 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 4684 | log("SI received at TC=", tc, ": ", sig.si); |
| 4685 | /* append to the per-TC bucket */ |
| 4686 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 4687 | repeat; |
| 4688 | } |
| 4689 | [] pt.receive { repeat; } |
| 4690 | [] T.timeout { } |
| 4691 | } |
| 4692 | |
| 4693 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4694 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 4695 | } |
| 4696 | log("si_per_tc=", si_per_tc); |
| 4697 | return si_per_tc; |
| 4698 | } |
| 4699 | |
| 4700 | /* helper function: Set given SI via RSL + validate scheduling. |
| 4701 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4702 | private function f_TC_si_sched(float duration := 8.0) runs on test_CT { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4703 | var SystemInformationVectorPerTc si_per_tc; |
| 4704 | f_init_l1ctl(); |
| 4705 | f_l1_tune(L1CTL); |
| 4706 | |
| 4707 | /* Sample + Validate Scheduling */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4708 | si_per_tc := f_l1_sample_si(L1CTL, duration); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4709 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 4710 | |
| 4711 | setverdict(pass); |
| 4712 | } |
| 4713 | |
| 4714 | testcase TC_si_sched_default() runs on test_CT { |
| 4715 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4716 | /* 2+3+4 are mandatory and set in f_init() */ |
| 4717 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4718 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4719 | } |
| 4720 | |
| 4721 | testcase TC_si_sched_1() runs on test_CT { |
| 4722 | f_init(); |
| 4723 | si_cfg.si1_present := true; |
| 4724 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4725 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4726 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4727 | } |
| 4728 | |
| 4729 | testcase TC_si_sched_2bis() runs on test_CT { |
| 4730 | f_init(); |
| 4731 | si_cfg.si2bis_present := true; |
| 4732 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4733 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4734 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4735 | } |
| 4736 | |
| 4737 | testcase TC_si_sched_2ter() runs on test_CT { |
| 4738 | f_init(); |
| 4739 | si_cfg.si2ter_present := true; |
| 4740 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4741 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4742 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4743 | } |
| 4744 | |
| 4745 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 4746 | f_init(); |
| 4747 | si_cfg.si2bis_present := true; |
| 4748 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4749 | si_cfg.si2ter_present := true; |
| 4750 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4751 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4752 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4753 | } |
| 4754 | |
| 4755 | testcase TC_si_sched_2quater() runs on test_CT { |
| 4756 | f_init(); |
| 4757 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4758 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4759 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4760 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4761 | } |
| 4762 | |
| 4763 | testcase TC_si_sched_13() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4764 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4765 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4766 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4767 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4768 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4769 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4770 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4771 | } |
| 4772 | |
| 4773 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4774 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4775 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4776 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4777 | si_cfg.si2bis_present := true; |
| 4778 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4779 | si_cfg.si2ter_present := true; |
| 4780 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4781 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4782 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4783 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4784 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4785 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4786 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4787 | } |
| 4788 | |
| 4789 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4790 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4791 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4792 | /* FIXME: enable / disable individual BCCH info */ |
| 4793 | //ts_RSL_BCCH_INFO(si_type, info); |
| 4794 | /* expect no ERROR REPORT after either of them * |
| 4795 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4796 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4797 | } |
| 4798 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4799 | /*********************************************************************** |
| 4800 | * Low-Level Protocol Errors / ERROR REPORT |
| 4801 | ***********************************************************************/ |
| 4802 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4803 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 4804 | timer T := 5.0; |
| 4805 | T.start; |
| 4806 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4807 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4808 | setverdict(pass); |
| 4809 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4810 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4811 | 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] | 4812 | } |
| 4813 | [] RSL_CCHAN.receive { |
| 4814 | repeat; |
| 4815 | } |
| 4816 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4817 | 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] | 4818 | } |
| 4819 | } |
| 4820 | } |
| 4821 | |
| 4822 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 4823 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4824 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4825 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4826 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4827 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4828 | |
| 4829 | f_exp_err_rep(RSL_ERR_PROTO); |
| 4830 | } |
| 4831 | |
| 4832 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 4833 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4834 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4835 | |
| 4836 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4837 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4838 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4839 | |
| 4840 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 4841 | } |
| 4842 | |
| 4843 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 4844 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4845 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4846 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4847 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4848 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4849 | |
| 4850 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 4851 | } |
| 4852 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4853 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 4854 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 4855 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4856 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 4857 | RSL.send(rsl); |
| 4858 | f_rslem_unregister(0, g_chan_nr); |
| 4859 | } |
| 4860 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 4861 | var ConnHdlr vc_conn; |
| 4862 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4863 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4864 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4865 | |
| 4866 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 4867 | vc_conn.done; |
| 4868 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 4869 | |
| 4870 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4871 | } |
| 4872 | |
| 4873 | /* Send messages with wrong message type */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4874 | private function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr { |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4875 | var template (value) RSL_Message rsl_tx; |
| 4876 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4877 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 4878 | RSL.send(rsl_tx); |
| 4879 | f_rslem_unregister(0, g_chan_nr); |
| 4880 | } |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4881 | private function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr { |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4882 | var template (value) RSL_Message rsl_tx; |
| 4883 | /* we first have to activate the dedicated channel */ |
| 4884 | f_rsl_chan_act(g_pars.chan_mode); |
| 4885 | /* ... to then send an invalid RLL message */ |
| 4886 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 4887 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 4888 | RSL.send(rsl_tx); |
| 4889 | f_rslem_unregister(0, g_chan_nr); |
| 4890 | } |
| 4891 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 4892 | var ConnHdlr vc_conn; |
| 4893 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4894 | var template (value) RSL_Message rsl_tx; |
| 4895 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4896 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4897 | |
| 4898 | /* Common Channel with wrong message type */ |
| 4899 | RSL_CCHAN.clear; |
| 4900 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4901 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4902 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4903 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4904 | |
| 4905 | /* TRX Management */ |
| 4906 | RSL_CCHAN.clear; |
| 4907 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 4908 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4909 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4910 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4911 | |
| 4912 | /* Dedicated Channel */ |
| 4913 | RSL_CCHAN.clear; |
| 4914 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 4915 | vc_conn.done; |
| 4916 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4917 | |
| 4918 | /* RLL */ |
| 4919 | RSL_CCHAN.clear; |
| 4920 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 4921 | vc_conn.done; |
| 4922 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4923 | } |
| 4924 | |
| 4925 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4926 | private function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr { |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4927 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 4928 | f_rslem_unregister(0, g_chan_nr); |
| 4929 | } |
| 4930 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 4931 | var ConnHdlr vc_conn; |
| 4932 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4933 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4934 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4935 | |
| 4936 | RSL_CCHAN.clear; |
| 4937 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 4938 | vc_conn.done; |
| 4939 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 4940 | } |
| 4941 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4942 | /*********************************************************************** |
| 4943 | * IPA CRCX/MDCX/DLCS media stream handling |
| 4944 | ***********************************************************************/ |
| 4945 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4946 | /* Send IPA DLCX to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4947 | private function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 4948 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4949 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4950 | } |
| 4951 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 4952 | 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] | 4953 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4954 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 4955 | vc_conn.done; |
| 4956 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4957 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4958 | /* Send IPA CRCX twice to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4959 | private function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4960 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4961 | "IPA CRCX ACK"); |
| 4962 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 4963 | "IPA CRCX NACK"); |
| 4964 | } |
| 4965 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 4966 | 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] | 4967 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4968 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 4969 | vc_conn.done; |
| 4970 | } |
| 4971 | |
| 4972 | /* Regular sequence of CRCX/MDCX/DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4973 | private function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4974 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4975 | "IPA CRCX ACK"); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 4976 | var OCT4 remote_ip := f_rnd_octstring(4); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4977 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4978 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4979 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4980 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4981 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4982 | "IPA MDCX ACK"); |
| 4983 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4984 | "IPA DLCX ACK"); |
| 4985 | } |
| 4986 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4987 | 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] | 4988 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4989 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 4990 | vc_conn.done; |
| 4991 | } |
| 4992 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4993 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4994 | private function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4995 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4996 | "IPA CRCX ACK"); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 4997 | var OCT4 remote_ip := f_rnd_octstring(4); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4998 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4999 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 5000 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 5001 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5002 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5003 | "IPA MDCX ACK"); |
| 5004 | /* Second MDCX */ |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 5005 | remote_ip := f_rnd_octstring(4); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5006 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 5007 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5008 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5009 | "IPA MDCX ACK"); |
| 5010 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5011 | "IPA DLCX ACK"); |
| 5012 | } |
| 5013 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 5014 | 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] | 5015 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5016 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 5017 | vc_conn.done; |
| 5018 | } |
| 5019 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 5020 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5021 | private function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 5022 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 5023 | "IPA CRCX NACK"); |
| 5024 | } |
| 5025 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 5026 | var ConnHdlrPars pars; |
| 5027 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5028 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 5029 | |
| 5030 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 5031 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 5032 | vc_conn.done; |
| 5033 | |
| 5034 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 5035 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 5036 | vc_conn.done; |
| 5037 | } |
| 5038 | |
Vadim Yanitskiy | 866afc2 | 2022-05-01 16:08:30 +0300 | [diff] [blame] | 5039 | /* Make sure that CRCX ACK contains a valid listen address (see OS#5242) */ |
| 5040 | private function f_TC_ipa_crcx_ack_addr(charstring id) runs on ConnHdlr { |
| 5041 | var OCT4 bind_ip := f_inet_addr("192.168.1.1"); |
| 5042 | var PortNumber bind_port := 16811; |
| 5043 | var RSL_Message crcx_ack; |
| 5044 | |
| 5045 | crcx_ack := f_rsl_transceive_ret(ts_RSL_IPA_CRCX(g_chan_nr, bind_ip, bind_port), |
| 5046 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5047 | "IPA CRCX ACK"); |
| 5048 | var HostName bts_bind_ip := f_inet_ntoa(crcx_ack.ies[2].body.ipa_local_ip); |
| 5049 | if (match(bts_bind_ip, "0.0.0.0")) { |
| 5050 | setverdict(fail, "CRCX ACK indicates nonsense addr ", bts_bind_ip); |
| 5051 | } |
| 5052 | |
| 5053 | var uint16_t conn_id := crcx_ack.ies[1].body.ipa_conn_id; |
| 5054 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, conn_id), |
| 5055 | tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5056 | "IPA DLCX ACK"); |
| 5057 | } |
| 5058 | testcase TC_ipa_crcx_ack_addr() runs on test_CT { |
| 5059 | var ConnHdlrPars pars; |
| 5060 | var ConnHdlr vc_conn; |
| 5061 | f_init(); |
| 5062 | |
| 5063 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 5064 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_ack_addr), pars); |
| 5065 | vc_conn.done; |
| 5066 | |
| 5067 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 5068 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_ack_addr), pars); |
| 5069 | vc_conn.done; |
| 5070 | } |
| 5071 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5072 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5073 | /*********************************************************************** |
| 5074 | * PCU Socket related tests |
| 5075 | ***********************************************************************/ |
| 5076 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5077 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5078 | 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] | 5079 | runs on test_CT { |
| 5080 | timer T := 3.0; |
| 5081 | |
| 5082 | /* we don't expect any RTS.req before PDCH are active */ |
| 5083 | T.start; |
| 5084 | alt { |
| 5085 | [] 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] | 5086 | 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] | 5087 | } |
| 5088 | [] PCU.receive { repeat; } |
| 5089 | [] T.timeout { } |
| 5090 | } |
| 5091 | |
| 5092 | /* Send PDCH activate request for known PDCH timeslot */ |
| 5093 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 5094 | |
| 5095 | /* we now expect RTS.req for this timeslot (only) */ |
| 5096 | T.start; |
| 5097 | alt { |
| 5098 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 5099 | setverdict(pass); |
| 5100 | } |
| 5101 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 5102 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5103 | 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] | 5104 | } |
| 5105 | [] 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] | 5106 | 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] | 5107 | } |
| 5108 | [] PCU.receive { repeat; } |
| 5109 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5110 | 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] | 5111 | } |
| 5112 | [not exp_success] T.timeout { |
| 5113 | setverdict(pass); |
| 5114 | } |
| 5115 | } |
| 5116 | } |
| 5117 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5118 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5119 | 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] | 5120 | runs on test_CT { |
| 5121 | timer T := 3.0; |
| 5122 | |
| 5123 | /* Send PDCH activate request for known PDCH timeslot */ |
| 5124 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr))); |
Harald Welte | c87d81f | 2020-10-11 18:17:25 +0200 | [diff] [blame] | 5125 | /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know |
| 5126 | * when it will actually have been executed in the BTS */ |
| 5127 | f_sleep(1.0); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5128 | PCU.clear; |
| 5129 | /* we now expect no RTS.req for this timeslot */ |
| 5130 | T.start; |
| 5131 | alt { |
| 5132 | [] 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] | 5133 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5134 | } |
| 5135 | [] PCU.receive { repeat; } |
| 5136 | [] T.timeout { |
| 5137 | setverdict(pass); |
| 5138 | } |
| 5139 | } |
| 5140 | } |
| 5141 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5142 | friend function f_init_with_pcuif() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5143 | f_init(); |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5144 | map(self:PCU, system:PCU); |
| 5145 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5146 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 5147 | } |
| 5148 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5149 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 5150 | testcase TC_pcu_act_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5151 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5152 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5153 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5154 | } |
| 5155 | |
| 5156 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 5157 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5158 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5159 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5160 | f_TC_pcu_act_req(0, 0, 1, false); |
| 5161 | } |
| 5162 | |
| 5163 | /* PDCH activation via PCU socket on wrong BTS */ |
| 5164 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5165 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5166 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5167 | f_TC_pcu_act_req(23, 0, 7, false); |
| 5168 | } |
| 5169 | |
| 5170 | /* PDCH activation via PCU socket on wrong TRX */ |
| 5171 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5172 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5173 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5174 | f_TC_pcu_act_req(0, 23, 7, false); |
| 5175 | } |
| 5176 | |
| 5177 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 5178 | testcase TC_pcu_deact_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5179 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5180 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5181 | /* Activate PDCH */ |
| 5182 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5183 | f_sleep(1.0); |
| 5184 | /* and De-Activate again */ |
| 5185 | f_TC_pcu_deact_req(0, 0, 7); |
| 5186 | } |
| 5187 | |
| 5188 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 5189 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5190 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5191 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5192 | f_TC_pcu_deact_req(0, 0, 1); |
| 5193 | } |
| 5194 | |
| 5195 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5196 | function f_TC_pcu_ver_siXX(octetstring si, RSL_IE_SysinfoType rsl_si_type) runs on test_CT { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5197 | var PCUIF_send_data sd; |
| 5198 | timer T:= 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5199 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5200 | |
| 5201 | /* Set SI13 via RSL */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5202 | f_rsl_bcch_fill_raw(rsl_si_type, si); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5203 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5204 | T.start; |
| 5205 | alt { |
| 5206 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5207 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si)) == si) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5208 | setverdict(pass); |
| 5209 | } else { |
| 5210 | repeat; |
| 5211 | } |
| 5212 | } |
| 5213 | [] PCU.receive { repeat; } |
| 5214 | [] T.timeout { |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5215 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5216 | } |
| 5217 | } |
| 5218 | } |
| 5219 | |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5220 | /* Test the PCU->BTS Version and BTS->PCU SI1 handshake */ |
| 5221 | testcase TC_pcu_ver_si1() runs on test_CT { |
| 5222 | const octetstring si1 := '550111132A252B27CC29AA11BB33CC'O; |
| 5223 | f_TC_pcu_ver_siXX(si1, RSL_SYSTEM_INFO_1); |
| 5224 | } |
| 5225 | |
| 5226 | /* Test the PCU->BTS Version and BTS->PCU SI3 handshake */ |
| 5227 | testcase TC_pcu_ver_si3() runs on test_CT { |
| 5228 | const octetstring si3 := '49012223242526272929AABBCC'O; |
| 5229 | f_TC_pcu_ver_siXX(si3, RSL_SYSTEM_INFO_3); |
| 5230 | } |
| 5231 | |
| 5232 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 5233 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 5234 | const octetstring si13 := '01010203040506070909'O; |
| 5235 | f_TC_pcu_ver_siXX(si13, RSL_SYSTEM_INFO_13); |
| 5236 | } |
| 5237 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5238 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 5239 | |
| 5240 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5241 | 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] | 5242 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 5243 | runs on test_CT |
| 5244 | { |
| 5245 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 5246 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 5247 | } |
| 5248 | |
| 5249 | /* 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] | 5250 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 5251 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5252 | runs on test_CT |
| 5253 | { |
| 5254 | var PCUIF_send_data sd; |
| 5255 | |
| 5256 | timer T := 3.0; |
| 5257 | T.start; |
| 5258 | alt { |
| 5259 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 5260 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 5261 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 5262 | sd.data.u.rts_req.fn, sapi, data); |
| 5263 | } |
| 5264 | [] PCU.receive { repeat; } |
| 5265 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5266 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5267 | } |
| 5268 | } |
| 5269 | } |
| 5270 | |
| 5271 | /* Send DATA.req on invalid BTS */ |
| 5272 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5273 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5274 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5275 | |
| 5276 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5277 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5278 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5279 | f_TfiUsfArrSet(tua, 7, 0); |
| 5280 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5281 | f_sleep(1.0); |
| 5282 | |
| 5283 | 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] | 5284 | } |
| 5285 | |
| 5286 | /* Send DATA.req on invalid TRX */ |
| 5287 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5288 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5289 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5290 | |
| 5291 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5292 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5293 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5294 | f_TfiUsfArrSet(tua, 7, 0); |
| 5295 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5296 | f_sleep(1.0); |
| 5297 | |
| 5298 | 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] | 5299 | } |
| 5300 | |
| 5301 | /* Send DATA.req on invalid timeslot */ |
| 5302 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5303 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5304 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5305 | |
| 5306 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5307 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5308 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5309 | f_TfiUsfArrSet(tua, 7, 0); |
| 5310 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5311 | f_sleep(1.0); |
| 5312 | |
| 5313 | 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] | 5314 | } |
| 5315 | |
| 5316 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 5317 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5318 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5319 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5320 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5321 | f_virtphy_common(); |
| 5322 | |
| 5323 | f_TfiUsfArrSet(tua, 7, 0); |
| 5324 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5325 | f_sleep(1.0); |
| 5326 | |
| 5327 | 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] | 5328 | } |
| 5329 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5330 | 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] | 5331 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 5332 | boolean wait_rts := true) |
| 5333 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5334 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5335 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5336 | |
| 5337 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5338 | if (wait_rts) { |
| 5339 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 5340 | } else { |
| 5341 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 5342 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5343 | |
| 5344 | T.start; |
| 5345 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5346 | [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] | 5347 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 5348 | setverdict(pass); |
| 5349 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5350 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 5351 | setverdict(fail, "Received unexpected ", rx_dl); |
| 5352 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5353 | [] L1CTL.receive { |
| 5354 | repeat; |
| 5355 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5356 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5357 | setverdict(fail, "Timeout waiting for ", data); |
| 5358 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5359 | [not expect_data] T.timeout { |
| 5360 | setverdict(pass); |
| 5361 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5362 | } |
| 5363 | } |
| 5364 | |
| 5365 | private function f_disable_dynamic_ts() runs on test_CT |
| 5366 | { |
| 5367 | f_init_vty_bsc(); |
| 5368 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 5369 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 5370 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 5371 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F"); |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5372 | f_init_with_pcuif(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5373 | } |
| 5374 | |
| 5375 | private function f_virtphy_common() runs on test_CT { |
| 5376 | f_disable_dynamic_ts(); |
| 5377 | f_init_l1ctl(); |
| 5378 | f_l1_tune(L1CTL); |
| 5379 | } |
| 5380 | |
| 5381 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 5382 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5383 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5384 | |
| 5385 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5386 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5387 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5388 | f_TfiUsfArrSet(tua, 7, 0); |
| 5389 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5390 | f_sleep(1.0); |
| 5391 | |
| 5392 | 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] | 5393 | } |
| 5394 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5395 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5396 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5397 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5398 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5399 | |
| 5400 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5401 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5402 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5403 | f_TfiUsfArrSet(tua, 7, 0); |
| 5404 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5405 | f_sleep(1.0); |
| 5406 | |
| 5407 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5408 | } |
| 5409 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5410 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 5411 | runs on test_CT { |
| 5412 | var template PCUIF_Message pcu_rach_ind; |
| 5413 | var PCUIF_send_data sd; |
| 5414 | var GsmFrameNumber fn; |
| 5415 | timer T; |
| 5416 | |
| 5417 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 5418 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 5419 | chan_nr := ts_RslChanNr_PDCH(7), |
| 5420 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 5421 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5422 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 5423 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5424 | |
| 5425 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 5426 | T.start(52.0 * 4.615 / 1000.0); |
| 5427 | alt { |
| 5428 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 5429 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 5430 | setverdict(pass); |
| 5431 | T.stop; |
| 5432 | } |
| 5433 | [] PCU.receive { repeat; } |
| 5434 | [] T.timeout { |
| 5435 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 5436 | /* Keep going, that's not the end of the world */ |
| 5437 | } |
| 5438 | } |
| 5439 | } |
| 5440 | |
| 5441 | testcase TC_pcu_ptcch() runs on test_CT { |
| 5442 | var L1ctlDlMessage dl; |
| 5443 | var octetstring data; |
| 5444 | timer T; |
| 5445 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5446 | f_init_with_pcuif(); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5447 | f_init_l1ctl(); |
| 5448 | f_l1_tune(L1CTL); |
| 5449 | |
| 5450 | /* Activate PDCH channel on TS7 */ |
| 5451 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5452 | |
| 5453 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5454 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_PDCH(7), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | 13a29d5 | 2020-07-15 14:41:54 +0700 | [diff] [blame] | 5455 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5456 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5457 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5458 | |
| 5459 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 5460 | for (var integer i := 0; i < 16; i := i + 1) { |
| 5461 | log("Sending an Access Burst towards the L1CTL interface"); |
| 5462 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 5463 | } |
| 5464 | |
| 5465 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 5466 | data := f_rnd_octstring(23); |
| 5467 | |
| 5468 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 5469 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 5470 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 5471 | |
| 5472 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 5473 | * let's give it more time in case if we miss the beginning. */ |
| 5474 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 5475 | alt { |
| 5476 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 5477 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 5478 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 5479 | frame := data)) -> value dl { |
| 5480 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 5481 | setverdict(pass); |
| 5482 | T.stop; |
| 5483 | } |
| 5484 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 5485 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 5486 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 5487 | l2_data := data)) -> value dl { |
| 5488 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 5489 | setverdict(pass); |
| 5490 | T.stop; |
| 5491 | } |
| 5492 | [] L1CTL.receive { repeat; } |
| 5493 | [] T.timeout { |
| 5494 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 5495 | } |
| 5496 | } |
| 5497 | } |
| 5498 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5499 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5500 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 5501 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5502 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5503 | f_init_l1ctl(); |
| 5504 | f_l1_tune(L1CTL); |
| 5505 | |
| 5506 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5507 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 5508 | |
| 5509 | T.start; |
| 5510 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5511 | [] 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] | 5512 | setverdict(pass); |
| 5513 | } |
| 5514 | [] L1CTL.receive { repeat; } |
| 5515 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5516 | 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] | 5517 | } |
| 5518 | } |
| 5519 | } |
| 5520 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5521 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5522 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 5523 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5524 | f_init_with_pcuif(); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5525 | f_init_l1ctl(); |
| 5526 | f_l1_tune(L1CTL); |
| 5527 | |
| 5528 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5529 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 5530 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 5531 | |
| 5532 | T.start; |
| 5533 | alt { |
| 5534 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 5535 | setverdict(pass); |
| 5536 | } |
| 5537 | [] L1CTL.receive { repeat; } |
| 5538 | [] T.timeout { |
| 5539 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 5540 | } |
| 5541 | } |
| 5542 | } |
| 5543 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5544 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 5545 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 5546 | var octetstring imm_ass := f_rnd_octstring(23); |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5547 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5548 | f_init_l1ctl(); |
| 5549 | f_l1_tune(L1CTL); |
| 5550 | |
| 5551 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 5552 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 5553 | |
| 5554 | timer T := 0.5; |
| 5555 | T.start; |
| 5556 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5557 | [] 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] | 5558 | /* TODO: verify paging group */ |
| 5559 | setverdict(pass); |
| 5560 | } |
| 5561 | [] L1CTL.receive { repeat; } |
| 5562 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5563 | 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] | 5564 | } |
| 5565 | } |
| 5566 | } |
| 5567 | |
| 5568 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 5569 | testcase TC_pcu_rach_content() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5570 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5571 | f_init_l1ctl(); |
| 5572 | f_l1_tune(L1CTL); |
| 5573 | |
| 5574 | var GsmFrameNumber fn_last := 0; |
| 5575 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5576 | var OCT1 ra := f_rnd_ra_ps(); |
| 5577 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 5578 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5579 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5580 | } |
| 5581 | fn_last := fn; |
| 5582 | |
| 5583 | timer T := 2.0; |
| 5584 | T.start; |
| 5585 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5586 | [] 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] | 5587 | T.stop; |
| 5588 | } |
| 5589 | [] 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] | 5590 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5591 | } |
| 5592 | [] PCU.receive { repeat; } |
| 5593 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5594 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5595 | } |
| 5596 | } |
| 5597 | } |
| 5598 | setverdict(pass); |
| 5599 | } |
| 5600 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5601 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 5602 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 5603 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 5604 | var template PCUIF_Message pcu_rach_ind; |
| 5605 | var GsmFrameNumber fn_last := 0; |
| 5606 | var L1ctlRachSynchSeq synch_seq; |
| 5607 | var PCUIF_BurstType pcu_bt; |
| 5608 | var GsmFrameNumber fn; |
| 5609 | var BIT11 ra11; |
| 5610 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5611 | f_init_with_pcuif(); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5612 | f_init_l1ctl(); |
| 5613 | f_l1_tune(L1CTL); |
| 5614 | |
| 5615 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5616 | /* We need to test both TS1 & TS2 */ |
| 5617 | if (i rem 2 == 0) { |
| 5618 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 5619 | pcu_bt := BURST_TYPE_1; |
| 5620 | } else { |
| 5621 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 5622 | pcu_bt := BURST_TYPE_2; |
| 5623 | } |
| 5624 | |
| 5625 | ra11 := f_rnd_ra11_ps(); |
| 5626 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 5627 | if (fn == fn_last) { |
| 5628 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5629 | "Two RACH in same FN?!?"); |
| 5630 | } |
| 5631 | fn_last := fn; |
| 5632 | |
| 5633 | /* Compose the expected message */ |
| 5634 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5635 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5636 | ra := bit2int(ra11), |
| 5637 | is_11bit := 1, |
| 5638 | burst_type := pcu_bt, |
| 5639 | fn := fn); |
| 5640 | |
| 5641 | timer T := 2.0; |
| 5642 | T.start; |
| 5643 | alt { |
| 5644 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 5645 | T.stop; |
| 5646 | } |
| 5647 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 5648 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 5649 | } |
| 5650 | [] PCU.receive { repeat; } |
| 5651 | [] T.timeout { |
| 5652 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 5653 | } |
| 5654 | } |
| 5655 | } |
| 5656 | setverdict(pass); |
| 5657 | } |
| 5658 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5659 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 5660 | runs on test_CT { |
| 5661 | var template PCUIF_send_data sdt; |
| 5662 | var PCUIF_send_data sd; |
| 5663 | var int16_t lqual_cb; |
| 5664 | timer T := 1.0; |
| 5665 | |
| 5666 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 5667 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 5668 | |
| 5669 | /* Send a random PDTCH frame over Um */ |
| 5670 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 5671 | '0000'O & f_rnd_octstring(21))); |
| 5672 | |
| 5673 | T.start; |
| 5674 | alt { |
| 5675 | /* If expected link quality is above the threshold */ |
| 5676 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 5677 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 5678 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 5679 | |
| 5680 | /* Make sure the actual link quality matches the expected value */ |
| 5681 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 5682 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 5683 | "expected value ", lqual_cb_exp)); |
| 5684 | } else { |
| 5685 | setverdict(pass); |
| 5686 | } |
| 5687 | } |
| 5688 | /* If expected link quality is below the threshold */ |
| 5689 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 5690 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5691 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 5692 | } |
| 5693 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 5694 | [] PCU.receive { repeat; } |
| 5695 | [lqual_cb_exp < thresh] T.timeout { |
| 5696 | log("Rx nothing, as expected"); |
| 5697 | setverdict(pass); |
| 5698 | } |
| 5699 | [lqual_cb_exp >= thresh] T.timeout { |
| 5700 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5701 | "Timeout waiting for PCUIF_DATA.ind"); |
| 5702 | } |
| 5703 | } |
| 5704 | } |
| 5705 | |
| 5706 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 5707 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5708 | f_init_with_pcuif(); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5709 | PCU.clear; |
| 5710 | |
| 5711 | f_init_l1ctl(); |
| 5712 | f_l1_tune(L1CTL); |
| 5713 | |
| 5714 | /* Activate a PDCH channel on TS7 */ |
| 5715 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5716 | |
| 5717 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5718 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_PDCH(7), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | 13a29d5 | 2020-07-15 14:41:54 +0700 | [diff] [blame] | 5719 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5720 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5721 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5722 | |
| 5723 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 5724 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 5725 | var TrxcMessage ret; |
| 5726 | |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 5727 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_CI(i)); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5728 | |
| 5729 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 5730 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 5731 | } |
| 5732 | } |
| 5733 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5734 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 5735 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5736 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5737 | |
| 5738 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5739 | var MobileIdentityLV mi_lv; |
| 5740 | var octetstring mi_lv_enc; |
| 5741 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5742 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5743 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5744 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5745 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5746 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5747 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5748 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5749 | |
| 5750 | /* Fancy encoding for PCUIF */ |
| 5751 | mi_lv := valueof(ts_MI_LV(mi)); |
| 5752 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 5753 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5754 | |
| 5755 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5756 | 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] | 5757 | T.start; |
| 5758 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5759 | [] 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] | 5760 | } |
| 5761 | [] 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] | 5762 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5763 | } |
| 5764 | [] PCU.receive { repeat; } |
| 5765 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5766 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5767 | } |
| 5768 | } |
| 5769 | } |
| 5770 | setverdict(pass); |
| 5771 | } |
| 5772 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5773 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 5774 | testcase TC_pcu_time_ind() runs on test_CT { |
| 5775 | var PCUIF_send_data pcu_sd; |
| 5776 | var integer num_time_ind := 0; |
| 5777 | var integer first_fn, last_fn; |
| 5778 | var float test_duration := 5.0; |
| 5779 | timer T; |
| 5780 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5781 | f_init_with_pcuif(); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5782 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5783 | |
| 5784 | PCU.clear; |
| 5785 | T.start(test_duration); |
| 5786 | alt { |
| 5787 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 5788 | num_time_ind := num_time_ind + 1; |
| 5789 | if (not isbound(first_fn)) { |
| 5790 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 5791 | } |
| 5792 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 5793 | repeat; |
| 5794 | } |
| 5795 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 5796 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 5797 | repeat; |
| 5798 | } |
| 5799 | [] PCU.receive { |
| 5800 | repeat; |
| 5801 | } |
| 5802 | [] T.timeout {} |
| 5803 | } |
| 5804 | var integer fn_expired := last_fn - first_fn; |
| 5805 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 5806 | |
| 5807 | /* verify the number of frames expired matches our expectation */ |
| 5808 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5809 | 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] | 5810 | 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] | 5811 | if (not match(fn_expired, t_fn_expected)) { |
| 5812 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5813 | } |
| 5814 | |
| 5815 | /* There are three TIME.ind in every fn MOD 13 */ |
| 5816 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 5817 | /* Add some tolerance */ |
| 5818 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 5819 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 5820 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 5821 | } |
| 5822 | |
| 5823 | setverdict(pass); |
| 5824 | } |
| 5825 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5826 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 5827 | testcase TC_pcu_rts_req() runs on test_CT { |
| 5828 | var PCUIF_send_data pcu_sd; |
| 5829 | var integer first_fn, last_fn; |
| 5830 | var integer num_rts_pdtch := 0; |
| 5831 | var integer num_rts_ptcch := 0; |
| 5832 | var float test_duration := 5.0; |
| 5833 | timer T; |
| 5834 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5835 | f_init_with_pcuif(); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5836 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5837 | |
| 5838 | PCU.clear; |
| 5839 | T.start(test_duration); |
| 5840 | alt { |
| 5841 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 5842 | -> value pcu_sd { |
| 5843 | num_rts_pdtch := num_rts_pdtch + 1; |
| 5844 | if (not isbound(first_fn)) { |
| 5845 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5846 | } |
| 5847 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5848 | repeat; |
| 5849 | } |
| 5850 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 5851 | -> value pcu_sd { |
| 5852 | num_rts_ptcch := num_rts_ptcch + 1; |
| 5853 | if (not isbound(first_fn)) { |
| 5854 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5855 | } |
| 5856 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5857 | repeat; |
| 5858 | } |
| 5859 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 5860 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 5861 | repeat; |
| 5862 | } |
| 5863 | [] PCU.receive { |
| 5864 | repeat; |
| 5865 | } |
| 5866 | [] T.timeout {} |
| 5867 | } |
| 5868 | var integer fn_expired := last_fn - first_fn; |
| 5869 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 5870 | ", num_rts_ptcch=", num_rts_ptcch); |
| 5871 | |
| 5872 | /* verify the number of frames expired matches our expectation */ |
| 5873 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5874 | 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] | 5875 | 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] | 5876 | if (not match(fn_expired, t_fn_expected)) { |
| 5877 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5878 | } |
| 5879 | |
| 5880 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 5881 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 5882 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 5883 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 5884 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 5885 | t_ptcch_exp); |
| 5886 | } |
| 5887 | |
| 5888 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 5889 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 5890 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 5891 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 5892 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 5893 | t_pdtch_exp); |
| 5894 | } |
| 5895 | |
| 5896 | setverdict(pass); |
| 5897 | } |
| 5898 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5899 | /* test for generating Abis side OML ALERT from the PCU */ |
| 5900 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 5901 | var PCUIF_send_data pcu_sd; |
| 5902 | var integer num_time_ind := 0; |
| 5903 | var integer first_fn, last_fn; |
| 5904 | var float test_duration := 5.0; |
| 5905 | timer T; |
| 5906 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5907 | f_init_with_pcuif(); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5908 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5909 | |
| 5910 | /* re-connect CTRL port from BTS to BSC */ |
| 5911 | f_ipa_ctrl_stop(); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 5912 | f_ipa_ctrl_start_client(mp_bsc_ctrl_ip, mp_bsc_ctrl_port); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5913 | |
| 5914 | /* Send that OML Alert */ |
| 5915 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 5916 | |
| 5917 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 5918 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 5919 | setverdict(pass); |
| 5920 | } |
| 5921 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5922 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 5923 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 5924 | var PCUIF_Message first_info; |
| 5925 | var integer pcu_conn_id := -1; |
| 5926 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5927 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 5928 | var OCT4 tlli := '01020304'O; |
| 5929 | var OCT1 cause := '23'O; |
| 5930 | timer T := 5.0; |
| 5931 | |
| 5932 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5933 | |
| 5934 | f_l1_tune(L1CTL); |
| 5935 | RSL.clear; |
| 5936 | |
| 5937 | f_est_dchan(); |
| 5938 | L1CTL.clear; |
| 5939 | |
| 5940 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 5941 | |
| 5942 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 5943 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 5944 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 5945 | |
| 5946 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 5947 | T.start; |
| 5948 | alt { |
| 5949 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 5950 | setverdict(pass); |
| 5951 | } |
| 5952 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 5953 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 5954 | } |
| 5955 | [] PCU.receive { |
| 5956 | repeat; |
| 5957 | } |
| 5958 | [] T.timeout { |
| 5959 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 5960 | } |
| 5961 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 5962 | |
| 5963 | /* release the channel */ |
| 5964 | f_rsl_chan_deact(); |
| 5965 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5966 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5967 | } |
| 5968 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 5969 | var ConnHdlrPars pars; |
| 5970 | var ConnHdlr vc_conn; |
| 5971 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5972 | f_init_with_pcuif(); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5973 | |
| 5974 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 5975 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 5976 | vc_conn.done; |
| 5977 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5978 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5979 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 5980 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5981 | var boolean connected := false; |
| 5982 | var UD_connect_result cr; |
| 5983 | var integer cid; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5984 | timer T := 5.0; |
| 5985 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5986 | var template UD_Result tr_ok := { result_code := SUCCESS, err := omit }; |
| 5987 | var template UD_Result tr_err := { result_code := ERROR, err := ? }; |
| 5988 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5989 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5990 | f_init_with_pcuif(); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5991 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5992 | /* try to establish a second connection */ |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5993 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 5994 | T.start; |
| 5995 | alt { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5996 | /* the IUT will first accept() the new connection, and close() it immediately */ |
| 5997 | [not connected] PCU.receive(UD_connect_result:{ id := ?, result := tr_ok }) -> value cr { |
| 5998 | log("BTS has accept()ed connection"); |
| 5999 | connected := true; |
| 6000 | cid := cr.id; |
| 6001 | repeat; |
| 6002 | } |
| 6003 | [connected] PCU.receive(UD_connect_result:{ id := cid, result := tr_err }) { |
| 6004 | log("BTS has close()d connection"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6005 | setverdict(pass); |
| 6006 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6007 | /* ignore other messages related to the first connection */ |
| 6008 | [] PCU.receive { repeat; } |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6009 | [] T.timeout { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6010 | setverdict(fail, "Timeout waiting for connection result"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6011 | } |
| 6012 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6013 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6014 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6015 | } |
| 6016 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6017 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 6018 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 6019 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6020 | f_init_with_pcuif(); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6021 | |
| 6022 | f_sleep(1.0); |
| 6023 | |
| 6024 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 6025 | g_pcu_conn_id := -1; |
| 6026 | |
| 6027 | f_sleep(1.0); |
| 6028 | |
| 6029 | /* re-connect */ |
| 6030 | PCU.clear; |
| 6031 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 6032 | setverdict(pass); |
| 6033 | |
| 6034 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6035 | } |
| 6036 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6037 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6038 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 6039 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6040 | var L1ctlDlMessage l1_dl; |
| 6041 | var SystemInformation si; |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 6042 | var integer rc; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6043 | timer T := 5.0; |
| 6044 | T.start; |
| 6045 | alt { |
| 6046 | [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 6047 | rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si); |
| 6048 | if (rc != 0 or si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6049 | repeat; |
| 6050 | } |
| 6051 | } |
| 6052 | [] pt.receive { |
| 6053 | repeat; |
| 6054 | } |
| 6055 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6056 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6057 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6058 | } |
| 6059 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6060 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6061 | } |
| 6062 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6063 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 6064 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 6065 | runs on test_CT return boolean { |
| 6066 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 6067 | |
| 6068 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 6069 | return si.payload.si3.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6070 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 6071 | return si.payload.si4.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6072 | } |
| 6073 | |
| 6074 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 6075 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6076 | } |
| 6077 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6078 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 6079 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 6080 | runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6081 | f_init(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6082 | f_init_l1ctl(); |
| 6083 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6084 | f_sleep(2.0); |
| 6085 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6086 | |
| 6087 | if (f_si_has_gprs_indicator(si_type)) { |
| 6088 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6089 | } else { |
| 6090 | setverdict(pass); |
| 6091 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6092 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6093 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6094 | } |
| 6095 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6096 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 6097 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 6098 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6099 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6100 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 6101 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 6102 | } |
| 6103 | |
| 6104 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 6105 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 6106 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6107 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6108 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6109 | f_init_l1ctl(); |
| 6110 | f_l1_tune(L1CTL); |
| 6111 | |
| 6112 | f_sleep(2.0); |
| 6113 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6114 | |
| 6115 | if (not f_si_has_gprs_indicator(si_type)) { |
| 6116 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6117 | } else { |
| 6118 | setverdict(pass); |
| 6119 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6120 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6121 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6122 | } |
| 6123 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6124 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 6125 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 6126 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6127 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6128 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 6129 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 6130 | } |
| 6131 | |
| 6132 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 6133 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 6134 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6135 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6136 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6137 | f_init_l1ctl(); |
| 6138 | f_l1_tune(L1CTL); |
| 6139 | |
| 6140 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 6141 | g_pcu_conn_id := -1; |
| 6142 | |
| 6143 | f_sleep(1.0); |
| 6144 | |
| 6145 | /* re-connect */ |
| 6146 | PCU.clear; |
| 6147 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 6148 | |
| 6149 | f_sleep(2.0); |
| 6150 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6151 | |
| 6152 | if (f_si_has_gprs_indicator(si_type)) { |
| 6153 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6154 | } else { |
| 6155 | setverdict(pass); |
| 6156 | } |
| 6157 | |
| 6158 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6159 | } |
| 6160 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6161 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 6162 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 6163 | } |
| 6164 | |
| 6165 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 6166 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 6167 | } |
| 6168 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6169 | /* 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) */ |
| 6170 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 6171 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 6172 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6173 | f_init_with_pcuif(); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6174 | |
Harald Welte | 7622022 | 2020-10-11 20:32:44 +0200 | [diff] [blame] | 6175 | /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct |
| 6176 | * information */ |
| 6177 | timer T := 2.0; |
| 6178 | T.start; |
| 6179 | alt { |
| 6180 | [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; } |
| 6181 | [] T.timeout {} |
| 6182 | } |
| 6183 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6184 | /* Verify cell_id */ |
| 6185 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 6186 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 6187 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 6188 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 6189 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 6190 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6191 | } |
| 6192 | |
| 6193 | /* Verify LAC */ |
| 6194 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 6195 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 6196 | if (lac_si3 != lac_pcu) { |
| 6197 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 6198 | } |
| 6199 | |
| 6200 | setverdict(pass); |
| 6201 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 6202 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6203 | /* Verify hopping parameters in the INFO.ind message (version >= 10) */ |
| 6204 | testcase TC_pcu_info_ind_fh_params() runs on test_CT { |
| 6205 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6206 | var FreqHopPars fhp; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6207 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6208 | f_init_with_pcuif(); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6209 | |
| 6210 | info_ind := g_pcu_last_info.u.info_ind; |
| 6211 | |
| 6212 | for (var integer i := 0; i < mp_transceiver_num; i := i + 1) { |
| 6213 | for (var integer tn := 0; tn < 8; tn := tn + 1) { |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6214 | if (info_ind.trx[i].pdch_mask[tn] != '1'B) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6215 | /* Skip inactive timeslots */ |
| 6216 | continue; |
| 6217 | } |
| 6218 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6219 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | 7e1d0a2 | 2020-09-17 19:48:11 +0700 | [diff] [blame] | 6220 | { f_resolve_fh_params(fhp, tn, trx_nr := i); } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6221 | else |
| 6222 | { fhp.enabled := false; } |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6223 | |
| 6224 | var template PCUIF_InfoTrxTs tr_ts; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6225 | if (fhp.enabled) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6226 | tr_ts := tr_PCUIF_InfoTrxTsH1( |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6227 | hsn := fhp.maio_hsn.hsn, |
| 6228 | maio := fhp.maio_hsn.maio, |
| 6229 | ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B), |
Vadim Yanitskiy | aa553ed | 2020-09-17 19:44:32 +0700 | [diff] [blame] | 6230 | ma_bit_len := mp_transceiver_num); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6231 | } else { |
| 6232 | tr_ts := tr_PCUIF_InfoTrxTsH0; |
| 6233 | } |
| 6234 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6235 | var PCUIF_InfoTrxTs ts := info_ind.trx[i].ts[tn]; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6236 | log("Checking timeslot #", tn, " of trx#", i, ": ", ts); |
| 6237 | if (not match(ts, tr_ts)) { |
| 6238 | setverdict(fail, "Hopping parameters do not match: ", |
| 6239 | "received ", ts, " vs expected ", tr_ts); |
| 6240 | } else { |
| 6241 | setverdict(pass); |
| 6242 | } |
| 6243 | } |
| 6244 | } |
| 6245 | } |
| 6246 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6247 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6248 | testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT { |
| 6249 | f_init_vty_bsc(); |
| 6250 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 6251 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 6252 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6253 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6254 | |
| 6255 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6256 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6257 | addr_type := { PCUIF_ADDR_TYPE_IPV4, ? }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 6258 | addr := { f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), ? } |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6259 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6260 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6261 | if (not match(remote_addr, tr_remote_addr)) { |
| 6262 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6263 | } |
| 6264 | |
| 6265 | setverdict(pass); |
| 6266 | } |
| 6267 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6268 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6269 | testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT { |
| 6270 | f_init_vty_bsc(); |
| 6271 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee"); |
| 6272 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6273 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6274 | |
| 6275 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6276 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6277 | addr_type := { PCUIF_ADDR_TYPE_IPV6, ? }, |
| 6278 | addr := { f_inet6_addr("fd00::ca:ff:ee"), ? } |
| 6279 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6280 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6281 | if (not match(remote_addr, tr_remote_addr)) { |
| 6282 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6283 | } |
| 6284 | |
| 6285 | setverdict(pass); |
| 6286 | } |
| 6287 | |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6288 | /* Verify coding of two NSVCs in the INFO.ind message */ |
| 6289 | testcase TC_pcu_socket_two_nsvc() runs on test_CT { |
| 6290 | f_init_vty_bsc(); |
| 6291 | |
| 6292 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 nsvci 1234"); |
| 6293 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 local udp port 1234"); |
| 6294 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 6295 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote udp port 1234"); |
| 6296 | |
| 6297 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 nsvci 5678"); |
| 6298 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 local udp port 5678"); |
| 6299 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote ip fd00::ca:ff:ee"); |
| 6300 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote udp port 5678"); |
| 6301 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 6302 | f_init_with_pcuif(); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6303 | |
| 6304 | var PCUIF_info_ind info_ind := g_pcu_last_info.u.info_ind; |
| 6305 | var PCUIF_RemoteAddr remote_addr := info_ind.remote_addr; |
| 6306 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6307 | addr_type := { PCUIF_ADDR_TYPE_IPV4, PCUIF_ADDR_TYPE_IPV6 }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 6308 | addr := { |
| 6309 | f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), |
| 6310 | f_inet6_addr("fd00::ca:ff:ee") |
| 6311 | } |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6312 | }; |
| 6313 | |
| 6314 | if (not match(info_ind.nsvci, { 1234, 5678 })) |
| 6315 | { setverdict(fail, "NSVCI ", info_ind.nsvci, " does not match { 1234, 5678 }"); } |
| 6316 | if (not match(remote_addr, tr_remote_addr)) |
| 6317 | { setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); } |
| 6318 | if (not match(info_ind.local_port, { 1234, 5678 })) |
| 6319 | { setverdict(fail, "NSVC lport ", info_ind.local_port, " does not match { 1234, 5678 }"); } |
| 6320 | if (not match(info_ind.remote_port, { 1234, 5678 })) |
| 6321 | { setverdict(fail, "NSVC rport ", info_ind.remote_port, " does not match { 1234, 5678 }"); } |
| 6322 | |
| 6323 | setverdict(pass); |
| 6324 | } |
| 6325 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6326 | /* Verify periodic interference reports on PDCH */ |
| 6327 | testcase TC_pcu_interf_ind() runs on test_CT { |
| 6328 | var template PCUIF_Message tr_interf_ind; |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6329 | var integer interf_ind_num := 0; |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6330 | var boolean first := true; |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6331 | var PCUIF_send_data sd; |
| 6332 | timer T; |
| 6333 | |
Vadim Yanitskiy | d9b60e6 | 2021-11-10 03:58:31 +0300 | [diff] [blame] | 6334 | /* Set the averaging/reporting period to 480ms */ |
| 6335 | f_init_vty_bsc(); |
| 6336 | f_vty_cfg_bts(BSCVTY, 0, { "interference-meas avg-period 1" }); |
| 6337 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 6338 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6339 | f_init_with_pcuif(); |
| 6340 | f_TC_pcu_act_req(0, 0, 7, true); |
| 6341 | |
| 6342 | /* We need trxcon for NOPE indications */ |
| 6343 | f_init_l1ctl(); |
| 6344 | f_l1_tune(L1CTL); |
| 6345 | |
| 6346 | /* Expect -120 .. -90 dBm on TS7 of BTS0/TRX0 */ |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6347 | tr_interf_ind := tr_PCUIF_INTERF_IND( |
| 6348 | bts_nr := 0, |
| 6349 | trx_nr := 0, |
| 6350 | fn := ?, |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 6351 | interf := { 0, 0, 0, 0, 0, 0, 0, (90..120) } |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6352 | ); |
| 6353 | |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6354 | T.start(0.480 * 1.5); |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6355 | alt { |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6356 | /* The first interference report may contain unreliable values, so we ignore it */ |
| 6357 | [first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) { |
| 6358 | /* 4 SACCH periods => 4 reports (plus some guard time) */ |
| 6359 | T.start(0.480 * 4.0 + 0.480 / 2.0); |
| 6360 | first := false; |
| 6361 | repeat; |
| 6362 | } |
| 6363 | /* Subsequent interference reports shall match our expectations */ |
| 6364 | [not first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_interf_ind)) -> value sd { |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6365 | /* Check TDMA frame number period */ |
| 6366 | if (sd.data.u.interf_ind.fn mod 104 != 0) { |
| 6367 | setverdict(fail, "Odd TDMA frame number := ", |
| 6368 | sd.data.u.interf_ind.fn); |
| 6369 | } |
| 6370 | interf_ind_num := interf_ind_num + 1; |
| 6371 | if (interf_ind_num < 4) |
| 6372 | { repeat; } |
| 6373 | } |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6374 | [not first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) -> value sd { |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6375 | setverdict(fail, "Received unexpected interference report: ", sd.data); |
| 6376 | } |
| 6377 | [] PCU.receive { repeat; } |
| 6378 | [] T.timeout { |
| 6379 | setverdict(fail, "Timeout waiting for interference reports"); |
| 6380 | } |
| 6381 | } |
| 6382 | |
Vadim Yanitskiy | d9b60e6 | 2021-11-10 03:58:31 +0300 | [diff] [blame] | 6383 | /* Reset the averaging/reporting period back to default */ |
| 6384 | f_vty_cfg_bts(BSCVTY, 0, { "interference-meas avg-period 6" }); |
| 6385 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6386 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6387 | } |
| 6388 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6389 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6390 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6391 | ***********************************************************************/ |
| 6392 | |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6393 | private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp, |
| 6394 | integer bts_nr, integer trx_nr) |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6395 | runs on ConnHdlr { |
| 6396 | var PCUIF_send_data sd; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6397 | |
| 6398 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6399 | var BIT8 pdch_mask := sd.data.u.info_ind.trx[trx_nr].pdch_mask; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6400 | if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) { |
| 6401 | repeat; |
| 6402 | } |
| 6403 | } |
| 6404 | } |
| 6405 | |
| 6406 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6407 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6408 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6409 | PCU.clear; |
| 6410 | f_rsl_chan_act(g_pars.chan_mode); |
| 6411 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6412 | timer T_wait := 2.0; |
| 6413 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6414 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6415 | [] as_pcuif_check_pdch_mask(pcu_conn_id, '1'B, bts_nr, trx_nr); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6416 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6417 | [] T_wait.timeout { |
| 6418 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6419 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6420 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6421 | } |
| 6422 | /* try to activate this PDCH from the PCU point of view */ |
| 6423 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6424 | /* FIXME: is there a response? */ |
| 6425 | } |
| 6426 | |
| 6427 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6428 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6429 | /* Send RSL CHAN REL (deactivate) */ |
| 6430 | PCU.clear; |
| 6431 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 6432 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6433 | timer T_wait := 2.0; |
| 6434 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6435 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6436 | [] as_pcuif_check_pdch_mask(pcu_conn_id, '0'B, bts_nr, trx_nr); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6437 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6438 | [] T_wait.timeout { |
| 6439 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6440 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6441 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6442 | } |
| 6443 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6444 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6445 | alt { |
| 6446 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 6447 | setverdict(pass); |
| 6448 | } |
| 6449 | [] RSL.receive { repeat; } |
| 6450 | } |
| 6451 | } |
| 6452 | |
| 6453 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6454 | private function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6455 | var PCUIF_Message first_info; |
| 6456 | var integer ts_nr := g_chan_nr.tn; |
| 6457 | var integer trx_nr := 0; |
| 6458 | var integer bts_nr := 0; |
| 6459 | var integer pcu_conn_id := -1; |
| 6460 | |
| 6461 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6462 | |
| 6463 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6464 | f_sleep(3.0); |
| 6465 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6466 | setverdict(pass); |
| 6467 | } |
| 6468 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 6469 | var ConnHdlrPars pars; |
| 6470 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6471 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6472 | |
| 6473 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6474 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 6475 | vc_conn.done; |
| 6476 | } |
| 6477 | |
| 6478 | /* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6479 | private function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6480 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6481 | var integer pcu_conn_id := -1; |
| 6482 | |
| 6483 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6484 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 6485 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 6486 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 6487 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6488 | setverdict(pass); |
| 6489 | } |
| 6490 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 6491 | var ConnHdlrPars pars; |
| 6492 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6493 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6494 | |
| 6495 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6496 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 6497 | vc_conn.done; |
| 6498 | } |
| 6499 | |
| 6500 | /* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6501 | private function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6502 | var PCUIF_Message first_info; |
| 6503 | var integer ts_nr := g_chan_nr.tn; |
| 6504 | var integer trx_nr := 0; |
| 6505 | var integer bts_nr := 0; |
| 6506 | var integer pcu_conn_id := -1; |
| 6507 | |
| 6508 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6509 | |
| 6510 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 6511 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 6512 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6513 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6514 | setverdict(pass); |
| 6515 | } |
| 6516 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 6517 | var ConnHdlrPars pars; |
| 6518 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6519 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6520 | |
| 6521 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6522 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 6523 | vc_conn.done; |
| 6524 | } |
| 6525 | |
| 6526 | /* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6527 | private function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6528 | var PCUIF_Message first_info; |
| 6529 | var integer ts_nr := g_chan_nr.tn; |
| 6530 | var integer trx_nr := 0; |
| 6531 | var integer bts_nr := 0; |
| 6532 | var integer pcu_conn_id := -1; |
| 6533 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 6534 | |
| 6535 | /* register for the TCH/F channel number */ |
| 6536 | f_rslem_register(0, chan_nr); |
| 6537 | |
| 6538 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6539 | |
| 6540 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 6541 | "RSL CHAN ACT"); |
| 6542 | setverdict(pass); |
| 6543 | } |
| 6544 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 6545 | var ConnHdlrPars pars; |
| 6546 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6547 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6548 | |
| 6549 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6550 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 6551 | vc_conn.done; |
| 6552 | } |
| 6553 | |
| 6554 | /* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6555 | private function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6556 | var PCUIF_Message first_info; |
| 6557 | var integer ts_nr := g_chan_nr.tn; |
| 6558 | var integer trx_nr := 0; |
| 6559 | var integer bts_nr := 0; |
| 6560 | var integer pcu_conn_id := -1; |
| 6561 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 6562 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 6563 | |
| 6564 | /* register for the TCH/H channel numbers */ |
| 6565 | f_rslem_register(0, chan_nr[0]); |
| 6566 | f_rslem_register(0, chan_nr[1]); |
| 6567 | |
| 6568 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6569 | |
| 6570 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 6571 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 6572 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 6573 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 6574 | setverdict(pass); |
| 6575 | } |
| 6576 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 6577 | var ConnHdlrPars pars; |
| 6578 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6579 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6580 | |
| 6581 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6582 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 6583 | vc_conn.done; |
| 6584 | } |
| 6585 | |
Pau Espin Pedrol | 8e57ac1 | 2021-06-29 17:04:24 +0200 | [diff] [blame] | 6586 | /* try to RSL CHAN ACT the SDCCH8 on an osmocom-style PDCH */ |
| 6587 | private function f_TC_dyn_osmo_pdch_sdcch8_act(charstring id) runs on ConnHdlr { |
| 6588 | var PCUIF_Message first_info; |
| 6589 | var integer ts_nr := g_chan_nr.tn; |
| 6590 | var integer trx_nr := 0; |
| 6591 | var integer bts_nr := 0; |
| 6592 | var integer pcu_conn_id := -1; |
| 6593 | var RslChannelNr chan_nr[8] := { valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 0)), |
| 6594 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 1)), |
| 6595 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 2)), |
| 6596 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 3)), |
| 6597 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 4)), |
| 6598 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 5)), |
| 6599 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 6)), |
| 6600 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 7)) }; |
| 6601 | |
| 6602 | /* register for the TCH/H channel numbers */ |
| 6603 | for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) { |
| 6604 | f_rslem_register(0, chan_nr[i]); |
| 6605 | } |
| 6606 | |
| 6607 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6608 | |
| 6609 | for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) { |
| 6610 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[i], g_pars.chan_mode), |
| 6611 | tr_RSL_CHAN_ACT_ACK(chan_nr[i]), "RSL CHAN ACT [" & int2str(i) & "]"); |
| 6612 | } |
| 6613 | setverdict(pass); |
| 6614 | } |
| 6615 | testcase TC_dyn_osmo_pdch_sdcch8_act() runs on test_CT { |
| 6616 | var ConnHdlrPars pars; |
| 6617 | var ConnHdlr vc_conn; |
| 6618 | f_init(); |
| 6619 | |
| 6620 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6621 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_sdcch8_act), pars, true); |
| 6622 | vc_conn.done; |
| 6623 | } |
| 6624 | |
Vadim Yanitskiy | 64043d8 | 2021-10-03 15:00:20 +0600 | [diff] [blame] | 6625 | /* Reproduce a race condition described in OS#5245 */ |
| 6626 | private function f_rsl_chan_act_deact(charstring id) runs on ConnHdlr { |
| 6627 | f_rsl_chan_act(g_pars.chan_mode); |
| 6628 | f_sleep(1.0); |
| 6629 | f_rsl_chan_deact(); |
| 6630 | setverdict(pass); |
| 6631 | } |
| 6632 | testcase TC_dyn_osmo_pdch_tchh_race_act() runs on test_CT { |
| 6633 | var ConnHdlrPars pars[2]; |
| 6634 | var ConnHdlr vc_conn[2]; |
| 6635 | var TrxcMessage rsp; |
| 6636 | |
| 6637 | f_init(); |
| 6638 | |
| 6639 | /* Configure an artificial delay of 200 ms for TRXC RSP messages */ |
| 6640 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6641 | ts_TRXC_FAKE_TRXC_DELAY(200)); |
| 6642 | |
| 6643 | /* Activate all sub-channels of TCH/H on TS4 immediately in hope that the second |
| 6644 | * CHANnel ACTIVation message will be handled before the PHY responds to 'SETSLOT' */ |
| 6645 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6646 | /* TS4 is an Osmocom style dynamic timeslot, we want it to be TCH/H */ |
| 6647 | pars[i] := valueof(t_Pars(t_RslChanNr_Lm(4, i), ts_RSL_ChanMode_SIGN)); |
| 6648 | vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact), |
| 6649 | pars[i], l1ctl := false); |
| 6650 | } |
| 6651 | |
| 6652 | /* Wait for all components to finish */ |
| 6653 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6654 | vc_conn[i].done; |
| 6655 | } |
| 6656 | |
| 6657 | /* Disable the artificial delay for TRXC RSP messages */ |
| 6658 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6659 | ts_TRXC_FAKE_TRXC_DELAY(0)); |
| 6660 | } |
| 6661 | testcase TC_dyn_osmo_pdch_sdcch8_race_act() runs on test_CT { |
| 6662 | var ConnHdlrPars pars[8]; |
| 6663 | var ConnHdlr vc_conn[8]; |
| 6664 | var TrxcMessage rsp; |
| 6665 | |
| 6666 | f_init(); |
| 6667 | |
| 6668 | /* Configure an artificial delay of 200 ms for TRXC RSP messages */ |
| 6669 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6670 | ts_TRXC_FAKE_TRXC_DELAY(200)); |
| 6671 | |
| 6672 | /* Activate all sub-channels of SDCCH/8 on TS4 immediately in hope that subsequent |
| 6673 | * CHANnel ACTIVation messages will be handled before the PHY responds to 'SETSLOT' */ |
| 6674 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6675 | /* TS4 is an Osmocom style dynamic timeslot, we want it to be SDCCH/8 */ |
| 6676 | pars[i] := valueof(t_Pars(t_RslChanNr_SDCCH8(4, i), ts_RSL_ChanMode_SIGN)); |
| 6677 | vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact), |
| 6678 | pars[i], l1ctl := false); |
| 6679 | } |
| 6680 | |
| 6681 | /* Wait for all components to finish */ |
| 6682 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6683 | vc_conn[i].done; |
| 6684 | } |
| 6685 | |
| 6686 | /* Disable the artificial delay for TRXC RSP messages */ |
| 6687 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6688 | ts_TRXC_FAKE_TRXC_DELAY(0)); |
| 6689 | } |
| 6690 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6691 | /*********************************************************************** |
| 6692 | * IPA Style Dynamic Timeslot Support |
| 6693 | ***********************************************************************/ |
| 6694 | |
| 6695 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6696 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6697 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6698 | PCU.clear; |
| 6699 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6700 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6701 | timer T_wait := 2.0; |
| 6702 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6703 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6704 | [] as_pcuif_check_pdch_mask(pcu_conn_id, '1'B, bts_nr, trx_nr); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6705 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6706 | [] T_wait.timeout { |
| 6707 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6708 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6709 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6710 | } |
| 6711 | /* try to activate this PDCH from the PCU point of view */ |
| 6712 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6713 | /* FIXME: is there a response? */ |
| 6714 | |
| 6715 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 6716 | } |
| 6717 | |
| 6718 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6719 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6720 | /* Send RSL CHAN REL (deactivate) */ |
| 6721 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 6722 | PCU.clear; |
| 6723 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6724 | timer T_wait := 2.0; |
| 6725 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6726 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6727 | [] as_pcuif_check_pdch_mask(pcu_conn_id, '0'B, bts_nr, trx_nr); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6728 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6729 | [] T_wait.timeout { |
| 6730 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6731 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6732 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6733 | } |
| 6734 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6735 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6736 | alt { |
| 6737 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 6738 | setverdict(pass); |
| 6739 | } |
| 6740 | [] RSL.receive { repeat; } |
| 6741 | } |
| 6742 | } |
| 6743 | |
| 6744 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6745 | private function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6746 | var PCUIF_Message first_info; |
| 6747 | var integer ts_nr := g_chan_nr.tn; |
| 6748 | var integer trx_nr := 0; |
| 6749 | var integer bts_nr := 0; |
| 6750 | var integer pcu_conn_id := -1; |
| 6751 | |
| 6752 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6753 | |
| 6754 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6755 | f_sleep(3.0); |
| 6756 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6757 | |
| 6758 | setverdict(pass); |
| 6759 | |
| 6760 | } |
| 6761 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 6762 | var ConnHdlrPars pars; |
| 6763 | var ConnHdlr vc_conn; |
| 6764 | f_init(); |
| 6765 | |
| 6766 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6767 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 6768 | vc_conn.done; |
| 6769 | } |
| 6770 | |
| 6771 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6772 | private function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6773 | var PCUIF_Message first_info; |
| 6774 | var integer ts_nr := g_chan_nr.tn; |
| 6775 | var integer trx_nr := 0; |
| 6776 | var integer bts_nr := 0; |
| 6777 | var integer pcu_conn_id := -1; |
| 6778 | |
| 6779 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6780 | |
| 6781 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6782 | "RSL CHAN ACT"); |
| 6783 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6784 | "RF CHAN REL", true); |
| 6785 | setverdict(pass); |
| 6786 | } |
| 6787 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 6788 | var ConnHdlrPars pars; |
| 6789 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6790 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6791 | |
| 6792 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6793 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 6794 | vc_conn.done; |
| 6795 | } |
| 6796 | |
| 6797 | /* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6798 | private function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6799 | var PCUIF_Message first_info; |
| 6800 | var integer ts_nr := g_chan_nr.tn; |
| 6801 | var integer trx_nr := 0; |
| 6802 | var integer bts_nr := 0; |
| 6803 | var integer pcu_conn_id := -1; |
| 6804 | |
| 6805 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6806 | |
| 6807 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6808 | "RSL CHAN ACT"); |
| 6809 | |
| 6810 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6811 | alt { |
| 6812 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 6813 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6814 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6815 | } |
| 6816 | [] RSL.receive { repeat; } |
| 6817 | } |
| 6818 | |
| 6819 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6820 | "RF CHAN REL", true); |
| 6821 | setverdict(pass); |
| 6822 | } |
| 6823 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 6824 | var ConnHdlrPars pars; |
| 6825 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6826 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6827 | |
| 6828 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6829 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 6830 | vc_conn.done; |
| 6831 | } |
| 6832 | |
| 6833 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6834 | private function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6835 | var PCUIF_Message first_info; |
| 6836 | var integer ts_nr := g_chan_nr.tn; |
| 6837 | var integer trx_nr := 0; |
| 6838 | var integer bts_nr := 0; |
| 6839 | var integer pcu_conn_id := -1; |
| 6840 | |
| 6841 | /* register for the TCH/F channel number */ |
| 6842 | f_rslem_register(0, g_chan_nr); |
| 6843 | |
| 6844 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6845 | |
| 6846 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6847 | |
| 6848 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6849 | "RSL CHAN ACT"); |
| 6850 | |
| 6851 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6852 | |
| 6853 | setverdict(pass); |
| 6854 | } |
| 6855 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 6856 | var ConnHdlrPars pars; |
| 6857 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6858 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6859 | |
| 6860 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6861 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 6862 | vc_conn.done; |
| 6863 | } |
| 6864 | |
| 6865 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6866 | /*********************************************************************** |
| 6867 | * LAPDm / RLL related |
| 6868 | ***********************************************************************/ |
| 6869 | |
| 6870 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 6871 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 6872 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6873 | var template (value) SacchL1Header l1h; |
| 6874 | |
| 6875 | /* 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] | 6876 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6877 | /* Compose dummy L1 header */ |
| 6878 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta); |
| 6879 | 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] | 6880 | } else { |
| 6881 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6882 | 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] | 6883 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6884 | } |
| 6885 | |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 6886 | friend type record RllTestCase { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6887 | uint3_t sapi, |
| 6888 | RslLinkId link_id, |
| 6889 | octetstring l3, |
| 6890 | boolean exp |
| 6891 | } |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 6892 | friend type record of RllTestCase RllTestCases; |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6893 | friend template RllTestCase t_EITC(template (present) uint3_t sapi, |
| 6894 | template (present) RslLinkId id, |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 6895 | octetstring l3, boolean exp) := { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6896 | sapi := sapi, |
| 6897 | link_id := id, |
| 6898 | l3 := l3, |
| 6899 | exp := exp |
| 6900 | } |
| 6901 | |
| 6902 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 6903 | * variety of logical channels */ |
| 6904 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 6905 | var ConnHdlrPars pars; |
| 6906 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6907 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6908 | |
| 6909 | /* test on each of the channels we have */ |
| 6910 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 6911 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 6912 | |
| 6913 | /* test each of the test cases on the current channel */ |
| 6914 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 6915 | pars.spec.rll := tcs[j]; |
| 6916 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 6917 | vc_conn := f_start_handler(fn, pars); |
| 6918 | vc_conn.done; |
| 6919 | } |
| 6920 | } |
| 6921 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6922 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6923 | } |
| 6924 | |
| 6925 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 6926 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 6927 | var RllTestCase tc := g_pars.spec.rll; |
| 6928 | timer T := 3.0; |
| 6929 | |
| 6930 | f_l1_tune(L1CTL); |
| 6931 | RSL.clear; |
| 6932 | |
| 6933 | /* activate the logical channel */ |
| 6934 | f_est_dchan(); |
| 6935 | L1CTL.clear; |
| 6936 | |
| 6937 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 6938 | T.start; |
| 6939 | alt { |
| 6940 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6941 | if (tc.exp) { |
| 6942 | setverdict(pass); |
| 6943 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6944 | 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] | 6945 | } |
| 6946 | } |
| 6947 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 6948 | if (tc.exp) { |
| 6949 | setverdict(pass); |
| 6950 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6951 | 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] | 6952 | } |
| 6953 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6954 | /* We also expect to receive the measurements */ |
| 6955 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6956 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6957 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6958 | } |
| 6959 | [not tc.exp] T.timeout { |
| 6960 | setverdict(pass); |
| 6961 | } |
| 6962 | } |
| 6963 | |
| 6964 | f_rsl_chan_deact(); |
| 6965 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6966 | f_rslem_unregister(0, g_chan_nr); |
| 6967 | } |
| 6968 | testcase TC_rll_est_ind() runs on test_CT { |
| 6969 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6970 | /* SAPI0 establishment (contention resolution) */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6971 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6972 | /* normal SAPI0 establishment */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6973 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6974 | /* SAPI 3 doesn't support contention resolution */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6975 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), '01020304'O, false)), |
| 6976 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), '01020304'O, false)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6977 | /* normal SAPI3 establishment on main DCCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6978 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6979 | /* normal SAPI3 establishment on SACCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6980 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6981 | }; |
| 6982 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 6983 | } |
| 6984 | |
| 6985 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 6986 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 6987 | var RllTestCase tc := g_pars.spec.rll; |
| 6988 | var L1ctlDlMessage dl; |
| 6989 | timer T := 3.0; |
| 6990 | |
| 6991 | f_l1_tune(L1CTL); |
| 6992 | RSL.clear; |
| 6993 | |
| 6994 | /* activate the logical channel */ |
| 6995 | f_est_dchan(); |
| 6996 | L1CTL.clear; |
| 6997 | |
| 6998 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 6999 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 7000 | T.start; |
| 7001 | alt { |
Vadim Yanitskiy | 0310f63 | 2021-06-01 01:22:24 +0200 | [diff] [blame] | 7002 | [] as_l1_exp_lapdm(tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O)); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7003 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7004 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7005 | } |
| 7006 | } |
| 7007 | |
| 7008 | f_rsl_chan_deact(); |
| 7009 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7010 | f_rslem_unregister(0, g_chan_nr); |
| 7011 | } |
| 7012 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 7013 | var RllTestCases tcs := { |
| 7014 | /* normal SAPI3 establishment on main DCCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7015 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true))//, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7016 | }; |
| 7017 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 7018 | } |
| 7019 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 7020 | var RllTestCases tcs := { |
| 7021 | /* normal SAPI3 establishment on SACCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7022 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7023 | } |
| 7024 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 7025 | } |
| 7026 | |
| 7027 | /* altstep to receive a LAPDm frame matching the given template */ |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 7028 | friend altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7029 | var L1ctlDlMessage dl; |
| 7030 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 7031 | var LapdmFrame lapdm; |
| 7032 | var octetstring l2 := dl.payload.data_ind.payload; |
| 7033 | if (dl.dl_info.link_id.c == SACCH) { |
| 7034 | /* remove L1 header */ |
| 7035 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 7036 | } |
| 7037 | if (ischosen(exp.ab)) { |
| 7038 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 7039 | } else if (ischosen(exp.b4)) { |
| 7040 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 7041 | } else if (ischosen(exp.bbis)) { |
| 7042 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 7043 | } |
| 7044 | log("Rx LAPDm ", lapdm); |
| 7045 | if (match(lapdm, exp)) { |
| 7046 | setverdict(pass); |
| 7047 | } else { |
| 7048 | repeat; |
| 7049 | } |
| 7050 | } |
| 7051 | [] L1CTL.receive { repeat; } |
| 7052 | } |
| 7053 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 7054 | timer T := t; |
| 7055 | T.start; |
| 7056 | alt { |
| 7057 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7058 | 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] | 7059 | } |
| 7060 | [] as_l1_exp_lapdm(exp); |
| 7061 | } |
| 7062 | } |
| 7063 | |
| 7064 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 7065 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 7066 | /* send SABM from MS -> BTS */ |
| 7067 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 7068 | /* expect RLL EST IND on Abis */ |
| 7069 | alt { |
| 7070 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 7071 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 7072 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7073 | 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] | 7074 | } |
| 7075 | [] RSL.receive { repeat; } |
| 7076 | } |
| 7077 | /* expect UA from BTS -> MS */ |
| 7078 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 7079 | } |
| 7080 | |
| 7081 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 7082 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 7083 | var RllTestCase tc := g_pars.spec.rll; |
| 7084 | |
| 7085 | f_l1_tune(L1CTL); |
| 7086 | RSL.clear; |
| 7087 | |
| 7088 | /* activate the logical channel */ |
| 7089 | f_est_dchan(); |
| 7090 | L1CTL.clear; |
| 7091 | |
| 7092 | /* first establish the link-layer */ |
| 7093 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 7094 | |
| 7095 | /* then send the DISC */ |
| 7096 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 7097 | /* ... and expect the REL IND on the RSL side */ |
| 7098 | alt { |
| 7099 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 7100 | setverdict(pass); |
| 7101 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 7102 | /* We also expect to receive the measurements */ |
| 7103 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7104 | } |
| 7105 | |
| 7106 | /* release the channel */ |
| 7107 | f_rsl_chan_deact(); |
| 7108 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7109 | f_rslem_unregister(0, g_chan_nr); |
| 7110 | } |
| 7111 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 7112 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7113 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7114 | }; |
| 7115 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7116 | } |
| 7117 | |
| 7118 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 7119 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7120 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7121 | }; |
| 7122 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7123 | } |
| 7124 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 7125 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7126 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7127 | }; |
| 7128 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7129 | } |
| 7130 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 7131 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7132 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7133 | }; |
| 7134 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7135 | } |
| 7136 | |
| 7137 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 7138 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 7139 | var RllTestCase tc := g_pars.spec.rll; |
| 7140 | f_l1_tune(L1CTL); |
| 7141 | RSL.clear; |
| 7142 | |
| 7143 | /* activate the logical channel */ |
| 7144 | f_est_dchan(); |
| 7145 | L1CTL.clear; |
| 7146 | |
| 7147 | /* first establish the link-layer */ |
| 7148 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 7149 | |
| 7150 | /* then send the REL REQ via RSL */ |
| 7151 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 7152 | /* ... and expect the DISC on the Um side */ |
| 7153 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 7154 | [] 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] | 7155 | /* FIXME: send a UA in resposne to the DISC */ |
| 7156 | } |
| 7157 | } |
| 7158 | |
| 7159 | /* release the channel */ |
| 7160 | f_rsl_chan_deact(); |
| 7161 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7162 | f_rslem_unregister(0, g_chan_nr); |
| 7163 | } |
| 7164 | testcase TC_rll_rel_req() runs on test_CT { |
| 7165 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7166 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)), |
| 7167 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)), |
| 7168 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)), |
| 7169 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7170 | }; |
| 7171 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 7172 | } |
| 7173 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 7174 | /* TODO: test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7175 | testcase TC_rll_data_req() runs on test_CT { |
| 7176 | } |
| 7177 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 7178 | /* TODO: test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7179 | testcase TC_rll_data_ind() runs on test_CT { |
| 7180 | } |
| 7181 | |
| 7182 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 7183 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 7184 | var RllTestCase tc := g_pars.spec.rll; |
| 7185 | |
| 7186 | f_l1_tune(L1CTL); |
| 7187 | RSL.clear; |
| 7188 | |
| 7189 | f_est_dchan(); |
| 7190 | L1CTL.clear; |
| 7191 | |
| 7192 | /* Send UNITDATA REQ on RSL side */ |
| 7193 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 7194 | /* Expect it to arrive on the other side */ |
| 7195 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7196 | 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] | 7197 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7198 | 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] | 7199 | } |
| 7200 | |
| 7201 | /* release the channel */ |
| 7202 | f_rsl_chan_deact(); |
| 7203 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7204 | f_rslem_unregister(0, g_chan_nr); |
| 7205 | } |
| 7206 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 7207 | var octetstring l3 := f_rnd_octstring(15); |
| 7208 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7209 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)), |
| 7210 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7211 | }; |
| 7212 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 7213 | } |
| 7214 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 7215 | var octetstring l3 := f_rnd_octstring(19); |
| 7216 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7217 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)), |
| 7218 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7219 | }; |
| 7220 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 7221 | } |
| 7222 | |
| 7223 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 7224 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 7225 | var RllTestCase tc := g_pars.spec.rll; |
| 7226 | |
| 7227 | f_l1_tune(L1CTL); |
| 7228 | RSL.clear; |
| 7229 | |
| 7230 | f_est_dchan(); |
| 7231 | L1CTL.clear; |
| 7232 | |
| 7233 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7234 | 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] | 7235 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 7236 | alt { |
| 7237 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 7238 | setverdict(pass); |
| 7239 | } |
| 7240 | [] RSL.receive { repeat; } |
| 7241 | } |
| 7242 | |
| 7243 | /* release the channel */ |
| 7244 | f_rsl_chan_deact(); |
| 7245 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7246 | f_rslem_unregister(0, g_chan_nr); |
| 7247 | } |
| 7248 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 7249 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7250 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7251 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)), |
| 7252 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7253 | }; |
| 7254 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 7255 | } |
| 7256 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 7257 | var octetstring l3 := f_rnd_octstring(18); |
| 7258 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7259 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)), |
| 7260 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7261 | }; |
| 7262 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 7263 | } |
| 7264 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7265 | /*********************************************************************** |
| 7266 | * Encryption Related |
| 7267 | ***********************************************************************/ |
| 7268 | |
| 7269 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 7270 | private function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7271 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 7272 | if (link_id.c == SACCH) { |
| 7273 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 7274 | } else { |
| 7275 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 7276 | } |
| 7277 | } |
| 7278 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7279 | /* Expect (or not expect) other kinds of messages */ |
| 7280 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 7281 | [exp_any] RSL.receive { repeat; } |
| 7282 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7283 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7284 | } |
| 7285 | } |
| 7286 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7287 | /* 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] | 7288 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 7289 | RslLinkId link_id, |
| 7290 | octetstring l3, |
| 7291 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 7292 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 7293 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7294 | timer T := 3.0; |
| 7295 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 7296 | T.start; |
| 7297 | /* Expect RLL UNITDATA IND on RSL side */ |
| 7298 | alt { |
| 7299 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 7300 | setverdict(pass); |
| 7301 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 7302 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7303 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7304 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7305 | 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] | 7306 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7307 | } |
| 7308 | } |
| 7309 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7310 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 7311 | private function f_data_mo( |
| 7312 | RslLinkId link_id, |
| 7313 | boolean p, uint3_t nr, uint3_t ns, |
| 7314 | octetstring l3, |
| 7315 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 7316 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7317 | ) runs on ConnHdlr { |
| 7318 | timer T := 3.0; |
| 7319 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 7320 | T.start; |
| 7321 | /* Expect RLL DATA IND on RSL side */ |
| 7322 | alt { |
| 7323 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 7324 | setverdict(pass); |
| 7325 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 7326 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7327 | [] as_rsl_any_ind(exp_any); |
| 7328 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7329 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7330 | } |
| 7331 | } |
| 7332 | } |
| 7333 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7334 | /* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7335 | private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7336 | f_l1_tune(L1CTL); |
| 7337 | f_est_dchan(true); |
| 7338 | |
| 7339 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 7340 | var L1ctlDlMessage dl; |
| 7341 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 7342 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7343 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7344 | |
| 7345 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 7346 | f_unitdata_mt(link_id, l3); |
| 7347 | |
| 7348 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 7349 | f_unitdata_mo(link_id, l3); |
| 7350 | |
| 7351 | /* release the channel */ |
| 7352 | f_rsl_chan_deact(); |
| 7353 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7354 | f_rslem_unregister(0, g_chan_nr); |
| 7355 | } |
| 7356 | testcase TC_chan_act_a51() runs on test_CT { |
| 7357 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7358 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7359 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7360 | } |
| 7361 | testcase TC_chan_act_a52() runs on test_CT { |
| 7362 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7363 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 7364 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7365 | } |
| 7366 | testcase TC_chan_act_a53() runs on test_CT { |
| 7367 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7368 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 7369 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7370 | } |
Eric Wild | b926039 | 2021-05-15 19:48:22 +0200 | [diff] [blame] | 7371 | testcase TC_chan_act_a54() runs on test_CT { |
| 7372 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7373 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16))); |
| 7374 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7375 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7376 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7377 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 7378 | which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7379 | private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7380 | f_l1_tune(L1CTL); |
| 7381 | f_est_dchan(true); |
| 7382 | |
| 7383 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 7384 | var L1ctlDlMessage dl; |
| 7385 | |
| 7386 | var octetstring l3 := f_rnd_octstring(20); |
| 7387 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7388 | |
| 7389 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 7390 | f_unitdata_mt(link_id, l3); |
| 7391 | |
| 7392 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 7393 | f_unitdata_mo(link_id, l3); |
| 7394 | |
| 7395 | var RSL_Message rsl; |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7396 | rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, ts_RSL_ChanMode_SIGN)); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7397 | |
| 7398 | /* modify key to break proper encryption */ |
| 7399 | g_pars.encr.key := f_rnd_octstring(8); |
| 7400 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 7401 | rsl.ies := rsl.ies & { ei }; |
| 7402 | RSL.send(rsl); |
| 7403 | |
| 7404 | timer T0 := 1.0; |
| 7405 | T0.start; |
| 7406 | /* Expect RSL MODIFY ACK */ |
| 7407 | alt { |
| 7408 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 7409 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 7410 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 7411 | } |
| 7412 | [] T0.timeout { |
| 7413 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 7414 | } |
| 7415 | } |
| 7416 | |
| 7417 | var octetstring l3msg := f_rnd_octstring(15); |
| 7418 | timer T1 := 3.0; |
| 7419 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 7420 | due to broken encryption */ |
| 7421 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 7422 | T1.start; |
| 7423 | alt { |
| 7424 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 7425 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 7426 | } |
| 7427 | [] T1.timeout { |
| 7428 | setverdict(pass); |
| 7429 | } |
| 7430 | } |
| 7431 | |
| 7432 | /* release the channel */ |
| 7433 | f_rsl_chan_deact(); |
| 7434 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7435 | f_rslem_unregister(0, g_chan_nr); |
| 7436 | } |
| 7437 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 7438 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7439 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7440 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 7441 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7442 | |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 7443 | /* Verify RF RESource INDication messages (periodically sent over the RSL) */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 7444 | private function f_TC_rsl_rf_resource_ind(template (present) RSL_ResourceInfo info) |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 7445 | runs on test_CT { |
| 7446 | const IpaStreamId sid := IPAC_PROTO_RSL_TRX0; |
| 7447 | var ASP_RSL_Unitdata ud; |
| 7448 | timer T; |
| 7449 | |
| 7450 | /* Intave is 6 SACCH periods by default */ |
| 7451 | var float Tval := int2float(6 * 480) / 1000.0 + 0.5; |
| 7452 | |
| 7453 | T.start(Tval); |
| 7454 | alt { |
| 7455 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(info), sid)) { |
| 7456 | setverdict(pass); |
| 7457 | } |
| 7458 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(?), sid)) -> value ud { |
| 7459 | setverdict(fail, "RF RESource INDication mismatch: ", ud.rsl); |
| 7460 | } |
| 7461 | [] RSL_CCHAN.receive { repeat; } |
| 7462 | [] T.timeout { |
| 7463 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 7464 | "Timeout waiting for RF RESource INDication"); |
| 7465 | } |
| 7466 | } |
| 7467 | } |
| 7468 | testcase TC_rsl_rf_resource_ind() runs on test_CT { |
| 7469 | var RSL_ResourceInfo info := { }; |
| 7470 | |
| 7471 | f_init(trx_nr := 0); |
| 7472 | |
| 7473 | f_init_l1ctl(); |
| 7474 | f_l1_tune(L1CTL); |
| 7475 | |
| 7476 | /* g_AllChannels contains all logical channels */ |
| 7477 | for (var integer i := 0; i < lengthof(g_AllChannels); i := i + 1) { |
| 7478 | var RslChannelNr chan_nr := g_AllChannels[i]; |
| 7479 | |
| 7480 | /* FIXME: osmo-bts does not report for Osmocom style dynamic timeslots */ |
| 7481 | if (mp_trx_pars[0].ts[chan_nr.tn].config == GSM_PCHAN_TCHH_TCHF_PDCH) |
| 7482 | { continue; } |
| 7483 | |
| 7484 | info := info & { valueof(ts_RSL_ResourceInfoItem(chan_nr, mp_interf_band)) }; |
| 7485 | } |
| 7486 | |
| 7487 | /* Align to the first interference report */ |
| 7488 | f_TC_rsl_rf_resource_ind(?); |
| 7489 | |
| 7490 | /* Test 4 consecutive messages */ |
| 7491 | for (var integer i := 0; i < 4; i := i + 1) { |
| 7492 | f_TC_rsl_rf_resource_ind(info); |
| 7493 | } |
| 7494 | |
| 7495 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7496 | } |
| 7497 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7498 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7499 | private function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7500 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 7501 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 7502 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 7503 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7504 | |
| 7505 | f_l1_tune(L1CTL); |
| 7506 | |
| 7507 | /* first establish a dedicated channel in the clear */ |
| 7508 | f_est_dchan(false); |
| 7509 | |
| 7510 | /* Establish ABM */ |
| 7511 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 7512 | |
| 7513 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 7514 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 7515 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 7516 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 7517 | |
| 7518 | /* configure L1 to apply ciphering */ |
| 7519 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 7520 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 7521 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7522 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 7523 | 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] | 7524 | |
| 7525 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 7526 | * and hence enable encryption also on the downlink */ |
| 7527 | |
| 7528 | /* expect bi-directional communication work in encrypted mode */ |
| 7529 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 7530 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 7531 | |
| 7532 | /* release the channel */ |
| 7533 | f_rsl_chan_deact(); |
| 7534 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7535 | f_rslem_unregister(0, g_chan_nr); |
| 7536 | } |
| 7537 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 7538 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7539 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7540 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7541 | } |
| 7542 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 7543 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7544 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 7545 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7546 | } |
| 7547 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 7548 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7549 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 7550 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7551 | } |
Eric Wild | b926039 | 2021-05-15 19:48:22 +0200 | [diff] [blame] | 7552 | testcase TC_encr_cmd_a54() runs on test_CT { |
| 7553 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7554 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16))); |
| 7555 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7556 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7557 | |
| 7558 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 7559 | var LapdmFrame lf; |
| 7560 | var octetstring reenc; |
| 7561 | |
| 7562 | /* decode the LAPDm frame */ |
| 7563 | if (ischosen(exp_match.ab)) { |
| 7564 | lf.ab := dec_LapdmFrameAB(enc); |
| 7565 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7566 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7567 | } |
| 7568 | |
| 7569 | /* check if decoder result matches expectation */ |
| 7570 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7571 | 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] | 7572 | } else { |
| 7573 | log(name, ": matched"); |
| 7574 | setverdict(pass); |
| 7575 | } |
| 7576 | |
| 7577 | /* test if re-encoded frame equals original input */ |
| 7578 | reenc := enc_LapdmFrame(lf); |
| 7579 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7580 | 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] | 7581 | } else { |
| 7582 | setverdict(pass); |
| 7583 | } |
| 7584 | } |
| 7585 | |
| 7586 | testcase TC_lapdm_selftest() runs on test_CT { |
| 7587 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 7588 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 7589 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 7590 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 7591 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 7592 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 7593 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 7594 | } |
| 7595 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7596 | /*********************************************************************** |
| 7597 | * DTX Related (see GSM 05.08, section 8.3) |
| 7598 | ***********************************************************************/ |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7599 | private function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7600 | var L1ctlDlMessage dl; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7601 | var GsmFrameNumber first_fn; |
| 7602 | var boolean is_first_frame := true; |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7603 | var integer nfill_frames := 0; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7604 | 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] | 7605 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 7606 | 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] | 7607 | const integer frame_dtx_tchf_mod := 104; |
| 7608 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 7609 | * which operates in terms of blocks rather than frames. */ |
| 7610 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 7611 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7612 | timer T := 5.0; |
| 7613 | |
| 7614 | f_l1_tune(L1CTL); |
| 7615 | RSL.clear; |
| 7616 | L1CTL.clear; |
| 7617 | |
| 7618 | /* activate TCHF signalling channel */ |
| 7619 | f_est_dchan(false); |
| 7620 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7621 | /* A template for matching dummy LAPDm func=UA frames */ |
| 7622 | var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND( |
| 7623 | chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?), |
| 7624 | l2_data := f_pad_oct('030301'O, 23, '2B'O)); |
| 7625 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7626 | T.start; |
| 7627 | alt { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7628 | [] L1CTL.receive(tr_fill_frame) -> value dl { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7629 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7630 | |
| 7631 | if (is_first_frame) { |
| 7632 | is_first_frame := false; |
| 7633 | first_fn := dl.dl_info.frame_nr; |
| 7634 | } |
| 7635 | |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7636 | if (g_pars.chan_mode.dtx_d) { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7637 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7638 | T.stop; |
| 7639 | f_rsl_chan_deact(); |
| 7640 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7641 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7642 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. */ |
| 7643 | expected_fill_frames := 2; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7644 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7645 | if (nfill_frames < expected_fill_frames) { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7646 | setverdict(fail, "Not enough fill frames received: ", |
| 7647 | nfill_frames, " out of ", expected_fill_frames); |
| 7648 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7649 | } else { |
| 7650 | setverdict(pass); |
| 7651 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7652 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7653 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 7654 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 7655 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 7656 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 7657 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 7658 | if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7659 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7660 | repeat; |
| 7661 | } |
| 7662 | } |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7663 | setverdict(fail, "Received DTX TCH fill frame with bad frame number: ", fn, |
| 7664 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 7665 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7666 | f_rsl_chan_deact(); |
| 7667 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7668 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7669 | } else { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7670 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7671 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7672 | T.stop; |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7673 | |
| 7674 | select (g_chan_nr) { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7675 | /* TCH/F: we expect 24 fill frames for every 104 frames. */ |
| 7676 | case (t_RslChanNr_Bm(?)) { expected_fill_frames := 24; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7677 | /* TCH/H: we expect 2 fill frames for every 104 frames. */ |
| 7678 | case (t_RslChanNr_Lm(?, ?)) { expected_fill_frames := 2; } |
| 7679 | /* SDCCH: we expect 5 fill frames for every 104 frames. */ |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7680 | case (t_RslChanNr_SDCCH4(?, ?)) { expected_fill_frames := 4; } |
| 7681 | case (t_RslChanNr_SDCCH8(?, ?)) { expected_fill_frames := 4; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7682 | case else { |
| 7683 | /* This shall not happen, just to be sure */ |
| 7684 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7685 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7686 | } |
| 7687 | |
| 7688 | f_rsl_chan_deact(); |
| 7689 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7690 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7691 | if (nfill_frames >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7692 | setverdict(pass); |
| 7693 | } else { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7694 | setverdict(fail, "Not enough fill frames received: ", |
| 7695 | nfill_frames, " out of ", expected_fill_frames); |
| 7696 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7697 | } |
| 7698 | } else { |
| 7699 | repeat; |
| 7700 | } |
| 7701 | } |
| 7702 | } |
| 7703 | [] L1CTL.receive { repeat; } |
| 7704 | [] T.timeout { |
| 7705 | f_rsl_chan_deact(); |
| 7706 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7707 | 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] | 7708 | } |
| 7709 | } |
| 7710 | } |
| 7711 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7712 | private function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7713 | var template RSL_IE_ChannelMode ch_mode; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7714 | var ConnHdlr vc_conn; |
| 7715 | var ConnHdlrPars pars; |
| 7716 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7717 | f_init(); |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7718 | ch_mode := ts_RSL_ChanMode_SIGN(dtx_downlink := dtxd); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7719 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7720 | pars := valueof(t_Pars(g_AllChannels[i], ch_mode)); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7721 | if (dtxd) { |
| 7722 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 7723 | break; |
| 7724 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7725 | } |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7726 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7727 | vc_conn.done; |
| 7728 | } |
| 7729 | } |
| 7730 | |
| 7731 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 7732 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 7733 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 7734 | f_tch_sign_l2_fill_frame(false); |
| 7735 | } |
| 7736 | |
| 7737 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 7738 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 7739 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 7740 | f_tch_sign_l2_fill_frame(true); |
| 7741 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7742 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 7743 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 7744 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7745 | } |
| 7746 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 7747 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 7748 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7749 | } |
| 7750 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7751 | |
| 7752 | /* Callback function to be called by as_TC_ms_pwr_ctrl_constant(). |
| 7753 | * Return value: Measurement Report to be sent (encoded octetstring). */ |
| 7754 | type function f_TC_ms_pwr_ctrl_cb(inout SacchL1Header l1h, integer num_blocks) |
| 7755 | runs on ConnHdlr return octetstring; |
| 7756 | |
| 7757 | private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks) |
| 7758 | runs on ConnHdlr { |
| 7759 | var L1ctlDlMessage l1_dl; |
| 7760 | var SacchL1Header l1h; |
| 7761 | var octetstring l2; |
| 7762 | |
| 7763 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 7764 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 7765 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 7766 | log("as_TC_ms_pwr_ctrl(): Rx SACCH L1 header: ", l1h); |
| 7767 | |
| 7768 | /* Pass it to the user specified call-back function */ |
| 7769 | l2 := cb.apply(l1h, num_blocks); |
| 7770 | /* Send a Measurement Report generated by the call-back */ |
| 7771 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(l1_dl.dl_info.chan_nr, |
| 7772 | l1_dl.dl_info.link_id, |
| 7773 | l1h, l2)); |
| 7774 | |
| 7775 | /* Shall we keep going? */ |
| 7776 | num_blocks := num_blocks - 1; |
| 7777 | log("as_TC_ms_pwr_ctrl(): ", num_blocks, " SACCH blocks remaining"); |
| 7778 | if (num_blocks > 0) { repeat; } |
| 7779 | } |
| 7780 | [] L1CTL.receive { repeat; } |
| 7781 | } |
| 7782 | |
| 7783 | private function f_TC_ms_pwr_ctrl_cb_def(inout SacchL1Header l1h, integer num_blocks) |
| 7784 | runs on ConnHdlr return octetstring { |
| 7785 | /* Command the L1 to apply received parameters */ |
| 7786 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 7787 | |
| 7788 | /* Dummy measurement report (the results are invalid) */ |
| 7789 | return f_pad_oct('010349'O & '0615004001C0'O, 21, '00'O); |
| 7790 | } |
| 7791 | |
| 7792 | private function f_TC_ms_pwr_ctrl_cb_const(inout SacchL1Header l1h, integer num_blocks) |
| 7793 | runs on ConnHdlr return octetstring { |
| 7794 | if (l1h.ms_power_lvl != g_pars.l1_pars.ms_power_level) { |
| 7795 | setverdict(fail, "Unexpected MS Power level change: ", |
| 7796 | g_pars.l1_pars.ms_power_level, " -> ", |
| 7797 | l1h.ms_power_lvl); |
| 7798 | } |
| 7799 | |
| 7800 | return f_TC_ms_pwr_ctrl_cb_def(l1h, num_blocks); |
| 7801 | } |
| 7802 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7803 | private function f_TC_ms_pwr_ctrl_cb_rssi_pwm(inout SacchL1Header l1h, integer num_blocks) |
| 7804 | runs on ConnHdlr return octetstring { |
| 7805 | /* UL RSSI oscillation driven by SACCH block number */ |
| 7806 | if (num_blocks rem 2 == 0) { |
| 7807 | f_trxc_fake_rssi(-100); |
| 7808 | } else { |
| 7809 | f_trxc_fake_rssi(-50); |
| 7810 | } |
| 7811 | |
| 7812 | /* Make sure that MS power level remains constant */ |
| 7813 | return f_TC_ms_pwr_ctrl_cb_const(l1h, num_blocks); |
| 7814 | } |
| 7815 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7816 | /* Make sure that MS power level remains constant when 'rx-current' equals 'rx-target' */ |
| 7817 | private function f_TC_ms_pwr_ctrl_constant(charstring id) |
| 7818 | runs on ConnHdlr { |
| 7819 | var integer num_blocks := 8; |
| 7820 | timer T := int2float(num_blocks); |
| 7821 | |
| 7822 | f_l1_tune(L1CTL); |
| 7823 | RSL.clear; |
| 7824 | |
| 7825 | /* These IEs are needed for autonomous MS power control */ |
| 7826 | var template (value) RSL_IE_List ies := { |
| 7827 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7828 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7829 | }), |
| 7830 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7831 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7832 | }) |
| 7833 | }; |
| 7834 | |
| 7835 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7836 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7837 | |
| 7838 | /* Establish a dedicated channel */ |
| 7839 | f_est_dchan(more_ies := valueof(ies)); |
| 7840 | |
| 7841 | L1CTL.clear; |
| 7842 | T.start; |
| 7843 | alt { |
| 7844 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_const), num_blocks); |
| 7845 | [] T.timeout { |
| 7846 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7847 | num_blocks, " were not handled"); |
| 7848 | } |
| 7849 | } |
Vadim Yanitskiy | 6b4404a | 2021-06-17 17:22:56 +0200 | [diff] [blame] | 7850 | |
| 7851 | /* Release the channel */ |
| 7852 | f_rsl_chan_deact(); |
| 7853 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7854 | } |
| 7855 | testcase TC_ms_pwr_ctrl_constant() runs on test_CT { |
| 7856 | var ConnHdlr vc_conn; |
| 7857 | var ConnHdlrPars pars; |
| 7858 | |
| 7859 | f_init(); |
| 7860 | |
| 7861 | /* Explicitly configure the Uplink power target (in dBm) */ |
| 7862 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target)); |
| 7863 | |
| 7864 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7865 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7866 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7867 | |
| 7868 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_constant), |
| 7869 | pars, trxc_comp := true); |
| 7870 | vc_conn.done; |
| 7871 | } |
| 7872 | |
| 7873 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7874 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7875 | } |
| 7876 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7877 | /* Test Exponentially Weighted Moving Average (EWMA) power filtering */ |
| 7878 | private function f_TC_ms_pwr_ctrl_pf_ewma(charstring id) |
| 7879 | runs on ConnHdlr { |
| 7880 | var integer num_blocks := 16; |
| 7881 | timer T := int2float(num_blocks); |
| 7882 | |
| 7883 | f_l1_tune(L1CTL); |
| 7884 | RSL.clear; |
| 7885 | |
| 7886 | /* These IEs are needed for autonomous MS power control */ |
| 7887 | var template (value) RSL_IE_List ies := { |
| 7888 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7889 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7890 | }), |
| 7891 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7892 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7893 | }) |
| 7894 | }; |
| 7895 | |
| 7896 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7897 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7898 | |
| 7899 | /* Establish a dedicated channel */ |
| 7900 | f_est_dchan(more_ies := valueof(ies)); |
| 7901 | |
| 7902 | L1CTL.clear; |
| 7903 | T.start; |
| 7904 | alt { |
| 7905 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_rssi_pwm), num_blocks); |
| 7906 | [] T.timeout { |
| 7907 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7908 | num_blocks, " were not handled"); |
| 7909 | } |
| 7910 | } |
Vadim Yanitskiy | 6b4404a | 2021-06-17 17:22:56 +0200 | [diff] [blame] | 7911 | |
| 7912 | /* Release the channel */ |
| 7913 | f_rsl_chan_deact(); |
| 7914 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7915 | } |
| 7916 | testcase TC_ms_pwr_ctrl_pf_ewma() runs on test_CT { |
| 7917 | var ConnHdlr vc_conn; |
| 7918 | var ConnHdlrPars pars; |
| 7919 | |
| 7920 | f_init(); |
| 7921 | |
| 7922 | /* Explicitly configure EWMA filtering with 80% smoothing (alpha = 0.2) */ |
| 7923 | f_vty_config(BTSVTY, "bts 0", "uplink-power-filtering algo ewma beta 80"); |
| 7924 | /* Explicitly configure the Uplink power range (target and delte) */ |
| 7925 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target) |
| 7926 | & " hysteresis " & int2str(mp_uplink_power_hysteresis)); |
| 7927 | |
| 7928 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7929 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7930 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7931 | |
| 7932 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_pf_ewma), |
| 7933 | pars, trxc_comp := true); |
| 7934 | vc_conn.done; |
| 7935 | } |
| 7936 | |
| 7937 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7938 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7939 | } |
| 7940 | |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 7941 | private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr { |
| 7942 | var template L1ctlDlMessage tr_bad_frame; |
| 7943 | var L1ctlDlMessage l1_dl; |
| 7944 | timer T := 8.0; |
| 7945 | |
| 7946 | f_l1_tune(L1CTL); |
| 7947 | RSL.clear; |
| 7948 | |
| 7949 | f_est_dchan(); |
| 7950 | |
| 7951 | /* There may be a few errors right after the channel activation */ |
| 7952 | f_sleep(2.0); /* ... so let's give the L1 some time to stabilize */ |
| 7953 | L1CTL.clear; |
| 7954 | |
| 7955 | /* A universal template for bad Downlink frame: {DATA,TRAFFIC}.ind */ |
| 7956 | tr_bad_frame := tr_L1CTL_TRAFFIC_IND(g_chan_nr, tr_RslLinkID_DCCH(0)); |
| 7957 | tr_bad_frame.header.msg_type := (L1CTL_DATA_IND, L1CTL_TRAFFIC_IND); |
| 7958 | tr_bad_frame.dl_info.fire_crc := (1..255); /* != 0 */ |
| 7959 | tr_bad_frame.payload := ?; |
| 7960 | |
| 7961 | T.start; |
| 7962 | alt { |
| 7963 | /* OS#4823: DATA.ind or TRAFFIC.ind with bad CRC most likely means that |
| 7964 | * the IUT is sending *dummy bursts*, so the L1 fails to decode them. */ |
| 7965 | [] L1CTL.receive(tr_bad_frame) -> value l1_dl { |
| 7966 | setverdict(fail, "Received {DATA,TRAFFIC}.ind with bad CRC: ", l1_dl); |
| 7967 | } |
| 7968 | [] as_l1_sacch(); |
| 7969 | [] L1CTL.receive { repeat; } |
| 7970 | [] T.timeout { |
| 7971 | /* We're done, break the loop */ |
| 7972 | setverdict(pass); |
| 7973 | } |
| 7974 | } |
| 7975 | |
| 7976 | f_rsl_chan_deact(); |
| 7977 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7978 | } |
| 7979 | testcase TC_speech_no_rtp_tchf() runs on test_CT { |
| 7980 | var ConnHdlr vc_conn; |
| 7981 | var ConnHdlrPars pars; |
| 7982 | |
| 7983 | f_init(); |
| 7984 | |
| 7985 | /* TS1, TCH/F, V1 (FR codec) */ |
| 7986 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 7987 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 7988 | vc_conn.done; |
| 7989 | } |
| 7990 | testcase TC_speech_no_rtp_tchh() runs on test_CT { |
| 7991 | var ConnHdlr vc_conn; |
| 7992 | var ConnHdlrPars pars; |
| 7993 | |
| 7994 | f_init(); |
| 7995 | |
| 7996 | /* TS5, TCH/H, V1 (HR codec) */ |
| 7997 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 7998 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 7999 | vc_conn.done; |
| 8000 | } |
| 8001 | |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8002 | /* Verify handling of Downlink and Uplink speech frames */ |
| 8003 | private function f_TC_speech_rtp(charstring id) runs on ConnHdlr { |
| 8004 | var L1ctlDlMessage l1_dl; |
| 8005 | var PDU_RTP rtp_pdu; |
| 8006 | var octetstring pl; |
| 8007 | timer Td, Tu; |
| 8008 | |
| 8009 | f_l1_tune(L1CTL); |
| 8010 | f_est_dchan(); |
| 8011 | |
| 8012 | /* Activate the RTP emulation */ |
| 8013 | pl := f_rnd_octstring(6); |
| 8014 | f_rtpem_activate(pl); |
| 8015 | |
| 8016 | /* Give the scheduler some time to fill up the buffers */ |
| 8017 | f_sleep(2.0); |
| 8018 | L1CTL.clear; |
| 8019 | RSL.clear; |
| 8020 | |
| 8021 | /* Make sure that Downlink frames are received at the UE */ |
| 8022 | Td.start(2.0); |
| 8023 | alt { |
| 8024 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := pl)) -> value l1_dl { |
| 8025 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
| 8026 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 8027 | l1_dl.payload.traffic_ind.data)); |
| 8028 | setverdict(pass); |
| 8029 | } |
| 8030 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := ?)) -> value l1_dl { |
| 8031 | setverdict(fail, "Rx unexpected Downlink speech frame ", |
| 8032 | "(", l1_dl.payload.traffic_ind.data, ") ", |
| 8033 | "expected (", pl, ")"); |
| 8034 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8035 | } |
| 8036 | [] as_l1_sacch(); |
| 8037 | [] L1CTL.receive { repeat; } |
| 8038 | [] Td.timeout { |
| 8039 | setverdict(fail, "Timeout waiting for Downlink speech frames"); |
| 8040 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8041 | } |
| 8042 | } |
| 8043 | |
| 8044 | /* Make sure that Uplink frames are received at the BTS */ |
| 8045 | RTPEM_DATA.clear; |
| 8046 | Tu.start(2.0); |
| 8047 | alt { |
| 8048 | [] RTPEM_DATA.receive(PDU_RTP:?) -> value rtp_pdu { |
| 8049 | if (rtp_pdu.data != pl) |
| 8050 | { repeat; } |
| 8051 | } |
| 8052 | [] RTPEM_DATA.receive { repeat; } |
| 8053 | [] Tu.timeout { |
| 8054 | setverdict(fail, "Timeout waiting for Uplink speech frames"); |
| 8055 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8056 | } |
| 8057 | } |
| 8058 | |
| 8059 | f_rtpem_mode(RTPEM_CTRL, RTPEM_MODE_NONE); |
| 8060 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8061 | f_rsl_chan_deact(); |
| 8062 | f_rslem_unregister(0, g_chan_nr); |
| 8063 | } |
| 8064 | testcase TC_speech_rtp_tchf() runs on test_CT { |
| 8065 | var ConnHdlr vc_conn; |
| 8066 | var ConnHdlrPars pars; |
| 8067 | |
| 8068 | f_init(); |
| 8069 | |
| 8070 | /* TS1, TCH/F, V1 (FR codec) */ |
| 8071 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 8072 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8073 | vc_conn.done; |
| 8074 | |
| 8075 | /* TS1, TCH/F, V2 (EFR codec) */ |
| 8076 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))); |
| 8077 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8078 | vc_conn.done; |
| 8079 | |
| 8080 | /* TODO: also test V3 (AMR codec) */ |
| 8081 | |
| 8082 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8083 | } |
| 8084 | testcase TC_speech_rtp_tchh() runs on test_CT { |
| 8085 | var ConnHdlr vc_conn; |
| 8086 | var ConnHdlrPars pars; |
| 8087 | |
| 8088 | f_init(); |
| 8089 | |
| 8090 | /* TS5, TCH/H0, V1 (HR codec) */ |
| 8091 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 8092 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8093 | vc_conn.done; |
| 8094 | |
| 8095 | /* TODO: also test V3 (AMR codec) */ |
| 8096 | |
| 8097 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8098 | } |
| 8099 | |
Neels Hofmeyr | af9d6ae | 2021-08-15 23:18:47 +0200 | [diff] [blame] | 8100 | private function f_TC_early_immediate_assignment(charstring id) runs on ConnHdlr { |
| 8101 | var GsmFrameNumber fn; |
| 8102 | var ChannelDescription ch_desc; |
| 8103 | var integer ra := 23; |
| 8104 | |
| 8105 | f_l1_tune(L1CTL); |
| 8106 | RSL.clear; |
| 8107 | |
| 8108 | /* Send RACH request and wait for ChanReq */ |
| 8109 | fn := f_rach_req_wait_chan_rqd(ra); |
| 8110 | |
| 8111 | /* The BSC already sends the Immediate Assignment, before the channel is active. |
| 8112 | * (Also before the Channel Activation, even. I tried to write this test so that we first send the Chan Act and then the IMM |
| 8113 | * ASS, but osmo-bts-trx responds so fast that the Chan Activ ACK comes back even before titan dispatches the |
| 8114 | * IMM ASS. So move the IMM ASS even before the Chan Activ.) */ |
| 8115 | if (g_pars.fhp.enabled) { |
| 8116 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
| 8117 | } else { |
| 8118 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
| 8119 | } |
| 8120 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
| 8121 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 8122 | |
| 8123 | /* Do not expect the Immediate Assignment to show up on MS side yet. Even give it one second before the BSC |
| 8124 | * requests Chan Activ, to make sure the RR IMM ASS is held back. */ |
| 8125 | var L1ctlDlMessage dl; |
| 8126 | var GsmRrMessage rr; |
| 8127 | |
| 8128 | var template GsmRrMessage rr_imm_ass := tr_IMM_ASS(ra, fn); |
| 8129 | rr_imm_ass.payload.imm_ass.ded_or_tbf := ?; |
| 8130 | rr_imm_ass.payload.imm_ass.pkt_chan_desc := *; |
| 8131 | rr_imm_ass.payload.imm_ass.chan_desc := *; |
| 8132 | |
| 8133 | timer T := 1.0; |
| 8134 | T.start; |
| 8135 | alt { |
| 8136 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl { |
| 8137 | rr := dec_GsmRrMessage(dl.payload.data_ind.payload); |
| 8138 | if (match(rr, rr_imm_ass)) { |
| 8139 | setverdict(fail, "Expected IMM ASS to be delayed until Chan Act ACK, but it was passed to the MS immediately"); |
| 8140 | mtc.stop; |
| 8141 | } else { |
| 8142 | repeat; |
| 8143 | } |
| 8144 | } |
| 8145 | [] L1CTL.receive { repeat; } |
| 8146 | [] T.timeout; |
| 8147 | } |
| 8148 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode, t_RSL_IE_ActType_IA)); |
| 8149 | RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)); |
| 8150 | |
| 8151 | /* Now expect the IMM ASS on Um */ |
| 8152 | f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 8153 | setverdict(pass); |
| 8154 | |
| 8155 | /* Release the channel */ |
| 8156 | f_rsl_chan_deact(); |
| 8157 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8158 | } |
| 8159 | |
| 8160 | testcase TC_early_immediate_assignment() runs on test_CT { |
| 8161 | var ConnHdlr vc_conn; |
| 8162 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 8163 | f_init(); |
| 8164 | vc_conn := f_start_handler(refers(f_TC_early_immediate_assignment), pars); |
| 8165 | vc_conn.done; |
| 8166 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8167 | } |
| 8168 | |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 8169 | private function f_TC_est_dchan(charstring id) runs on ConnHdlr { |
| 8170 | var integer ra := oct2int(f_rnd_ra_cs()); |
| 8171 | var ChannelDescription ch_desc; |
| 8172 | |
| 8173 | /* Tune the MS to BCCH */ |
| 8174 | f_l1_tune(L1CTL); |
| 8175 | |
| 8176 | /* Send RACH request and wait for ChanReq */ |
| 8177 | var GsmFrameNumber fn := f_rach_req_wait_chan_rqd(ra); |
| 8178 | |
| 8179 | /* Activate channel on the BTS side */ |
| 8180 | f_rsl_chan_act(g_pars.chan_mode); |
| 8181 | |
| 8182 | /* Craft channel description (with or without frequency hopping parameters) */ |
| 8183 | if (g_pars.fhp.enabled) { |
| 8184 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
| 8185 | } else { |
| 8186 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
| 8187 | } |
| 8188 | |
| 8189 | /* Send IMM.ASS via CCHAN */ |
| 8190 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
| 8191 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 8192 | |
| 8193 | /* Receive IMM.ASS on the MS side */ |
| 8194 | var ImmediateAssignment imm_ass := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 8195 | |
| 8196 | /* Match the Channel Description IE in received IMM.ASS */ |
| 8197 | if (not match(imm_ass.chan_desc, ch_desc)) { |
| 8198 | setverdict(fail, "Channel Description IE does not match"); |
| 8199 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8200 | } |
| 8201 | |
| 8202 | /* Tune the MS to a dedicated channel indicated in the IMM.ASS */ |
| 8203 | f_L1CTL_DM_EST_REQ_IA(L1CTL, imm_ass, g_pars.fhp.ma); |
| 8204 | |
| 8205 | /* Expect SACCH frames on Downlink */ |
| 8206 | L1CTL.clear; |
| 8207 | f_exp_sacch(true); |
| 8208 | |
| 8209 | /* We're done, deactivate and release */ |
| 8210 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8211 | f_rsl_chan_deact(); |
| 8212 | } |
| 8213 | testcase TC_est_dchan() runs on test_CT { |
| 8214 | var ConnHdlr vc_conn; |
| 8215 | var ConnHdlrPars pars; |
| 8216 | |
| 8217 | f_init(); |
| 8218 | |
| 8219 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 8220 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 8221 | vc_conn := f_start_handler(refers(f_TC_est_dchan), pars); |
| 8222 | vc_conn.done; |
| 8223 | } |
| 8224 | |
| 8225 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8226 | } |
| 8227 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8228 | private type record TopTestCase { |
| 8229 | RSL_IE_BS_Power bs_power, |
| 8230 | RSL_IE_OSMO_TopAcchCap top_cap, |
| 8231 | record of TopTestStep steps |
| 8232 | }; |
| 8233 | private type record TopTestStep { |
| 8234 | MeasurementResults meas_res optional, |
| 8235 | GsmRxLev overpower_sacch, |
| 8236 | GsmRxLev overpower_facch |
| 8237 | }; |
| 8238 | |
| 8239 | private function f_rxlev_match(template (present) RslLinkId link_id, |
| 8240 | template (present) GsmRxLev rxlev) |
| 8241 | runs on ConnHdlr { |
| 8242 | var L1ctlDlMessage dl := f_L1CTL_rx_data(L1CTL, g_chan_nr, link_id); |
| 8243 | if (not match(dl.dl_info.rx_level, rxlev)) { |
| 8244 | setverdict(fail, "RxLev(", link_id, ") := ", dl.dl_info.rx_level, |
| 8245 | " does not match expected RxLev := ", rxlev); |
| 8246 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8247 | } |
| 8248 | } |
| 8249 | |
| 8250 | private function f_TC_acch_overpower(charstring id) runs on ConnHdlr { |
| 8251 | var TopTestCase tc := g_pars.spec.top; |
| 8252 | var GsmRxLev rxlev_dcch; |
| 8253 | var L1ctlDlMessage dl; |
| 8254 | |
| 8255 | /* Wait for Pau ramping to complete */ |
| 8256 | f_sleep(6.0); |
| 8257 | |
| 8258 | f_l1_tune(L1CTL); |
| 8259 | L1CTL.clear; |
| 8260 | RSL.clear; |
| 8261 | |
| 8262 | /* Measure RxLev(BCCH), calculate RxLev(DCCH) */ |
| 8263 | dl := f_L1CTL_rx_data(L1CTL, t_RslChanNr_BCCH(0)); |
| 8264 | rxlev_dcch := dl.dl_info.rx_level - (tc.bs_power.power_level * 2); |
| 8265 | |
| 8266 | log("RxLev(BCCH) := ", dl.dl_info.rx_level); |
| 8267 | log("Expected RxLev(DCCH) := ", rxlev_dcch); |
| 8268 | |
| 8269 | /* Additional IEs for the CHANnel ACTIVation message */ |
| 8270 | var template (value) RSL_IE_List ies := { |
| 8271 | /* Employ BS power control in static mode */ |
| 8272 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 8273 | bs_power := tc.bs_power |
| 8274 | }), |
| 8275 | /* Indicate the given Temporary Overpower capability */ |
| 8276 | t_RSL_IE(RSL_IE_OSMO_TOP_ACCH_CAP, RSL_IE_Body:{ |
| 8277 | top_acch_cap := tc.top_cap |
| 8278 | }) |
| 8279 | }; |
| 8280 | |
| 8281 | /* Establish a dedicated channel */ |
| 8282 | f_est_dchan(more_ies := valueof(ies)); |
| 8283 | |
| 8284 | /* Give it some time to stabilize */ |
| 8285 | f_sleep(0.480 * 2.0); |
| 8286 | L1CTL.clear; |
| 8287 | RSL.clear; |
| 8288 | |
| 8289 | for (var integer i := 0; i < lengthof(tc.steps); i := i + 1) { |
| 8290 | var TopTestStep step := tc.steps[i]; |
| 8291 | var GsmRxLev rxlev_facch := rxlev_dcch + step.overpower_facch; |
| 8292 | var GsmRxLev rxlev_sacch := rxlev_dcch + step.overpower_sacch; |
| 8293 | |
| 8294 | log("Executing step[", i, "] := ", step); |
| 8295 | |
| 8296 | /* Send RR Measurement Report (if present) */ |
| 8297 | if (ispresent(step.meas_res)) { |
| 8298 | f_transceive_meas_rep(step.meas_res); |
| 8299 | f_sleep(0.480 * 2.0); |
| 8300 | L1CTL.clear; |
| 8301 | } |
| 8302 | |
| 8303 | /* Check RxLev on both FACCH and SACCH */ |
| 8304 | f_rxlev_match(tr_RslLinkID_DCCH(?), rxlev_facch); |
| 8305 | f_rxlev_match(tr_RslLinkID_SACCH(?), rxlev_sacch); |
| 8306 | |
| 8307 | setverdict(pass); |
| 8308 | } |
| 8309 | } |
| 8310 | testcase TC_acch_overpower_rxqual_thresh() runs on test_CT { |
| 8311 | var ConnHdlrPars pars; |
| 8312 | var ConnHdlr vc_conn; |
| 8313 | |
| 8314 | f_init(); |
| 8315 | |
| 8316 | /* Verify lower and upper RxQual thresholds */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8317 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8318 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8319 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(4), /* 4dB */ |
| 8320 | steps := { |
| 8321 | /* Channel established, no overpower */ |
| 8322 | { meas_res := omit, |
| 8323 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8324 | |
| 8325 | /* Worst possible RxQual value, overpower of 4dB */ |
| 8326 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8327 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8328 | /* Worst possible RxQual value, disabling overpower */ |
| 8329 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8330 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8331 | |
| 8332 | /* Lower threshold not reached, no overpower */ |
| 8333 | { meas_res := ts_MeasurementResults(rxq_f := 1), |
| 8334 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8335 | /* Lower threshold not reached, no overpower */ |
| 8336 | { meas_res := ts_MeasurementResults(rxq_f := 2), |
| 8337 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8338 | /* Lower threshold reached, overpower of 4dB */ |
| 8339 | { meas_res := ts_MeasurementResults(rxq_f := 4), |
| 8340 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8341 | /* Upper threshold not reached, keeping overpower */ |
| 8342 | { meas_res := ts_MeasurementResults(rxq_f := 3), |
| 8343 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8344 | /* Upper threshold reached, disabling overpower */ |
| 8345 | { meas_res := ts_MeasurementResults(rxq_f := 2), |
| 8346 | overpower_sacch := 0, overpower_facch := 0 } |
| 8347 | } |
| 8348 | }; |
| 8349 | |
| 8350 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8351 | spec := { top := top }, trx_nr := 1)); |
| 8352 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8353 | vc_conn.done; |
| 8354 | |
| 8355 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8356 | } |
| 8357 | testcase TC_acch_overpower_rxqual_thresh_dtx() runs on test_CT { |
| 8358 | var ConnHdlrPars pars; |
| 8359 | var ConnHdlr vc_conn; |
| 8360 | |
| 8361 | f_init(); |
| 8362 | |
| 8363 | /* Verify handling of FULL and SUB values */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8364 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8365 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8366 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(4), /* 4dB */ |
| 8367 | steps := { |
| 8368 | /* Channel established, no overpower */ |
| 8369 | { meas_res := omit, |
| 8370 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8371 | |
| 8372 | /* Invalid measurement results, no overpower */ |
| 8373 | { meas_res := ts_MeasurementResults(rxq_f := 7, |
| 8374 | rxq_s := 7, |
| 8375 | valid := false), |
| 8376 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8377 | |
| 8378 | /* DTXu was in use, no overpower */ |
| 8379 | { meas_res := ts_MeasurementResults(rxq_f := 7, |
| 8380 | rxq_s := 0, |
| 8381 | dtx_used := true), |
| 8382 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8383 | /* DTXu was in use, overpower of 4 dB */ |
| 8384 | { meas_res := ts_MeasurementResults(rxq_f := 0, |
| 8385 | rxq_s := 7, |
| 8386 | dtx_used := true), |
| 8387 | overpower_sacch := 4, overpower_facch := 4 } |
| 8388 | } |
| 8389 | }; |
| 8390 | |
| 8391 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8392 | spec := { top := top }, trx_nr := 1)); |
| 8393 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8394 | vc_conn.done; |
| 8395 | |
| 8396 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8397 | } |
| 8398 | testcase TC_acch_overpower_always_on_facch() runs on test_CT { |
| 8399 | var ConnHdlrPars pars; |
| 8400 | var ConnHdlr vc_conn; |
| 8401 | |
| 8402 | f_init(); |
| 8403 | |
| 8404 | /* Overpower is always on, SACCH disabled */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8405 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8406 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8407 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8408 | rxqual := 0, /* always on */ |
| 8409 | sacch_enable := false), |
| 8410 | steps := { |
| 8411 | /* Channel established, FACCH overpower */ |
| 8412 | { meas_res := omit, |
| 8413 | overpower_sacch := 0, overpower_facch := 4 }, |
| 8414 | /* MS indicates good RxQual, no difference */ |
| 8415 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8416 | overpower_sacch := 0, overpower_facch := 4 }, |
| 8417 | /* MS indicates bad RxQual, no difference */ |
| 8418 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8419 | overpower_sacch := 0, overpower_facch := 4 } |
| 8420 | } |
| 8421 | }; |
| 8422 | |
| 8423 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8424 | spec := { top := top }, trx_nr := 1)); |
| 8425 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8426 | vc_conn.done; |
| 8427 | |
| 8428 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8429 | } |
| 8430 | testcase TC_acch_overpower_always_on_sacch() runs on test_CT { |
| 8431 | var ConnHdlrPars pars; |
| 8432 | var ConnHdlr vc_conn; |
| 8433 | |
| 8434 | f_init(); |
| 8435 | |
| 8436 | /* Overpower is always on, FACCH disabled */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8437 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8438 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8439 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8440 | rxqual := 0, /* always on */ |
| 8441 | facch_enable := false), |
| 8442 | steps := { |
| 8443 | /* Channel established, SACCH overpower */ |
| 8444 | { meas_res := omit, |
| 8445 | overpower_sacch := 4, overpower_facch := 0 }, |
| 8446 | /* MS indicates good RxQual, no difference */ |
| 8447 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8448 | overpower_sacch := 4, overpower_facch := 0 }, |
| 8449 | /* MS indicates bad RxQual, no difference */ |
| 8450 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8451 | overpower_sacch := 4, overpower_facch := 0 } |
| 8452 | } |
| 8453 | }; |
| 8454 | |
| 8455 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8456 | spec := { top := top }, trx_nr := 1)); |
| 8457 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8458 | vc_conn.done; |
| 8459 | |
| 8460 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8461 | } |
| 8462 | testcase TC_acch_overpower_limit() runs on test_CT { |
| 8463 | var ConnHdlrPars pars; |
| 8464 | var ConnHdlr vc_conn; |
| 8465 | |
| 8466 | f_init(); |
| 8467 | |
| 8468 | /* Overpower higher than current power reduction level (2dB) */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8469 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8470 | bs_power := ts_RSL_IE_BS_Power(1), /* 1 x 2dB = 2dB */ |
| 8471 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8472 | rxqual := 0 /* always on */), |
| 8473 | steps := { |
| 8474 | /* Channel established, ACCH overpower of 2dB */ |
| 8475 | { meas_res := omit, |
| 8476 | overpower_sacch := 2, overpower_facch := 2 }, |
| 8477 | /* MS indicates good RxQual, no difference */ |
| 8478 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8479 | overpower_sacch := 2, overpower_facch := 2 }, |
| 8480 | /* MS indicates bad RxQual, no difference */ |
| 8481 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8482 | overpower_sacch := 2, overpower_facch := 2 } |
| 8483 | } |
| 8484 | }; |
| 8485 | |
| 8486 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8487 | spec := { top := top }, trx_nr := 1)); |
| 8488 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8489 | vc_conn.done; |
| 8490 | |
| 8491 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8492 | } |
| 8493 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 8494 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 8495 | /* protocol error as per 44.006 */ |
| 8496 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 8497 | /* repetition of SABM or DISC N200 times without ACK */ |
| 8498 | /* receptiom of SABM in multi-frame established state */ |
| 8499 | |
| 8500 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8501 | /* TODO Areas: |
| 8502 | |
| 8503 | * channel activation |
| 8504 | ** with BS_Power / MS_Power, bypassing power control loop |
| 8505 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8506 | ** with timing advance from initial activation on |
| 8507 | * mode modify |
| 8508 | ** encryption |
| 8509 | ** multirate |
| 8510 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8511 | ** unsupported algorithm |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8512 | * BS Power Control |
| 8513 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8514 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8515 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8516 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8517 | ** DATA_IND from BTS->PCU |
| 8518 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8519 | |
| 8520 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8521 | |
| 8522 | control { |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 8523 | execute( TC_est_dchan() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8524 | execute( TC_chan_act_stress() ); |
| 8525 | execute( TC_chan_act_react() ); |
| 8526 | execute( TC_chan_deact_not_active() ); |
| 8527 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 8528 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 8529 | execute( TC_sacch_filling() ); |
| 8530 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 8531 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 8532 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 8533 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 8534 | execute( TC_sacch_chan_act_ho_async() ); |
| 8535 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 8536 | execute( TC_rach_content() ); |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 8537 | execute( TC_rach_content_emerg() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 8538 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 8539 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 8540 | execute( TC_ho_rach() ); |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 8541 | execute( TC_ho_physical_info() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 8542 | execute( TC_rach_load_idle_thresh0() ); |
| 8543 | execute( TC_rach_load_idle_below_thresh() ); |
| 8544 | execute( TC_rach_load_count() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 8545 | execute( TC_meas_res_speech_tchf() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 8546 | execute( TC_meas_res_speech_tchf_facch() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 8547 | execute( TC_meas_res_speech_tchh() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 8548 | execute( TC_meas_res_speech_tchh_facch() ); |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 8549 | execute( TC_meas_res_speech_tchh_toa256() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8550 | execute( TC_meas_res_sign_tchf() ); |
| 8551 | execute( TC_meas_res_sign_tchh() ); |
| 8552 | execute( TC_meas_res_sign_sdcch4() ); |
| 8553 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 8554 | execute( TC_meas_res_sign_tchh_toa256() ); |
Vadim Yanitskiy | 8f6eae0 | 2021-10-26 02:49:21 +0300 | [diff] [blame] | 8555 | execute( TC_meas_res_speech_tchf_sapi3() ); |
| 8556 | execute( TC_meas_res_speech_tchh_sapi3() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 8557 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 8558 | execute( TC_tx_power_start_ramp_down_bcch() ); |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 8559 | execute( TC_tx_power_ramp_adm_state_change() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 8560 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 8561 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 8562 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 8563 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 8564 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 8565 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 8566 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 8567 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 8568 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 8569 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 8570 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 8571 | execute( TC_rsl_modify_encr() ); |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 8572 | execute( TC_rsl_rf_resource_ind() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8573 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8574 | execute( TC_paging_imsi_80percent() ); |
| 8575 | execute( TC_paging_tmsi_80percent() ); |
| 8576 | execute( TC_paging_imsi_200percent() ); |
| 8577 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 8578 | execute( TC_rsl_protocol_error() ); |
| 8579 | execute( TC_rsl_mand_ie_error() ); |
| 8580 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 8581 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 8582 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 8583 | execute( TC_si_sched_2bis() ); |
| 8584 | execute( TC_si_sched_2ter() ); |
| 8585 | execute( TC_si_sched_2ter_2bis() ); |
| 8586 | execute( TC_si_sched_2quater() ); |
| 8587 | execute( TC_si_sched_13() ); |
| 8588 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 8589 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 8590 | execute( TC_ipa_crcx_twice_not_active() ); |
| 8591 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 8592 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 8593 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Vadim Yanitskiy | 866afc2 | 2022-05-01 16:08:30 +0300 | [diff] [blame] | 8594 | execute( TC_ipa_crcx_ack_addr() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8595 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8596 | if (mp_pcu_socket != "") { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 8597 | execute( TC_paging_imsi_200percent_with_ps() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8598 | execute( TC_pcu_act_req() ); |
| 8599 | execute( TC_pcu_act_req_wrong_ts() ); |
| 8600 | execute( TC_pcu_act_req_wrong_bts() ); |
| 8601 | execute( TC_pcu_act_req_wrong_trx() ); |
| 8602 | execute( TC_pcu_deact_req() ); |
| 8603 | execute( TC_pcu_deact_req_wrong_ts() ); |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 8604 | execute( TC_pcu_ver_si1() ); |
| 8605 | execute( TC_pcu_ver_si3() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8606 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 8607 | if (mp_l1_supports_gprs) { |
| 8608 | execute( TC_pcu_data_req_pdtch() ); |
| 8609 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 8610 | execute( TC_pcu_data_req_wrong_bts() ); |
| 8611 | execute( TC_pcu_data_req_wrong_trx() ); |
| 8612 | execute( TC_pcu_data_req_wrong_ts() ); |
| 8613 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 8614 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 8615 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8616 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 8617 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8618 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 8619 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 8620 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 8621 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8622 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 8623 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 8624 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 8625 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 8626 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 8627 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 8628 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8629 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8630 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8631 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8632 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8633 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8634 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 8635 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 8636 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 8637 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 8638 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 8639 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 8640 | execute( TC_pcu_info_ind_fh_params() ); |
| 8641 | execute( TC_pcu_socket_nsvc_ipv4() ); |
| 8642 | execute( TC_pcu_socket_nsvc_ipv6() ); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 8643 | execute( TC_pcu_socket_two_nsvc() ); |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 8644 | execute( TC_pcu_interf_ind() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8645 | } else { |
| 8646 | log("PCU socket path not available, skipping PCU tests"); |
| 8647 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 8648 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 8649 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 8650 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 8651 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Pau Espin Pedrol | 8e57ac1 | 2021-06-29 17:04:24 +0200 | [diff] [blame] | 8652 | execute( TC_dyn_osmo_pdch_sdcch8_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 8653 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 8654 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 8655 | |
| 8656 | execute( TC_rll_est_ind() ); |
| 8657 | execute( TC_rll_est_req_DCCH_3() ); |
| 8658 | execute( TC_rll_est_req_ACCH_3() ); |
| 8659 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 8660 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 8661 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 8662 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 8663 | execute( TC_rll_rel_req() ); |
| 8664 | execute( TC_rll_unit_data_req_DCCH() ); |
| 8665 | execute( TC_rll_unit_data_req_ACCH() ); |
| 8666 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 8667 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 8668 | |
| 8669 | execute( TC_chan_act_a51() ); |
| 8670 | execute( TC_chan_act_a52() ); |
| 8671 | execute( TC_chan_act_a53() ); |
| 8672 | execute( TC_encr_cmd_a51() ); |
| 8673 | execute( TC_encr_cmd_a52() ); |
| 8674 | execute( TC_encr_cmd_a53() ); |
| 8675 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 8676 | execute( TC_err_rep_wrong_mdisc() ); |
| 8677 | execute( TC_err_rep_wrong_msg_type() ); |
| 8678 | execute( TC_err_rep_wrong_sequence() ); |
| 8679 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 8680 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 8681 | |
| 8682 | execute( TC_tch_sign_l2_fill_frame() ); |
| 8683 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 8684 | |
| 8685 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 8686 | execute( TC_chopped_ipa_payload() ); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 8687 | |
| 8688 | execute( TC_ms_pwr_ctrl_constant() ); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8689 | execute( TC_ms_pwr_ctrl_pf_ewma() ); |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 8690 | |
| 8691 | execute( TC_speech_no_rtp_tchf() ); |
| 8692 | execute( TC_speech_no_rtp_tchh() ); |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8693 | execute( TC_speech_rtp_tchf() ); |
| 8694 | execute( TC_speech_rtp_tchh() ); |
Neels Hofmeyr | af9d6ae | 2021-08-15 23:18:47 +0200 | [diff] [blame] | 8695 | |
| 8696 | execute( TC_early_immediate_assignment() ); |
Vadim Yanitskiy | 46f1992 | 2021-10-06 02:36:22 +0600 | [diff] [blame] | 8697 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8698 | execute( TC_acch_overpower_rxqual_thresh() ); |
| 8699 | execute( TC_acch_overpower_rxqual_thresh_dtx() ); |
| 8700 | execute( TC_acch_overpower_always_on_facch() ); |
| 8701 | execute( TC_acch_overpower_always_on_sacch() ); |
| 8702 | execute( TC_acch_overpower_limit() ); |
| 8703 | |
Vadim Yanitskiy | 46f1992 | 2021-10-06 02:36:22 +0600 | [diff] [blame] | 8704 | /* BEWARE: these test cases can potentially break the IUT or cause |
| 8705 | * weird/unexpected behavior. Ensure that they are executed last. */ |
| 8706 | execute( TC_dyn_osmo_pdch_tchh_race_act() ); |
| 8707 | execute( TC_dyn_osmo_pdch_sdcch8_race_act() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8708 | } |
| 8709 | |
| 8710 | |
| 8711 | } |