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; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 138 | } |
| 139 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 140 | type record of RslChannelNr ChannelNrs; |
| 141 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 142 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 143 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 144 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 145 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 146 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 147 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 148 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 149 | |
| 150 | /* L1CTL port (for classic tests) */ |
| 151 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 152 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 153 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 154 | port TRXC_CODEC_PT BTS_TRXC; |
| 155 | var integer g_bts_trxc_conn_id; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 156 | |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 157 | /* VTY connections to both BTS and BSC */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 158 | port TELNETasp_PT BTSVTY; |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 159 | port TELNETasp_PT BSCVTY; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 160 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 161 | /* PCU Interface of BTS */ |
| 162 | port PCUIF_CODEC_PT PCU; |
| 163 | var integer g_pcu_conn_id; |
| 164 | /* Last PCU INFO IND we received */ |
| 165 | var PCUIF_Message g_pcu_last_info; |
| 166 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 167 | /* SI configuration */ |
| 168 | var SystemInformationConfig si_cfg := { |
| 169 | bcch_extended := false, |
| 170 | si1_present := false, |
| 171 | si2bis_present := false, |
| 172 | si2ter_present := false, |
| 173 | si2quater_present := false, |
| 174 | si7_present := false, |
| 175 | si8_present := false, |
| 176 | si9_present := false, |
| 177 | si13_present := false, |
| 178 | si13alt_present := false, |
| 179 | si15_present := false, |
| 180 | si16_present := false, |
| 181 | si17_present := false, |
| 182 | si2n_present := false, |
| 183 | si21_present := false, |
| 184 | si22_present := false |
| 185 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 186 | |
| 187 | /* all logical channels available on the BTS */ |
| 188 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 189 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | /* an individual call / channel */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 193 | type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 194 | port L1CTL_PT L1CTL; |
| 195 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 196 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 197 | port TRXC_CODEC_PT BTS_TRXC; |
| 198 | var integer g_bts_trxc_conn_id; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 199 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 200 | /* port to be initialized optionally to access BSC VTY */ |
| 201 | port TELNETasp_PT BSCVTY; |
| 202 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 203 | timer g_Tguard; |
| 204 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 205 | |
| 206 | var ConnHdlrPars g_pars; |
| 207 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 208 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 209 | |
| 210 | /* PCU Interface of BTS */ |
| 211 | port PCUIF_CODEC_PT PCU; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 212 | |
| 213 | var RTP_Emulation_CT vc_RTPEM; |
| 214 | port RTPEM_CTRL_PT RTPEM_CTRL; |
| 215 | port RTPEM_DATA_PT RTPEM_DATA; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 216 | } |
| 217 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 218 | private function f_init_rsl(charstring id) runs on test_CT { |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 219 | var bitstring trx_mask := '00000000'B; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 220 | var bitstring rfind_mask := '00000000'B; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 221 | var integer trx_count := 0; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 222 | var integer rfind_count := 0; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 223 | var RSLEm_Event ev; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 224 | var ASP_RSL_Unitdata rx_ud; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 225 | timer T; |
| 226 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 227 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 228 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 229 | |
| 230 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 231 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 232 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 233 | |
| 234 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 235 | vc_RSL.start(RSL_Emulation.main(false)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 236 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 237 | /* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here. |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 238 | * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 239 | T.start(mp_ipa_up_timeout); |
| 240 | alt { |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 241 | /* These events are sent by the RSL_Emulation_CT */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 242 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev { |
| 243 | /* Make sure that all transceivers use unique stream ID */ |
| 244 | if (trx_mask[enum2int(ev.sid)] == '1'B) { |
| 245 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 246 | log2str("Duplicate RSL stream ID (", ev.sid, ")")); |
| 247 | } |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 248 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 249 | trx_mask[enum2int(ev.sid)] := '1'B; |
| 250 | trx_count := trx_count + 1; |
| 251 | |
| 252 | log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected"); |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 253 | repeat; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 254 | } |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 255 | /* This message (RF RESource INDication) is sent by the IUT itself */ |
| 256 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ?)) -> value rx_ud { |
| 257 | if (trx_mask[enum2int(rx_ud.streamId)] == '0'B) { |
| 258 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 259 | log2str("Got RF Resource Indication before RSLEM_EV_TRX_UP (", rx_ud.streamId, ")")); |
| 260 | } |
| 261 | if (rfind_mask[enum2int(rx_ud.streamId)] == '1'B) { |
| 262 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 263 | log2str("Duplicate RF Resource Indication ID (", rx_ud.streamId, ")")); |
| 264 | } |
| 265 | |
| 266 | rfind_mask[enum2int(rx_ud.streamId)] := '1'B; |
| 267 | rfind_count := rfind_count + 1; |
| 268 | log(rfind_count, "/", mp_transceiver_num, " RF Resource Indication(s) received"); |
| 269 | if (rfind_count < mp_transceiver_num) { repeat; } |
| 270 | } |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 271 | /* osmo-bts may send us CCCH LOAD INDication or whatever else */ |
| 272 | [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; } |
| 273 | [] T.timeout { |
| 274 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 275 | "Timeout waiting for RSL bring up"); |
| 276 | } |
| 277 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 278 | } |
| 279 | |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 280 | friend type record length(1 .. 256) of TrxParsItem TrxPars; |
| 281 | friend type record TrxParsItem { |
| 282 | GsmArfcn arfcn, |
| 283 | TrxTsPars ts |
| 284 | }; |
| 285 | |
| 286 | friend type record length(8) of TrxTsParsItem TrxTsPars; |
| 287 | friend type record TrxTsParsItem { |
| 288 | PchanConfig config |
| 289 | }; |
| 290 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 291 | friend type record FreqHopPars { |
| 292 | /* Whether frequency hopping is in use */ |
| 293 | boolean enabled, |
| 294 | /* Mobile Allocation Index Offset / Hopping Sequence Number */ |
| 295 | MaioHsn maio_hsn, |
| 296 | /* MA bitmap to be indicated in RR Immediate Assignment */ |
| 297 | MobileAllocationLV ma_map, |
| 298 | /* The actual Mobile Allocation (ARFCN list) to be used */ |
| 299 | L1ctlMA ma |
| 300 | }; |
| 301 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 302 | type record ConnHdlrPars { |
| 303 | RslChannelNr chan_nr, |
| 304 | RSL_IE_ChannelMode chan_mode, |
| 305 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 306 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 307 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 308 | RSL_IE_EncryptionInfo encr optional, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 309 | BtsBand bts0_band optional, |
| 310 | |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 311 | /* Training Sequence Code */ |
| 312 | GsmTsc tsc, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 313 | /* Frequency hopping parameters */ |
| 314 | FreqHopPars fhp |
| 315 | }; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 316 | |
| 317 | /* Test-specific parameters */ |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 318 | friend type union TestSpecUnion { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 319 | RllTestCase rll |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 320 | } |
| 321 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 322 | private template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 323 | max_retrans := RACH_MAX_RETRANS_7, |
| 324 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 325 | cell_barr_access := false, |
| 326 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 327 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 328 | }; |
| 329 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 330 | private template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 331 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 332 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 333 | acs := '0'B, |
| 334 | neci := true, |
| 335 | rxlev_access_min := 0 |
| 336 | } |
| 337 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 338 | private template (value) LocationAreaIdentification ts_LAI_default := { |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 339 | mcc_mnc := '262F42'H, |
| 340 | lac := 42 |
| 341 | } |
| 342 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 343 | private template (value) GPRSIndicator ts_GPRSIndicator_def := { |
| 344 | ra_colour := 0, |
| 345 | si13_pos := '0'B |
| 346 | } |
| 347 | |
| 348 | private template (value) SI3RestOctets ts_SI3RestOctets_def |
| 349 | modifies ts_SI3RestOctets := { |
| 350 | gprs_ind := { |
| 351 | presence := CSN1_H, |
| 352 | ind := ts_GPRSIndicator_def |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | private template (value) SI4RestOctets ts_SI4RestOctets_def |
| 357 | modifies ts_SI4RestOctets := { |
| 358 | gprs_ind := { |
Vadim Yanitskiy | ab5363f | 2020-05-05 00:30:22 +0700 | [diff] [blame] | 359 | presence := CSN1_H, |
| 360 | ind := ts_GPRSIndicator_def |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 361 | } |
| 362 | } |
| 363 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 364 | /* Default SYSTEM INFORMATION 3 */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 365 | private template (value) SystemInformation ts_SI3_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 366 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 367 | payload := { |
| 368 | si3 := { |
| 369 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 370 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 371 | ctrl_chan_desc := { |
| 372 | msc_r99 := true, |
| 373 | att := true, |
| 374 | bs_ag_blks_res := 1, |
| 375 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 376 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 377 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 378 | spare := '00'B, |
| 379 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 380 | t3212 := 1 /* 6 minutes */ |
| 381 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 382 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 383 | dn_ind := false, |
| 384 | pwrc := false, |
| 385 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 386 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 387 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 388 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 389 | rach_control := ts_RachCtrl_default, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 390 | rest_octets := valueof(ts_SI3RestOctets_def) |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 391 | } |
| 392 | } |
| 393 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 394 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 395 | private template (value) SystemInformation ts_SI2_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 396 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 397 | payload := { |
| 398 | si2 := { |
| 399 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 400 | ncc_permitted := '11111111'B, |
| 401 | rach_control := ts_RachCtrl_default |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 406 | private template (value) SystemInformation ts_SI4_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 407 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 408 | payload := { |
| 409 | si4 := { |
| 410 | lai := ts_LAI_default, |
| 411 | cell_sel_par := ts_CellSelPar_default, |
| 412 | rach_control := ts_RachCtrl_default, |
| 413 | cbch_chan_desc := omit, |
| 414 | cbch_mobile_alloc := omit, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 415 | rest_octets := valueof(ts_SI4RestOctets_def) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 416 | } |
| 417 | } |
| 418 | } |
| 419 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 420 | 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] | 421 | runs on test_CT { |
| 422 | log("Setting ", rsl_si_type, ": ", si_enc); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 423 | 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] | 424 | } |
| 425 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 426 | 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] | 427 | runs on test_CT { |
| 428 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 429 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 430 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 431 | } |
| 432 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 433 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 434 | map(self:BTSVTY, system:BTSVTY); |
| 435 | f_vty_set_prompts(BTSVTY); |
| 436 | f_vty_transceive(BTSVTY, "enable"); |
| 437 | } |
| 438 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 439 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 440 | map(self:BSCVTY, system:BSCVTY); |
| 441 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 442 | f_vty_transceive(BSCVTY, "enable"); |
| 443 | } |
| 444 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 445 | friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr { |
| 446 | map(self:BSCVTY, system:BSCVTY); |
| 447 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 448 | f_vty_transceive(BSCVTY, "enable"); |
| 449 | } |
| 450 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 451 | /* PCU socket may at any time receive a new INFO.ind */ |
Pau Espin Pedrol | 65d712e | 2021-06-25 13:55:38 +0200 | [diff] [blame] | 452 | 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] | 453 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 454 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 455 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 456 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 457 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 458 | [] 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] | 459 | 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] | 460 | } |
| 461 | } |
| 462 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 463 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 464 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 465 | timer T := 2.0; |
| 466 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 467 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 468 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 469 | return; |
| 470 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 471 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 472 | |
| 473 | T.start; |
| 474 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 475 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 476 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 477 | 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] | 478 | } |
| 479 | } |
| 480 | } |
| 481 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 482 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 483 | out integer trxc_conn_id) { |
| 484 | var Result res; |
| 485 | |
| 486 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 487 | "", -1, -1, { udp := {} }, {}); |
| 488 | if (not ispresent(res.connId)) { |
| 489 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 490 | "Could not connect to the control (TRXC) interface " & |
| 491 | "of FakeTRX, check your configuration"); |
| 492 | } |
| 493 | trxc_conn_id := res.connId; |
| 494 | } |
| 495 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 496 | /* global init function (without PCUIF connection) */ |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 497 | friend function f_init(uint8_t trx_nr := 0) |
| 498 | runs on test_CT |
| 499 | { |
| 500 | var TrxParsItem trx_pars := mp_trx_pars[trx_nr]; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 501 | var charstring id := testcasename(); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 502 | |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 503 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653. |
| 504 | * TODO: also generate this list dynamically from module parameters. */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 505 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 506 | g_AllChanTypes := { |
| 507 | /* TS 1..4: TCH/F */ |
| 508 | valueof(ts_RslChanNr_Bm(1)), |
| 509 | /* TS 5: TCH/H */ |
| 510 | valueof(ts_RslChanNr_Lm(5,1)), |
| 511 | /* TS 0: SDCCH/4 */ |
| 512 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 513 | /* TS 6: SDCCH/8 */ |
| 514 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 515 | }; |
| 516 | } else { |
| 517 | g_AllChanTypes := { |
| 518 | /* TS 1..4: TCH/F */ |
| 519 | valueof(ts_RslChanNr_Bm(1)), |
| 520 | /* TS 0: SDCCH/4 */ |
| 521 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 522 | /* TS 6: SDCCH/8 */ |
| 523 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 524 | }; |
| 525 | } |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 526 | |
| 527 | g_AllChannels := { }; |
| 528 | |
| 529 | /* Generate list of all logical channels from module parameters */ |
| 530 | for (var integer tn := 0; tn < lengthof(trx_pars.ts); tn := tn + 1) { |
| 531 | select (trx_pars.ts[tn].config) { |
| 532 | case (GSM_PCHAN_CCCH_SDCCH4) { |
| 533 | g_AllChannels := g_AllChannels & |
| 534 | { valueof(ts_RslChanNr_SDCCH4(tn, 0)), |
| 535 | valueof(ts_RslChanNr_SDCCH4(tn, 1)), |
| 536 | valueof(ts_RslChanNr_SDCCH4(tn, 2)), |
| 537 | valueof(ts_RslChanNr_SDCCH4(tn, 3)) }; |
| 538 | } |
| 539 | case (GSM_PCHAN_SDCCH8) { |
| 540 | g_AllChannels := g_AllChannels & |
| 541 | { valueof(ts_RslChanNr_SDCCH8(tn, 0)), |
| 542 | valueof(ts_RslChanNr_SDCCH8(tn, 1)), |
| 543 | valueof(ts_RslChanNr_SDCCH8(tn, 2)), |
| 544 | valueof(ts_RslChanNr_SDCCH8(tn, 3)), |
| 545 | valueof(ts_RslChanNr_SDCCH8(tn, 4)), |
| 546 | valueof(ts_RslChanNr_SDCCH8(tn, 5)), |
| 547 | valueof(ts_RslChanNr_SDCCH8(tn, 6)), |
| 548 | valueof(ts_RslChanNr_SDCCH8(tn, 7)) }; |
| 549 | } |
| 550 | case (GSM_PCHAN_TCHH_TCHF_PDCH) { |
| 551 | g_AllChannels := g_AllChannels & |
| 552 | { valueof(ts_RslChanNr_Lm(tn, 0)), |
| 553 | valueof(ts_RslChanNr_Lm(tn, 1)), |
| 554 | valueof(ts_RslChanNr_Bm(tn)) }; |
| 555 | } |
| 556 | case (GSM_PCHAN_TCHH) { |
| 557 | g_AllChannels := g_AllChannels & |
| 558 | { valueof(ts_RslChanNr_Lm(tn, 0)), |
| 559 | valueof(ts_RslChanNr_Lm(tn, 1)) }; |
| 560 | } |
| 561 | case (GSM_PCHAN_TCHF, GSM_PCHAN_TCHF_PDCH) { |
| 562 | g_AllChannels := g_AllChannels & |
| 563 | { valueof(ts_RslChanNr_Bm(tn)) }; |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 568 | f_init_rsl(id); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 569 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 570 | f_init_vty(id); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 571 | f_ipa_ctrl_start_client(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 572 | |
| 573 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 574 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 575 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 576 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 577 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 578 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 579 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 580 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 581 | |
| 582 | /* Init TRXC interface to FakeTRX */ |
| 583 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 584 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 585 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 586 | /* 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] | 587 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(2*256)); |
| 588 | 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] | 589 | /* 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] | 590 | 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] | 591 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 592 | |
| 593 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 594 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 595 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 596 | } |
| 597 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 598 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 599 | friend function f_init_l1ctl() runs on test_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 600 | map(self:L1CTL, system:L1CTL); |
| 601 | f_connect_reset(L1CTL); |
| 602 | } |
| 603 | |
Vadim Yanitskiy | 7387813 | 2021-05-05 02:22:45 +0200 | [diff] [blame] | 604 | friend type function void_fn(charstring id) runs on ConnHdlr; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 605 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 606 | private type record length(8) of FreqHopGroups FreqHopConfig; |
| 607 | |
| 608 | private type record of FreqHopGroup FreqHopGroups; |
| 609 | private type record FreqHopGroup { |
| 610 | uint6_t hsn, |
| 611 | FreqHopGroupItems trx_maio |
| 612 | }; |
| 613 | |
| 614 | private type record of FreqHopGroupItem FreqHopGroupItems; |
| 615 | private type record FreqHopGroupItem { |
| 616 | uint8_t trx_nr, |
| 617 | uint6_t maio |
| 618 | }; |
| 619 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 620 | friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn, |
| 621 | uint8_t trx_nr := 0) |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 622 | { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 623 | var FreqHopGroups groups := mp_fh_config[tn]; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 624 | var integer i, j; |
| 625 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 626 | fhp.enabled := false; |
| 627 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 628 | for (i := 0; i < lengthof(groups); i := i + 1) { |
| 629 | var FreqHopGroup g := groups[i]; |
| 630 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 631 | var FreqHopGroupItem gi := g.trx_maio[j]; |
| 632 | if (gi.trx_nr == trx_nr) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 633 | fhp.maio_hsn.maio := gi.maio; |
| 634 | fhp.maio_hsn.hsn := g.hsn; |
| 635 | fhp.enabled := true; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 636 | break; |
| 637 | } |
| 638 | } |
| 639 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 640 | if (fhp.enabled) { |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 641 | /* Prepare the Mobile Allocation bitmask (length & padding) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 642 | fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */ |
| 643 | fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B); |
| 644 | fhp.ma := { }; /* to be composed below */ |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 645 | |
| 646 | /* Compose the actual Mobile Allocation and the bitmask */ |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 647 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 648 | var FreqHopGroupItem gi := g.trx_maio[j]; |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 649 | var GsmArfcn arfcn := mp_trx_pars[gi.trx_nr].arfcn; |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 650 | fhp.ma := fhp.ma & { valueof(ts_GsmBandArfcn(arfcn)) }; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 651 | fhp.ma_map.ma[gi.trx_nr] := '1'B; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 652 | } |
| 653 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 654 | log("Freq. hopping parameters: ", fhp); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 655 | break; /* We're done */ |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 660 | /* create a new test component */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 661 | friend function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 662 | boolean pcu_comp := false, |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 663 | boolean trxc_comp := false, |
| 664 | boolean l1ctl := true) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 665 | runs on test_CT return ConnHdlr { |
| 666 | var charstring id := testcasename(); |
| 667 | var ConnHdlr vc_conn; |
| 668 | |
| 669 | vc_conn := ConnHdlr.create(id); |
| 670 | /* connect to RSL Emulation main component */ |
| 671 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 672 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 673 | |
| 674 | /* The ConnHdlr component may want to talk to some ports directly, |
| 675 | * so we disconnect it from the test_CT and connect it to the component. |
| 676 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 677 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 678 | unmap(self:PCU, system:PCU); |
| 679 | map(vc_conn:PCU, system:PCU); |
| 680 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 681 | if (trxc_comp) { |
| 682 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 683 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 684 | } |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 685 | if (l1ctl) { |
| 686 | map(vc_conn:L1CTL, system:L1CTL); |
| 687 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 688 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 689 | /* Obtain frequency hopping parameters for a given timeslot */ |
| 690 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 691 | f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 692 | } |
| 693 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 694 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 695 | return vc_conn; |
| 696 | } |
| 697 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 698 | private altstep as_Tguard() runs on ConnHdlr { |
| 699 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 700 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 701 | } |
| 702 | } |
| 703 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 704 | 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] | 705 | var GsmBandArfcn arfcn := valueof(ts_GsmBandArfcn(mp_trx_pars[0].arfcn)); |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 706 | f_L1CTL_FBSB(L1CTL, arfcn, ccch_mode, mp_rxlev_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 707 | } |
| 708 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 709 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 710 | var TrxcMessage ret; |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 711 | 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] | 712 | } |
| 713 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 714 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 715 | var TrxcMessage ret; |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 716 | 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] | 717 | } |
| 718 | |
| 719 | /* first function started in ConnHdlr component */ |
| 720 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 721 | runs on ConnHdlr { |
| 722 | g_pars := pars; |
| 723 | g_chan_nr := pars.chan_nr; |
| 724 | |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 725 | if (L1CTL.checkstate("Mapped")) { |
| 726 | f_connect_reset(L1CTL); |
| 727 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 728 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 729 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 730 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 731 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 732 | |
| 733 | g_Tguard.start(pars.t_guard); |
| 734 | activate(as_Tguard()); |
| 735 | |
| 736 | f_rslem_register(0, pars.chan_nr); |
| 737 | |
| 738 | /* call the user-supplied test case function */ |
| 739 | fn.apply(id); |
| 740 | } |
| 741 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 742 | private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, |
| 743 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 744 | runs on ConnHdlr return RSL_Message { |
| 745 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 746 | timer T := 3.0; |
| 747 | RSL.send(tx); |
| 748 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 749 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 750 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 751 | T.stop; |
| 752 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 753 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 754 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 755 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 756 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 757 | [not ignore_other] as_l1_sacch(); |
| 758 | [not ignore_other] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 759 | [not ignore_other] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 760 | [not ignore_other] as_l1_tch_loop(); |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 761 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 762 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 763 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 764 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 765 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 766 | return rx; |
| 767 | } |
| 768 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 769 | friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, |
| 770 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 771 | runs on ConnHdlr { |
| 772 | 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] | 773 | } |
| 774 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 775 | friend function f_rsl_chan_act(RSL_IE_ChannelMode mode, |
| 776 | boolean encr_enable := false, |
| 777 | RSL_IE_List more_ies := {}, |
| 778 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) |
| 779 | runs on ConnHdlr { |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 780 | 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] | 781 | if (encr_enable) { |
| 782 | /* append encryption related IEs, if requested */ |
| 783 | var RSL_IE_EncryptionInfo encr_info; |
| 784 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 785 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 786 | encr_info})) }; |
| 787 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 788 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 789 | 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] | 790 | } |
| 791 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 792 | friend function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 793 | 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] | 794 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 795 | } |
| 796 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 797 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Vadim Yanitskiy | e6c1755 | 2021-06-01 01:20:55 +0200 | [diff] [blame] | 798 | template RSL_IE_ChannelMode chan_mode, |
| 799 | template (omit) TestSpecUnion spec := omit, |
| 800 | float t_guard := 20.0) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 801 | chan_nr := valueof(chan_nr), |
| 802 | chan_mode := valueof(chan_mode), |
| 803 | t_guard := t_guard, |
| 804 | l1_pars := { |
| 805 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 806 | toa256_enabled := false, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 807 | meas_valid := true, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 808 | meas_ul := { |
| 809 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 810 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 811 | rxqual := 0 |
| 812 | }, |
| 813 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 814 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 815 | rxqual := 0 |
| 816 | } |
| 817 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 818 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 819 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 820 | ms_power_level := mp_ms_power_level_exp, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 821 | ms_actual_ta := mp_ms_actual_ta_exp, |
| 822 | facch_enabled := false |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 823 | }, |
Vadim Yanitskiy | e6c1755 | 2021-06-01 01:20:55 +0200 | [diff] [blame] | 824 | spec := spec, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 825 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 826 | bts0_band := omit, |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 827 | tsc := mp_tsc_def, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 828 | fhp := { |
| 829 | enabled := false, |
| 830 | maio_hsn := ts_HsnMaio(0, 0), |
| 831 | ma_map := c_MA_null, |
Vadim Yanitskiy | 2b991b6 | 2020-11-14 21:40:41 +0700 | [diff] [blame] | 832 | ma := { } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 833 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 834 | } |
| 835 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 836 | /*********************************************************************** |
| 837 | * Channel Activation / Deactivation |
| 838 | ***********************************************************************/ |
| 839 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 840 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 841 | private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 842 | for (var integer i := 0; i < 500; i := i+1) { |
| 843 | f_rsl_chan_act(g_pars.chan_mode); |
| 844 | f_rsl_chan_deact(); |
| 845 | } |
| 846 | setverdict(pass); |
| 847 | } |
| 848 | testcase TC_chan_act_stress() runs on test_CT { |
| 849 | var ConnHdlr vc_conn; |
| 850 | 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] | 851 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 852 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 853 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 854 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | /* Test if re-activation of an already active channel fails as expected */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 858 | private function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 859 | f_rsl_chan_act(g_pars.chan_mode); |
| 860 | /* attempt to activate the same lchan again -> expect reject */ |
| 861 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 862 | alt { |
| 863 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 864 | 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] | 865 | } |
| 866 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 867 | setverdict(pass); |
| 868 | } |
| 869 | } |
| 870 | f_rsl_chan_deact(); |
| 871 | } |
| 872 | testcase TC_chan_act_react() runs on test_CT { |
| 873 | var ConnHdlr vc_conn; |
| 874 | 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] | 875 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 876 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 877 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 878 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 879 | } |
| 880 | |
| 881 | /* Attempt to de-activate a channel that's not active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 882 | 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] | 883 | timer T := 3.0; |
| 884 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 885 | T.start; |
| 886 | alt { |
| 887 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 888 | setverdict(pass); |
| 889 | } |
| 890 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 891 | 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] | 892 | } |
| 893 | } |
| 894 | } |
| 895 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 896 | 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] | 897 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 898 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 899 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 900 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 904 | 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] | 905 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 906 | alt { |
| 907 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 908 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 909 | } |
| 910 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 911 | setverdict(pass); |
| 912 | } |
| 913 | } |
| 914 | } |
| 915 | private type record WrongChanNrCase { |
| 916 | RslChannelNr chan_nr, |
| 917 | charstring description |
| 918 | } |
| 919 | private type record of WrongChanNrCase WrongChanNrCases; |
| 920 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 921 | chan_nr := chan_nr, |
| 922 | description := desc |
| 923 | } |
| 924 | |
| 925 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 926 | var ConnHdlr vc_conn; |
| 927 | var ConnHdlrPars pars; |
| 928 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 929 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 930 | |
| 931 | var WrongChanNrCases wrong := { |
| 932 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 933 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 934 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 935 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 936 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 937 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 938 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 939 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 940 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 941 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 942 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 943 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 944 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 945 | }; |
| 946 | |
| 947 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 948 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 949 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 950 | vc_conn.done; |
| 951 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 952 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 953 | } |
| 954 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 955 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 956 | 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] | 957 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 958 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 959 | |
| 960 | /* test on each of the channels we have */ |
| 961 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 962 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 963 | |
| 964 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 965 | vc_conn := f_start_handler(fn, pars); |
| 966 | vc_conn.done; |
| 967 | } |
| 968 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 969 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 970 | } |
| 971 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 972 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 973 | * SACCH handling |
| 974 | ***********************************************************************/ |
| 975 | |
| 976 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 977 | timer T_sacch := 3.0; |
| 978 | T_sacch.start; |
| 979 | alt { |
| 980 | [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] | 981 | 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] | 982 | } |
| 983 | [not exp] T_sacch.timeout { |
| 984 | setverdict(pass); |
| 985 | } |
| 986 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 987 | setverdict(pass); |
| 988 | } |
| 989 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 990 | 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] | 991 | } |
| 992 | [] L1CTL.receive { repeat; } |
| 993 | [] RSL.receive { repeat; } |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 998 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 999 | f_l1_tune(L1CTL); |
| 1000 | RSL.clear; |
| 1001 | |
| 1002 | /* activate the logical channel */ |
| 1003 | f_est_dchan(); |
| 1004 | L1CTL.clear; |
| 1005 | |
| 1006 | /* check that SACCH actually are received as expected */ |
| 1007 | f_exp_sacch(true); |
| 1008 | |
| 1009 | /* deactivate SACCH on the logical channel */ |
| 1010 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 1011 | f_sleep(1.0); |
| 1012 | L1CTL.clear; |
| 1013 | |
| 1014 | /* check that no SACCH are received anymore */ |
| 1015 | f_exp_sacch(false); |
| 1016 | |
| 1017 | /* release the channel */ |
| 1018 | f_rsl_chan_deact(); |
| 1019 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1020 | } |
| 1021 | testcase TC_deact_sacch() runs on test_CT { |
| 1022 | var ConnHdlr vc_conn; |
| 1023 | var ConnHdlrPars pars; |
| 1024 | f_init(); |
| 1025 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1026 | //for (var integer i := 0; i < 1; i := i+1) { |
| 1027 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1028 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1029 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 1030 | vc_conn.done; |
| 1031 | } |
| 1032 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1033 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1034 | } |
| 1035 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1036 | /* verify that given SACCH payload is present */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1037 | private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr { |
| 1038 | var L1ctlDlMessage dl; |
| 1039 | /* check that the specified SI5 value is actually sent */ |
| 1040 | timer T_sacch := 3.0; |
| 1041 | L1CTL.clear; |
| 1042 | T_sacch.start; |
| 1043 | alt { |
| 1044 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1045 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1046 | if (match(l3, l3_exp)) { |
| 1047 | setverdict(pass); |
| 1048 | } else { |
| 1049 | repeat; |
| 1050 | } |
| 1051 | } |
| 1052 | [] L1CTL.receive { repeat; } |
| 1053 | [] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1054 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp)); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1055 | } |
| 1056 | } |
| 1057 | } |
| 1058 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1059 | /* verify that given SACCH payload is not present */ |
| 1060 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 1061 | var L1ctlDlMessage dl; |
| 1062 | /* check that the specified SI5 value is actually sent */ |
| 1063 | timer T_sacch := 3.0; |
| 1064 | L1CTL.clear; |
| 1065 | T_sacch.start; |
| 1066 | alt { |
| 1067 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1068 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1069 | if (match(l3, l3_exp)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1070 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl)); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1071 | } else { |
| 1072 | repeat; |
| 1073 | } |
| 1074 | } |
| 1075 | [] L1CTL.receive { repeat; } |
| 1076 | [] T_sacch.timeout { |
| 1077 | setverdict(pass); |
| 1078 | } |
| 1079 | } |
| 1080 | } |
| 1081 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1082 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1083 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 1084 | /* Set a known default SACCH filling for SI5 */ |
| 1085 | var octetstring si5 := f_rnd_octstring(19); |
| 1086 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1087 | |
| 1088 | f_l1_tune(L1CTL); |
| 1089 | RSL.clear; |
| 1090 | |
| 1091 | /* activate the logical channel */ |
| 1092 | f_est_dchan(); |
| 1093 | |
| 1094 | /* check that the specified SI5 value is actually sent */ |
| 1095 | f_sacch_present(si5); |
| 1096 | |
| 1097 | /* release the channel */ |
| 1098 | RSL.clear; |
| 1099 | f_rsl_chan_deact(); |
| 1100 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1101 | } |
| 1102 | testcase TC_sacch_filling() runs on test_CT { |
| 1103 | var ConnHdlr vc_conn; |
| 1104 | var ConnHdlrPars pars; |
| 1105 | f_init(); |
| 1106 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1107 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1108 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1109 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 1110 | vc_conn.done; |
| 1111 | } |
| 1112 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1113 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1114 | } |
| 1115 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1116 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1117 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 1118 | /* Set a known default SACCH filling for SI5 */ |
| 1119 | var octetstring si5 := f_rnd_octstring(19); |
| 1120 | var octetstring si5_diff := f_rnd_octstring(19); |
| 1121 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1122 | |
| 1123 | f_l1_tune(L1CTL); |
| 1124 | RSL.clear; |
| 1125 | |
| 1126 | log("Activating channel, expecting standard SI5"); |
| 1127 | /* activate the logical channel */ |
| 1128 | f_est_dchan(); |
| 1129 | /* check that the specified SI5 value is actually sent */ |
| 1130 | f_sacch_present(si5); |
| 1131 | |
| 1132 | /* set channel-specific different SI5 */ |
| 1133 | log("Setting channel specific SACCH INFO, expecting it"); |
| 1134 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 1135 | /* check that the specified lchan-specific value is now used */ |
| 1136 | f_sacch_present(si5_diff); |
| 1137 | |
| 1138 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 1139 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 1140 | f_rsl_chan_deact(); |
| 1141 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 1142 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 1143 | f_sacch_present(si5); |
| 1144 | |
| 1145 | /* release the channel */ |
| 1146 | RSL.clear; |
| 1147 | f_rsl_chan_deact(); |
| 1148 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1149 | } |
| 1150 | testcase TC_sacch_info_mod() runs on test_CT { |
| 1151 | var ConnHdlr vc_conn; |
| 1152 | var ConnHdlrPars pars; |
| 1153 | f_init(); |
| 1154 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1155 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1156 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1157 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 1158 | vc_conn.done; |
| 1159 | } |
| 1160 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1161 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1162 | } |
| 1163 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1164 | /* Test SACCH scheduling of multiple different SI message types */ |
| 1165 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 1166 | var octetstring si5 := f_rnd_octstring(19); |
| 1167 | var octetstring si5bis := f_rnd_octstring(19); |
| 1168 | var octetstring si5ter := f_rnd_octstring(19); |
| 1169 | var octetstring si6 := f_rnd_octstring(19); |
| 1170 | |
| 1171 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1172 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 1173 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 1174 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1175 | |
| 1176 | f_l1_tune(L1CTL); |
| 1177 | RSL.clear; |
| 1178 | |
| 1179 | /* activate the logical channel */ |
| 1180 | f_est_dchan(); |
| 1181 | L1CTL.clear; |
| 1182 | |
| 1183 | /* check that SACCH actually are received as expected */ |
| 1184 | f_sacch_present(si5); |
| 1185 | f_sacch_present(si5bis); |
| 1186 | f_sacch_present(si5ter); |
| 1187 | f_sacch_present(si6); |
| 1188 | |
| 1189 | /* release the channel */ |
| 1190 | f_rsl_chan_deact(); |
| 1191 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1192 | } |
| 1193 | testcase TC_sacch_multi() runs on test_CT { |
| 1194 | var ConnHdlr vc_conn; |
| 1195 | var ConnHdlrPars pars; |
| 1196 | f_init(); |
| 1197 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1198 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1199 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1200 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 1201 | vc_conn.done; |
| 1202 | } |
| 1203 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1204 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1205 | } |
| 1206 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1207 | /* Test if SACH information is modified as expected */ |
| 1208 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1209 | var octetstring si5 := f_rnd_octstring(19); |
| 1210 | var octetstring si6 := f_rnd_octstring(19); |
| 1211 | |
| 1212 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1213 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1214 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1215 | |
| 1216 | f_l1_tune(L1CTL); |
| 1217 | RSL.clear; |
| 1218 | |
| 1219 | /* activate the logical channel */ |
| 1220 | f_est_dchan(); |
| 1221 | L1CTL.clear; |
| 1222 | |
| 1223 | /* check that SACCH actually are received as expected */ |
| 1224 | f_sacch_present(si5); |
| 1225 | f_sacch_present(si6); |
| 1226 | |
| 1227 | /* disable SI6 */ |
| 1228 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1229 | |
| 1230 | /* check that SI5 is still transmitted */ |
| 1231 | f_sacch_present(si5); |
| 1232 | /* check if SI6 is now gone */ |
| 1233 | f_sacch_missing(si6); |
| 1234 | |
| 1235 | /* release the channel */ |
| 1236 | f_rsl_chan_deact(); |
| 1237 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1238 | } |
| 1239 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1240 | var ConnHdlr vc_conn; |
| 1241 | var ConnHdlrPars pars; |
| 1242 | f_init(); |
| 1243 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1244 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1245 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1246 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1247 | vc_conn.done; |
| 1248 | } |
| 1249 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1250 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1251 | } |
| 1252 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1253 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1254 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1255 | var octetstring si5 := f_rnd_octstring(19); |
| 1256 | var octetstring si6 := f_rnd_octstring(19); |
| 1257 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1258 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1259 | |
| 1260 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1261 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1262 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1263 | |
| 1264 | f_l1_tune(L1CTL); |
| 1265 | RSL.clear; |
| 1266 | |
| 1267 | /* activate channel with different SACCH filling */ |
| 1268 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1269 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1270 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1271 | })); |
| 1272 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1273 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1274 | f_est_dchan(more_ies := addl_ies); |
| 1275 | |
| 1276 | /* check that SACCH actually are received as expected */ |
| 1277 | f_sacch_present(si5_specific); |
| 1278 | f_sacch_present(si6_specific); |
| 1279 | |
| 1280 | /* release the channel */ |
| 1281 | f_rsl_chan_deact(); |
| 1282 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1283 | } |
| 1284 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1285 | var ConnHdlr vc_conn; |
| 1286 | var ConnHdlrPars pars; |
| 1287 | f_init(); |
| 1288 | |
| 1289 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1290 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1291 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1292 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1293 | vc_conn.done; |
| 1294 | } |
| 1295 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1296 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1297 | } |
| 1298 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1299 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1300 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1301 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1302 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1303 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1304 | |
| 1305 | f_l1_tune(L1CTL); |
| 1306 | RSL.clear; |
| 1307 | |
| 1308 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1309 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1310 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1311 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1312 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1313 | var RSL_IE_List addl_ies := { |
| 1314 | ho_ref_ie |
| 1315 | }; |
| 1316 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1317 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1318 | 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] | 1319 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1320 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1321 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1322 | |
| 1323 | /* Verify that no DL SACCH is being received */ |
| 1324 | f_sacch_missing(?); |
| 1325 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1326 | /* Send handover Access Burst and expect SACCH to start */ |
| 1327 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1328 | |
| 1329 | f_sacch_present(si5); |
| 1330 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1331 | f_rsl_chan_deact(); |
| 1332 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1333 | |
| 1334 | |
| 1335 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1336 | |
| 1337 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1338 | addl_ies := { |
| 1339 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1340 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1341 | }; |
| 1342 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1343 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1344 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1345 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1346 | |
| 1347 | /* Verify that DL SACCH is being received */ |
| 1348 | f_sacch_present(si5); |
| 1349 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1350 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1351 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1352 | |
| 1353 | f_sacch_present(si5); |
| 1354 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1355 | f_rsl_chan_deact(); |
| 1356 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1357 | } |
| 1358 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1359 | var ConnHdlr vc_conn; |
| 1360 | var ConnHdlrPars pars; |
| 1361 | f_init(); |
| 1362 | |
| 1363 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1364 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1365 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1366 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1367 | vc_conn.done; |
| 1368 | } |
| 1369 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1370 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1371 | } |
| 1372 | |
| 1373 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1374 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1375 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1376 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1377 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1378 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1379 | var RSL_IE_List addl_ies; |
| 1380 | |
| 1381 | f_l1_tune(L1CTL); |
| 1382 | RSL.clear; |
| 1383 | |
| 1384 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1385 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1386 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1387 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1388 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1389 | addl_ies := { |
| 1390 | ho_ref_ie |
| 1391 | }; |
| 1392 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1393 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1394 | 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] | 1395 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1396 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1397 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1398 | |
| 1399 | /* Verify that no DL SACCH is being received */ |
| 1400 | f_sacch_missing(?); |
| 1401 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1402 | /* Send handover Access Burst and expect SACCH to start */ |
| 1403 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1404 | |
| 1405 | f_sacch_present(si5); |
| 1406 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1407 | f_rsl_chan_deact(); |
| 1408 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1409 | |
| 1410 | |
| 1411 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1412 | |
| 1413 | /* Activate channel on BTS side */ |
| 1414 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1415 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1416 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1417 | }; |
| 1418 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1419 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1420 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1421 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1422 | |
Neels Hofmeyr | d55a3ac | 2020-11-09 00:54:34 +0000 | [diff] [blame] | 1423 | /* Verify that DL SACCH is being received, because MS Power IE was sent */ |
| 1424 | f_sacch_present(si5); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1425 | |
Neels Hofmeyr | d55a3ac | 2020-11-09 00:54:34 +0000 | [diff] [blame] | 1426 | /* Send handover Access Burst and expect SACCH to remain present */ |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1427 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1428 | |
| 1429 | f_sacch_present(si5); |
| 1430 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1431 | f_rsl_chan_deact(); |
| 1432 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1433 | |
| 1434 | |
| 1435 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1436 | |
| 1437 | /* Activate channel on BTS side */ |
| 1438 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1439 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1440 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1441 | }; |
| 1442 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1443 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1444 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1445 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1446 | |
| 1447 | /* Verify that no DL SACCH is being received */ |
| 1448 | f_sacch_missing(?); |
| 1449 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1450 | /* Send handover Access Burst and expect SACCH to start */ |
| 1451 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1452 | |
| 1453 | f_sacch_present(si5); |
| 1454 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1455 | f_rsl_chan_deact(); |
| 1456 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1457 | |
| 1458 | |
| 1459 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1460 | |
| 1461 | /* Activate channel on BTS side */ |
| 1462 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1463 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1464 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1465 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1466 | }; |
| 1467 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1468 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1469 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1470 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1471 | |
| 1472 | /* Verify that DL SACCH is being received */ |
| 1473 | f_sacch_present(si5); |
| 1474 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1475 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1476 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1477 | |
| 1478 | f_sacch_present(si5); |
| 1479 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1480 | f_rsl_chan_deact(); |
| 1481 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1482 | } |
| 1483 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1484 | var ConnHdlr vc_conn; |
| 1485 | var ConnHdlrPars pars; |
| 1486 | f_init(); |
| 1487 | |
| 1488 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1489 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1490 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1491 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1492 | vc_conn.done; |
| 1493 | } |
| 1494 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1495 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1496 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1497 | |
| 1498 | |
| 1499 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1500 | * RACH Handling |
| 1501 | ***********************************************************************/ |
| 1502 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1503 | /* 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] | 1504 | private function f_TC_rach_content(boolean emerg) runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1505 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1506 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1507 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1508 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1509 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1510 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1511 | for (var integer i := 0; i < 1000; i := i+1) { |
Neels Hofmeyr | c897cfb | 2020-11-09 00:06:01 +0000 | [diff] [blame] | 1512 | var OCT1 ra; |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1513 | if (emerg == true) { |
| 1514 | ra := f_rnd_ra_emerg(); |
| 1515 | } else { |
| 1516 | ra := f_rnd_ra_cs(); |
| 1517 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1518 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1519 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1520 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1521 | } |
| 1522 | fn_last := fn; |
| 1523 | |
| 1524 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1525 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1526 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1527 | [] 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] | 1528 | T.stop; |
| 1529 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1530 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1531 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1532 | } |
| 1533 | [] RSL_CCHAN.receive { repeat; } |
| 1534 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1535 | test_failed := true; |
| 1536 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1537 | } |
| 1538 | } |
| 1539 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1540 | if (test_failed) { |
| 1541 | 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] | 1542 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1543 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1544 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1545 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1546 | |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1547 | /* Normal variant */ |
| 1548 | testcase TC_rach_content() runs on test_CT { |
| 1549 | f_TC_rach_content(emerg := false); |
| 1550 | } |
| 1551 | |
| 1552 | /* Emergency call variant */ |
| 1553 | testcase TC_rach_content_emerg() runs on test_CT { |
| 1554 | f_TC_rach_content(emerg := true); |
| 1555 | } |
| 1556 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1557 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1558 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1559 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1560 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1561 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1562 | f_l1_tune(L1CTL); |
| 1563 | |
| 1564 | var GsmFrameNumber fn_last := 0; |
| 1565 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1566 | var OCT1 ra := f_rnd_ra_cs(); |
| 1567 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1568 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1569 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1570 | } |
| 1571 | fn_last := fn; |
| 1572 | } |
| 1573 | var integer rsl_chrqd := 0; |
| 1574 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1575 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1576 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1577 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1578 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1579 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1580 | repeat; |
| 1581 | } |
| 1582 | [] RSL_CCHAN.receive { repeat; } |
| 1583 | [] T.timeout { } |
| 1584 | } |
| 1585 | if (rsl_chrqd == 1000) { |
| 1586 | setverdict(pass); |
| 1587 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1588 | 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] | 1589 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1590 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1591 | } |
| 1592 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1593 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1594 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1595 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1596 | } |
| 1597 | |
| 1598 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1599 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1600 | |
| 1601 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1602 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1603 | var ASP_RSL_Unitdata rx_ud; |
| 1604 | |
| 1605 | f_init_vty_bsc(); |
| 1606 | /* send load indications even at 0% load */ |
| 1607 | f_vty_load_ind_thresh(0); |
| 1608 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1609 | f_sleep(2.0); |
| 1610 | |
| 1611 | f_init(); |
| 1612 | |
Harald Welte | e37f9a5 | 2020-10-11 20:45:23 +0200 | [diff] [blame] | 1613 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1614 | alt { |
| 1615 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1616 | [] RSL_CCHAN.receive { repeat } |
| 1617 | } |
| 1618 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1619 | timer T := 5.0; |
| 1620 | T.start; |
| 1621 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1622 | [] 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] | 1623 | setverdict(pass); |
| 1624 | repeat; |
| 1625 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1626 | [] 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] | 1627 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1628 | repeat; |
| 1629 | } |
| 1630 | [] RSL_CCHAN.receive { |
| 1631 | repeat; |
| 1632 | } |
| 1633 | [] T.timeout { } |
| 1634 | } |
| 1635 | |
| 1636 | f_vty_load_ind_thresh(10); |
| 1637 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1638 | } |
| 1639 | |
| 1640 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1641 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1642 | var ASP_RSL_Unitdata rx_ud; |
| 1643 | |
| 1644 | f_init_vty_bsc(); |
| 1645 | f_init(); |
| 1646 | |
| 1647 | timer T := 5.0; |
| 1648 | T.start; |
| 1649 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1650 | [] 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] | 1651 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1652 | repeat; |
| 1653 | } |
| 1654 | [] RSL_CCHAN.receive { |
| 1655 | repeat; |
| 1656 | } |
| 1657 | [] T.timeout { |
| 1658 | setverdict(pass); |
| 1659 | } |
| 1660 | } |
| 1661 | |
| 1662 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1663 | } |
| 1664 | |
| 1665 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1666 | testcase TC_rach_load_count() runs on test_CT { |
| 1667 | var ASP_RSL_Unitdata rx_ud; |
| 1668 | var integer load_access_count := 0; |
| 1669 | |
| 1670 | f_init_vty_bsc(); |
| 1671 | /* send load indications even at 0% load */ |
| 1672 | f_vty_load_ind_thresh(0); |
| 1673 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1674 | f_sleep(2.0); |
| 1675 | f_init(); |
| 1676 | |
| 1677 | f_init_l1ctl(); |
| 1678 | f_sleep(1.0); |
| 1679 | f_l1_tune(L1CTL); |
| 1680 | |
Harald Welte | 52ae168 | 2020-10-11 20:45:55 +0200 | [diff] [blame] | 1681 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1682 | alt { |
| 1683 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1684 | [] RSL_CCHAN.receive { repeat } |
| 1685 | } |
| 1686 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1687 | var GsmFrameNumber fn_last := 0; |
| 1688 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1689 | var OCT1 ra := f_rnd_ra_cs(); |
| 1690 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1691 | if (fn == fn_last) { |
| 1692 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1693 | } |
| 1694 | fn_last := fn; |
| 1695 | } |
| 1696 | |
| 1697 | timer T := 5.0; |
| 1698 | T.start; |
| 1699 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1700 | [] 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] | 1701 | -> value rx_ud { |
| 1702 | var RSL_IE_Body ie; |
| 1703 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1704 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1705 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1706 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1707 | } |
| 1708 | repeat; |
| 1709 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1710 | [] 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] | 1711 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1712 | repeat; |
| 1713 | } |
| 1714 | [] RSL_CCHAN.receive { |
| 1715 | repeat; |
| 1716 | } |
| 1717 | [] T.timeout { } |
| 1718 | } |
| 1719 | if (load_access_count == 1000) { |
| 1720 | setverdict(pass); |
| 1721 | } else { |
| 1722 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1723 | } |
| 1724 | |
| 1725 | f_vty_load_ind_thresh(10); |
| 1726 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1727 | } |
| 1728 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1729 | 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] | 1730 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1731 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 1732 | 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] | 1733 | f_sleep(0.5); |
| 1734 | |
| 1735 | /* Transmit RACH request + wait for confirmation */ |
| 1736 | var OCT1 ra := f_rnd_ra_cs(); |
| 1737 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1738 | |
| 1739 | /* Check for expected result */ |
| 1740 | timer T := 1.5; |
| 1741 | T.start; |
| 1742 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1743 | [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] | 1744 | setverdict(pass); |
| 1745 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1746 | [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] | 1747 | 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] | 1748 | } |
| 1749 | [] RSL_CCHAN.receive { repeat; } |
| 1750 | [not expect_pass] T.timeout { |
| 1751 | setverdict(pass); |
| 1752 | } |
| 1753 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1754 | 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] | 1755 | } |
| 1756 | } |
| 1757 | } |
| 1758 | |
| 1759 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1760 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1761 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1762 | f_init_l1ctl(); |
| 1763 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1764 | f_sleep(1.0); |
| 1765 | |
| 1766 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1767 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1768 | /* We allow early arrival up to 2 symbols */ |
| 1769 | f_rach_toffs(-1*256, true); |
| 1770 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1771 | f_rach_toffs(-10*256, false); |
| 1772 | |
| 1773 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1774 | f_rach_toffs(0, true); |
| 1775 | f_rach_toffs(32*256, true); |
| 1776 | f_rach_toffs(63*256, true); |
| 1777 | |
| 1778 | /* more than 63 bits is not legal / permitted */ |
| 1779 | f_rach_toffs(64*256, false); |
| 1780 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1781 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1782 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1783 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1784 | private function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1785 | var GsmFrameNumber fn; |
| 1786 | var RSL_Message rm; |
| 1787 | |
| 1788 | f_l1_tune(L1CTL); |
| 1789 | RSL.clear; |
| 1790 | |
| 1791 | /* Generate a random Handover Reference */ |
| 1792 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1793 | |
| 1794 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1795 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1796 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1797 | |
| 1798 | /* Activate a channel on the BTS side (no encryption) */ |
| 1799 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1800 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1801 | |
| 1802 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1803 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1804 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1805 | |
| 1806 | /* Send handover Access Burst */ |
| 1807 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1808 | |
| 1809 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1810 | |
| 1811 | /* Wait for handover detection */ |
| 1812 | timer T := 3.0; |
| 1813 | T.start; |
| 1814 | alt { |
| 1815 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1816 | log("Handover RACH has been detected: ", rm); |
| 1817 | setverdict(pass); |
| 1818 | } |
| 1819 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1820 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1821 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1822 | } |
| 1823 | [] RSL.receive { repeat; } |
| 1824 | [] T.timeout { |
| 1825 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1826 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1827 | } |
| 1828 | } |
| 1829 | |
| 1830 | /* Release the channel */ |
| 1831 | f_rsl_chan_deact(); |
| 1832 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1833 | } |
| 1834 | |
| 1835 | /* Test handover RACH detection */ |
| 1836 | testcase TC_ho_rach() runs on test_CT { |
| 1837 | var ConnHdlrPars pars; |
| 1838 | var ConnHdlr vc_conn; |
| 1839 | |
| 1840 | f_init(); |
| 1841 | |
| 1842 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 1843 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1844 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1845 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 1846 | vc_conn.done; |
| 1847 | } |
| 1848 | |
| 1849 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1850 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1851 | } |
| 1852 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1853 | /*********************************************************************** |
| 1854 | * Measurement Processing / Reporting |
| 1855 | ***********************************************************************/ |
| 1856 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1857 | private template (value) LapdmAddressField |
| 1858 | ts_LapdmAddr(template (value) LapdmSapi sapi, |
| 1859 | template (value) boolean c_r) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1860 | spare := '0'B, |
| 1861 | lpd := 0, |
| 1862 | sapi := sapi, |
| 1863 | c_r := c_r, |
| 1864 | ea := true |
| 1865 | } |
| 1866 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1867 | private template (value) LapdmFrameAB |
| 1868 | ts_LAPDm_AB(template (value) LapdmSapi sapi, |
| 1869 | template (value) GsmRrL3Message l3, |
| 1870 | template (value) boolean c_r := false, |
| 1871 | template (value) boolean p := false) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1872 | addr := ts_LapdmAddr(sapi, c_r), |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1873 | ctrl := ts_LapdmCtrlUI(valueof(p)), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1874 | len := 0, /* overwritten */ |
| 1875 | m := false, |
| 1876 | el := 1, |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1877 | payload := enc_GsmRrL3Message(valueof(l3)) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1878 | } |
| 1879 | |
| 1880 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1881 | private altstep as_l1_sacch() runs on ConnHdlr { |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1882 | var template (value) LapdmFrameAB lb; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1883 | var L1ctlDlMessage l1_dl; |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1884 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1885 | [] 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] | 1886 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1887 | |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 1888 | 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] | 1889 | g_pars.l1_pars.meas_ul.full.rxlev, |
| 1890 | g_pars.l1_pars.meas_ul.sub.rxlev, |
| 1891 | g_pars.l1_pars.meas_ul.full.rxqual, |
| 1892 | g_pars.l1_pars.meas_ul.sub.rxqual)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1893 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 1894 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 1895 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
| 1896 | g_pars.l1_pars.ms_power_level, false, |
| 1897 | g_pars.l1_pars.ms_actual_ta); |
| 1898 | |
Vadim Yanitskiy | f105a5b | 2020-11-30 14:27:55 +0100 | [diff] [blame] | 1899 | /* According to 3GPP TS 44.018, section 10.5.2.20, we should pad with zeroes */ |
| 1900 | 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] | 1901 | |
| 1902 | log("Sending Measurement Report: ", l1h, l2); |
| 1903 | 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] | 1904 | repeat; |
| 1905 | } |
| 1906 | } |
| 1907 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 1908 | /* handle incoming downlink SACCH, decode the L1 header into the given record */ |
| 1909 | private altstep as_l1_sacch_l1h(inout SacchL1Header l1h, |
| 1910 | boolean do_apply := true) |
| 1911 | runs on ConnHdlr |
| 1912 | { |
| 1913 | var L1ctlDlMessage l1_dl; |
| 1914 | |
| 1915 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 1916 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 1917 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 1918 | log(%definitionId, "(): Rx SACCH L1 header: ", l1h); |
| 1919 | |
| 1920 | if (do_apply) { |
| 1921 | /* Update TA and MS power to follow what BTS requests */ |
| 1922 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 1923 | } |
| 1924 | } |
| 1925 | } |
| 1926 | |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 1927 | private altstep as_l1_dcch_loop() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1928 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1929 | [] 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] | 1930 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 1931 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 1932 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1933 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1934 | repeat; |
| 1935 | } |
| 1936 | } |
| 1937 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 1938 | private altstep as_l1_tch_loop() runs on ConnHdlr { |
| 1939 | var L1ctlDlMessage l1_dl; |
| 1940 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl { |
| 1941 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 1942 | |
| 1943 | /* occasionaly inject FACCH frames into the uplink */ |
| 1944 | if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) { |
| 1945 | var octetstring pl := '010301'O; |
| 1946 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1947 | f_pad_oct(pl, 23, '2B'O))); |
| 1948 | } else { |
| 1949 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 1950 | l1_dl.payload.traffic_ind.data)); |
| 1951 | } |
| 1952 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 1953 | repeat; |
| 1954 | } |
| 1955 | } |
| 1956 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1957 | private type record MeasElem { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1958 | uint6_t rxlev, |
| 1959 | uint3_t rxqual |
| 1960 | } |
| 1961 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1962 | private type record MeasElemFS { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1963 | MeasElem full, |
| 1964 | MeasElem sub |
| 1965 | } |
| 1966 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1967 | private type record ConnL1Pars { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1968 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1969 | boolean toa256_enabled, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 1970 | boolean meas_valid, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1971 | MeasElemFS meas_ul, |
| 1972 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 1973 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1974 | uint5_t ms_power_level, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 1975 | uint8_t ms_actual_ta, |
| 1976 | boolean facch_enabled |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1977 | } |
| 1978 | |
| 1979 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 1980 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 1981 | return 63 + (toffs256s/256); |
| 1982 | } |
| 1983 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1984 | private function f_max(integer a, integer b) return integer { |
| 1985 | if (a > b) { |
| 1986 | return a; |
| 1987 | } else { |
| 1988 | return b; |
| 1989 | } |
| 1990 | } |
| 1991 | |
| 1992 | private function f_min(integer a, integer b) return integer { |
| 1993 | if (a < b) { |
| 1994 | return a; |
| 1995 | } else { |
| 1996 | return b; |
| 1997 | } |
| 1998 | } |
| 1999 | |
| 2000 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 2001 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 2002 | val := val - tolerance; |
| 2003 | return f_max(val, min); |
| 2004 | } |
| 2005 | |
| 2006 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 2007 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 2008 | val := val + tolerance; |
| 2009 | return f_min(val, max); |
| 2010 | } |
| 2011 | |
| 2012 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 2013 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 2014 | return template integer { |
| 2015 | var template integer ret; |
| 2016 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 2017 | return ret; |
| 2018 | } |
| 2019 | |
| 2020 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2021 | /* build a template for matching measurement results against */ |
| 2022 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 2023 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2024 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2025 | len := 3, |
| 2026 | rfu := '0'B, |
| 2027 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2028 | 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] | 2029 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2030 | 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] | 2031 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2032 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 2033 | 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] | 2034 | supp_meas_info := omit |
| 2035 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2036 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 2037 | ul_meas.len := (3+8); |
| 2038 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2039 | 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] | 2040 | toa256_min := ?, |
| 2041 | toa256_max := ?, |
| 2042 | toa256_std_dev := ? |
| 2043 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2044 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2045 | var template RSL_IE_BS_Power bs_power := { |
| 2046 | reserved := 0, |
| 2047 | epc := false, |
| 2048 | fpc := false, |
| 2049 | power_level := l1p.bs_power_level |
| 2050 | }; |
| 2051 | var template RSL_IE_L1Info l1_info := { |
| 2052 | ms_power_lvl := l1p.ms_power_level, |
| 2053 | fpc := false, |
| 2054 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2055 | 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] | 2056 | }; |
| 2057 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2058 | 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] | 2059 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 2060 | ?, t_toffs); |
| 2061 | } |
| 2062 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2063 | /* build a template for matching measurement results that do not contain any |
| 2064 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 2065 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 2066 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2067 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2068 | len := 3, |
| 2069 | rfu := '0'B, |
| 2070 | dtx_d := l1p.dtx_enabled, |
| 2071 | rxlev_f_u := ?, |
| 2072 | reserved1 := '00'B, |
| 2073 | rxlev_s_u := ?, |
| 2074 | reserved2 := '00'B, |
| 2075 | rxq_f_u := ?, |
| 2076 | rxq_s_u := ?, |
| 2077 | supp_meas_info := omit |
| 2078 | }; |
| 2079 | if (l1p.toa256_enabled) { |
| 2080 | ul_meas.len := (3+8); |
| 2081 | ul_meas.supp_meas_info := { |
| 2082 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 2083 | toa256_min := ?, |
| 2084 | toa256_max := ?, |
| 2085 | toa256_std_dev := ? |
| 2086 | } |
| 2087 | } |
| 2088 | var template RSL_IE_BS_Power bs_power := { |
| 2089 | reserved := 0, |
| 2090 | epc := false, |
| 2091 | fpc := false, |
| 2092 | power_level := l1p.bs_power_level |
| 2093 | }; |
| 2094 | |
| 2095 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 2096 | } |
| 2097 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2098 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2099 | private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2100 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2101 | var boolean chan_est := false; |
| 2102 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 2103 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2104 | |
| 2105 | /* Receive osmocom specific measurement reports. This is the normal |
| 2106 | * case. Here we verify that the measurement reports we sent are |
| 2107 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2108 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 2109 | /* increment counter of next to-be-expected meas rep */ |
| 2110 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2111 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 2112 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2113 | |
| 2114 | /* The following two cases may only happen in the beginning |
| 2115 | * of the channel establishment phase. Once we have received |
| 2116 | * the "our" measurement report the first time, the channel |
| 2117 | * is established and empty or hardcoded TRXCON reports must |
| 2118 | * not occur anymore. */ |
| 2119 | chan_est := true; |
| 2120 | |
| 2121 | repeat; |
| 2122 | } |
| 2123 | |
| 2124 | /* When the BTS has established the channel, the MS might need slightly |
| 2125 | * more time to establish the channel and actually start sending. The |
| 2126 | * result is then a measurement report that just lacks the measurement |
| 2127 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 2128 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 2129 | /* increment counter of next to-be-expected meas rep */ |
| 2130 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2131 | /* Re-start the timer expecting the next MEAS RES */ |
| 2132 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2133 | repeat; |
| 2134 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2135 | |
| 2136 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 2137 | * measurements if the TTCN3 side does not supply measurement input in |
| 2138 | * time. In those cases TRXCON will either use a cached measurement |
| 2139 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 2140 | * report the templates above will not match. We tolerate this |
| 2141 | * behavior, but only once. */ |
| 2142 | [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] | 2143 | /* increment counter of next to-be-expected meas rep */ |
| 2144 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2145 | if (g_first_meas_res) { |
| 2146 | g_first_meas_res := false; |
| 2147 | repeat; |
| 2148 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2149 | 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] | 2150 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2151 | } |
| 2152 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2153 | 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] | 2154 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 2155 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2156 | 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] | 2157 | } |
| 2158 | } |
| 2159 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2160 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 2161 | select (rsl_alg_id) { |
| 2162 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 2163 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 2164 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 2165 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 2166 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 2167 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 2168 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 2169 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 2170 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2171 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2172 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2173 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2174 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2175 | } |
| 2176 | } |
| 2177 | } |
| 2178 | |
| 2179 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 2180 | select (rsl_alg_id) { |
| 2181 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 2182 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 2183 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 2184 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 2185 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 2186 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 2187 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 2188 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2189 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2190 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2191 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2192 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2193 | } |
| 2194 | } |
| 2195 | } |
| 2196 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2197 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 2198 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 2199 | var GsmFrameNumber fn; |
| 2200 | timer T := 8.0; |
| 2201 | |
| 2202 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 2203 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 2204 | |
| 2205 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 2206 | /* Send the actual RACH */ |
| 2207 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 2208 | |
| 2209 | T.start; |
| 2210 | alt { |
| 2211 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 2212 | [] T.timeout { |
| 2213 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 2214 | } |
| 2215 | } |
| 2216 | T.stop |
| 2217 | return fn; |
| 2218 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2219 | |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2220 | /* Tune to a dedicated channel: L1CTL only */ |
| 2221 | private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2222 | if (not pars.fhp.enabled) { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2223 | pt.send(ts_L1CTL_DM_EST_REQ_H0(pars.chan_nr, pars.tsc, |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 2224 | mp_trx_pars[0].arfcn)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2225 | } else { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2226 | 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] | 2227 | pars.fhp.maio_hsn.hsn, |
| 2228 | pars.fhp.maio_hsn.maio, |
| 2229 | pars.fhp.ma)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2230 | } |
| 2231 | } |
| 2232 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2233 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2234 | private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2235 | var GsmFrameNumber fn; |
| 2236 | var ImmediateAssignment imm_ass; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2237 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2238 | var integer ra := 23; |
| 2239 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2240 | /* Send RACH request and wait for ChanReq */ |
| 2241 | fn := f_rach_req_wait_chan_rqd(ra); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2242 | |
| 2243 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2244 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2245 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2246 | /* Craft channel description (with or without frequency hopping parameters) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2247 | if (g_pars.fhp.enabled) { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2248 | 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] | 2249 | } else { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2250 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2251 | } |
| 2252 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2253 | /* Send IMM.ASS via CCHAN */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2254 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2255 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 2256 | |
| 2257 | /* receive IMM.ASS on MS side */ |
| 2258 | var ImmediateAssignment ia_um; |
| 2259 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2260 | |
| 2261 | /* Make sure that IMM.ASS contains hopping parameters (if enabled) */ |
| 2262 | if (ch_desc.h != ia_um.chan_desc.h) { |
| 2263 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch"); |
| 2264 | } |
| 2265 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2266 | /* enable dedicated mode */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2267 | f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um, ma := g_pars.fhp.ma); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2268 | /* enable encryption, if requested */ |
| 2269 | if (encr_enable) { |
| 2270 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 2271 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 2272 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2273 | |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2274 | /* Send TCH Mode Request to the L1 if needed */ |
| 2275 | if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) { |
| 2276 | var L1ctlTchMode tch_mode; |
| 2277 | |
| 2278 | select (g_pars.chan_mode.coding_alg_rate) { |
| 2279 | case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; } |
| 2280 | case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; } |
| 2281 | case (RSL_CMOD_SP_GSM2) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V2; } |
| 2282 | case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3; } |
| 2283 | case else { |
| 2284 | log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate, |
| 2285 | " is not supported by the L1, falling back to signalling"); |
| 2286 | tch_mode := L1CTL_CHAN_MODE_SIGN; |
| 2287 | } |
| 2288 | } |
| 2289 | |
| 2290 | f_L1CTL_TCH_MODE(L1CTL, tch_mode); |
| 2291 | } |
| 2292 | |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2293 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2294 | } |
| 2295 | |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2296 | /* Initialize and start the RTP emulation component for a ConnHdlr */ |
| 2297 | friend function f_rtpem_activate(inout octetstring payload, |
| 2298 | RtpemConfig cfg := c_RtpemDefaultCfg, |
| 2299 | RtpemMode mode := RTPEM_MODE_BIDIR) |
| 2300 | runs on ConnHdlr { |
| 2301 | /* Step 0: initialize, connect and start the emulation component */ |
| 2302 | vc_RTPEM := RTP_Emulation_CT.create(testcasename() & "-RTPEM"); |
| 2303 | map(vc_RTPEM:RTP, system:RTP); |
| 2304 | map(vc_RTPEM:RTCP, system:RTCP); |
| 2305 | connect(vc_RTPEM:CTRL, self:RTPEM_CTRL); |
| 2306 | connect(vc_RTPEM:DATA, self:RTPEM_DATA); |
| 2307 | vc_RTPEM.start(RTP_Emulation.f_main()); |
| 2308 | |
| 2309 | /* Step 1: configure the RTP parameters */ |
| 2310 | var integer payload_len := 0; |
| 2311 | var octetstring hdr := ''O; |
| 2312 | |
| 2313 | select (g_pars.chan_mode) { |
| 2314 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)) /* TCH/FS */ |
| 2315 | { payload_len := 33; hdr := 'D0'O; } |
| 2316 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)) /* TCH/HS */ |
| 2317 | { payload_len := 15; hdr := '00'O; } |
| 2318 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2)) /* TCH/EFS */ |
| 2319 | { payload_len := 31; hdr := 'C0'O; } |
| 2320 | case else { /* FIXME: also handle TCH/AFS and TCH/AHS */ |
| 2321 | setverdict(fail, "Unhandled RSL channel mode := ", g_pars.chan_mode); |
| 2322 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2323 | } |
| 2324 | } |
| 2325 | |
| 2326 | /* Pad the payload to conform the expected length */ |
| 2327 | payload := f_pad_oct(hdr & payload, payload_len, '00'O); |
| 2328 | cfg.tx_fixed_payload := payload; |
| 2329 | f_rtpem_configure(RTPEM_CTRL, cfg); |
| 2330 | |
| 2331 | /* Step 2: bind the RTP emulation to the configured address */ |
| 2332 | var PortNumber rtpem_bind_port := mp_rtpem_bind_port; |
| 2333 | f_rtpem_bind(RTPEM_CTRL, mp_rtpem_bind_ip, rtpem_bind_port); |
| 2334 | |
| 2335 | /* Step 3: send CRCX with the configured address/port to the IUT */ |
| 2336 | var RSL_Message rsl_pdu := f_rsl_transceive_ret( |
| 2337 | ts_RSL_IPA_CRCX(g_chan_nr, f_inet_addr(mp_rtpem_bind_ip), rtpem_bind_port), |
| 2338 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 2339 | "IPA CRCX ACK"); |
| 2340 | |
| 2341 | /* Step 4: connect to the IUT's address/port parsed from CRCX ACK */ |
| 2342 | var HostName local_addr := f_inet_ntoa(rsl_pdu.ies[2].body.ipa_local_ip); |
| 2343 | var PortNumber local_port := rsl_pdu.ies[3].body.ipa_local_port; |
| 2344 | f_rtpem_connect(RTPEM_CTRL, local_addr, local_port); |
| 2345 | |
| 2346 | /* Step 5: set the given RTP emulation mode */ |
| 2347 | f_rtpem_mode(RTPEM_CTRL, mode); |
| 2348 | } |
| 2349 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2350 | /* establish DChan, verify existance + contents of measurement reports */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2351 | private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2352 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2353 | RSL.clear; |
| 2354 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 2355 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 2356 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2357 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2358 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2359 | |
| 2360 | f_est_dchan(); |
| 2361 | |
| 2362 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2363 | * RSL measurement reports on Abis side */ |
| 2364 | timer T := 8.0; |
| 2365 | T.start; |
| 2366 | alt { |
| 2367 | [] as_l1_sacch(); |
| 2368 | [] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2369 | [] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2370 | [] as_l1_tch_loop(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2371 | [] L1CTL.receive { repeat; } |
| 2372 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2373 | /* 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] | 2374 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2375 | setverdict(pass); |
| 2376 | } |
| 2377 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2378 | 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] | 2379 | } |
| 2380 | } |
| 2381 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2382 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2383 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2384 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2385 | /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */ |
| 2386 | private function f_wait_ramp_up() runs on ConnHdlr return integer { |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2387 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2388 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2389 | timer Tup := 10.0; |
| 2390 | Tup.start; |
| 2391 | alt { |
| 2392 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2393 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2394 | log("Received rx_level=", rx_lvl); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2395 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2396 | if (rx_lvl != max_rx_lvl) { |
| 2397 | repeat; |
| 2398 | } |
| 2399 | Tup.stop; |
| 2400 | } |
| 2401 | [] L1CTL.receive { repeat; } |
| 2402 | [] Tup.timeout { |
| 2403 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2404 | log2str("Didn't reach full power ", max_rx_lvl)); |
| 2405 | } |
| 2406 | } |
| 2407 | return max_rx_lvl; |
| 2408 | } |
| 2409 | |
| 2410 | /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */ |
| 2411 | private function f_verify_ramp_up() runs on ConnHdlr { |
| 2412 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2413 | var integer initial_rx_lvl := -1; |
| 2414 | var integer last_rx_lvl := -1; |
| 2415 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2416 | |
| 2417 | timer T := 2.0; |
| 2418 | alt { |
| 2419 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2420 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2421 | log("Received rx_level=", rx_lvl); |
| 2422 | if (initial_rx_lvl == -1) { |
| 2423 | initial_rx_lvl := rx_lvl; |
| 2424 | last_rx_lvl := rx_lvl; |
| 2425 | |
| 2426 | /* Expect a somehow low value during first received messages */ |
| 2427 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2428 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2429 | log2str("Detected high initial tx power during ramp up: ", |
| 2430 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2431 | } |
| 2432 | } |
| 2433 | |
| 2434 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2435 | if (rx_lvl > max_rx_lvl) { |
| 2436 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2437 | log2str("Detected Tx power higher than full power: ", |
| 2438 | rx_lvl , " > ", max_rx_lvl)); |
| 2439 | } |
| 2440 | |
| 2441 | /* Make sure it never decreases, since we are rumping up */ |
| 2442 | if (last_rx_lvl > rx_lvl) { |
| 2443 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2444 | log2str("Detected Tx power decrease during ramp up: ", |
| 2445 | last_rx_lvl , " -> ", rx_lvl)); |
| 2446 | } |
| 2447 | |
| 2448 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2449 | /* We reached the maximum power, start timer and receive |
| 2450 | /* a few more to make sure we don't surpass it */ |
| 2451 | log("Reached full power, wating a bit more until success"); |
| 2452 | T.start; |
| 2453 | } |
| 2454 | |
| 2455 | last_rx_lvl := rx_lvl; |
| 2456 | repeat; |
| 2457 | } |
| 2458 | [] L1CTL.receive { repeat; } |
| 2459 | [] T.timeout { } |
| 2460 | } |
| 2461 | |
| 2462 | /* We didn't increase tx power during ramp up */ |
| 2463 | if (initial_rx_lvl < last_rx_lvl) { |
| 2464 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2465 | } else { |
| 2466 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2467 | log2str("No Tx power increase during whole ramp up: ", |
| 2468 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2469 | } |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2470 | } |
| 2471 | |
| 2472 | /* verify BTS ramps power down to rx_level 0 */ |
| 2473 | private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2474 | var L1ctlDlMessage l1_dl; |
| 2475 | var integer last_rx_lvl := max_rx_lvl; |
| 2476 | |
| 2477 | timer Tdown := 5.0; |
| 2478 | Tdown.start; |
| 2479 | alt { |
| 2480 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2481 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2482 | log("Received rx_level=", rx_lvl); |
| 2483 | |
| 2484 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2485 | if (rx_lvl > max_rx_lvl) { |
| 2486 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2487 | log2str("Detected Tx power higher than full power: ", |
| 2488 | rx_lvl , " > ", max_rx_lvl)); |
| 2489 | } |
| 2490 | |
| 2491 | /* Make sure it never increases, since we are rumping down */ |
| 2492 | if (last_rx_lvl < rx_lvl) { |
| 2493 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2494 | log2str("Detected Tx power increase during ramp up: ", |
| 2495 | last_rx_lvl , " -> ", rx_lvl)); |
| 2496 | } |
| 2497 | |
| 2498 | last_rx_lvl := rx_lvl; |
| 2499 | if (last_rx_lvl != 0) { |
| 2500 | repeat; |
| 2501 | } |
| 2502 | /* we reached power level 0, we are done */ |
| 2503 | Tdown.stop; |
| 2504 | } |
| 2505 | [] L1CTL.receive { repeat; } |
| 2506 | [] Tdown.timeout { } |
| 2507 | } |
| 2508 | |
| 2509 | /* We didn't increase tx power during ramp down */ |
| 2510 | if (max_rx_lvl > last_rx_lvl) { |
| 2511 | log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl); |
| 2512 | } else { |
| 2513 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2514 | log2str("No Tx power decrease during whole ramp down: ", |
| 2515 | max_rx_lvl , " -> ", last_rx_lvl)); |
| 2516 | } |
| 2517 | } |
| 2518 | |
| 2519 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2520 | 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] | 2521 | f_l1_tune(L1CTL); |
| 2522 | RSL.clear; |
| 2523 | |
| 2524 | f_verify_ramp_up(); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2525 | |
| 2526 | setverdict(pass); |
| 2527 | } |
| 2528 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2529 | var ConnHdlr vc_conn; |
| 2530 | var ConnHdlrPars pars; |
| 2531 | f_init(); |
| 2532 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2533 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2534 | pcu_comp := false, trxc_comp := true); |
| 2535 | vc_conn.done; |
| 2536 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2537 | } |
| 2538 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2539 | /* 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] | 2540 | 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] | 2541 | f_connhdlr_init_vty_bsc(); |
| 2542 | |
| 2543 | f_l1_tune(L1CTL); |
| 2544 | RSL.clear; |
| 2545 | |
| 2546 | /* Wait until BTS is started and at full power */ |
| 2547 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2548 | log("Reached nominal level ", max_rx_lvl, ", shutting down OML link"); |
| 2549 | |
| 2550 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 2551 | f_verify_ramp_down(max_rx_lvl); |
| 2552 | |
| 2553 | setverdict(pass); |
| 2554 | } |
| 2555 | testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT { |
| 2556 | var ConnHdlr vc_conn; |
| 2557 | var ConnHdlrPars pars; |
| 2558 | f_init(); |
| 2559 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2560 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars, |
| 2561 | pcu_comp := false, trxc_comp := true); |
| 2562 | vc_conn.done; |
| 2563 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2564 | } |
| 2565 | |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2566 | /* Verify Tx power: |
| 2567 | * + ramping down during ADM state UNLOCKED->LOCKED |
| 2568 | * + ramping up during ADM state LOCKED->UNLOCKED |
| 2569 | */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2570 | 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] | 2571 | var L1ctlDlMessage l1_dl; |
| 2572 | var integer last_rx_lvl; |
| 2573 | |
| 2574 | f_connhdlr_init_vty_bsc(); |
| 2575 | |
| 2576 | f_l1_tune(L1CTL); |
| 2577 | RSL.clear; |
| 2578 | |
| 2579 | /* Wait until BTS is started and at full power */ |
| 2580 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2581 | log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED"); |
| 2582 | |
| 2583 | log("ADM STATE UNLOCKED->LOCKED"); |
| 2584 | f_vty_enter_cfg_trx(BSCVTY); |
| 2585 | f_vty_transceive(BSCVTY, "rf_locked 1"); |
| 2586 | last_rx_lvl := max_rx_lvl; |
| 2587 | f_verify_ramp_down(max_rx_lvl); |
| 2588 | |
| 2589 | /* Let some time after we received 0dBm, then check we don't receive BCCH |
| 2590 | * anymore because scheduler has stopped after ramping down */ |
| 2591 | f_sleep(2.0); |
| 2592 | L1CTL.clear; |
| 2593 | timer Tlocked := 2.0; |
| 2594 | Tlocked.start; |
| 2595 | alt { |
| 2596 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2597 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2598 | log2str("Received data_ind during rf_locked: ", l1_dl)); |
| 2599 | } |
| 2600 | [] L1CTL.receive { repeat; } |
| 2601 | [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); } |
| 2602 | } |
| 2603 | |
| 2604 | log("ADM STATE LOCKED->UNLOCKED"); |
| 2605 | f_vty_transceive(BSCVTY, "rf_locked 0"); |
| 2606 | f_verify_ramp_up(); |
| 2607 | setverdict(pass); |
| 2608 | } |
| 2609 | testcase TC_tx_power_ramp_adm_state_change() runs on test_CT { |
| 2610 | var ConnHdlr vc_conn; |
| 2611 | var ConnHdlrPars pars; |
| 2612 | f_init(); |
| 2613 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2614 | vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars, |
| 2615 | pcu_comp := false, trxc_comp := true); |
| 2616 | vc_conn.done; |
| 2617 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2618 | } |
| 2619 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2620 | 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] | 2621 | timer T := 8.0; |
| 2622 | T.start; |
| 2623 | var RSL_Message rsl; |
| 2624 | alt { |
| 2625 | [] as_l1_sacch(); |
| 2626 | [] L1CTL.receive { repeat; } |
| 2627 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 2628 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 2629 | setverdict(pass) |
| 2630 | } else { |
| 2631 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 2632 | } |
| 2633 | } |
| 2634 | [] T.timeout { |
| 2635 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 2636 | } |
| 2637 | } |
| 2638 | } |
| 2639 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2640 | /* See if the RSL MEASurement RESult contains expeced BS power level |
| 2641 | * set _during_ the CHANnel ACTIVation procedure. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2642 | 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] | 2643 | f_l1_tune(L1CTL); |
| 2644 | RSL.clear; |
| 2645 | |
| 2646 | if (mp_bts_trxc_port != -1) { |
| 2647 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2648 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2649 | } |
| 2650 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2651 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2652 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2653 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 2654 | |
| 2655 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2656 | |
| 2657 | f_check_meas_bs_power_level(pwr_var); |
| 2658 | |
| 2659 | f_rsl_chan_deact(); |
| 2660 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2661 | } |
| 2662 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2663 | /* See if the RSL MEASurement RESult contains expeced BS power level |
| 2664 | * set _after_ the CHANnel ACTIVation procedure. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2665 | 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] | 2666 | f_l1_tune(L1CTL); |
| 2667 | RSL.clear; |
| 2668 | |
| 2669 | if (mp_bts_trxc_port != -1) { |
| 2670 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2671 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2672 | } |
| 2673 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2674 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2675 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2676 | |
| 2677 | f_est_dchan(); |
| 2678 | |
| 2679 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 2680 | |
| 2681 | f_check_meas_bs_power_level(pwr_var); |
| 2682 | |
| 2683 | f_rsl_chan_deact(); |
| 2684 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2685 | } |
| 2686 | |
| 2687 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 2688 | var ConnHdlr vc_conn; |
| 2689 | var ConnHdlrPars pars; |
| 2690 | f_init(); |
| 2691 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2692 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2693 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 2694 | pcu_comp := false, trxc_comp := true); |
| 2695 | vc_conn.done; |
| 2696 | } |
| 2697 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2698 | } |
| 2699 | |
| 2700 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 2701 | var ConnHdlr vc_conn; |
| 2702 | var ConnHdlrPars pars; |
| 2703 | f_init(); |
| 2704 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2705 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2706 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 2707 | pcu_comp := false, trxc_comp := true); |
| 2708 | vc_conn.done; |
| 2709 | } |
| 2710 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2711 | } |
| 2712 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2713 | /* Target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 2714 | * second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds. |
| 2715 | * 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] | 2716 | 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] | 2717 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2718 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2719 | |
| 2720 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2721 | f_l1_tune(L1CTL); |
| 2722 | RSL.clear; |
| 2723 | |
| 2724 | var RSL_IE_List addl_ies; |
| 2725 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2726 | |
| 2727 | addl_ies := { |
| 2728 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2729 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2730 | }; |
| 2731 | |
| 2732 | /* establish with power parameters */ |
| 2733 | f_est_dchan(more_ies := addl_ies); |
| 2734 | |
| 2735 | /* set a high value to ensure L1 power control level increases */ |
| 2736 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2737 | |
| 2738 | timer T2 := 6.0; |
| 2739 | T2.start; |
| 2740 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2741 | [] as_l1_sacch_l1h(l1h) { |
| 2742 | if (l1h.ms_power_lvl < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2743 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2744 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2745 | T2.stop; |
| 2746 | } |
| 2747 | [] L1CTL.receive { repeat; } |
| 2748 | [] T2.timeout { |
| 2749 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2750 | "Power Level in L1 header has not increased sufficiently"); |
| 2751 | } |
| 2752 | } |
| 2753 | |
| 2754 | /* set a low value to ensure L1 power control level decreases */ |
| 2755 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 2756 | |
| 2757 | timer T4 := 6.0; |
| 2758 | T4.start; |
| 2759 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2760 | [] as_l1_sacch_l1h(l1h) { |
| 2761 | if (l1h.ms_power_lvl > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2762 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2763 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2764 | T4.stop; |
| 2765 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 2766 | } |
| 2767 | [] L1CTL.receive { repeat; } |
| 2768 | [] T4.timeout { |
| 2769 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2770 | "Power Level in L1 header has not decreased sufficiently"); |
| 2771 | } |
| 2772 | } |
| 2773 | |
| 2774 | f_rsl_chan_deact(); |
| 2775 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2776 | |
| 2777 | } |
| 2778 | |
| 2779 | /* check that we do not exceed the max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2780 | 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] | 2781 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2782 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2783 | |
| 2784 | /* set a low value to ensure power increases */ |
| 2785 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2786 | f_l1_tune(L1CTL); |
| 2787 | RSL.clear; |
| 2788 | |
| 2789 | var RSL_IE_List addl_ies; |
| 2790 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2791 | |
| 2792 | addl_ies := { |
| 2793 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2794 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2795 | }; |
| 2796 | |
| 2797 | /* establish with power parameters */ |
| 2798 | f_est_dchan(more_ies := addl_ies); |
| 2799 | |
| 2800 | timer T1 := 10.0; |
| 2801 | T1.start; |
| 2802 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2803 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2804 | [] L1CTL.receive { repeat; } |
| 2805 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2806 | if (not isbound(l1h)) { |
| 2807 | setverdict(fail, "No SACCH blocks were received"); |
| 2808 | } else if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2809 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 2810 | } |
| 2811 | } |
| 2812 | } |
| 2813 | |
| 2814 | f_rsl_chan_deact(); |
| 2815 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2816 | |
| 2817 | } |
| 2818 | |
| 2819 | /* see if we reach the band max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2820 | 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] | 2821 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2822 | var uint5_t pwr_var := 15; |
| 2823 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 2824 | |
| 2825 | /* set a low value to ensure power increases */ |
| 2826 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2827 | f_l1_tune(L1CTL); |
| 2828 | RSL.clear; |
| 2829 | |
| 2830 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2831 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2832 | |
| 2833 | /* establish with fixed power level */ |
| 2834 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2835 | |
| 2836 | /* check our initial power level */ |
| 2837 | f_wait_for_l1_power_level(pwr_var); |
| 2838 | |
| 2839 | /* update power param to enable power loop |
| 2840 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 2841 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 2842 | |
| 2843 | /* wait, then check that our power level was reduced */ |
| 2844 | timer T1 := 10.0; |
| 2845 | T1.start; |
| 2846 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2847 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2848 | [] L1CTL.receive { repeat; } |
| 2849 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2850 | if (not isbound(l1h)) { |
| 2851 | setverdict(fail, "No SACCH blocks were received"); |
| 2852 | } else if (f_power_level_is_highest_dbm(l1h.ms_power_lvl)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2853 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 2854 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2855 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, " did not ", |
| 2856 | "reach the expected value := ", pwr_max_var); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2857 | } |
| 2858 | } |
| 2859 | } |
| 2860 | |
| 2861 | f_rsl_chan_deact(); |
| 2862 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2863 | |
| 2864 | } |
| 2865 | |
| 2866 | /* see if we reach the band min power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2867 | 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] | 2868 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2869 | |
| 2870 | /* set a high value to ensure power decreases */ |
| 2871 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2872 | f_l1_tune(L1CTL); |
| 2873 | RSL.clear; |
| 2874 | |
| 2875 | var uint5_t pwr_var := 5; |
| 2876 | var uint5_t pwr_target_val := 15; |
| 2877 | |
| 2878 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2879 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2880 | |
| 2881 | /* establish with fixed power level */ |
| 2882 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2883 | |
| 2884 | /* check our initial power level */ |
| 2885 | f_wait_for_l1_power_level(pwr_var); |
| 2886 | |
| 2887 | /* update power param to enable power loop |
| 2888 | 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] | 2889 | 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] | 2890 | |
| 2891 | /* wait, then check that our power level was increased */ |
| 2892 | timer T1 := 10.0; |
| 2893 | T1.start; |
| 2894 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2895 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2896 | [] L1CTL.receive { repeat; } |
| 2897 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2898 | if (not isbound(l1h)) { |
| 2899 | setverdict(fail, "No SACCH blocks were received"); |
| 2900 | } else if (f_power_level_is_lowest_dbm(l1h.ms_power_lvl)) { |
| 2901 | setverdict(pass, "Power level increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2902 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2903 | setverdict(fail, "Power level NOT increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2904 | } |
| 2905 | } |
| 2906 | } |
| 2907 | |
| 2908 | f_rsl_chan_deact(); |
| 2909 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2910 | |
| 2911 | } |
| 2912 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2913 | /* See if the power level remains constant when MS Power Parameters IE |
| 2914 | * is _absent_ in the CHANnel ACTIVation message. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2915 | 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] | 2916 | var SacchL1Header l1h; |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2917 | |
| 2918 | /* set a high value to ensure power decreases */ |
| 2919 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2920 | f_l1_tune(L1CTL); |
| 2921 | RSL.clear; |
| 2922 | |
| 2923 | var uint5_t pwr_var := 5; |
| 2924 | |
| 2925 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2926 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2927 | |
| 2928 | /* establish with fixed power level */ |
| 2929 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2930 | |
| 2931 | /* check our initial power level */ |
| 2932 | f_wait_for_l1_power_level(pwr_var); |
| 2933 | |
| 2934 | /* wait, then check that our power level did not change */ |
| 2935 | timer T1 := 10.0; |
| 2936 | T1.start; |
| 2937 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2938 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 2939 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2940 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2941 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2942 | } |
| 2943 | repeat; |
| 2944 | } |
| 2945 | [] L1CTL.receive { repeat; } |
| 2946 | [] T1.timeout { setverdict(pass); } |
| 2947 | } |
| 2948 | |
| 2949 | f_rsl_chan_deact(); |
| 2950 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2951 | |
| 2952 | } |
| 2953 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2954 | /* See if the power level remains constant when MS Power Parameters IE |
| 2955 | * is _absent_ in the CHANnel ACTIVation and MS Power Control messages. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2956 | 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] | 2957 | var SacchL1Header l1h; |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2958 | |
| 2959 | /* set a high value to ensure power decreases */ |
| 2960 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2961 | f_l1_tune(L1CTL); |
| 2962 | RSL.clear; |
| 2963 | |
| 2964 | var uint5_t pwr_var := 5; |
| 2965 | |
| 2966 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2967 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2968 | |
| 2969 | /* establish with fixed power level */ |
| 2970 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2971 | |
| 2972 | /* check our initial power level */ |
| 2973 | f_wait_for_l1_power_level(pwr_var); |
| 2974 | |
| 2975 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 2976 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2977 | |
| 2978 | /* wait, then check that our power level did not change */ |
| 2979 | timer T1 := 10.0; |
| 2980 | T1.start; |
| 2981 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2982 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 2983 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2984 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2985 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2986 | } |
| 2987 | repeat; |
| 2988 | } |
| 2989 | [] L1CTL.receive { repeat; } |
| 2990 | [] T1.timeout { setverdict(pass); } |
| 2991 | } |
| 2992 | |
| 2993 | f_rsl_chan_deact(); |
| 2994 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2995 | |
| 2996 | } |
| 2997 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2998 | 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] | 2999 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3000 | timer T0 := 10.0; |
| 3001 | T0.start; |
| 3002 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3003 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3004 | if (l1h.ms_power_lvl != level) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3005 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3006 | "Power level in L1 header != signaled (RSL) power level."); |
| 3007 | } |
| 3008 | } |
| 3009 | [] L1CTL.receive { repeat; } |
| 3010 | [] T0.timeout { |
| 3011 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3012 | "Timeout waiting for initial power level"); |
| 3013 | } |
| 3014 | } |
| 3015 | T0.stop; |
| 3016 | } |
| 3017 | |
| 3018 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 3019 | var IntegerRecord min_dbm_level; |
| 3020 | var IntegerRecord max_dbm_level; |
| 3021 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3022 | |
| 3023 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 3024 | if (min_dbm_level[i] == level) { |
| 3025 | return true; |
| 3026 | } |
| 3027 | } |
| 3028 | return false; |
| 3029 | } |
| 3030 | |
| 3031 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 3032 | var IntegerRecord min_dbm_level; |
| 3033 | var IntegerRecord max_dbm_level; |
| 3034 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3035 | |
| 3036 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 3037 | if (max_dbm_level[i] == level) { |
| 3038 | return true; |
| 3039 | } |
| 3040 | } |
| 3041 | return false; |
| 3042 | } |
| 3043 | |
| 3044 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 3045 | var IntegerRecord min_dbm_level; |
| 3046 | var IntegerRecord max_dbm_level; |
| 3047 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3048 | return max_dbm_level[0]; |
| 3049 | } |
| 3050 | |
| 3051 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3052 | private template charstring BtsBand_allGSM := pattern "GSM???"; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3053 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 3054 | // 45.005 4.1.1 |
| 3055 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 3056 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 3057 | 2, 1, 0}; |
| 3058 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 3059 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 3060 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 3061 | var IntegerRecord rv; |
| 3062 | |
| 3063 | select(band){ |
| 3064 | case (BtsBand_allGSM){ |
| 3065 | rv := gsm_power; |
| 3066 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 3067 | max_dbm_level := {2, 1, 0}; |
| 3068 | } |
| 3069 | case("DCS1800"){ |
| 3070 | rv := dcs_power; |
| 3071 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 3072 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 3073 | } |
| 3074 | case("PCS1900"){ |
| 3075 | rv := pcs_power; |
| 3076 | min_dbm_level := {15}; |
| 3077 | max_dbm_level := {30}; |
| 3078 | } |
Harald Welte | 194b691 | 2020-10-11 21:01:55 +0200 | [diff] [blame] | 3079 | case else { |
| 3080 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band); |
| 3081 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3082 | } |
| 3083 | |
| 3084 | return rv; |
| 3085 | } |
| 3086 | |
| 3087 | 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] | 3088 | 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] | 3089 | } |
| 3090 | |
| 3091 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 3092 | var ConnHdlr vc_conn; |
| 3093 | var ConnHdlrPars pars; |
| 3094 | f_init(); |
| 3095 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3096 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3097 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3098 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3099 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 3100 | vc_conn.done; |
| 3101 | } |
| 3102 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3103 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3104 | } |
| 3105 | |
| 3106 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 3107 | var ConnHdlr vc_conn; |
| 3108 | var ConnHdlrPars pars; |
| 3109 | f_init(); |
| 3110 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3111 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3112 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3113 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3114 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 3115 | vc_conn.done; |
| 3116 | } |
| 3117 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3118 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3119 | } |
| 3120 | |
| 3121 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 3122 | var ConnHdlr vc_conn; |
| 3123 | var ConnHdlrPars pars; |
| 3124 | f_init(); |
| 3125 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3126 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3127 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3128 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3129 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 3130 | vc_conn.done; |
| 3131 | } |
| 3132 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3133 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3134 | } |
| 3135 | |
| 3136 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 3137 | var ConnHdlr vc_conn; |
| 3138 | var ConnHdlrPars pars; |
| 3139 | f_init(); |
| 3140 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3141 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3142 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3143 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3144 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 3145 | vc_conn.done; |
| 3146 | } |
| 3147 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3148 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3149 | } |
| 3150 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3151 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 3152 | var ConnHdlr vc_conn; |
| 3153 | var ConnHdlrPars pars; |
| 3154 | f_init(); |
| 3155 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3156 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3157 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3158 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3159 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 3160 | vc_conn.done; |
| 3161 | } |
| 3162 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3163 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3164 | } |
| 3165 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3166 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 3167 | var ConnHdlr vc_conn; |
| 3168 | var ConnHdlrPars pars; |
| 3169 | f_init(); |
| 3170 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3171 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3172 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3173 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3174 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 3175 | vc_conn.done; |
| 3176 | } |
| 3177 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3178 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3179 | } |
| 3180 | |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3181 | 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] | 3182 | var template RSL_IE_ChannelMode ch_mode; |
| 3183 | var ConnHdlr vc_conn; |
| 3184 | var ConnHdlrPars pars; |
| 3185 | f_init(); |
| 3186 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3187 | for (var integer tn := 1; tn <= 1; tn := tn + 1) { |
| 3188 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3189 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3190 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3191 | pcu_comp := false, trxc_comp := true); |
| 3192 | vc_conn.done; |
| 3193 | } |
| 3194 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3195 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3196 | |
| 3197 | testcase TC_meas_res_speech_tchf() runs on test_CT { |
| 3198 | f_TC_meas_res_speech_tchf(false); |
| 3199 | } |
| 3200 | |
| 3201 | testcase TC_meas_res_speech_tchf_facch() runs on test_CT { |
| 3202 | f_TC_meas_res_speech_tchf(true); |
| 3203 | } |
| 3204 | |
| 3205 | 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] | 3206 | var template RSL_IE_ChannelMode ch_mode; |
| 3207 | var ConnHdlr vc_conn; |
| 3208 | var ConnHdlrPars pars; |
| 3209 | f_init(); |
| 3210 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3211 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3212 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3213 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3214 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3215 | pcu_comp := false, trxc_comp := true); |
| 3216 | vc_conn.done; |
| 3217 | } |
| 3218 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3219 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3220 | |
| 3221 | testcase TC_meas_res_speech_tchh() runs on test_CT { |
| 3222 | f_TC_meas_res_speech_tchh(false) |
| 3223 | } |
| 3224 | |
| 3225 | testcase TC_meas_res_speech_tchh_facch() runs on test_CT { |
| 3226 | f_TC_meas_res_speech_tchh(true) |
| 3227 | } |
| 3228 | |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 3229 | testcase TC_meas_res_speech_tchh_toa256() runs on test_CT { |
| 3230 | var template RSL_IE_ChannelMode ch_mode; |
| 3231 | var ConnHdlr vc_conn; |
| 3232 | var ConnHdlrPars pars; |
| 3233 | f_init(); |
| 3234 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3235 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3236 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3237 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
| 3238 | pars.l1_pars.toa256_enabled := true; |
| 3239 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3240 | pcu_comp := false, trxc_comp := true); |
| 3241 | vc_conn.done; |
| 3242 | } |
| 3243 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3244 | } |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3245 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3246 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 3247 | var ConnHdlr vc_conn; |
| 3248 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3249 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3250 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3251 | 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] | 3252 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3253 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3254 | vc_conn.done; |
| 3255 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3256 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3257 | } |
| 3258 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 3259 | var ConnHdlr vc_conn; |
| 3260 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3261 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3262 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3263 | 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] | 3264 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3265 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3266 | vc_conn.done; |
| 3267 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3268 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3269 | } |
| 3270 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 3271 | var ConnHdlr vc_conn; |
| 3272 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3273 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3274 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 3275 | 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] | 3276 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3277 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3278 | vc_conn.done; |
| 3279 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3280 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3281 | } |
| 3282 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 3283 | var ConnHdlr vc_conn; |
| 3284 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3285 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3286 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 3287 | 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] | 3288 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3289 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3290 | vc_conn.done; |
| 3291 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3292 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3293 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3294 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 3295 | var ConnHdlr vc_conn; |
| 3296 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3297 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3298 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3299 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3300 | 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] | 3301 | pars.l1_pars.toa256_enabled := true; |
Vadim Yanitskiy | 0b65219 | 2020-10-20 02:39:02 +0700 | [diff] [blame] | 3302 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3303 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3304 | vc_conn.done; |
| 3305 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3306 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3307 | } |
| 3308 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3309 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 3310 | * 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] | 3311 | 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] | 3312 | var SacchL1Header l1h; |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3313 | var RSL_IE_MS_Power ms_power; |
| 3314 | var RSL_Message rsl; |
| 3315 | var uint5_t power_level := 0; |
| 3316 | |
| 3317 | f_l1_tune(L1CTL); |
| 3318 | RSL.clear; |
| 3319 | |
| 3320 | f_est_dchan(); |
| 3321 | |
| 3322 | ms_power.reserved := 0; |
| 3323 | ms_power.fpc_epc := false; |
| 3324 | |
| 3325 | /* Send the first power control command. This will disable any BTS/TRX |
| 3326 | * internal power control and switch the MS (which is not in scope of |
| 3327 | * this test) to a constant power level. We start with a power level |
| 3328 | * of 0 */ |
| 3329 | ms_power.power_level := power_level; |
| 3330 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3331 | RSL.send(rsl); |
| 3332 | |
| 3333 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3334 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3335 | if (l1h.ms_power_lvl != power_level) { |
| 3336 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3337 | "match the signaled (RSL) power level := ", power_level); |
| 3338 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3339 | } |
| 3340 | |
| 3341 | /* Signal a new power level via RSL for the next turn. */ |
| 3342 | if (power_level < 31) { |
| 3343 | power_level := power_level + 1; |
| 3344 | ms_power.power_level := power_level; |
| 3345 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3346 | RSL.send(rsl); |
| 3347 | repeat; |
| 3348 | } |
| 3349 | |
| 3350 | } |
| 3351 | |
| 3352 | /* Ignore all other blocks */ |
| 3353 | [] L1CTL.receive { repeat; } |
| 3354 | |
| 3355 | } |
| 3356 | |
| 3357 | f_rsl_chan_deact(); |
| 3358 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3359 | |
| 3360 | setverdict(pass); |
| 3361 | } |
| 3362 | |
| 3363 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 3364 | var ConnHdlr vc_conn; |
| 3365 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3366 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3367 | |
| 3368 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 3369 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3370 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 3371 | vc_conn.done; |
| 3372 | } |
| 3373 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3374 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3375 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 3376 | /* 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] | 3377 | 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] | 3378 | 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] | 3379 | var uint5_t ta_to_test := 16; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3380 | var SacchL1Header l1h; |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3381 | |
| 3382 | f_l1_tune(L1CTL); |
| 3383 | RSL.clear; |
| 3384 | |
| 3385 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 3386 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3387 | |
| 3388 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 3389 | |
| 3390 | |
| 3391 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3392 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3393 | if (l1h.actual_ta != ta_to_test) { |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3394 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 3395 | } |
| 3396 | |
| 3397 | } |
| 3398 | |
| 3399 | /* Ignore all other blocks */ |
| 3400 | [] L1CTL.receive { repeat; } |
| 3401 | |
| 3402 | } |
| 3403 | |
| 3404 | f_rsl_chan_deact(); |
| 3405 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3406 | |
| 3407 | setverdict(pass); |
| 3408 | } |
| 3409 | |
| 3410 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 3411 | var ConnHdlr vc_conn; |
| 3412 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3413 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3414 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3415 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 3416 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3417 | vc_conn.done; |
| 3418 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3419 | } |
| 3420 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3421 | /* 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] | 3422 | 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] | 3423 | var uint5_t ms_power_level := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3424 | var SacchL1Header l1h; |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3425 | |
| 3426 | var RSL_IE_MS_Power ms_power; |
| 3427 | ms_power.reserved := 0; |
| 3428 | ms_power.fpc_epc := false; |
| 3429 | ms_power.power_level := ms_power_level; |
| 3430 | |
| 3431 | f_l1_tune(L1CTL); |
| 3432 | RSL.clear; |
| 3433 | |
| 3434 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 3435 | |
| 3436 | timer T := 1.0; |
| 3437 | T.start; |
| 3438 | alt { |
| 3439 | /* Pick all SACCH blocks for checking */ |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3440 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3441 | if (l1h.ms_power_lvl != ms_power_level) { |
| 3442 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3443 | "match the signaled (RSL) power level := ", ms_power_level); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3444 | } |
| 3445 | } |
| 3446 | /* Ignore all other blocks */ |
| 3447 | [] L1CTL.receive { repeat; } |
| 3448 | [] T.timeout { |
| 3449 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3450 | } |
| 3451 | } |
| 3452 | |
| 3453 | f_rsl_chan_deact(); |
| 3454 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3455 | setverdict(pass); |
| 3456 | } |
| 3457 | |
| 3458 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 3459 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3460 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 3461 | } |
| 3462 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3463 | /* 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] | 3464 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3465 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3466 | RSL.clear; |
| 3467 | |
| 3468 | f_est_dchan(); |
| 3469 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3470 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3471 | |
| 3472 | timer T := 40.0; |
| 3473 | T.start; |
| 3474 | alt { |
| 3475 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 3476 | setverdict(pass) |
| 3477 | } |
| 3478 | [] RSL.receive { repeat }; |
| 3479 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3480 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3481 | } |
| 3482 | } |
| 3483 | f_rsl_chan_deact(); |
| 3484 | } |
| 3485 | testcase TC_conn_fail_crit() runs on test_CT { |
| 3486 | var ConnHdlr vc_conn; |
| 3487 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3488 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3489 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 3490 | pars.t_guard := 60.0; |
| 3491 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 3492 | vc_conn.done; |
| 3493 | } |
| 3494 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3495 | /*********************************************************************** |
| 3496 | * Paging |
| 3497 | ***********************************************************************/ |
| 3498 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3499 | private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3500 | if (tmsi == 'FFFFFFFF'O) { |
| 3501 | return true; |
| 3502 | } else { |
| 3503 | return false; |
| 3504 | } |
| 3505 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3506 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3507 | private type record allowedFn { integer frame_nr } |
| 3508 | private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 3509 | private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 3510 | private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 3511 | private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 3512 | private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 3513 | private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 3514 | private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 3515 | private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 3516 | 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] | 3517 | { |
| 3518 | var integer frame_nr_51; |
| 3519 | frame_nr_51 := frame_nr mod 51 |
| 3520 | |
| 3521 | var allowedFn fn_check; |
| 3522 | fn_check.frame_nr := frame_nr_51; |
| 3523 | |
| 3524 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3525 | 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] | 3526 | return; |
| 3527 | } |
| 3528 | |
| 3529 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 3530 | return; |
| 3531 | } |
| 3532 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 3533 | return; |
| 3534 | } |
| 3535 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 3536 | return; |
| 3537 | } |
| 3538 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 3539 | return; |
| 3540 | } |
| 3541 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 3542 | return; |
| 3543 | } |
| 3544 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 3545 | return; |
| 3546 | } |
| 3547 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 3548 | return; |
| 3549 | } |
| 3550 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 3551 | return; |
| 3552 | } |
| 3553 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3554 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3555 | return; |
| 3556 | } |
| 3557 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3558 | private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, |
| 3559 | inout integer num_paging_rcv_ids, |
| 3560 | PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3561 | runs on test_CT { |
| 3562 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3563 | [] 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] | 3564 | repeat; |
| 3565 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3566 | [] 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] | 3567 | var octetstring without_plen := |
| 3568 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 3569 | 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] | 3570 | |
| 3571 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 3572 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 3573 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 3574 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 3575 | * TODO: does it make sense to count them? */ |
| 3576 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3577 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3578 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3579 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3580 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3581 | } |
| 3582 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 3583 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3584 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 3585 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3586 | } |
| 3587 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 3588 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3589 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3590 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3591 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3592 | } |
| 3593 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 3594 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3595 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 3596 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3597 | } |
| 3598 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 3599 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3600 | } |
| 3601 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 3602 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3603 | } |
| 3604 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 3605 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3606 | } |
| 3607 | } |
| 3608 | repeat; |
| 3609 | } |
| 3610 | } |
| 3611 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3612 | private type record PagingTestCfg { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3613 | boolean combined_ccch, |
| 3614 | integer bs_ag_blks_res, |
| 3615 | float load_factor, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3616 | /* Mix in a paging request through the PCU socket for every Nth (ps_load_modulus) |
| 3617 | * paging command that is issued via RSL. */ |
| 3618 | integer ps_load_modulus, |
| 3619 | /* Wait until the paging queue inside the BTS is congested before starting to add |
| 3620 | * pagings via the PCU socket (0 = disabled) */ |
| 3621 | boolean ps_wait_cong, |
| 3622 | /* Maximum time to wait until the paging queue is drained at the end of the test. |
| 3623 | * This usually takes about 15s (size: 200, ~ 13 per s -> 15s), it is recommended |
| 3624 | * to set this value to 18s, however the draining process may take significantly |
| 3625 | * longer when the queue contains paging requests for PS as those are implemented |
| 3626 | * as immediate assignments and require an entire MAC block alone. */ |
| 3627 | float queue_drain_timeout, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3628 | boolean exp_load_ind, |
| 3629 | boolean exp_overload, |
| 3630 | boolean use_tmsi |
| 3631 | } |
| 3632 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3633 | private type record PagingTestState { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3634 | integer num_paging_sent, |
| 3635 | integer num_paging_rcv_msgs, |
| 3636 | integer num_paging_rcv_ids, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3637 | integer num_overload, |
| 3638 | /* When free space inside the paging queue reaches more than 2 thirds |
| 3639 | * of its capacity cong_detected is set to true. */ |
| 3640 | boolean cong_detected |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3641 | } |
| 3642 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3643 | /* Helper function for paging related testing */ |
| 3644 | 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] | 3645 | /* Using the PCU socket affects the timing of the paging processing. We only |
| 3646 | * activate the PCU socket if we do paging load tests that include additional |
| 3647 | * paging load that is introduced through the PCU socket. */ |
| 3648 | if (cfg.ps_load_modulus > 0) { |
| 3649 | f_init_with_pcuif(); |
| 3650 | } else { |
| 3651 | f_init(); |
| 3652 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3653 | f_init_l1ctl(); |
| 3654 | f_l1_tune(L1CTL); |
| 3655 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3656 | var octetstring imm_ass := f_rnd_octstring(23); |
| 3657 | var ASP_RSL_Unitdata load_ind; |
| 3658 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3659 | var PagingTestState st := { |
| 3660 | num_paging_sent := 0, |
| 3661 | num_paging_rcv_msgs := 0, |
| 3662 | num_paging_rcv_ids := 0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3663 | num_overload := 0, |
| 3664 | cong_detected := false |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3665 | }; |
| 3666 | |
| 3667 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 3668 | var float max_pch_imsi_per_sec; |
| 3669 | if (cfg.use_tmsi) { |
| 3670 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 3671 | } else { |
| 3672 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 3673 | } |
| 3674 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 3675 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3676 | var float time_total := 20.0; |
| 3677 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 3678 | 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] | 3679 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3680 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 3681 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3682 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3683 | timer T_itv := 0.0; |
| 3684 | T_itv.start; |
| 3685 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3686 | alt { |
| 3687 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3688 | [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] | 3689 | st.num_overload := st.num_overload + 1; |
| 3690 | repeat; |
| 3691 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3692 | [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] | 3693 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3694 | } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3695 | [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] | 3696 | log("Rx LOAD_IND"); |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3697 | |
| 3698 | /* Detect paging congestion: The logic inside the BTS will diagnose the |
| 3699 | * paging queue as congested when the fill state is more than 66% (which |
| 3700 | * is two thirds fill state, or approx. 66 of 200 paging slots. When a |
| 3701 | * paging congestion is detected pagings that are issued through the PCU |
| 3702 | * socket (PS) are dropped in order to prefer the CS related pagings. */ |
| 3703 | if (load_ind.rsl.ies[1].body.paging_load < 66) { |
| 3704 | st.cong_detected := true; |
| 3705 | } |
| 3706 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3707 | /* FIXME: analyze/verify interval + contents */ |
| 3708 | repeat; |
| 3709 | } |
Vadim Yanitskiy | 2372db6 | 2021-06-09 00:50:11 +0200 | [diff] [blame] | 3710 | /* ignore other RSL messages like RF RESource INDication */ |
| 3711 | [] RSL_CCHAN.receive { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3712 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3713 | [] 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] | 3714 | [] L1CTL.receive { repeat; } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3715 | /* Only relevant when testing including with PCU sock connected */ |
| 3716 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3717 | [] T_itv.timeout { |
| 3718 | /* Send paging cmds based on elapsed time */ |
| 3719 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 3720 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3721 | var MobileIdentityV mi; |
| 3722 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3723 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3724 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3725 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3726 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3727 | 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] | 3728 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3729 | |
| 3730 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3731 | 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] | 3732 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3733 | /* Add additional pagings through the PCU socket interface. */ |
| 3734 | if (cfg.ps_load_modulus > 0 and st.num_paging_sent mod cfg.ps_load_modulus == 0) { |
| 3735 | if (st.cong_detected == true or cfg.ps_wait_cong == false) { |
| 3736 | f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H, wait_for_cnf := false); |
| 3737 | } |
| 3738 | } |
| 3739 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3740 | st.num_paging_sent := st.num_paging_sent + 1; |
| 3741 | } |
| 3742 | if (st.num_paging_sent < pkt_total) { |
| 3743 | /* Wait for interval to next PAGING COMMAND */ |
| 3744 | var float time_now := T_total.read; |
| 3745 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 3746 | if (next_sched > time_now) { |
| 3747 | T_itv.start(next_sched - time_now); |
| 3748 | } else { |
| 3749 | T_itv.start(0.0); |
| 3750 | } |
| 3751 | } else { |
| 3752 | /* We are done, no need to keep counting */ |
| 3753 | T_total.stop; |
| 3754 | } |
| 3755 | } |
| 3756 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3757 | } |
| 3758 | } |
| 3759 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3760 | timer T_wait := cfg.queue_drain_timeout |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3761 | T_wait.start; |
| 3762 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3763 | [] 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] | 3764 | [] L1CTL.receive { repeat; } |
| 3765 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3766 | [] 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] | 3767 | [] 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] | 3768 | /* ignore other RSL messages like RF RESource INDication */ |
| 3769 | [] RSL_CCHAN.receive { repeat; } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3770 | /* Only relevant when testing including with PCU sock connected */ |
| 3771 | [] PCU.receive { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3772 | [] T_wait.timeout { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3773 | 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] | 3774 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3775 | } |
| 3776 | |
| 3777 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 3778 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 3779 | return st; |
| 3780 | } |
| 3781 | |
| 3782 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 3783 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3784 | * - that CCCH LOAD IND (PCH) are being generated |
| 3785 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3786 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3787 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3788 | var PagingTestCfg cfg := { |
| 3789 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3790 | 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] | 3791 | load_factor := 0.8, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3792 | ps_load_modulus := 0, |
| 3793 | ps_wait_cong := false, |
| 3794 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3795 | exp_load_ind := true, |
| 3796 | exp_overload := false, |
| 3797 | use_tmsi := false |
| 3798 | }; |
| 3799 | var PagingTestState st := f_TC_paging(cfg); |
| 3800 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3801 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3802 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3803 | } else { |
| 3804 | setverdict(pass); |
| 3805 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3806 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3807 | } |
| 3808 | |
| 3809 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 3810 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3811 | * - that CCCH LOAD IND (PCH) are being generated |
| 3812 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3813 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3814 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3815 | var PagingTestCfg cfg := { |
| 3816 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3817 | 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] | 3818 | load_factor := 0.8, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3819 | ps_load_modulus := 0, |
| 3820 | ps_wait_cong := false, |
| 3821 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3822 | exp_load_ind := true, |
| 3823 | exp_overload := false, |
| 3824 | use_tmsi := true |
| 3825 | }; |
| 3826 | var PagingTestState st := f_TC_paging(cfg); |
| 3827 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3828 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3829 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3830 | } else { |
| 3831 | setverdict(pass); |
| 3832 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3833 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3834 | } |
| 3835 | |
| 3836 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 3837 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3838 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3839 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3840 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3841 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3842 | var PagingTestCfg cfg := { |
| 3843 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3844 | 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] | 3845 | load_factor := 2.0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3846 | ps_load_modulus := 0, |
| 3847 | ps_wait_cong := false, |
| 3848 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3849 | exp_load_ind := true, |
| 3850 | exp_overload := true, |
| 3851 | use_tmsi := false |
| 3852 | }; |
| 3853 | var PagingTestState st := f_TC_paging(cfg); |
| 3854 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 3855 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3856 | 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] | 3857 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3858 | 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] | 3859 | } else { |
| 3860 | setverdict(pass); |
| 3861 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3862 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3863 | } |
| 3864 | |
| 3865 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 3866 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3867 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3868 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3869 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3870 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3871 | var PagingTestCfg cfg := { |
| 3872 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3873 | 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] | 3874 | load_factor := 2.0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3875 | ps_load_modulus := 0, |
| 3876 | ps_wait_cong := false, |
| 3877 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3878 | exp_load_ind := true, |
| 3879 | exp_overload := true, |
| 3880 | use_tmsi := true |
| 3881 | }; |
| 3882 | var PagingTestState st := f_TC_paging(cfg); |
| 3883 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 3884 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3885 | 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] | 3886 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3887 | 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] | 3888 | } else { |
| 3889 | setverdict(pass); |
| 3890 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3891 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3892 | } |
| 3893 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3894 | /* Same as above, but with additional paging load created by PS pagings that |
| 3895 | * are issued through the PCU socket. The additional load is introduced when |
| 3896 | * the paging queue is already two thirds full. Since the BTS implements a |
| 3897 | * prioritization logic that drops the pagings from the PCU under in those |
| 3898 | * congestive sitautions the behaviour on the PS side is expected to be |
| 3899 | * unaffected and match the behavior of TC_paging_imsi_200percent() */ |
| 3900 | testcase TC_paging_imsi_200percent_with_ps() runs on test_CT { |
| 3901 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 3902 | var PagingTestCfg cfg := { |
| 3903 | combined_ccch := true, |
| 3904 | bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res, |
| 3905 | load_factor := 2.0, |
| 3906 | ps_load_modulus := 16, |
| 3907 | ps_wait_cong := true, |
| 3908 | queue_drain_timeout := 18.0, |
| 3909 | exp_load_ind := true, |
| 3910 | exp_overload := true, |
| 3911 | use_tmsi := false |
| 3912 | }; |
| 3913 | var PagingTestState st := f_TC_paging(cfg); |
| 3914 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 3915 | * slots and will fully drain that buffer before returning */ |
| 3916 | var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100); |
| 3917 | if (not match(st.num_paging_rcv_ids, tpl)) { |
| 3918 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids)); |
| 3919 | } else { |
| 3920 | setverdict(pass); |
| 3921 | } |
| 3922 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3923 | } |
| 3924 | |
| 3925 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3926 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3927 | /*********************************************************************** |
| 3928 | * Immediate Assignment / AGCH |
| 3929 | ***********************************************************************/ |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 3930 | private const MobileAllocationLV c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3931 | len := 0, |
| 3932 | ma := ''B |
| 3933 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3934 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3935 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 3936 | return int2str(num_tx) & " sent, " |
| 3937 | & int2str(num_rx) & " received, " |
| 3938 | & int2str(num_del) & " deleted"; |
| 3939 | } |
| 3940 | |
| 3941 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 3942 | var L1ctlDlMessage l1_dl; |
| 3943 | timer T := 10.0; |
| 3944 | var integer num_tx := 0; |
| 3945 | var integer num_rx := 0; |
| 3946 | var integer num_del := 0; |
| 3947 | var charstring res_str; |
| 3948 | var float rx_ratio; |
| 3949 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3950 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3951 | f_init_l1ctl(); |
| 3952 | f_l1_tune(L1CTL); |
| 3953 | |
| 3954 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 3955 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0), |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 3956 | mp_trx_pars[0].arfcn, |
| 3957 | mp_tsc_def)); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3958 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 3959 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3960 | 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] | 3961 | num_tx := num_tx+1; |
| 3962 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3963 | } |
| 3964 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3965 | T.start; |
| 3966 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3967 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3968 | num_del := num_del+1; |
| 3969 | repeat; |
| 3970 | } |
| 3971 | [] RSL_CCHAN.receive { |
| 3972 | repeat; |
| 3973 | } |
| 3974 | [] 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] | 3975 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 3976 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 3977 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3978 | //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] | 3979 | } else { |
| 3980 | num_rx := num_rx+1; |
| 3981 | } |
| 3982 | repeat; |
| 3983 | } |
| 3984 | [] L1CTL.receive { repeat; } |
| 3985 | [] T.timeout { } |
| 3986 | } |
| 3987 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 3988 | log("AGCH test: " & res_str); |
| 3989 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3990 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3991 | } |
| 3992 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 3993 | 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] | 3994 | 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] | 3995 | } else { |
| 3996 | setverdict(pass); |
| 3997 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3998 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3999 | } |
| 4000 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4001 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 4002 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 4003 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 4004 | } |
| 4005 | |
| 4006 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 4007 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 4008 | f_TC_imm_ass(200, 0.0, 0.05); |
| 4009 | } |
| 4010 | |
| 4011 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 4012 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 4013 | f_TC_imm_ass(150, 0.076, 1.00); |
| 4014 | } |
| 4015 | |
| 4016 | |
| 4017 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4018 | /*********************************************************************** |
| 4019 | * BCCH |
| 4020 | ***********************************************************************/ |
| 4021 | |
| 4022 | /* tuple of Frame Number + decoded SI */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4023 | private type record SystemInformationFn { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4024 | GsmFrameNumber frame_number, |
| 4025 | SystemInformation si |
| 4026 | } |
| 4027 | |
| 4028 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4029 | private type record of SystemInformationFn SystemInformationVector; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4030 | |
| 4031 | /* an array of SI-vectors indexed by TC value */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4032 | private type SystemInformationVector SystemInformationVectorPerTc[8]; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4033 | |
| 4034 | /* 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] | 4035 | private function f_si_vecslot_contains(SystemInformationVector arr, |
| 4036 | RrMessageType key, |
| 4037 | boolean bcch_ext := false) |
| 4038 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4039 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 4040 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4041 | if (not bcch_ext and fn_mod51 == 2 or |
| 4042 | bcch_ext and fn_mod51 == 6) { |
| 4043 | if (arr[i].si.header.message_type == key) { |
| 4044 | return true; |
| 4045 | } |
| 4046 | } |
| 4047 | } |
| 4048 | return false; |
| 4049 | } |
| 4050 | |
| 4051 | /* 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] | 4052 | private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, |
| 4053 | integer tc, RrMessageType key, |
| 4054 | boolean ext_bcch := false) |
| 4055 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4056 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4057 | 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] | 4058 | } |
| 4059 | } |
| 4060 | |
| 4061 | /* 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] | 4062 | private function f_si_vec_contains(SystemInformationVectorPerTc arr, |
| 4063 | RrMessageType key) |
| 4064 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4065 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 4066 | if (f_si_vecslot_contains(arr[tc], key) or |
| 4067 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 4068 | return true; |
| 4069 | } |
| 4070 | } |
| 4071 | return false; |
| 4072 | } |
| 4073 | |
| 4074 | /* 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] | 4075 | private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, |
| 4076 | RrMessageType key, |
| 4077 | boolean bcch_ext := false, |
| 4078 | integer n := 1, integer m := 4) |
| 4079 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4080 | var integer count := 0; |
| 4081 | if (sizeof(arr) < m) { |
Harald Welte | a616ec9 | 2020-10-11 21:28:00 +0200 | [diff] [blame] | 4082 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: " |
| 4083 | & int2str(sizeof(arr)) & " < " & int2str(m)); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4084 | } |
| 4085 | for (var integer i:= 0; i < m; i := i + 1) { |
| 4086 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4087 | if (not bcch_ext and fn_mod51 == 2 or |
| 4088 | bcch_ext and fn_mod51 == 6) { |
| 4089 | if (arr[i].si.header.message_type == key) { |
| 4090 | count := count + 1; |
| 4091 | } |
| 4092 | } |
| 4093 | } |
| 4094 | if (count >= n) { |
| 4095 | return true; |
| 4096 | } else { |
| 4097 | return false; |
| 4098 | } |
| 4099 | } |
| 4100 | |
| 4101 | /* 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] | 4102 | private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, |
| 4103 | integer tc, RrMessageType key, |
| 4104 | boolean ext_bcch := false, |
| 4105 | integer n, integer m) |
| 4106 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4107 | 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] | 4108 | 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] | 4109 | } |
| 4110 | } |
| 4111 | |
| 4112 | /* 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] | 4113 | private function f_si_vecslot_contains_only(SystemInformationVector arr, |
| 4114 | RrMessageType key, |
| 4115 | boolean bcch_ext := false) |
| 4116 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4117 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 4118 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4119 | if (not bcch_ext and fn_mod51 == 2 or |
| 4120 | bcch_ext and fn_mod51 == 6) { |
| 4121 | if (arr[i].si.header.message_type != key) { |
| 4122 | return false; |
| 4123 | } |
| 4124 | } |
| 4125 | } |
| 4126 | return true; |
| 4127 | } |
| 4128 | |
| 4129 | /* 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] | 4130 | private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, |
| 4131 | integer tc, RrMessageType key, |
| 4132 | boolean ext_bcch := false) |
| 4133 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4134 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4135 | 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] | 4136 | } |
| 4137 | } |
| 4138 | |
| 4139 | /* SI configuration of cell, against which we validate actual SI messages */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4140 | private type set SystemInformationConfig { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4141 | boolean bcch_extended, |
| 4142 | boolean si1_present, |
| 4143 | boolean si2bis_present, |
| 4144 | boolean si2ter_present, |
| 4145 | boolean si2quater_present, |
| 4146 | boolean si7_present, |
| 4147 | boolean si8_present, |
| 4148 | boolean si9_present, |
| 4149 | boolean si13_present, |
| 4150 | boolean si13alt_present, |
| 4151 | boolean si15_present, |
| 4152 | boolean si16_present, |
| 4153 | boolean si17_present, |
| 4154 | boolean si2n_present, |
| 4155 | boolean si21_present, |
| 4156 | boolean si22_present |
| 4157 | } |
| 4158 | |
| 4159 | /* 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] | 4160 | private function f_validate_si_scheduling(SystemInformationConfig cfg, |
| 4161 | SystemInformationVectorPerTc si_per_tc) |
| 4162 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4163 | var integer i; |
| 4164 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 4165 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4166 | 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] | 4167 | } |
| 4168 | } |
| 4169 | if (cfg.si1_present) { |
| 4170 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 4171 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 4172 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 4173 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4174 | /* make sure *ALL* contain SI1 */ |
| 4175 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4176 | } |
| 4177 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 4178 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 4179 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 4180 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 4181 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 4182 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 4183 | |
| 4184 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 4185 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 4186 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 4187 | * consecutive occurrences of TC = 4. */ |
| 4188 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 4189 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4190 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 4191 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 4192 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 4193 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4194 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 4195 | } |
| 4196 | |
| 4197 | if (cfg.si7_present or cfg.si8_present) { |
| 4198 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 4199 | * if System Information type 4 does not contain all information needed for cell |
| 4200 | * selection and reselection. */ |
| 4201 | if (not cfg.bcch_extended) { |
| 4202 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 4203 | } |
| 4204 | if (cfg.si7_present) { |
| 4205 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 4206 | } |
| 4207 | if (cfg.si8_present) { |
| 4208 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 4209 | } |
| 4210 | } |
| 4211 | |
| 4212 | if (cfg.si2quater_present) { |
| 4213 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 4214 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 4215 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 4216 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 4217 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 4218 | if (not (cfg.bcch_extended)) { |
| 4219 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 4220 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 4221 | } else { |
| 4222 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 4223 | } |
| 4224 | } else { |
| 4225 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 4226 | } |
| 4227 | } |
| 4228 | if (cfg.si9_present) { |
| 4229 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 4230 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 4231 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 4232 | } |
| 4233 | if (cfg.si13_present) { |
| 4234 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 4235 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 4236 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 4237 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 4238 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 4239 | * within any of 4 consecutive occurrences of TC=4. */ |
| 4240 | if (not cfg.bcch_extended) { |
| 4241 | log("not-bccch-extended"); |
| 4242 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 4243 | } else { |
| 4244 | log("bccch-extended"); |
| 4245 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 4246 | } |
| 4247 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4248 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4249 | } |
| 4250 | } |
| 4251 | if (cfg.si16_present or cfg.si17_present) { |
| 4252 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 4253 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 4254 | if (cfg.si22_present) { |
| 4255 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4256 | } |
| 4257 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4258 | 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] | 4259 | } |
| 4260 | if (not cfg.bcch_extended) { |
| 4261 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 4262 | } |
| 4263 | if (cfg.si16_present) { |
| 4264 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 4265 | } |
| 4266 | if (cfg.si17_present) { |
| 4267 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 4268 | } |
| 4269 | } |
| 4270 | |
| 4271 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 4272 | * broadcast information. The frequency with which they are sent is determined by the |
| 4273 | * system operator. System Information type 9 identifies the scheduling of System |
| 4274 | * Information type 18 and 20 messages. */ |
| 4275 | |
| 4276 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 4277 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 4278 | * Information Type 9. */ |
| 4279 | |
| 4280 | if (cfg.si15_present) { |
| 4281 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 4282 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 4283 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 4284 | * 4 consecutive occurrences of TC = 1. */ |
| 4285 | if (not cfg.bcch_extended) { |
| 4286 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 4287 | } else { |
| 4288 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 4289 | } |
| 4290 | } |
| 4291 | if (cfg.si13alt_present) { |
| 4292 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 4293 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 4294 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 4295 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 4296 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 4297 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 4298 | * of TC = 4. */ |
| 4299 | if (cfg.si13_present) { |
| 4300 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 4301 | } |
| 4302 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4303 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4304 | } |
| 4305 | if (not cfg.bcch_extended) { |
| 4306 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 4307 | } else { |
| 4308 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 4309 | } |
| 4310 | } |
| 4311 | if (cfg.si2n_present) { |
| 4312 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 4313 | * as determined by the system operator. In the case that the message is sent on the |
| 4314 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 4315 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 4316 | * consecutive occurrences of TC = 4. */ |
| 4317 | if (not cfg.bcch_extended) { |
| 4318 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 4319 | } else { |
| 4320 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 4321 | } |
| 4322 | } |
| 4323 | if (cfg.si21_present) { |
| 4324 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 4325 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 4326 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 4327 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 4328 | * cell then this message shall only be sent on BCCH Ext. */ |
| 4329 | if (not cfg.bcch_extended) { |
| 4330 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 4331 | } else { |
| 4332 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 4333 | 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] | 4334 | 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] | 4335 | } |
| 4336 | } |
| 4337 | } |
| 4338 | if (cfg.si22_present) { |
| 4339 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 4340 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 4341 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 4342 | * =2 and TC=6. */ |
| 4343 | if (cfg.si16_present or cfg.si17_present) { |
| 4344 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4345 | } |
| 4346 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 4347 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4348 | 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] | 4349 | } |
| 4350 | if (not cfg.bcch_extended) { |
| 4351 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 4352 | } else { |
| 4353 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 4354 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 4355 | } |
| 4356 | } |
| 4357 | } |
| 4358 | |
| 4359 | /* sample Systme Information for specified duration via L1CTL */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4360 | private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) |
| 4361 | return SystemInformationVectorPerTc { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4362 | timer T := duration; |
| 4363 | var SystemInformationVectorPerTc si_per_tc; |
| 4364 | var L1ctlDlMessage l1_dl; |
| 4365 | |
| 4366 | /* initialize all per-TC vectors empty */ |
| 4367 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4368 | si_per_tc[i] := {}; |
| 4369 | } |
| 4370 | |
| 4371 | /* flush all previous L1 queued msgs */ |
| 4372 | pt.clear; |
| 4373 | |
| 4374 | T.start; |
| 4375 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4376 | [] 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] | 4377 | var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr }; |
| 4378 | if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) { |
| 4379 | log("Ignoring non-RR or invalid SI ", l1_dl); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4380 | repeat; |
| 4381 | } |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 4382 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4383 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 4384 | log("SI received at TC=", tc, ": ", sig.si); |
| 4385 | /* append to the per-TC bucket */ |
| 4386 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 4387 | repeat; |
| 4388 | } |
| 4389 | [] pt.receive { repeat; } |
| 4390 | [] T.timeout { } |
| 4391 | } |
| 4392 | |
| 4393 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4394 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 4395 | } |
| 4396 | log("si_per_tc=", si_per_tc); |
| 4397 | return si_per_tc; |
| 4398 | } |
| 4399 | |
| 4400 | /* helper function: Set given SI via RSL + validate scheduling. |
| 4401 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4402 | 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] | 4403 | var SystemInformationVectorPerTc si_per_tc; |
| 4404 | f_init_l1ctl(); |
| 4405 | f_l1_tune(L1CTL); |
| 4406 | |
| 4407 | /* Sample + Validate Scheduling */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4408 | si_per_tc := f_l1_sample_si(L1CTL, duration); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4409 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 4410 | |
| 4411 | setverdict(pass); |
| 4412 | } |
| 4413 | |
| 4414 | testcase TC_si_sched_default() runs on test_CT { |
| 4415 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4416 | /* 2+3+4 are mandatory and set in f_init() */ |
| 4417 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4418 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4419 | } |
| 4420 | |
| 4421 | testcase TC_si_sched_1() runs on test_CT { |
| 4422 | f_init(); |
| 4423 | si_cfg.si1_present := true; |
| 4424 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4425 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4426 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4427 | } |
| 4428 | |
| 4429 | testcase TC_si_sched_2bis() runs on test_CT { |
| 4430 | f_init(); |
| 4431 | si_cfg.si2bis_present := true; |
| 4432 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4433 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4434 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4435 | } |
| 4436 | |
| 4437 | testcase TC_si_sched_2ter() runs on test_CT { |
| 4438 | f_init(); |
| 4439 | si_cfg.si2ter_present := true; |
| 4440 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4441 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4442 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4443 | } |
| 4444 | |
| 4445 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 4446 | f_init(); |
| 4447 | si_cfg.si2bis_present := true; |
| 4448 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4449 | si_cfg.si2ter_present := true; |
| 4450 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4451 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4452 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4453 | } |
| 4454 | |
| 4455 | testcase TC_si_sched_2quater() runs on test_CT { |
| 4456 | f_init(); |
| 4457 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4458 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4459 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4460 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4461 | } |
| 4462 | |
| 4463 | testcase TC_si_sched_13() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4464 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4465 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4466 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4467 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4468 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4469 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4470 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4471 | } |
| 4472 | |
| 4473 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4474 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4475 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4476 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4477 | si_cfg.si2bis_present := true; |
| 4478 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4479 | si_cfg.si2ter_present := true; |
| 4480 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4481 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4482 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4483 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4484 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4485 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4486 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4487 | } |
| 4488 | |
| 4489 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4490 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4491 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4492 | /* FIXME: enable / disable individual BCCH info */ |
| 4493 | //ts_RSL_BCCH_INFO(si_type, info); |
| 4494 | /* expect no ERROR REPORT after either of them * |
| 4495 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4496 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4497 | } |
| 4498 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4499 | /*********************************************************************** |
| 4500 | * Low-Level Protocol Errors / ERROR REPORT |
| 4501 | ***********************************************************************/ |
| 4502 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4503 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 4504 | timer T := 5.0; |
| 4505 | T.start; |
| 4506 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4507 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4508 | setverdict(pass); |
| 4509 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4510 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4511 | 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] | 4512 | } |
| 4513 | [] RSL_CCHAN.receive { |
| 4514 | repeat; |
| 4515 | } |
| 4516 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4517 | 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] | 4518 | } |
| 4519 | } |
| 4520 | } |
| 4521 | |
| 4522 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 4523 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4524 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4525 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4526 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4527 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4528 | |
| 4529 | f_exp_err_rep(RSL_ERR_PROTO); |
| 4530 | } |
| 4531 | |
| 4532 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 4533 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4534 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4535 | |
| 4536 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4537 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4538 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4539 | |
| 4540 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 4541 | } |
| 4542 | |
| 4543 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 4544 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4545 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4546 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4547 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4548 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4549 | |
| 4550 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 4551 | } |
| 4552 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4553 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 4554 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 4555 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4556 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 4557 | RSL.send(rsl); |
| 4558 | f_rslem_unregister(0, g_chan_nr); |
| 4559 | } |
| 4560 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 4561 | var ConnHdlr vc_conn; |
| 4562 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4563 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4564 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4565 | |
| 4566 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 4567 | vc_conn.done; |
| 4568 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 4569 | |
| 4570 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4571 | } |
| 4572 | |
| 4573 | /* Send messages with wrong message type */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4574 | 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] | 4575 | var template (value) RSL_Message rsl_tx; |
| 4576 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4577 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 4578 | RSL.send(rsl_tx); |
| 4579 | f_rslem_unregister(0, g_chan_nr); |
| 4580 | } |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4581 | 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] | 4582 | var template (value) RSL_Message rsl_tx; |
| 4583 | /* we first have to activate the dedicated channel */ |
| 4584 | f_rsl_chan_act(g_pars.chan_mode); |
| 4585 | /* ... to then send an invalid RLL message */ |
| 4586 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 4587 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 4588 | RSL.send(rsl_tx); |
| 4589 | f_rslem_unregister(0, g_chan_nr); |
| 4590 | } |
| 4591 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 4592 | var ConnHdlr vc_conn; |
| 4593 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4594 | var template (value) RSL_Message rsl_tx; |
| 4595 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4596 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4597 | |
| 4598 | /* Common Channel with wrong message type */ |
| 4599 | RSL_CCHAN.clear; |
| 4600 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4601 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4602 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4603 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4604 | |
| 4605 | /* TRX Management */ |
| 4606 | RSL_CCHAN.clear; |
| 4607 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 4608 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4609 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4610 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4611 | |
| 4612 | /* Dedicated Channel */ |
| 4613 | RSL_CCHAN.clear; |
| 4614 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 4615 | vc_conn.done; |
| 4616 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4617 | |
| 4618 | /* RLL */ |
| 4619 | RSL_CCHAN.clear; |
| 4620 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 4621 | vc_conn.done; |
| 4622 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4623 | } |
| 4624 | |
| 4625 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4626 | 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] | 4627 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 4628 | f_rslem_unregister(0, g_chan_nr); |
| 4629 | } |
| 4630 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 4631 | var ConnHdlr vc_conn; |
| 4632 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4633 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4634 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4635 | |
| 4636 | RSL_CCHAN.clear; |
| 4637 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 4638 | vc_conn.done; |
| 4639 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 4640 | } |
| 4641 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4642 | /*********************************************************************** |
| 4643 | * IPA CRCX/MDCX/DLCS media stream handling |
| 4644 | ***********************************************************************/ |
| 4645 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4646 | /* Send IPA DLCX to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4647 | 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] | 4648 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4649 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4650 | } |
| 4651 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 4652 | 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] | 4653 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4654 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 4655 | vc_conn.done; |
| 4656 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4657 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4658 | /* Send IPA CRCX twice to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4659 | 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] | 4660 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4661 | "IPA CRCX ACK"); |
| 4662 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 4663 | "IPA CRCX NACK"); |
| 4664 | } |
| 4665 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 4666 | 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] | 4667 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4668 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 4669 | vc_conn.done; |
| 4670 | } |
| 4671 | |
| 4672 | /* Regular sequence of CRCX/MDCX/DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4673 | 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] | 4674 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4675 | "IPA CRCX ACK"); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 4676 | var OCT4 remote_ip := f_rnd_octstring(4); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4677 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4678 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4679 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4680 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4681 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4682 | "IPA MDCX ACK"); |
| 4683 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4684 | "IPA DLCX ACK"); |
| 4685 | } |
| 4686 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4687 | 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] | 4688 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4689 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 4690 | vc_conn.done; |
| 4691 | } |
| 4692 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4693 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4694 | 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] | 4695 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4696 | "IPA CRCX ACK"); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 4697 | var OCT4 remote_ip := f_rnd_octstring(4); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4698 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4699 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4700 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4701 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4702 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4703 | "IPA MDCX ACK"); |
| 4704 | /* Second MDCX */ |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 4705 | remote_ip := f_rnd_octstring(4); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4706 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 4707 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4708 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4709 | "IPA MDCX ACK"); |
| 4710 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4711 | "IPA DLCX ACK"); |
| 4712 | } |
| 4713 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4714 | 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] | 4715 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4716 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 4717 | vc_conn.done; |
| 4718 | } |
| 4719 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4720 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4721 | 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] | 4722 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 4723 | "IPA CRCX NACK"); |
| 4724 | } |
| 4725 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 4726 | var ConnHdlrPars pars; |
| 4727 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4728 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4729 | |
| 4730 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 4731 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4732 | vc_conn.done; |
| 4733 | |
| 4734 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 4735 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4736 | vc_conn.done; |
| 4737 | } |
| 4738 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4739 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4740 | /*********************************************************************** |
| 4741 | * PCU Socket related tests |
| 4742 | ***********************************************************************/ |
| 4743 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4744 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4745 | 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] | 4746 | runs on test_CT { |
| 4747 | timer T := 3.0; |
| 4748 | |
| 4749 | /* we don't expect any RTS.req before PDCH are active */ |
| 4750 | T.start; |
| 4751 | alt { |
| 4752 | [] 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] | 4753 | 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] | 4754 | } |
| 4755 | [] PCU.receive { repeat; } |
| 4756 | [] T.timeout { } |
| 4757 | } |
| 4758 | |
| 4759 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4760 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 4761 | |
| 4762 | /* we now expect RTS.req for this timeslot (only) */ |
| 4763 | T.start; |
| 4764 | alt { |
| 4765 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 4766 | setverdict(pass); |
| 4767 | } |
| 4768 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4769 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4770 | 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] | 4771 | } |
| 4772 | [] 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] | 4773 | 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] | 4774 | } |
| 4775 | [] PCU.receive { repeat; } |
| 4776 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4777 | 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] | 4778 | } |
| 4779 | [not exp_success] T.timeout { |
| 4780 | setverdict(pass); |
| 4781 | } |
| 4782 | } |
| 4783 | } |
| 4784 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4785 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4786 | 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] | 4787 | runs on test_CT { |
| 4788 | timer T := 3.0; |
| 4789 | |
| 4790 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4791 | 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] | 4792 | /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know |
| 4793 | * when it will actually have been executed in the BTS */ |
| 4794 | f_sleep(1.0); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4795 | PCU.clear; |
| 4796 | /* we now expect no RTS.req for this timeslot */ |
| 4797 | T.start; |
| 4798 | alt { |
| 4799 | [] 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] | 4800 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4801 | } |
| 4802 | [] PCU.receive { repeat; } |
| 4803 | [] T.timeout { |
| 4804 | setverdict(pass); |
| 4805 | } |
| 4806 | } |
| 4807 | } |
| 4808 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4809 | friend function f_init_with_pcuif() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4810 | f_init(); |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4811 | map(self:PCU, system:PCU); |
| 4812 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4813 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 4814 | } |
| 4815 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4816 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 4817 | testcase TC_pcu_act_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4818 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4819 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4820 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4821 | } |
| 4822 | |
| 4823 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 4824 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4825 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4826 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4827 | f_TC_pcu_act_req(0, 0, 1, false); |
| 4828 | } |
| 4829 | |
| 4830 | /* PDCH activation via PCU socket on wrong BTS */ |
| 4831 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4832 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4833 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4834 | f_TC_pcu_act_req(23, 0, 7, false); |
| 4835 | } |
| 4836 | |
| 4837 | /* PDCH activation via PCU socket on wrong TRX */ |
| 4838 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4839 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4840 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4841 | f_TC_pcu_act_req(0, 23, 7, false); |
| 4842 | } |
| 4843 | |
| 4844 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 4845 | testcase TC_pcu_deact_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4846 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4847 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4848 | /* Activate PDCH */ |
| 4849 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4850 | f_sleep(1.0); |
| 4851 | /* and De-Activate again */ |
| 4852 | f_TC_pcu_deact_req(0, 0, 7); |
| 4853 | } |
| 4854 | |
| 4855 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 4856 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4857 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4858 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4859 | f_TC_pcu_deact_req(0, 0, 1); |
| 4860 | } |
| 4861 | |
| 4862 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 4863 | 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] | 4864 | var PCUIF_send_data sd; |
| 4865 | timer T:= 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4866 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4867 | |
| 4868 | /* Set SI13 via RSL */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 4869 | f_rsl_bcch_fill_raw(rsl_si_type, si); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4870 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4871 | T.start; |
| 4872 | alt { |
| 4873 | [] 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] | 4874 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si)) == si) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4875 | setverdict(pass); |
| 4876 | } else { |
| 4877 | repeat; |
| 4878 | } |
| 4879 | } |
| 4880 | [] PCU.receive { repeat; } |
| 4881 | [] T.timeout { |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 4882 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4883 | } |
| 4884 | } |
| 4885 | } |
| 4886 | |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 4887 | /* Test the PCU->BTS Version and BTS->PCU SI1 handshake */ |
| 4888 | testcase TC_pcu_ver_si1() runs on test_CT { |
| 4889 | const octetstring si1 := '550111132A252B27CC29AA11BB33CC'O; |
| 4890 | f_TC_pcu_ver_siXX(si1, RSL_SYSTEM_INFO_1); |
| 4891 | } |
| 4892 | |
| 4893 | /* Test the PCU->BTS Version and BTS->PCU SI3 handshake */ |
| 4894 | testcase TC_pcu_ver_si3() runs on test_CT { |
| 4895 | const octetstring si3 := '49012223242526272929AABBCC'O; |
| 4896 | f_TC_pcu_ver_siXX(si3, RSL_SYSTEM_INFO_3); |
| 4897 | } |
| 4898 | |
| 4899 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 4900 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 4901 | const octetstring si13 := '01010203040506070909'O; |
| 4902 | f_TC_pcu_ver_siXX(si13, RSL_SYSTEM_INFO_13); |
| 4903 | } |
| 4904 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4905 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 4906 | |
| 4907 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4908 | 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] | 4909 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 4910 | runs on test_CT |
| 4911 | { |
| 4912 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 4913 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 4914 | } |
| 4915 | |
| 4916 | /* 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] | 4917 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 4918 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4919 | runs on test_CT |
| 4920 | { |
| 4921 | var PCUIF_send_data sd; |
| 4922 | |
| 4923 | timer T := 3.0; |
| 4924 | T.start; |
| 4925 | alt { |
| 4926 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4927 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 4928 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 4929 | sd.data.u.rts_req.fn, sapi, data); |
| 4930 | } |
| 4931 | [] PCU.receive { repeat; } |
| 4932 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4933 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4934 | } |
| 4935 | } |
| 4936 | } |
| 4937 | |
| 4938 | /* Send DATA.req on invalid BTS */ |
| 4939 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4940 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4941 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4942 | |
| 4943 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4944 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4945 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4946 | f_TfiUsfArrSet(tua, 7, 0); |
| 4947 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4948 | f_sleep(1.0); |
| 4949 | |
| 4950 | 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] | 4951 | } |
| 4952 | |
| 4953 | /* Send DATA.req on invalid TRX */ |
| 4954 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4955 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4956 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4957 | |
| 4958 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4959 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4960 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4961 | f_TfiUsfArrSet(tua, 7, 0); |
| 4962 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4963 | f_sleep(1.0); |
| 4964 | |
| 4965 | 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] | 4966 | } |
| 4967 | |
| 4968 | /* Send DATA.req on invalid timeslot */ |
| 4969 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4970 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4971 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4972 | |
| 4973 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4974 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4975 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4976 | f_TfiUsfArrSet(tua, 7, 0); |
| 4977 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4978 | f_sleep(1.0); |
| 4979 | |
| 4980 | 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] | 4981 | } |
| 4982 | |
| 4983 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 4984 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4985 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4986 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4987 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4988 | f_virtphy_common(); |
| 4989 | |
| 4990 | f_TfiUsfArrSet(tua, 7, 0); |
| 4991 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4992 | f_sleep(1.0); |
| 4993 | |
| 4994 | 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] | 4995 | } |
| 4996 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4997 | 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] | 4998 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 4999 | boolean wait_rts := true) |
| 5000 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5001 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5002 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5003 | |
| 5004 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5005 | if (wait_rts) { |
| 5006 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 5007 | } else { |
| 5008 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 5009 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5010 | |
| 5011 | T.start; |
| 5012 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5013 | [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] | 5014 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 5015 | setverdict(pass); |
| 5016 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5017 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 5018 | setverdict(fail, "Received unexpected ", rx_dl); |
| 5019 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5020 | [] L1CTL.receive { |
| 5021 | repeat; |
| 5022 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5023 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5024 | setverdict(fail, "Timeout waiting for ", data); |
| 5025 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5026 | [not expect_data] T.timeout { |
| 5027 | setverdict(pass); |
| 5028 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5029 | } |
| 5030 | } |
| 5031 | |
| 5032 | private function f_disable_dynamic_ts() runs on test_CT |
| 5033 | { |
| 5034 | f_init_vty_bsc(); |
| 5035 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 5036 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 5037 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 5038 | 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] | 5039 | f_init_with_pcuif(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5040 | } |
| 5041 | |
| 5042 | private function f_virtphy_common() runs on test_CT { |
| 5043 | f_disable_dynamic_ts(); |
| 5044 | f_init_l1ctl(); |
| 5045 | f_l1_tune(L1CTL); |
| 5046 | } |
| 5047 | |
| 5048 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 5049 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5050 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5051 | |
| 5052 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5053 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5054 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5055 | f_TfiUsfArrSet(tua, 7, 0); |
| 5056 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5057 | f_sleep(1.0); |
| 5058 | |
| 5059 | 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] | 5060 | } |
| 5061 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5062 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5063 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5064 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5065 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5066 | |
| 5067 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5068 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5069 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5070 | f_TfiUsfArrSet(tua, 7, 0); |
| 5071 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5072 | f_sleep(1.0); |
| 5073 | |
| 5074 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5075 | } |
| 5076 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5077 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 5078 | runs on test_CT { |
| 5079 | var template PCUIF_Message pcu_rach_ind; |
| 5080 | var PCUIF_send_data sd; |
| 5081 | var GsmFrameNumber fn; |
| 5082 | timer T; |
| 5083 | |
| 5084 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 5085 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 5086 | chan_nr := ts_RslChanNr_PDCH(7), |
| 5087 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 5088 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5089 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 5090 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5091 | |
| 5092 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 5093 | T.start(52.0 * 4.615 / 1000.0); |
| 5094 | alt { |
| 5095 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 5096 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 5097 | setverdict(pass); |
| 5098 | T.stop; |
| 5099 | } |
| 5100 | [] PCU.receive { repeat; } |
| 5101 | [] T.timeout { |
| 5102 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 5103 | /* Keep going, that's not the end of the world */ |
| 5104 | } |
| 5105 | } |
| 5106 | } |
| 5107 | |
| 5108 | testcase TC_pcu_ptcch() runs on test_CT { |
| 5109 | var L1ctlDlMessage dl; |
| 5110 | var octetstring data; |
| 5111 | timer T; |
| 5112 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5113 | f_init_with_pcuif(); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5114 | f_init_l1ctl(); |
| 5115 | f_l1_tune(L1CTL); |
| 5116 | |
| 5117 | /* Activate PDCH channel on TS7 */ |
| 5118 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5119 | |
| 5120 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5121 | 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] | 5122 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5123 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5124 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5125 | |
| 5126 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 5127 | for (var integer i := 0; i < 16; i := i + 1) { |
| 5128 | log("Sending an Access Burst towards the L1CTL interface"); |
| 5129 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 5130 | } |
| 5131 | |
| 5132 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 5133 | data := f_rnd_octstring(23); |
| 5134 | |
| 5135 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 5136 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 5137 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 5138 | |
| 5139 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 5140 | * let's give it more time in case if we miss the beginning. */ |
| 5141 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 5142 | alt { |
| 5143 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 5144 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 5145 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 5146 | frame := data)) -> value dl { |
| 5147 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 5148 | setverdict(pass); |
| 5149 | T.stop; |
| 5150 | } |
| 5151 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 5152 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 5153 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 5154 | l2_data := data)) -> value dl { |
| 5155 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 5156 | setverdict(pass); |
| 5157 | T.stop; |
| 5158 | } |
| 5159 | [] L1CTL.receive { repeat; } |
| 5160 | [] T.timeout { |
| 5161 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 5162 | } |
| 5163 | } |
| 5164 | } |
| 5165 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5166 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5167 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 5168 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5169 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5170 | f_init_l1ctl(); |
| 5171 | f_l1_tune(L1CTL); |
| 5172 | |
| 5173 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5174 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 5175 | |
| 5176 | T.start; |
| 5177 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5178 | [] 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] | 5179 | setverdict(pass); |
| 5180 | } |
| 5181 | [] L1CTL.receive { repeat; } |
| 5182 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5183 | 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] | 5184 | } |
| 5185 | } |
| 5186 | } |
| 5187 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5188 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5189 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 5190 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5191 | f_init_with_pcuif(); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5192 | f_init_l1ctl(); |
| 5193 | f_l1_tune(L1CTL); |
| 5194 | |
| 5195 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5196 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 5197 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 5198 | |
| 5199 | T.start; |
| 5200 | alt { |
| 5201 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 5202 | setverdict(pass); |
| 5203 | } |
| 5204 | [] L1CTL.receive { repeat; } |
| 5205 | [] T.timeout { |
| 5206 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 5207 | } |
| 5208 | } |
| 5209 | } |
| 5210 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5211 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 5212 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 5213 | var octetstring imm_ass := f_rnd_octstring(23); |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5214 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5215 | f_init_l1ctl(); |
| 5216 | f_l1_tune(L1CTL); |
| 5217 | |
| 5218 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 5219 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 5220 | |
| 5221 | timer T := 0.5; |
| 5222 | T.start; |
| 5223 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5224 | [] 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] | 5225 | /* TODO: verify paging group */ |
| 5226 | setverdict(pass); |
| 5227 | } |
| 5228 | [] L1CTL.receive { repeat; } |
| 5229 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5230 | 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] | 5231 | } |
| 5232 | } |
| 5233 | } |
| 5234 | |
| 5235 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 5236 | testcase TC_pcu_rach_content() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5237 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5238 | f_init_l1ctl(); |
| 5239 | f_l1_tune(L1CTL); |
| 5240 | |
| 5241 | var GsmFrameNumber fn_last := 0; |
| 5242 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5243 | var OCT1 ra := f_rnd_ra_ps(); |
| 5244 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 5245 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5246 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5247 | } |
| 5248 | fn_last := fn; |
| 5249 | |
| 5250 | timer T := 2.0; |
| 5251 | T.start; |
| 5252 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5253 | [] 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] | 5254 | T.stop; |
| 5255 | } |
| 5256 | [] 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] | 5257 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5258 | } |
| 5259 | [] PCU.receive { repeat; } |
| 5260 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5261 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5262 | } |
| 5263 | } |
| 5264 | } |
| 5265 | setverdict(pass); |
| 5266 | } |
| 5267 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5268 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 5269 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 5270 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 5271 | var template PCUIF_Message pcu_rach_ind; |
| 5272 | var GsmFrameNumber fn_last := 0; |
| 5273 | var L1ctlRachSynchSeq synch_seq; |
| 5274 | var PCUIF_BurstType pcu_bt; |
| 5275 | var GsmFrameNumber fn; |
| 5276 | var BIT11 ra11; |
| 5277 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5278 | f_init_with_pcuif(); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5279 | f_init_l1ctl(); |
| 5280 | f_l1_tune(L1CTL); |
| 5281 | |
| 5282 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5283 | /* We need to test both TS1 & TS2 */ |
| 5284 | if (i rem 2 == 0) { |
| 5285 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 5286 | pcu_bt := BURST_TYPE_1; |
| 5287 | } else { |
| 5288 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 5289 | pcu_bt := BURST_TYPE_2; |
| 5290 | } |
| 5291 | |
| 5292 | ra11 := f_rnd_ra11_ps(); |
| 5293 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 5294 | if (fn == fn_last) { |
| 5295 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5296 | "Two RACH in same FN?!?"); |
| 5297 | } |
| 5298 | fn_last := fn; |
| 5299 | |
| 5300 | /* Compose the expected message */ |
| 5301 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5302 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5303 | ra := bit2int(ra11), |
| 5304 | is_11bit := 1, |
| 5305 | burst_type := pcu_bt, |
| 5306 | fn := fn); |
| 5307 | |
| 5308 | timer T := 2.0; |
| 5309 | T.start; |
| 5310 | alt { |
| 5311 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 5312 | T.stop; |
| 5313 | } |
| 5314 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 5315 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 5316 | } |
| 5317 | [] PCU.receive { repeat; } |
| 5318 | [] T.timeout { |
| 5319 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 5320 | } |
| 5321 | } |
| 5322 | } |
| 5323 | setverdict(pass); |
| 5324 | } |
| 5325 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5326 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 5327 | runs on test_CT { |
| 5328 | var template PCUIF_send_data sdt; |
| 5329 | var PCUIF_send_data sd; |
| 5330 | var int16_t lqual_cb; |
| 5331 | timer T := 1.0; |
| 5332 | |
| 5333 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 5334 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 5335 | |
| 5336 | /* Send a random PDTCH frame over Um */ |
| 5337 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 5338 | '0000'O & f_rnd_octstring(21))); |
| 5339 | |
| 5340 | T.start; |
| 5341 | alt { |
| 5342 | /* If expected link quality is above the threshold */ |
| 5343 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 5344 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 5345 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 5346 | |
| 5347 | /* Make sure the actual link quality matches the expected value */ |
| 5348 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 5349 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 5350 | "expected value ", lqual_cb_exp)); |
| 5351 | } else { |
| 5352 | setverdict(pass); |
| 5353 | } |
| 5354 | } |
| 5355 | /* If expected link quality is below the threshold */ |
| 5356 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 5357 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5358 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 5359 | } |
| 5360 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 5361 | [] PCU.receive { repeat; } |
| 5362 | [lqual_cb_exp < thresh] T.timeout { |
| 5363 | log("Rx nothing, as expected"); |
| 5364 | setverdict(pass); |
| 5365 | } |
| 5366 | [lqual_cb_exp >= thresh] T.timeout { |
| 5367 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5368 | "Timeout waiting for PCUIF_DATA.ind"); |
| 5369 | } |
| 5370 | } |
| 5371 | } |
| 5372 | |
| 5373 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 5374 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5375 | f_init_with_pcuif(); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5376 | PCU.clear; |
| 5377 | |
| 5378 | f_init_l1ctl(); |
| 5379 | f_l1_tune(L1CTL); |
| 5380 | |
| 5381 | /* Activate a PDCH channel on TS7 */ |
| 5382 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5383 | |
| 5384 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5385 | 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] | 5386 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5387 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5388 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5389 | |
| 5390 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 5391 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 5392 | var TrxcMessage ret; |
| 5393 | |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 5394 | 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] | 5395 | |
| 5396 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 5397 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 5398 | } |
| 5399 | } |
| 5400 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5401 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 5402 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5403 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5404 | |
| 5405 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5406 | var MobileIdentityLV mi_lv; |
| 5407 | var octetstring mi_lv_enc; |
| 5408 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5409 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5410 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5411 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5412 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5413 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5414 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5415 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5416 | |
| 5417 | /* Fancy encoding for PCUIF */ |
| 5418 | mi_lv := valueof(ts_MI_LV(mi)); |
| 5419 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 5420 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5421 | |
| 5422 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5423 | 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] | 5424 | T.start; |
| 5425 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5426 | [] 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] | 5427 | } |
| 5428 | [] 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] | 5429 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5430 | } |
| 5431 | [] PCU.receive { repeat; } |
| 5432 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5433 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5434 | } |
| 5435 | } |
| 5436 | } |
| 5437 | setverdict(pass); |
| 5438 | } |
| 5439 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5440 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 5441 | testcase TC_pcu_time_ind() runs on test_CT { |
| 5442 | var PCUIF_send_data pcu_sd; |
| 5443 | var integer num_time_ind := 0; |
| 5444 | var integer first_fn, last_fn; |
| 5445 | var float test_duration := 5.0; |
| 5446 | timer T; |
| 5447 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5448 | f_init_with_pcuif(); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5449 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5450 | |
| 5451 | PCU.clear; |
| 5452 | T.start(test_duration); |
| 5453 | alt { |
| 5454 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 5455 | num_time_ind := num_time_ind + 1; |
| 5456 | if (not isbound(first_fn)) { |
| 5457 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 5458 | } |
| 5459 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 5460 | repeat; |
| 5461 | } |
| 5462 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 5463 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 5464 | repeat; |
| 5465 | } |
| 5466 | [] PCU.receive { |
| 5467 | repeat; |
| 5468 | } |
| 5469 | [] T.timeout {} |
| 5470 | } |
| 5471 | var integer fn_expired := last_fn - first_fn; |
| 5472 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 5473 | |
| 5474 | /* verify the number of frames expired matches our expectation */ |
| 5475 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5476 | 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] | 5477 | 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] | 5478 | if (not match(fn_expired, t_fn_expected)) { |
| 5479 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5480 | } |
| 5481 | |
| 5482 | /* There are three TIME.ind in every fn MOD 13 */ |
| 5483 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 5484 | /* Add some tolerance */ |
| 5485 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 5486 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 5487 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 5488 | } |
| 5489 | |
| 5490 | setverdict(pass); |
| 5491 | } |
| 5492 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5493 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 5494 | testcase TC_pcu_rts_req() runs on test_CT { |
| 5495 | var PCUIF_send_data pcu_sd; |
| 5496 | var integer first_fn, last_fn; |
| 5497 | var integer num_rts_pdtch := 0; |
| 5498 | var integer num_rts_ptcch := 0; |
| 5499 | var float test_duration := 5.0; |
| 5500 | timer T; |
| 5501 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5502 | f_init_with_pcuif(); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5503 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5504 | |
| 5505 | PCU.clear; |
| 5506 | T.start(test_duration); |
| 5507 | alt { |
| 5508 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 5509 | -> value pcu_sd { |
| 5510 | num_rts_pdtch := num_rts_pdtch + 1; |
| 5511 | if (not isbound(first_fn)) { |
| 5512 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5513 | } |
| 5514 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5515 | repeat; |
| 5516 | } |
| 5517 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 5518 | -> value pcu_sd { |
| 5519 | num_rts_ptcch := num_rts_ptcch + 1; |
| 5520 | if (not isbound(first_fn)) { |
| 5521 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5522 | } |
| 5523 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5524 | repeat; |
| 5525 | } |
| 5526 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 5527 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 5528 | repeat; |
| 5529 | } |
| 5530 | [] PCU.receive { |
| 5531 | repeat; |
| 5532 | } |
| 5533 | [] T.timeout {} |
| 5534 | } |
| 5535 | var integer fn_expired := last_fn - first_fn; |
| 5536 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 5537 | ", num_rts_ptcch=", num_rts_ptcch); |
| 5538 | |
| 5539 | /* verify the number of frames expired matches our expectation */ |
| 5540 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5541 | 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] | 5542 | 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] | 5543 | if (not match(fn_expired, t_fn_expected)) { |
| 5544 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5545 | } |
| 5546 | |
| 5547 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 5548 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 5549 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 5550 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 5551 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 5552 | t_ptcch_exp); |
| 5553 | } |
| 5554 | |
| 5555 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 5556 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 5557 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 5558 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 5559 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 5560 | t_pdtch_exp); |
| 5561 | } |
| 5562 | |
| 5563 | setverdict(pass); |
| 5564 | } |
| 5565 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5566 | /* test for generating Abis side OML ALERT from the PCU */ |
| 5567 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 5568 | var PCUIF_send_data pcu_sd; |
| 5569 | var integer num_time_ind := 0; |
| 5570 | var integer first_fn, last_fn; |
| 5571 | var float test_duration := 5.0; |
| 5572 | timer T; |
| 5573 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5574 | f_init_with_pcuif(); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5575 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5576 | |
| 5577 | /* re-connect CTRL port from BTS to BSC */ |
| 5578 | f_ipa_ctrl_stop(); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 5579 | 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] | 5580 | |
| 5581 | /* Send that OML Alert */ |
| 5582 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 5583 | |
| 5584 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 5585 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 5586 | setverdict(pass); |
| 5587 | } |
| 5588 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5589 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 5590 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 5591 | var PCUIF_Message first_info; |
| 5592 | var integer pcu_conn_id := -1; |
| 5593 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5594 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 5595 | var OCT4 tlli := '01020304'O; |
| 5596 | var OCT1 cause := '23'O; |
| 5597 | timer T := 5.0; |
| 5598 | |
| 5599 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5600 | |
| 5601 | f_l1_tune(L1CTL); |
| 5602 | RSL.clear; |
| 5603 | |
| 5604 | f_est_dchan(); |
| 5605 | L1CTL.clear; |
| 5606 | |
| 5607 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 5608 | |
| 5609 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 5610 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 5611 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 5612 | |
| 5613 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 5614 | T.start; |
| 5615 | alt { |
| 5616 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 5617 | setverdict(pass); |
| 5618 | } |
| 5619 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 5620 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 5621 | } |
| 5622 | [] PCU.receive { |
| 5623 | repeat; |
| 5624 | } |
| 5625 | [] T.timeout { |
| 5626 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 5627 | } |
| 5628 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 5629 | |
| 5630 | /* release the channel */ |
| 5631 | f_rsl_chan_deact(); |
| 5632 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5633 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5634 | } |
| 5635 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 5636 | var ConnHdlrPars pars; |
| 5637 | var ConnHdlr vc_conn; |
| 5638 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5639 | f_init_with_pcuif(); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5640 | |
| 5641 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 5642 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 5643 | vc_conn.done; |
| 5644 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5645 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5646 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 5647 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5648 | var boolean connected := false; |
| 5649 | var UD_connect_result cr; |
| 5650 | var integer cid; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5651 | timer T := 5.0; |
| 5652 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5653 | var template UD_Result tr_ok := { result_code := SUCCESS, err := omit }; |
| 5654 | var template UD_Result tr_err := { result_code := ERROR, err := ? }; |
| 5655 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5656 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5657 | f_init_with_pcuif(); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5658 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5659 | /* try to establish a second connection */ |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5660 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 5661 | T.start; |
| 5662 | alt { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5663 | /* the IUT will first accept() the new connection, and close() it immediately */ |
| 5664 | [not connected] PCU.receive(UD_connect_result:{ id := ?, result := tr_ok }) -> value cr { |
| 5665 | log("BTS has accept()ed connection"); |
| 5666 | connected := true; |
| 5667 | cid := cr.id; |
| 5668 | repeat; |
| 5669 | } |
| 5670 | [connected] PCU.receive(UD_connect_result:{ id := cid, result := tr_err }) { |
| 5671 | log("BTS has close()d connection"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5672 | setverdict(pass); |
| 5673 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5674 | /* ignore other messages related to the first connection */ |
| 5675 | [] PCU.receive { repeat; } |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5676 | [] T.timeout { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5677 | setverdict(fail, "Timeout waiting for connection result"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5678 | } |
| 5679 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5680 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5681 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5682 | } |
| 5683 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 5684 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 5685 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 5686 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5687 | f_init_with_pcuif(); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 5688 | |
| 5689 | f_sleep(1.0); |
| 5690 | |
| 5691 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5692 | g_pcu_conn_id := -1; |
| 5693 | |
| 5694 | f_sleep(1.0); |
| 5695 | |
| 5696 | /* re-connect */ |
| 5697 | PCU.clear; |
| 5698 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5699 | setverdict(pass); |
| 5700 | |
| 5701 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5702 | } |
| 5703 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5704 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5705 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 5706 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5707 | var L1ctlDlMessage l1_dl; |
| 5708 | var SystemInformation si; |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 5709 | var integer rc; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5710 | timer T := 5.0; |
| 5711 | T.start; |
| 5712 | alt { |
| 5713 | [] 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] | 5714 | rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si); |
| 5715 | if (rc != 0 or si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5716 | repeat; |
| 5717 | } |
| 5718 | } |
| 5719 | [] pt.receive { |
| 5720 | repeat; |
| 5721 | } |
| 5722 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5723 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5724 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5725 | } |
| 5726 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5727 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5728 | } |
| 5729 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5730 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 5731 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 5732 | runs on test_CT return boolean { |
| 5733 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 5734 | |
| 5735 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 5736 | return si.payload.si3.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5737 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 5738 | return si.payload.si4.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5739 | } |
| 5740 | |
| 5741 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 5742 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5743 | } |
| 5744 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5745 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 5746 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 5747 | runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5748 | f_init(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5749 | f_init_l1ctl(); |
| 5750 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5751 | f_sleep(2.0); |
| 5752 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5753 | |
| 5754 | if (f_si_has_gprs_indicator(si_type)) { |
| 5755 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5756 | } else { |
| 5757 | setverdict(pass); |
| 5758 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5759 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5760 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5761 | } |
| 5762 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5763 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 5764 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5765 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5766 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5767 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 5768 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5769 | } |
| 5770 | |
| 5771 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 5772 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 5773 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5774 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5775 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5776 | f_init_l1ctl(); |
| 5777 | f_l1_tune(L1CTL); |
| 5778 | |
| 5779 | f_sleep(2.0); |
| 5780 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5781 | |
| 5782 | if (not f_si_has_gprs_indicator(si_type)) { |
| 5783 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5784 | } else { |
| 5785 | setverdict(pass); |
| 5786 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5787 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5788 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5789 | } |
| 5790 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5791 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 5792 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 5793 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5794 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5795 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 5796 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 5797 | } |
| 5798 | |
| 5799 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 5800 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 5801 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5802 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5803 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5804 | f_init_l1ctl(); |
| 5805 | f_l1_tune(L1CTL); |
| 5806 | |
| 5807 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5808 | g_pcu_conn_id := -1; |
| 5809 | |
| 5810 | f_sleep(1.0); |
| 5811 | |
| 5812 | /* re-connect */ |
| 5813 | PCU.clear; |
| 5814 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5815 | |
| 5816 | f_sleep(2.0); |
| 5817 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5818 | |
| 5819 | if (f_si_has_gprs_indicator(si_type)) { |
| 5820 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5821 | } else { |
| 5822 | setverdict(pass); |
| 5823 | } |
| 5824 | |
| 5825 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5826 | } |
| 5827 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5828 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 5829 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5830 | } |
| 5831 | |
| 5832 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 5833 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5834 | } |
| 5835 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5836 | /* 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) */ |
| 5837 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 5838 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 5839 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5840 | f_init_with_pcuif(); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5841 | |
Harald Welte | 7622022 | 2020-10-11 20:32:44 +0200 | [diff] [blame] | 5842 | /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct |
| 5843 | * information */ |
| 5844 | timer T := 2.0; |
| 5845 | T.start; |
| 5846 | alt { |
| 5847 | [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; } |
| 5848 | [] T.timeout {} |
| 5849 | } |
| 5850 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5851 | /* Verify cell_id */ |
| 5852 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 5853 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 5854 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 5855 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 5856 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 5857 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5858 | } |
| 5859 | |
| 5860 | /* Verify LAC */ |
| 5861 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 5862 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 5863 | if (lac_si3 != lac_pcu) { |
| 5864 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 5865 | } |
| 5866 | |
| 5867 | setverdict(pass); |
| 5868 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5869 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5870 | /* Verify hopping parameters in the INFO.ind message (version >= 10) */ |
| 5871 | testcase TC_pcu_info_ind_fh_params() runs on test_CT { |
| 5872 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5873 | var FreqHopPars fhp; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5874 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5875 | f_init_with_pcuif(); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5876 | |
| 5877 | info_ind := g_pcu_last_info.u.info_ind; |
| 5878 | |
| 5879 | for (var integer i := 0; i < mp_transceiver_num; i := i + 1) { |
| 5880 | for (var integer tn := 0; tn < 8; tn := tn + 1) { |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5881 | if (info_ind.trx[i].pdch_mask[tn] != '1'B) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5882 | /* Skip inactive timeslots */ |
| 5883 | continue; |
| 5884 | } |
| 5885 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5886 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | 7e1d0a2 | 2020-09-17 19:48:11 +0700 | [diff] [blame] | 5887 | { f_resolve_fh_params(fhp, tn, trx_nr := i); } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5888 | else |
| 5889 | { fhp.enabled := false; } |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5890 | |
| 5891 | var template PCUIF_InfoTrxTs tr_ts; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5892 | if (fhp.enabled) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5893 | tr_ts := tr_PCUIF_InfoTrxTsH1( |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5894 | hsn := fhp.maio_hsn.hsn, |
| 5895 | maio := fhp.maio_hsn.maio, |
| 5896 | ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B), |
Vadim Yanitskiy | aa553ed | 2020-09-17 19:44:32 +0700 | [diff] [blame] | 5897 | ma_bit_len := mp_transceiver_num); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5898 | } else { |
| 5899 | tr_ts := tr_PCUIF_InfoTrxTsH0; |
| 5900 | } |
| 5901 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5902 | var PCUIF_InfoTrxTs ts := info_ind.trx[i].ts[tn]; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5903 | log("Checking timeslot #", tn, " of trx#", i, ": ", ts); |
| 5904 | if (not match(ts, tr_ts)) { |
| 5905 | setverdict(fail, "Hopping parameters do not match: ", |
| 5906 | "received ", ts, " vs expected ", tr_ts); |
| 5907 | } else { |
| 5908 | setverdict(pass); |
| 5909 | } |
| 5910 | } |
| 5911 | } |
| 5912 | } |
| 5913 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5914 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5915 | testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT { |
| 5916 | f_init_vty_bsc(); |
| 5917 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 5918 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 5919 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5920 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5921 | |
| 5922 | 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] | 5923 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 5924 | addr_type := { PCUIF_ADDR_TYPE_IPV4, ? }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 5925 | 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] | 5926 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5927 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5928 | if (not match(remote_addr, tr_remote_addr)) { |
| 5929 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5930 | } |
| 5931 | |
| 5932 | setverdict(pass); |
| 5933 | } |
| 5934 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5935 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5936 | testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT { |
| 5937 | f_init_vty_bsc(); |
| 5938 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee"); |
| 5939 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5940 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5941 | |
| 5942 | 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] | 5943 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 5944 | addr_type := { PCUIF_ADDR_TYPE_IPV6, ? }, |
| 5945 | addr := { f_inet6_addr("fd00::ca:ff:ee"), ? } |
| 5946 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5947 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5948 | if (not match(remote_addr, tr_remote_addr)) { |
| 5949 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5950 | } |
| 5951 | |
| 5952 | setverdict(pass); |
| 5953 | } |
| 5954 | |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 5955 | /* Verify coding of two NSVCs in the INFO.ind message */ |
| 5956 | testcase TC_pcu_socket_two_nsvc() runs on test_CT { |
| 5957 | f_init_vty_bsc(); |
| 5958 | |
| 5959 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 nsvci 1234"); |
| 5960 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 local udp port 1234"); |
| 5961 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 5962 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote udp port 1234"); |
| 5963 | |
| 5964 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 nsvci 5678"); |
| 5965 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 local udp port 5678"); |
| 5966 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote ip fd00::ca:ff:ee"); |
| 5967 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote udp port 5678"); |
| 5968 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5969 | f_init_with_pcuif(); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 5970 | |
| 5971 | var PCUIF_info_ind info_ind := g_pcu_last_info.u.info_ind; |
| 5972 | var PCUIF_RemoteAddr remote_addr := info_ind.remote_addr; |
| 5973 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 5974 | addr_type := { PCUIF_ADDR_TYPE_IPV4, PCUIF_ADDR_TYPE_IPV6 }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 5975 | addr := { |
| 5976 | f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), |
| 5977 | f_inet6_addr("fd00::ca:ff:ee") |
| 5978 | } |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 5979 | }; |
| 5980 | |
| 5981 | if (not match(info_ind.nsvci, { 1234, 5678 })) |
| 5982 | { setverdict(fail, "NSVCI ", info_ind.nsvci, " does not match { 1234, 5678 }"); } |
| 5983 | if (not match(remote_addr, tr_remote_addr)) |
| 5984 | { setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); } |
| 5985 | if (not match(info_ind.local_port, { 1234, 5678 })) |
| 5986 | { setverdict(fail, "NSVC lport ", info_ind.local_port, " does not match { 1234, 5678 }"); } |
| 5987 | if (not match(info_ind.remote_port, { 1234, 5678 })) |
| 5988 | { setverdict(fail, "NSVC rport ", info_ind.remote_port, " does not match { 1234, 5678 }"); } |
| 5989 | |
| 5990 | setverdict(pass); |
| 5991 | } |
| 5992 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 5993 | /* Verify periodic interference reports on PDCH */ |
| 5994 | testcase TC_pcu_interf_ind() runs on test_CT { |
| 5995 | var template PCUIF_Message tr_interf_ind; |
| 5996 | var template PCUIF_interf ts_interf; |
| 5997 | var integer interf_ind_num := 0; |
| 5998 | var PCUIF_send_data sd; |
| 5999 | timer T; |
| 6000 | |
| 6001 | f_init_with_pcuif(); |
| 6002 | f_TC_pcu_act_req(0, 0, 7, true); |
| 6003 | |
| 6004 | /* We need trxcon for NOPE indications */ |
| 6005 | f_init_l1ctl(); |
| 6006 | f_l1_tune(L1CTL); |
| 6007 | |
| 6008 | /* Expect -120 .. -90 dBm on TS7 of BTS0/TRX0 */ |
| 6009 | ts_interf := { 0, 0, 0, 0, 0, 0, 0, (90..120) }; |
| 6010 | tr_interf_ind := tr_PCUIF_INTERF_IND( |
| 6011 | bts_nr := 0, |
| 6012 | trx_nr := 0, |
| 6013 | fn := ?, |
| 6014 | interf := ts_interf |
| 6015 | ); |
| 6016 | |
| 6017 | /* 4 SACCH periods => 4 reports (plus some guard time) */ |
| 6018 | var float Tval := int2float(4 * 480) / 1000.0 + 0.5; |
| 6019 | |
| 6020 | /* Let it some time to stabilize */ |
| 6021 | f_sleep(0.5); |
| 6022 | PCU.clear; |
| 6023 | |
| 6024 | T.start(Tval); |
| 6025 | alt { |
| 6026 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_interf_ind)) -> value sd { |
| 6027 | /* Check TDMA frame number period */ |
| 6028 | if (sd.data.u.interf_ind.fn mod 104 != 0) { |
| 6029 | setverdict(fail, "Odd TDMA frame number := ", |
| 6030 | sd.data.u.interf_ind.fn); |
| 6031 | } |
| 6032 | interf_ind_num := interf_ind_num + 1; |
| 6033 | if (interf_ind_num < 4) |
| 6034 | { repeat; } |
| 6035 | } |
| 6036 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) -> value sd { |
| 6037 | setverdict(fail, "Received unexpected interference report: ", sd.data); |
| 6038 | } |
| 6039 | [] PCU.receive { repeat; } |
| 6040 | [] T.timeout { |
| 6041 | setverdict(fail, "Timeout waiting for interference reports"); |
| 6042 | } |
| 6043 | } |
| 6044 | |
| 6045 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6046 | } |
| 6047 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6048 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6049 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6050 | ***********************************************************************/ |
| 6051 | |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6052 | private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp, |
| 6053 | integer bts_nr, integer trx_nr) |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6054 | runs on ConnHdlr { |
| 6055 | var PCUIF_send_data sd; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6056 | |
| 6057 | [] 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] | 6058 | 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] | 6059 | if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) { |
| 6060 | repeat; |
| 6061 | } |
| 6062 | } |
| 6063 | } |
| 6064 | |
| 6065 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6066 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6067 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6068 | PCU.clear; |
| 6069 | f_rsl_chan_act(g_pars.chan_mode); |
| 6070 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6071 | timer T_wait := 2.0; |
| 6072 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6073 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6074 | [] 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] | 6075 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6076 | [] T_wait.timeout { |
| 6077 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6078 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6079 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6080 | } |
| 6081 | /* try to activate this PDCH from the PCU point of view */ |
| 6082 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6083 | /* FIXME: is there a response? */ |
| 6084 | } |
| 6085 | |
| 6086 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6087 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6088 | /* Send RSL CHAN REL (deactivate) */ |
| 6089 | PCU.clear; |
| 6090 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 6091 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6092 | timer T_wait := 2.0; |
| 6093 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6094 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6095 | [] 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] | 6096 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6097 | [] T_wait.timeout { |
| 6098 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6099 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6100 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6101 | } |
| 6102 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6103 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6104 | alt { |
| 6105 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 6106 | setverdict(pass); |
| 6107 | } |
| 6108 | [] RSL.receive { repeat; } |
| 6109 | } |
| 6110 | } |
| 6111 | |
| 6112 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6113 | 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] | 6114 | var PCUIF_Message first_info; |
| 6115 | var integer ts_nr := g_chan_nr.tn; |
| 6116 | var integer trx_nr := 0; |
| 6117 | var integer bts_nr := 0; |
| 6118 | var integer pcu_conn_id := -1; |
| 6119 | |
| 6120 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6121 | |
| 6122 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6123 | f_sleep(3.0); |
| 6124 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6125 | setverdict(pass); |
| 6126 | } |
| 6127 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 6128 | var ConnHdlrPars pars; |
| 6129 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6130 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6131 | |
| 6132 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6133 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 6134 | vc_conn.done; |
| 6135 | } |
| 6136 | |
| 6137 | /* 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] | 6138 | 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] | 6139 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6140 | var integer pcu_conn_id := -1; |
| 6141 | |
| 6142 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6143 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 6144 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 6145 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 6146 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6147 | setverdict(pass); |
| 6148 | } |
| 6149 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 6150 | var ConnHdlrPars pars; |
| 6151 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6152 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6153 | |
| 6154 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6155 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 6156 | vc_conn.done; |
| 6157 | } |
| 6158 | |
| 6159 | /* 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] | 6160 | 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] | 6161 | var PCUIF_Message first_info; |
| 6162 | var integer ts_nr := g_chan_nr.tn; |
| 6163 | var integer trx_nr := 0; |
| 6164 | var integer bts_nr := 0; |
| 6165 | var integer pcu_conn_id := -1; |
| 6166 | |
| 6167 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6168 | |
| 6169 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 6170 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 6171 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6172 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6173 | setverdict(pass); |
| 6174 | } |
| 6175 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 6176 | var ConnHdlrPars pars; |
| 6177 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6178 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6179 | |
| 6180 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6181 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 6182 | vc_conn.done; |
| 6183 | } |
| 6184 | |
| 6185 | /* 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] | 6186 | 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] | 6187 | var PCUIF_Message first_info; |
| 6188 | var integer ts_nr := g_chan_nr.tn; |
| 6189 | var integer trx_nr := 0; |
| 6190 | var integer bts_nr := 0; |
| 6191 | var integer pcu_conn_id := -1; |
| 6192 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 6193 | |
| 6194 | /* register for the TCH/F channel number */ |
| 6195 | f_rslem_register(0, chan_nr); |
| 6196 | |
| 6197 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6198 | |
| 6199 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 6200 | "RSL CHAN ACT"); |
| 6201 | setverdict(pass); |
| 6202 | } |
| 6203 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 6204 | var ConnHdlrPars pars; |
| 6205 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6206 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6207 | |
| 6208 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6209 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 6210 | vc_conn.done; |
| 6211 | } |
| 6212 | |
| 6213 | /* 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] | 6214 | 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] | 6215 | var PCUIF_Message first_info; |
| 6216 | var integer ts_nr := g_chan_nr.tn; |
| 6217 | var integer trx_nr := 0; |
| 6218 | var integer bts_nr := 0; |
| 6219 | var integer pcu_conn_id := -1; |
| 6220 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 6221 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 6222 | |
| 6223 | /* register for the TCH/H channel numbers */ |
| 6224 | f_rslem_register(0, chan_nr[0]); |
| 6225 | f_rslem_register(0, chan_nr[1]); |
| 6226 | |
| 6227 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6228 | |
| 6229 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 6230 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 6231 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 6232 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 6233 | setverdict(pass); |
| 6234 | } |
| 6235 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 6236 | var ConnHdlrPars pars; |
| 6237 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6238 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6239 | |
| 6240 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6241 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 6242 | vc_conn.done; |
| 6243 | } |
| 6244 | |
Pau Espin Pedrol | 8e57ac1 | 2021-06-29 17:04:24 +0200 | [diff] [blame] | 6245 | /* try to RSL CHAN ACT the SDCCH8 on an osmocom-style PDCH */ |
| 6246 | private function f_TC_dyn_osmo_pdch_sdcch8_act(charstring id) runs on ConnHdlr { |
| 6247 | var PCUIF_Message first_info; |
| 6248 | var integer ts_nr := g_chan_nr.tn; |
| 6249 | var integer trx_nr := 0; |
| 6250 | var integer bts_nr := 0; |
| 6251 | var integer pcu_conn_id := -1; |
| 6252 | var RslChannelNr chan_nr[8] := { valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 0)), |
| 6253 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 1)), |
| 6254 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 2)), |
| 6255 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 3)), |
| 6256 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 4)), |
| 6257 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 5)), |
| 6258 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 6)), |
| 6259 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 7)) }; |
| 6260 | |
| 6261 | /* register for the TCH/H channel numbers */ |
| 6262 | for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) { |
| 6263 | f_rslem_register(0, chan_nr[i]); |
| 6264 | } |
| 6265 | |
| 6266 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6267 | |
| 6268 | for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) { |
| 6269 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[i], g_pars.chan_mode), |
| 6270 | tr_RSL_CHAN_ACT_ACK(chan_nr[i]), "RSL CHAN ACT [" & int2str(i) & "]"); |
| 6271 | } |
| 6272 | setverdict(pass); |
| 6273 | } |
| 6274 | testcase TC_dyn_osmo_pdch_sdcch8_act() runs on test_CT { |
| 6275 | var ConnHdlrPars pars; |
| 6276 | var ConnHdlr vc_conn; |
| 6277 | f_init(); |
| 6278 | |
| 6279 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6280 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_sdcch8_act), pars, true); |
| 6281 | vc_conn.done; |
| 6282 | } |
| 6283 | |
Vadim Yanitskiy | 64043d8 | 2021-10-03 15:00:20 +0600 | [diff] [blame] | 6284 | /* Reproduce a race condition described in OS#5245 */ |
| 6285 | private function f_rsl_chan_act_deact(charstring id) runs on ConnHdlr { |
| 6286 | f_rsl_chan_act(g_pars.chan_mode); |
| 6287 | f_sleep(1.0); |
| 6288 | f_rsl_chan_deact(); |
| 6289 | setverdict(pass); |
| 6290 | } |
| 6291 | testcase TC_dyn_osmo_pdch_tchh_race_act() runs on test_CT { |
| 6292 | var ConnHdlrPars pars[2]; |
| 6293 | var ConnHdlr vc_conn[2]; |
| 6294 | var TrxcMessage rsp; |
| 6295 | |
| 6296 | f_init(); |
| 6297 | |
| 6298 | /* Configure an artificial delay of 200 ms for TRXC RSP messages */ |
| 6299 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6300 | ts_TRXC_FAKE_TRXC_DELAY(200)); |
| 6301 | |
| 6302 | /* Activate all sub-channels of TCH/H on TS4 immediately in hope that the second |
| 6303 | * CHANnel ACTIVation message will be handled before the PHY responds to 'SETSLOT' */ |
| 6304 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6305 | /* TS4 is an Osmocom style dynamic timeslot, we want it to be TCH/H */ |
| 6306 | pars[i] := valueof(t_Pars(t_RslChanNr_Lm(4, i), ts_RSL_ChanMode_SIGN)); |
| 6307 | vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact), |
| 6308 | pars[i], l1ctl := false); |
| 6309 | } |
| 6310 | |
| 6311 | /* Wait for all components to finish */ |
| 6312 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6313 | vc_conn[i].done; |
| 6314 | } |
| 6315 | |
| 6316 | /* Disable the artificial delay for TRXC RSP messages */ |
| 6317 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6318 | ts_TRXC_FAKE_TRXC_DELAY(0)); |
| 6319 | } |
| 6320 | testcase TC_dyn_osmo_pdch_sdcch8_race_act() runs on test_CT { |
| 6321 | var ConnHdlrPars pars[8]; |
| 6322 | var ConnHdlr vc_conn[8]; |
| 6323 | var TrxcMessage rsp; |
| 6324 | |
| 6325 | f_init(); |
| 6326 | |
| 6327 | /* Configure an artificial delay of 200 ms for TRXC RSP messages */ |
| 6328 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6329 | ts_TRXC_FAKE_TRXC_DELAY(200)); |
| 6330 | |
| 6331 | /* Activate all sub-channels of SDCCH/8 on TS4 immediately in hope that subsequent |
| 6332 | * CHANnel ACTIVation messages will be handled before the PHY responds to 'SETSLOT' */ |
| 6333 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6334 | /* TS4 is an Osmocom style dynamic timeslot, we want it to be SDCCH/8 */ |
| 6335 | pars[i] := valueof(t_Pars(t_RslChanNr_SDCCH8(4, i), ts_RSL_ChanMode_SIGN)); |
| 6336 | vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact), |
| 6337 | pars[i], l1ctl := false); |
| 6338 | } |
| 6339 | |
| 6340 | /* Wait for all components to finish */ |
| 6341 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6342 | vc_conn[i].done; |
| 6343 | } |
| 6344 | |
| 6345 | /* Disable the artificial delay for TRXC RSP messages */ |
| 6346 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6347 | ts_TRXC_FAKE_TRXC_DELAY(0)); |
| 6348 | } |
| 6349 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6350 | /*********************************************************************** |
| 6351 | * IPA Style Dynamic Timeslot Support |
| 6352 | ***********************************************************************/ |
| 6353 | |
| 6354 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6355 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6356 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6357 | PCU.clear; |
| 6358 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6359 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6360 | timer T_wait := 2.0; |
| 6361 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6362 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6363 | [] 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] | 6364 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6365 | [] T_wait.timeout { |
| 6366 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6367 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6368 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6369 | } |
| 6370 | /* try to activate this PDCH from the PCU point of view */ |
| 6371 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6372 | /* FIXME: is there a response? */ |
| 6373 | |
| 6374 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 6375 | } |
| 6376 | |
| 6377 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6378 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6379 | /* Send RSL CHAN REL (deactivate) */ |
| 6380 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 6381 | PCU.clear; |
| 6382 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6383 | timer T_wait := 2.0; |
| 6384 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6385 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6386 | [] 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] | 6387 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6388 | [] T_wait.timeout { |
| 6389 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6390 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6391 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6392 | } |
| 6393 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6394 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6395 | alt { |
| 6396 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 6397 | setverdict(pass); |
| 6398 | } |
| 6399 | [] RSL.receive { repeat; } |
| 6400 | } |
| 6401 | } |
| 6402 | |
| 6403 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6404 | 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] | 6405 | var PCUIF_Message first_info; |
| 6406 | var integer ts_nr := g_chan_nr.tn; |
| 6407 | var integer trx_nr := 0; |
| 6408 | var integer bts_nr := 0; |
| 6409 | var integer pcu_conn_id := -1; |
| 6410 | |
| 6411 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6412 | |
| 6413 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6414 | f_sleep(3.0); |
| 6415 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6416 | |
| 6417 | setverdict(pass); |
| 6418 | |
| 6419 | } |
| 6420 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 6421 | var ConnHdlrPars pars; |
| 6422 | var ConnHdlr vc_conn; |
| 6423 | f_init(); |
| 6424 | |
| 6425 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6426 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 6427 | vc_conn.done; |
| 6428 | } |
| 6429 | |
| 6430 | /* 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] | 6431 | 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] | 6432 | var PCUIF_Message first_info; |
| 6433 | var integer ts_nr := g_chan_nr.tn; |
| 6434 | var integer trx_nr := 0; |
| 6435 | var integer bts_nr := 0; |
| 6436 | var integer pcu_conn_id := -1; |
| 6437 | |
| 6438 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6439 | |
| 6440 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6441 | "RSL CHAN ACT"); |
| 6442 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6443 | "RF CHAN REL", true); |
| 6444 | setverdict(pass); |
| 6445 | } |
| 6446 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 6447 | var ConnHdlrPars pars; |
| 6448 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6449 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6450 | |
| 6451 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6452 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 6453 | vc_conn.done; |
| 6454 | } |
| 6455 | |
| 6456 | /* 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] | 6457 | 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] | 6458 | var PCUIF_Message first_info; |
| 6459 | var integer ts_nr := g_chan_nr.tn; |
| 6460 | var integer trx_nr := 0; |
| 6461 | var integer bts_nr := 0; |
| 6462 | var integer pcu_conn_id := -1; |
| 6463 | |
| 6464 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6465 | |
| 6466 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6467 | "RSL CHAN ACT"); |
| 6468 | |
| 6469 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6470 | alt { |
| 6471 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 6472 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6473 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6474 | } |
| 6475 | [] RSL.receive { repeat; } |
| 6476 | } |
| 6477 | |
| 6478 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6479 | "RF CHAN REL", true); |
| 6480 | setverdict(pass); |
| 6481 | } |
| 6482 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 6483 | var ConnHdlrPars pars; |
| 6484 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6485 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6486 | |
| 6487 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6488 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 6489 | vc_conn.done; |
| 6490 | } |
| 6491 | |
| 6492 | /* 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] | 6493 | 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] | 6494 | var PCUIF_Message first_info; |
| 6495 | var integer ts_nr := g_chan_nr.tn; |
| 6496 | var integer trx_nr := 0; |
| 6497 | var integer bts_nr := 0; |
| 6498 | var integer pcu_conn_id := -1; |
| 6499 | |
| 6500 | /* register for the TCH/F channel number */ |
| 6501 | f_rslem_register(0, g_chan_nr); |
| 6502 | |
| 6503 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6504 | |
| 6505 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6506 | |
| 6507 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6508 | "RSL CHAN ACT"); |
| 6509 | |
| 6510 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6511 | |
| 6512 | setverdict(pass); |
| 6513 | } |
| 6514 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 6515 | var ConnHdlrPars pars; |
| 6516 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6517 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6518 | |
| 6519 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6520 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 6521 | vc_conn.done; |
| 6522 | } |
| 6523 | |
| 6524 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6525 | /*********************************************************************** |
| 6526 | * LAPDm / RLL related |
| 6527 | ***********************************************************************/ |
| 6528 | |
| 6529 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 6530 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 6531 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6532 | var template (value) SacchL1Header l1h; |
| 6533 | |
| 6534 | /* 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] | 6535 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6536 | /* Compose dummy L1 header */ |
| 6537 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta); |
| 6538 | 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] | 6539 | } else { |
| 6540 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6541 | 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] | 6542 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6543 | } |
| 6544 | |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 6545 | friend type record RllTestCase { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6546 | uint3_t sapi, |
| 6547 | RslLinkId link_id, |
| 6548 | octetstring l3, |
| 6549 | boolean exp |
| 6550 | } |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 6551 | friend type record of RllTestCase RllTestCases; |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6552 | friend template RllTestCase t_EITC(template (present) uint3_t sapi, |
| 6553 | template (present) RslLinkId id, |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 6554 | octetstring l3, boolean exp) := { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6555 | sapi := sapi, |
| 6556 | link_id := id, |
| 6557 | l3 := l3, |
| 6558 | exp := exp |
| 6559 | } |
| 6560 | |
| 6561 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 6562 | * variety of logical channels */ |
| 6563 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 6564 | var ConnHdlrPars pars; |
| 6565 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6566 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6567 | |
| 6568 | /* test on each of the channels we have */ |
| 6569 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 6570 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 6571 | |
| 6572 | /* test each of the test cases on the current channel */ |
| 6573 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 6574 | pars.spec.rll := tcs[j]; |
| 6575 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 6576 | vc_conn := f_start_handler(fn, pars); |
| 6577 | vc_conn.done; |
| 6578 | } |
| 6579 | } |
| 6580 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6581 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6582 | } |
| 6583 | |
| 6584 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 6585 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 6586 | var RllTestCase tc := g_pars.spec.rll; |
| 6587 | timer T := 3.0; |
| 6588 | |
| 6589 | f_l1_tune(L1CTL); |
| 6590 | RSL.clear; |
| 6591 | |
| 6592 | /* activate the logical channel */ |
| 6593 | f_est_dchan(); |
| 6594 | L1CTL.clear; |
| 6595 | |
| 6596 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 6597 | T.start; |
| 6598 | alt { |
| 6599 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6600 | if (tc.exp) { |
| 6601 | setverdict(pass); |
| 6602 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6603 | 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] | 6604 | } |
| 6605 | } |
| 6606 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 6607 | if (tc.exp) { |
| 6608 | setverdict(pass); |
| 6609 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6610 | 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] | 6611 | } |
| 6612 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6613 | /* We also expect to receive the measurements */ |
| 6614 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6615 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6616 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6617 | } |
| 6618 | [not tc.exp] T.timeout { |
| 6619 | setverdict(pass); |
| 6620 | } |
| 6621 | } |
| 6622 | |
| 6623 | f_rsl_chan_deact(); |
| 6624 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6625 | f_rslem_unregister(0, g_chan_nr); |
| 6626 | } |
| 6627 | testcase TC_rll_est_ind() runs on test_CT { |
| 6628 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6629 | /* SAPI0 establishment (contention resolution) */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6630 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6631 | /* normal SAPI0 establishment */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6632 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6633 | /* SAPI 3 doesn't support contention resolution */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6634 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), '01020304'O, false)), |
| 6635 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), '01020304'O, false)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6636 | /* normal SAPI3 establishment on main DCCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6637 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6638 | /* normal SAPI3 establishment on SACCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6639 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6640 | }; |
| 6641 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 6642 | } |
| 6643 | |
| 6644 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 6645 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 6646 | var RllTestCase tc := g_pars.spec.rll; |
| 6647 | var L1ctlDlMessage dl; |
| 6648 | timer T := 3.0; |
| 6649 | |
| 6650 | f_l1_tune(L1CTL); |
| 6651 | RSL.clear; |
| 6652 | |
| 6653 | /* activate the logical channel */ |
| 6654 | f_est_dchan(); |
| 6655 | L1CTL.clear; |
| 6656 | |
| 6657 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 6658 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 6659 | T.start; |
| 6660 | alt { |
Vadim Yanitskiy | 0310f63 | 2021-06-01 01:22:24 +0200 | [diff] [blame] | 6661 | [] 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] | 6662 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6663 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6664 | } |
| 6665 | } |
| 6666 | |
| 6667 | f_rsl_chan_deact(); |
| 6668 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6669 | f_rslem_unregister(0, g_chan_nr); |
| 6670 | } |
| 6671 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 6672 | var RllTestCases tcs := { |
| 6673 | /* normal SAPI3 establishment on main DCCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6674 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true))//, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6675 | }; |
| 6676 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 6677 | } |
| 6678 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 6679 | var RllTestCases tcs := { |
| 6680 | /* normal SAPI3 establishment on SACCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6681 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6682 | } |
| 6683 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 6684 | } |
| 6685 | |
| 6686 | /* altstep to receive a LAPDm frame matching the given template */ |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 6687 | friend altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6688 | var L1ctlDlMessage dl; |
| 6689 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6690 | var LapdmFrame lapdm; |
| 6691 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6692 | if (dl.dl_info.link_id.c == SACCH) { |
| 6693 | /* remove L1 header */ |
| 6694 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 6695 | } |
| 6696 | if (ischosen(exp.ab)) { |
| 6697 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 6698 | } else if (ischosen(exp.b4)) { |
| 6699 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 6700 | } else if (ischosen(exp.bbis)) { |
| 6701 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 6702 | } |
| 6703 | log("Rx LAPDm ", lapdm); |
| 6704 | if (match(lapdm, exp)) { |
| 6705 | setverdict(pass); |
| 6706 | } else { |
| 6707 | repeat; |
| 6708 | } |
| 6709 | } |
| 6710 | [] L1CTL.receive { repeat; } |
| 6711 | } |
| 6712 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 6713 | timer T := t; |
| 6714 | T.start; |
| 6715 | alt { |
| 6716 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6717 | 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] | 6718 | } |
| 6719 | [] as_l1_exp_lapdm(exp); |
| 6720 | } |
| 6721 | } |
| 6722 | |
| 6723 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 6724 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 6725 | /* send SABM from MS -> BTS */ |
| 6726 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 6727 | /* expect RLL EST IND on Abis */ |
| 6728 | alt { |
| 6729 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 6730 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 6731 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6732 | 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] | 6733 | } |
| 6734 | [] RSL.receive { repeat; } |
| 6735 | } |
| 6736 | /* expect UA from BTS -> MS */ |
| 6737 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 6738 | } |
| 6739 | |
| 6740 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 6741 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 6742 | var RllTestCase tc := g_pars.spec.rll; |
| 6743 | |
| 6744 | f_l1_tune(L1CTL); |
| 6745 | RSL.clear; |
| 6746 | |
| 6747 | /* activate the logical channel */ |
| 6748 | f_est_dchan(); |
| 6749 | L1CTL.clear; |
| 6750 | |
| 6751 | /* first establish the link-layer */ |
| 6752 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6753 | |
| 6754 | /* then send the DISC */ |
| 6755 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 6756 | /* ... and expect the REL IND on the RSL side */ |
| 6757 | alt { |
| 6758 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 6759 | setverdict(pass); |
| 6760 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6761 | /* We also expect to receive the measurements */ |
| 6762 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6763 | } |
| 6764 | |
| 6765 | /* release the channel */ |
| 6766 | f_rsl_chan_deact(); |
| 6767 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6768 | f_rslem_unregister(0, g_chan_nr); |
| 6769 | } |
| 6770 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 6771 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6772 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6773 | }; |
| 6774 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6775 | } |
| 6776 | |
| 6777 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 6778 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6779 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6780 | }; |
| 6781 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6782 | } |
| 6783 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 6784 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6785 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6786 | }; |
| 6787 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6788 | } |
| 6789 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 6790 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6791 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6792 | }; |
| 6793 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6794 | } |
| 6795 | |
| 6796 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 6797 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 6798 | var RllTestCase tc := g_pars.spec.rll; |
| 6799 | f_l1_tune(L1CTL); |
| 6800 | RSL.clear; |
| 6801 | |
| 6802 | /* activate the logical channel */ |
| 6803 | f_est_dchan(); |
| 6804 | L1CTL.clear; |
| 6805 | |
| 6806 | /* first establish the link-layer */ |
| 6807 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6808 | |
| 6809 | /* then send the REL REQ via RSL */ |
| 6810 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 6811 | /* ... and expect the DISC on the Um side */ |
| 6812 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 6813 | [] 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] | 6814 | /* FIXME: send a UA in resposne to the DISC */ |
| 6815 | } |
| 6816 | } |
| 6817 | |
| 6818 | /* release the channel */ |
| 6819 | f_rsl_chan_deact(); |
| 6820 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6821 | f_rslem_unregister(0, g_chan_nr); |
| 6822 | } |
| 6823 | testcase TC_rll_rel_req() runs on test_CT { |
| 6824 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6825 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)), |
| 6826 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)), |
| 6827 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)), |
| 6828 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6829 | }; |
| 6830 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 6831 | } |
| 6832 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6833 | /* 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] | 6834 | testcase TC_rll_data_req() runs on test_CT { |
| 6835 | } |
| 6836 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6837 | /* 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] | 6838 | testcase TC_rll_data_ind() runs on test_CT { |
| 6839 | } |
| 6840 | |
| 6841 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 6842 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 6843 | var RllTestCase tc := g_pars.spec.rll; |
| 6844 | |
| 6845 | f_l1_tune(L1CTL); |
| 6846 | RSL.clear; |
| 6847 | |
| 6848 | f_est_dchan(); |
| 6849 | L1CTL.clear; |
| 6850 | |
| 6851 | /* Send UNITDATA REQ on RSL side */ |
| 6852 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 6853 | /* Expect it to arrive on the other side */ |
| 6854 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6855 | 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] | 6856 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6857 | 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] | 6858 | } |
| 6859 | |
| 6860 | /* release the channel */ |
| 6861 | f_rsl_chan_deact(); |
| 6862 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6863 | f_rslem_unregister(0, g_chan_nr); |
| 6864 | } |
| 6865 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 6866 | var octetstring l3 := f_rnd_octstring(15); |
| 6867 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6868 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)), |
| 6869 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6870 | }; |
| 6871 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6872 | } |
| 6873 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 6874 | var octetstring l3 := f_rnd_octstring(19); |
| 6875 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6876 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)), |
| 6877 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6878 | }; |
| 6879 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6880 | } |
| 6881 | |
| 6882 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 6883 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 6884 | var RllTestCase tc := g_pars.spec.rll; |
| 6885 | |
| 6886 | f_l1_tune(L1CTL); |
| 6887 | RSL.clear; |
| 6888 | |
| 6889 | f_est_dchan(); |
| 6890 | L1CTL.clear; |
| 6891 | |
| 6892 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6893 | 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] | 6894 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 6895 | alt { |
| 6896 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6897 | setverdict(pass); |
| 6898 | } |
| 6899 | [] RSL.receive { repeat; } |
| 6900 | } |
| 6901 | |
| 6902 | /* release the channel */ |
| 6903 | f_rsl_chan_deact(); |
| 6904 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6905 | f_rslem_unregister(0, g_chan_nr); |
| 6906 | } |
| 6907 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 6908 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6909 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6910 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)), |
| 6911 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6912 | }; |
| 6913 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6914 | } |
| 6915 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 6916 | var octetstring l3 := f_rnd_octstring(18); |
| 6917 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6918 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)), |
| 6919 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6920 | }; |
| 6921 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6922 | } |
| 6923 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6924 | /*********************************************************************** |
| 6925 | * Encryption Related |
| 6926 | ***********************************************************************/ |
| 6927 | |
| 6928 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6929 | 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] | 6930 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 6931 | if (link_id.c == SACCH) { |
| 6932 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6933 | } else { |
| 6934 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6935 | } |
| 6936 | } |
| 6937 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6938 | /* Expect (or not expect) other kinds of messages */ |
| 6939 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 6940 | [exp_any] RSL.receive { repeat; } |
| 6941 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6942 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6943 | } |
| 6944 | } |
| 6945 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6946 | /* 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] | 6947 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6948 | RslLinkId link_id, |
| 6949 | octetstring l3, |
| 6950 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6951 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6952 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6953 | timer T := 3.0; |
| 6954 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 6955 | T.start; |
| 6956 | /* Expect RLL UNITDATA IND on RSL side */ |
| 6957 | alt { |
| 6958 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 6959 | setverdict(pass); |
| 6960 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6961 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6962 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6963 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6964 | 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] | 6965 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6966 | } |
| 6967 | } |
| 6968 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6969 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 6970 | private function f_data_mo( |
| 6971 | RslLinkId link_id, |
| 6972 | boolean p, uint3_t nr, uint3_t ns, |
| 6973 | octetstring l3, |
| 6974 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6975 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6976 | ) runs on ConnHdlr { |
| 6977 | timer T := 3.0; |
| 6978 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 6979 | T.start; |
| 6980 | /* Expect RLL DATA IND on RSL side */ |
| 6981 | alt { |
| 6982 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 6983 | setverdict(pass); |
| 6984 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6985 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6986 | [] as_rsl_any_ind(exp_any); |
| 6987 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6988 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6989 | } |
| 6990 | } |
| 6991 | } |
| 6992 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6993 | /* 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] | 6994 | private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6995 | f_l1_tune(L1CTL); |
| 6996 | f_est_dchan(true); |
| 6997 | |
| 6998 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6999 | var L1ctlDlMessage dl; |
| 7000 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 7001 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7002 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7003 | |
| 7004 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 7005 | f_unitdata_mt(link_id, l3); |
| 7006 | |
| 7007 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 7008 | f_unitdata_mo(link_id, l3); |
| 7009 | |
| 7010 | /* release the channel */ |
| 7011 | f_rsl_chan_deact(); |
| 7012 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7013 | f_rslem_unregister(0, g_chan_nr); |
| 7014 | } |
| 7015 | testcase TC_chan_act_a51() runs on test_CT { |
| 7016 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7017 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7018 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7019 | } |
| 7020 | testcase TC_chan_act_a52() runs on test_CT { |
| 7021 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7022 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 7023 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7024 | } |
| 7025 | testcase TC_chan_act_a53() runs on test_CT { |
| 7026 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7027 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 7028 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7029 | } |
Eric Wild | b926039 | 2021-05-15 19:48:22 +0200 | [diff] [blame] | 7030 | testcase TC_chan_act_a54() runs on test_CT { |
| 7031 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7032 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16))); |
| 7033 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7034 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7035 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7036 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 7037 | 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] | 7038 | private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7039 | f_l1_tune(L1CTL); |
| 7040 | f_est_dchan(true); |
| 7041 | |
| 7042 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 7043 | var L1ctlDlMessage dl; |
| 7044 | |
| 7045 | var octetstring l3 := f_rnd_octstring(20); |
| 7046 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7047 | |
| 7048 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 7049 | f_unitdata_mt(link_id, l3); |
| 7050 | |
| 7051 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 7052 | f_unitdata_mo(link_id, l3); |
| 7053 | |
| 7054 | var RSL_Message rsl; |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7055 | 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] | 7056 | |
| 7057 | /* modify key to break proper encryption */ |
| 7058 | g_pars.encr.key := f_rnd_octstring(8); |
| 7059 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 7060 | rsl.ies := rsl.ies & { ei }; |
| 7061 | RSL.send(rsl); |
| 7062 | |
| 7063 | timer T0 := 1.0; |
| 7064 | T0.start; |
| 7065 | /* Expect RSL MODIFY ACK */ |
| 7066 | alt { |
| 7067 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 7068 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 7069 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 7070 | } |
| 7071 | [] T0.timeout { |
| 7072 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 7073 | } |
| 7074 | } |
| 7075 | |
| 7076 | var octetstring l3msg := f_rnd_octstring(15); |
| 7077 | timer T1 := 3.0; |
| 7078 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 7079 | due to broken encryption */ |
| 7080 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 7081 | T1.start; |
| 7082 | alt { |
| 7083 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 7084 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 7085 | } |
| 7086 | [] T1.timeout { |
| 7087 | setverdict(pass); |
| 7088 | } |
| 7089 | } |
| 7090 | |
| 7091 | /* release the channel */ |
| 7092 | f_rsl_chan_deact(); |
| 7093 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7094 | f_rslem_unregister(0, g_chan_nr); |
| 7095 | } |
| 7096 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 7097 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7098 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7099 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 7100 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7101 | |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 7102 | /* Verify RF RESource INDication messages (periodically sent over the RSL) */ |
| 7103 | private function f_TC_rsl_rf_resource_ind(template RSL_ResourceInfo info) |
| 7104 | runs on test_CT { |
| 7105 | const IpaStreamId sid := IPAC_PROTO_RSL_TRX0; |
| 7106 | var ASP_RSL_Unitdata ud; |
| 7107 | timer T; |
| 7108 | |
| 7109 | /* Intave is 6 SACCH periods by default */ |
| 7110 | var float Tval := int2float(6 * 480) / 1000.0 + 0.5; |
| 7111 | |
| 7112 | T.start(Tval); |
| 7113 | alt { |
| 7114 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(info), sid)) { |
| 7115 | setverdict(pass); |
| 7116 | } |
| 7117 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(?), sid)) -> value ud { |
| 7118 | setverdict(fail, "RF RESource INDication mismatch: ", ud.rsl); |
| 7119 | } |
| 7120 | [] RSL_CCHAN.receive { repeat; } |
| 7121 | [] T.timeout { |
| 7122 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 7123 | "Timeout waiting for RF RESource INDication"); |
| 7124 | } |
| 7125 | } |
| 7126 | } |
| 7127 | testcase TC_rsl_rf_resource_ind() runs on test_CT { |
| 7128 | var RSL_ResourceInfo info := { }; |
| 7129 | |
| 7130 | f_init(trx_nr := 0); |
| 7131 | |
| 7132 | f_init_l1ctl(); |
| 7133 | f_l1_tune(L1CTL); |
| 7134 | |
| 7135 | /* g_AllChannels contains all logical channels */ |
| 7136 | for (var integer i := 0; i < lengthof(g_AllChannels); i := i + 1) { |
| 7137 | var RslChannelNr chan_nr := g_AllChannels[i]; |
| 7138 | |
| 7139 | /* FIXME: osmo-bts does not report for Osmocom style dynamic timeslots */ |
| 7140 | if (mp_trx_pars[0].ts[chan_nr.tn].config == GSM_PCHAN_TCHH_TCHF_PDCH) |
| 7141 | { continue; } |
| 7142 | |
| 7143 | info := info & { valueof(ts_RSL_ResourceInfoItem(chan_nr, mp_interf_band)) }; |
| 7144 | } |
| 7145 | |
| 7146 | /* Align to the first interference report */ |
| 7147 | f_TC_rsl_rf_resource_ind(?); |
| 7148 | |
| 7149 | /* Test 4 consecutive messages */ |
| 7150 | for (var integer i := 0; i < 4; i := i + 1) { |
| 7151 | f_TC_rsl_rf_resource_ind(info); |
| 7152 | } |
| 7153 | |
| 7154 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7155 | } |
| 7156 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7157 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7158 | private function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7159 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 7160 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 7161 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 7162 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7163 | |
| 7164 | f_l1_tune(L1CTL); |
| 7165 | |
| 7166 | /* first establish a dedicated channel in the clear */ |
| 7167 | f_est_dchan(false); |
| 7168 | |
| 7169 | /* Establish ABM */ |
| 7170 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 7171 | |
| 7172 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 7173 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 7174 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 7175 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 7176 | |
| 7177 | /* configure L1 to apply ciphering */ |
| 7178 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 7179 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 7180 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7181 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 7182 | 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] | 7183 | |
| 7184 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 7185 | * and hence enable encryption also on the downlink */ |
| 7186 | |
| 7187 | /* expect bi-directional communication work in encrypted mode */ |
| 7188 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 7189 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 7190 | |
| 7191 | /* release the channel */ |
| 7192 | f_rsl_chan_deact(); |
| 7193 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7194 | f_rslem_unregister(0, g_chan_nr); |
| 7195 | } |
| 7196 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 7197 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7198 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7199 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7200 | } |
| 7201 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 7202 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7203 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 7204 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7205 | } |
| 7206 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 7207 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7208 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 7209 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7210 | } |
Eric Wild | b926039 | 2021-05-15 19:48:22 +0200 | [diff] [blame] | 7211 | testcase TC_encr_cmd_a54() runs on test_CT { |
| 7212 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7213 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16))); |
| 7214 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7215 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7216 | |
| 7217 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 7218 | var LapdmFrame lf; |
| 7219 | var octetstring reenc; |
| 7220 | |
| 7221 | /* decode the LAPDm frame */ |
| 7222 | if (ischosen(exp_match.ab)) { |
| 7223 | lf.ab := dec_LapdmFrameAB(enc); |
| 7224 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7225 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7226 | } |
| 7227 | |
| 7228 | /* check if decoder result matches expectation */ |
| 7229 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7230 | 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] | 7231 | } else { |
| 7232 | log(name, ": matched"); |
| 7233 | setverdict(pass); |
| 7234 | } |
| 7235 | |
| 7236 | /* test if re-encoded frame equals original input */ |
| 7237 | reenc := enc_LapdmFrame(lf); |
| 7238 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7239 | 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] | 7240 | } else { |
| 7241 | setverdict(pass); |
| 7242 | } |
| 7243 | } |
| 7244 | |
| 7245 | testcase TC_lapdm_selftest() runs on test_CT { |
| 7246 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 7247 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 7248 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 7249 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 7250 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 7251 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 7252 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 7253 | } |
| 7254 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7255 | /*********************************************************************** |
| 7256 | * DTX Related (see GSM 05.08, section 8.3) |
| 7257 | ***********************************************************************/ |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7258 | 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] | 7259 | var L1ctlDlMessage dl; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7260 | var GsmFrameNumber first_fn; |
| 7261 | var boolean is_first_frame := true; |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7262 | var integer nfill_frames := 0; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7263 | 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] | 7264 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 7265 | 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] | 7266 | const integer frame_dtx_tchf_mod := 104; |
| 7267 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 7268 | * which operates in terms of blocks rather than frames. */ |
| 7269 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 7270 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7271 | timer T := 5.0; |
| 7272 | |
| 7273 | f_l1_tune(L1CTL); |
| 7274 | RSL.clear; |
| 7275 | L1CTL.clear; |
| 7276 | |
| 7277 | /* activate TCHF signalling channel */ |
| 7278 | f_est_dchan(false); |
| 7279 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7280 | /* A template for matching dummy LAPDm func=UA frames */ |
| 7281 | var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND( |
| 7282 | chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?), |
| 7283 | l2_data := f_pad_oct('030301'O, 23, '2B'O)); |
| 7284 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7285 | T.start; |
| 7286 | alt { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7287 | [] L1CTL.receive(tr_fill_frame) -> value dl { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7288 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7289 | |
| 7290 | if (is_first_frame) { |
| 7291 | is_first_frame := false; |
| 7292 | first_fn := dl.dl_info.frame_nr; |
| 7293 | } |
| 7294 | |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7295 | if (g_pars.chan_mode.dtx_d) { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7296 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7297 | T.stop; |
| 7298 | f_rsl_chan_deact(); |
| 7299 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7300 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7301 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. */ |
| 7302 | expected_fill_frames := 2; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7303 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7304 | if (nfill_frames < expected_fill_frames) { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7305 | setverdict(fail, "Not enough fill frames received: ", |
| 7306 | nfill_frames, " out of ", expected_fill_frames); |
| 7307 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7308 | } else { |
| 7309 | setverdict(pass); |
| 7310 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7311 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7312 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 7313 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 7314 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 7315 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 7316 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 7317 | 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] | 7318 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7319 | repeat; |
| 7320 | } |
| 7321 | } |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7322 | setverdict(fail, "Received DTX TCH fill frame with bad frame number: ", fn, |
| 7323 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 7324 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7325 | f_rsl_chan_deact(); |
| 7326 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7327 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7328 | } else { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7329 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7330 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7331 | T.stop; |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7332 | |
| 7333 | select (g_chan_nr) { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7334 | /* TCH/F: we expect 24 fill frames for every 104 frames. */ |
| 7335 | case (t_RslChanNr_Bm(?)) { expected_fill_frames := 24; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7336 | /* TCH/H: we expect 2 fill frames for every 104 frames. */ |
| 7337 | case (t_RslChanNr_Lm(?, ?)) { expected_fill_frames := 2; } |
| 7338 | /* SDCCH: we expect 5 fill frames for every 104 frames. */ |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7339 | case (t_RslChanNr_SDCCH4(?, ?)) { expected_fill_frames := 4; } |
| 7340 | case (t_RslChanNr_SDCCH8(?, ?)) { expected_fill_frames := 4; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7341 | case else { |
| 7342 | /* This shall not happen, just to be sure */ |
| 7343 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7344 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7345 | } |
| 7346 | |
| 7347 | f_rsl_chan_deact(); |
| 7348 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7349 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7350 | if (nfill_frames >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7351 | setverdict(pass); |
| 7352 | } else { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7353 | setverdict(fail, "Not enough fill frames received: ", |
| 7354 | nfill_frames, " out of ", expected_fill_frames); |
| 7355 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7356 | } |
| 7357 | } else { |
| 7358 | repeat; |
| 7359 | } |
| 7360 | } |
| 7361 | } |
| 7362 | [] L1CTL.receive { repeat; } |
| 7363 | [] T.timeout { |
| 7364 | f_rsl_chan_deact(); |
| 7365 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7366 | 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] | 7367 | } |
| 7368 | } |
| 7369 | } |
| 7370 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7371 | 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] | 7372 | var template RSL_IE_ChannelMode ch_mode; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7373 | var ConnHdlr vc_conn; |
| 7374 | var ConnHdlrPars pars; |
| 7375 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7376 | f_init(); |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7377 | ch_mode := ts_RSL_ChanMode_SIGN(dtx_downlink := dtxd); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7378 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7379 | pars := valueof(t_Pars(g_AllChannels[i], ch_mode)); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7380 | if (dtxd) { |
| 7381 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 7382 | break; |
| 7383 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7384 | } |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7385 | 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] | 7386 | vc_conn.done; |
| 7387 | } |
| 7388 | } |
| 7389 | |
| 7390 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 7391 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 7392 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 7393 | f_tch_sign_l2_fill_frame(false); |
| 7394 | } |
| 7395 | |
| 7396 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 7397 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 7398 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 7399 | f_tch_sign_l2_fill_frame(true); |
| 7400 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7401 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 7402 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 7403 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7404 | } |
| 7405 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 7406 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 7407 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7408 | } |
| 7409 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7410 | |
| 7411 | /* Callback function to be called by as_TC_ms_pwr_ctrl_constant(). |
| 7412 | * Return value: Measurement Report to be sent (encoded octetstring). */ |
| 7413 | type function f_TC_ms_pwr_ctrl_cb(inout SacchL1Header l1h, integer num_blocks) |
| 7414 | runs on ConnHdlr return octetstring; |
| 7415 | |
| 7416 | private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks) |
| 7417 | runs on ConnHdlr { |
| 7418 | var L1ctlDlMessage l1_dl; |
| 7419 | var SacchL1Header l1h; |
| 7420 | var octetstring l2; |
| 7421 | |
| 7422 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 7423 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 7424 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 7425 | log("as_TC_ms_pwr_ctrl(): Rx SACCH L1 header: ", l1h); |
| 7426 | |
| 7427 | /* Pass it to the user specified call-back function */ |
| 7428 | l2 := cb.apply(l1h, num_blocks); |
| 7429 | /* Send a Measurement Report generated by the call-back */ |
| 7430 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(l1_dl.dl_info.chan_nr, |
| 7431 | l1_dl.dl_info.link_id, |
| 7432 | l1h, l2)); |
| 7433 | |
| 7434 | /* Shall we keep going? */ |
| 7435 | num_blocks := num_blocks - 1; |
| 7436 | log("as_TC_ms_pwr_ctrl(): ", num_blocks, " SACCH blocks remaining"); |
| 7437 | if (num_blocks > 0) { repeat; } |
| 7438 | } |
| 7439 | [] L1CTL.receive { repeat; } |
| 7440 | } |
| 7441 | |
| 7442 | private function f_TC_ms_pwr_ctrl_cb_def(inout SacchL1Header l1h, integer num_blocks) |
| 7443 | runs on ConnHdlr return octetstring { |
| 7444 | /* Command the L1 to apply received parameters */ |
| 7445 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 7446 | |
| 7447 | /* Dummy measurement report (the results are invalid) */ |
| 7448 | return f_pad_oct('010349'O & '0615004001C0'O, 21, '00'O); |
| 7449 | } |
| 7450 | |
| 7451 | private function f_TC_ms_pwr_ctrl_cb_const(inout SacchL1Header l1h, integer num_blocks) |
| 7452 | runs on ConnHdlr return octetstring { |
| 7453 | if (l1h.ms_power_lvl != g_pars.l1_pars.ms_power_level) { |
| 7454 | setverdict(fail, "Unexpected MS Power level change: ", |
| 7455 | g_pars.l1_pars.ms_power_level, " -> ", |
| 7456 | l1h.ms_power_lvl); |
| 7457 | } |
| 7458 | |
| 7459 | return f_TC_ms_pwr_ctrl_cb_def(l1h, num_blocks); |
| 7460 | } |
| 7461 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7462 | private function f_TC_ms_pwr_ctrl_cb_rssi_pwm(inout SacchL1Header l1h, integer num_blocks) |
| 7463 | runs on ConnHdlr return octetstring { |
| 7464 | /* UL RSSI oscillation driven by SACCH block number */ |
| 7465 | if (num_blocks rem 2 == 0) { |
| 7466 | f_trxc_fake_rssi(-100); |
| 7467 | } else { |
| 7468 | f_trxc_fake_rssi(-50); |
| 7469 | } |
| 7470 | |
| 7471 | /* Make sure that MS power level remains constant */ |
| 7472 | return f_TC_ms_pwr_ctrl_cb_const(l1h, num_blocks); |
| 7473 | } |
| 7474 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7475 | /* Make sure that MS power level remains constant when 'rx-current' equals 'rx-target' */ |
| 7476 | private function f_TC_ms_pwr_ctrl_constant(charstring id) |
| 7477 | runs on ConnHdlr { |
| 7478 | var integer num_blocks := 8; |
| 7479 | timer T := int2float(num_blocks); |
| 7480 | |
| 7481 | f_l1_tune(L1CTL); |
| 7482 | RSL.clear; |
| 7483 | |
| 7484 | /* These IEs are needed for autonomous MS power control */ |
| 7485 | var template (value) RSL_IE_List ies := { |
| 7486 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7487 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7488 | }), |
| 7489 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7490 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7491 | }) |
| 7492 | }; |
| 7493 | |
| 7494 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7495 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7496 | |
| 7497 | /* Establish a dedicated channel */ |
| 7498 | f_est_dchan(more_ies := valueof(ies)); |
| 7499 | |
| 7500 | L1CTL.clear; |
| 7501 | T.start; |
| 7502 | alt { |
| 7503 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_const), num_blocks); |
| 7504 | [] T.timeout { |
| 7505 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7506 | num_blocks, " were not handled"); |
| 7507 | } |
| 7508 | } |
Vadim Yanitskiy | 6b4404a | 2021-06-17 17:22:56 +0200 | [diff] [blame] | 7509 | |
| 7510 | /* Release the channel */ |
| 7511 | f_rsl_chan_deact(); |
| 7512 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7513 | } |
| 7514 | testcase TC_ms_pwr_ctrl_constant() runs on test_CT { |
| 7515 | var ConnHdlr vc_conn; |
| 7516 | var ConnHdlrPars pars; |
| 7517 | |
| 7518 | f_init(); |
| 7519 | |
| 7520 | /* Explicitly configure the Uplink power target (in dBm) */ |
| 7521 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target)); |
| 7522 | |
| 7523 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7524 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7525 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7526 | |
| 7527 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_constant), |
| 7528 | pars, trxc_comp := true); |
| 7529 | vc_conn.done; |
| 7530 | } |
| 7531 | |
| 7532 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7533 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7534 | } |
| 7535 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7536 | /* Test Exponentially Weighted Moving Average (EWMA) power filtering */ |
| 7537 | private function f_TC_ms_pwr_ctrl_pf_ewma(charstring id) |
| 7538 | runs on ConnHdlr { |
| 7539 | var integer num_blocks := 16; |
| 7540 | timer T := int2float(num_blocks); |
| 7541 | |
| 7542 | f_l1_tune(L1CTL); |
| 7543 | RSL.clear; |
| 7544 | |
| 7545 | /* These IEs are needed for autonomous MS power control */ |
| 7546 | var template (value) RSL_IE_List ies := { |
| 7547 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7548 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7549 | }), |
| 7550 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7551 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7552 | }) |
| 7553 | }; |
| 7554 | |
| 7555 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7556 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7557 | |
| 7558 | /* Establish a dedicated channel */ |
| 7559 | f_est_dchan(more_ies := valueof(ies)); |
| 7560 | |
| 7561 | L1CTL.clear; |
| 7562 | T.start; |
| 7563 | alt { |
| 7564 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_rssi_pwm), num_blocks); |
| 7565 | [] T.timeout { |
| 7566 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7567 | num_blocks, " were not handled"); |
| 7568 | } |
| 7569 | } |
Vadim Yanitskiy | 6b4404a | 2021-06-17 17:22:56 +0200 | [diff] [blame] | 7570 | |
| 7571 | /* Release the channel */ |
| 7572 | f_rsl_chan_deact(); |
| 7573 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7574 | } |
| 7575 | testcase TC_ms_pwr_ctrl_pf_ewma() runs on test_CT { |
| 7576 | var ConnHdlr vc_conn; |
| 7577 | var ConnHdlrPars pars; |
| 7578 | |
| 7579 | f_init(); |
| 7580 | |
| 7581 | /* Explicitly configure EWMA filtering with 80% smoothing (alpha = 0.2) */ |
| 7582 | f_vty_config(BTSVTY, "bts 0", "uplink-power-filtering algo ewma beta 80"); |
| 7583 | /* Explicitly configure the Uplink power range (target and delte) */ |
| 7584 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target) |
| 7585 | & " hysteresis " & int2str(mp_uplink_power_hysteresis)); |
| 7586 | |
| 7587 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7588 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7589 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7590 | |
| 7591 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_pf_ewma), |
| 7592 | pars, trxc_comp := true); |
| 7593 | vc_conn.done; |
| 7594 | } |
| 7595 | |
| 7596 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7597 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7598 | } |
| 7599 | |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 7600 | private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr { |
| 7601 | var template L1ctlDlMessage tr_bad_frame; |
| 7602 | var L1ctlDlMessage l1_dl; |
| 7603 | timer T := 8.0; |
| 7604 | |
| 7605 | f_l1_tune(L1CTL); |
| 7606 | RSL.clear; |
| 7607 | |
| 7608 | f_est_dchan(); |
| 7609 | |
| 7610 | /* There may be a few errors right after the channel activation */ |
| 7611 | f_sleep(2.0); /* ... so let's give the L1 some time to stabilize */ |
| 7612 | L1CTL.clear; |
| 7613 | |
| 7614 | /* A universal template for bad Downlink frame: {DATA,TRAFFIC}.ind */ |
| 7615 | tr_bad_frame := tr_L1CTL_TRAFFIC_IND(g_chan_nr, tr_RslLinkID_DCCH(0)); |
| 7616 | tr_bad_frame.header.msg_type := (L1CTL_DATA_IND, L1CTL_TRAFFIC_IND); |
| 7617 | tr_bad_frame.dl_info.fire_crc := (1..255); /* != 0 */ |
| 7618 | tr_bad_frame.payload := ?; |
| 7619 | |
| 7620 | T.start; |
| 7621 | alt { |
| 7622 | /* OS#4823: DATA.ind or TRAFFIC.ind with bad CRC most likely means that |
| 7623 | * the IUT is sending *dummy bursts*, so the L1 fails to decode them. */ |
| 7624 | [] L1CTL.receive(tr_bad_frame) -> value l1_dl { |
| 7625 | setverdict(fail, "Received {DATA,TRAFFIC}.ind with bad CRC: ", l1_dl); |
| 7626 | } |
| 7627 | [] as_l1_sacch(); |
| 7628 | [] L1CTL.receive { repeat; } |
| 7629 | [] T.timeout { |
| 7630 | /* We're done, break the loop */ |
| 7631 | setverdict(pass); |
| 7632 | } |
| 7633 | } |
| 7634 | |
| 7635 | f_rsl_chan_deact(); |
| 7636 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7637 | } |
| 7638 | testcase TC_speech_no_rtp_tchf() runs on test_CT { |
| 7639 | var ConnHdlr vc_conn; |
| 7640 | var ConnHdlrPars pars; |
| 7641 | |
| 7642 | f_init(); |
| 7643 | |
| 7644 | /* TS1, TCH/F, V1 (FR codec) */ |
| 7645 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 7646 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 7647 | vc_conn.done; |
| 7648 | } |
| 7649 | testcase TC_speech_no_rtp_tchh() runs on test_CT { |
| 7650 | var ConnHdlr vc_conn; |
| 7651 | var ConnHdlrPars pars; |
| 7652 | |
| 7653 | f_init(); |
| 7654 | |
| 7655 | /* TS5, TCH/H, V1 (HR codec) */ |
| 7656 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 7657 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 7658 | vc_conn.done; |
| 7659 | } |
| 7660 | |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 7661 | /* Verify handling of Downlink and Uplink speech frames */ |
| 7662 | private function f_TC_speech_rtp(charstring id) runs on ConnHdlr { |
| 7663 | var L1ctlDlMessage l1_dl; |
| 7664 | var PDU_RTP rtp_pdu; |
| 7665 | var octetstring pl; |
| 7666 | timer Td, Tu; |
| 7667 | |
| 7668 | f_l1_tune(L1CTL); |
| 7669 | f_est_dchan(); |
| 7670 | |
| 7671 | /* Activate the RTP emulation */ |
| 7672 | pl := f_rnd_octstring(6); |
| 7673 | f_rtpem_activate(pl); |
| 7674 | |
| 7675 | /* Give the scheduler some time to fill up the buffers */ |
| 7676 | f_sleep(2.0); |
| 7677 | L1CTL.clear; |
| 7678 | RSL.clear; |
| 7679 | |
| 7680 | /* Make sure that Downlink frames are received at the UE */ |
| 7681 | Td.start(2.0); |
| 7682 | alt { |
| 7683 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := pl)) -> value l1_dl { |
| 7684 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
| 7685 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 7686 | l1_dl.payload.traffic_ind.data)); |
| 7687 | setverdict(pass); |
| 7688 | } |
| 7689 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := ?)) -> value l1_dl { |
| 7690 | setverdict(fail, "Rx unexpected Downlink speech frame ", |
| 7691 | "(", l1_dl.payload.traffic_ind.data, ") ", |
| 7692 | "expected (", pl, ")"); |
| 7693 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7694 | } |
| 7695 | [] as_l1_sacch(); |
| 7696 | [] L1CTL.receive { repeat; } |
| 7697 | [] Td.timeout { |
| 7698 | setverdict(fail, "Timeout waiting for Downlink speech frames"); |
| 7699 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7700 | } |
| 7701 | } |
| 7702 | |
| 7703 | /* Make sure that Uplink frames are received at the BTS */ |
| 7704 | RTPEM_DATA.clear; |
| 7705 | Tu.start(2.0); |
| 7706 | alt { |
| 7707 | [] RTPEM_DATA.receive(PDU_RTP:?) -> value rtp_pdu { |
| 7708 | if (rtp_pdu.data != pl) |
| 7709 | { repeat; } |
| 7710 | } |
| 7711 | [] RTPEM_DATA.receive { repeat; } |
| 7712 | [] Tu.timeout { |
| 7713 | setverdict(fail, "Timeout waiting for Uplink speech frames"); |
| 7714 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7715 | } |
| 7716 | } |
| 7717 | |
| 7718 | f_rtpem_mode(RTPEM_CTRL, RTPEM_MODE_NONE); |
| 7719 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7720 | f_rsl_chan_deact(); |
| 7721 | f_rslem_unregister(0, g_chan_nr); |
| 7722 | } |
| 7723 | testcase TC_speech_rtp_tchf() runs on test_CT { |
| 7724 | var ConnHdlr vc_conn; |
| 7725 | var ConnHdlrPars pars; |
| 7726 | |
| 7727 | f_init(); |
| 7728 | |
| 7729 | /* TS1, TCH/F, V1 (FR codec) */ |
| 7730 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 7731 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 7732 | vc_conn.done; |
| 7733 | |
| 7734 | /* TS1, TCH/F, V2 (EFR codec) */ |
| 7735 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))); |
| 7736 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 7737 | vc_conn.done; |
| 7738 | |
| 7739 | /* TODO: also test V3 (AMR codec) */ |
| 7740 | |
| 7741 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7742 | } |
| 7743 | testcase TC_speech_rtp_tchh() runs on test_CT { |
| 7744 | var ConnHdlr vc_conn; |
| 7745 | var ConnHdlrPars pars; |
| 7746 | |
| 7747 | f_init(); |
| 7748 | |
| 7749 | /* TS5, TCH/H0, V1 (HR codec) */ |
| 7750 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 7751 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 7752 | vc_conn.done; |
| 7753 | |
| 7754 | /* TODO: also test V3 (AMR codec) */ |
| 7755 | |
| 7756 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7757 | } |
| 7758 | |
Neels Hofmeyr | af9d6ae | 2021-08-15 23:18:47 +0200 | [diff] [blame] | 7759 | private function f_TC_early_immediate_assignment(charstring id) runs on ConnHdlr { |
| 7760 | var GsmFrameNumber fn; |
| 7761 | var ChannelDescription ch_desc; |
| 7762 | var integer ra := 23; |
| 7763 | |
| 7764 | f_l1_tune(L1CTL); |
| 7765 | RSL.clear; |
| 7766 | |
| 7767 | /* Send RACH request and wait for ChanReq */ |
| 7768 | fn := f_rach_req_wait_chan_rqd(ra); |
| 7769 | |
| 7770 | /* The BSC already sends the Immediate Assignment, before the channel is active. |
| 7771 | * (Also before the Channel Activation, even. I tried to write this test so that we first send the Chan Act and then the IMM |
| 7772 | * ASS, but osmo-bts-trx responds so fast that the Chan Activ ACK comes back even before titan dispatches the |
| 7773 | * IMM ASS. So move the IMM ASS even before the Chan Activ.) */ |
| 7774 | if (g_pars.fhp.enabled) { |
| 7775 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
| 7776 | } else { |
| 7777 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
| 7778 | } |
| 7779 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
| 7780 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 7781 | |
| 7782 | /* Do not expect the Immediate Assignment to show up on MS side yet. Even give it one second before the BSC |
| 7783 | * requests Chan Activ, to make sure the RR IMM ASS is held back. */ |
| 7784 | var L1ctlDlMessage dl; |
| 7785 | var GsmRrMessage rr; |
| 7786 | |
| 7787 | var template GsmRrMessage rr_imm_ass := tr_IMM_ASS(ra, fn); |
| 7788 | rr_imm_ass.payload.imm_ass.ded_or_tbf := ?; |
| 7789 | rr_imm_ass.payload.imm_ass.pkt_chan_desc := *; |
| 7790 | rr_imm_ass.payload.imm_ass.chan_desc := *; |
| 7791 | |
| 7792 | timer T := 1.0; |
| 7793 | T.start; |
| 7794 | alt { |
| 7795 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl { |
| 7796 | rr := dec_GsmRrMessage(dl.payload.data_ind.payload); |
| 7797 | if (match(rr, rr_imm_ass)) { |
| 7798 | setverdict(fail, "Expected IMM ASS to be delayed until Chan Act ACK, but it was passed to the MS immediately"); |
| 7799 | mtc.stop; |
| 7800 | } else { |
| 7801 | repeat; |
| 7802 | } |
| 7803 | } |
| 7804 | [] L1CTL.receive { repeat; } |
| 7805 | [] T.timeout; |
| 7806 | } |
| 7807 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode, t_RSL_IE_ActType_IA)); |
| 7808 | RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)); |
| 7809 | |
| 7810 | /* Now expect the IMM ASS on Um */ |
| 7811 | f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 7812 | setverdict(pass); |
| 7813 | |
| 7814 | /* Release the channel */ |
| 7815 | f_rsl_chan_deact(); |
| 7816 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7817 | } |
| 7818 | |
| 7819 | testcase TC_early_immediate_assignment() runs on test_CT { |
| 7820 | var ConnHdlr vc_conn; |
| 7821 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7822 | f_init(); |
| 7823 | vc_conn := f_start_handler(refers(f_TC_early_immediate_assignment), pars); |
| 7824 | vc_conn.done; |
| 7825 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7826 | } |
| 7827 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7828 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 7829 | /* protocol error as per 44.006 */ |
| 7830 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 7831 | /* repetition of SABM or DISC N200 times without ACK */ |
| 7832 | /* receptiom of SABM in multi-frame established state */ |
| 7833 | |
| 7834 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7835 | /* TODO Areas: |
| 7836 | |
| 7837 | * channel activation |
| 7838 | ** with BS_Power / MS_Power, bypassing power control loop |
| 7839 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7840 | ** with timing advance from initial activation on |
| 7841 | * mode modify |
| 7842 | ** encryption |
| 7843 | ** multirate |
| 7844 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7845 | ** unsupported algorithm |
| 7846 | * handover detection |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7847 | * BS Power Control |
| 7848 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7849 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7850 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7851 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7852 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7853 | ** DATA_IND from BTS->PCU |
| 7854 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7855 | |
| 7856 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7857 | |
| 7858 | control { |
| 7859 | execute( TC_chan_act_stress() ); |
| 7860 | execute( TC_chan_act_react() ); |
| 7861 | execute( TC_chan_deact_not_active() ); |
| 7862 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 7863 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 7864 | execute( TC_sacch_filling() ); |
| 7865 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 7866 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 7867 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 7868 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 7869 | execute( TC_sacch_chan_act_ho_async() ); |
| 7870 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 7871 | execute( TC_rach_content() ); |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 7872 | execute( TC_rach_content_emerg() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 7873 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 7874 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 7875 | execute( TC_ho_rach() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 7876 | execute( TC_rach_load_idle_thresh0() ); |
| 7877 | execute( TC_rach_load_idle_below_thresh() ); |
| 7878 | execute( TC_rach_load_count() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 7879 | execute( TC_meas_res_speech_tchf() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 7880 | execute( TC_meas_res_speech_tchf_facch() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 7881 | execute( TC_meas_res_speech_tchh() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 7882 | execute( TC_meas_res_speech_tchh_facch() ); |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 7883 | execute( TC_meas_res_speech_tchh_toa256() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7884 | execute( TC_meas_res_sign_tchf() ); |
| 7885 | execute( TC_meas_res_sign_tchh() ); |
| 7886 | execute( TC_meas_res_sign_sdcch4() ); |
| 7887 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 7888 | execute( TC_meas_res_sign_tchh_toa256() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 7889 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 7890 | execute( TC_tx_power_start_ramp_down_bcch() ); |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 7891 | execute( TC_tx_power_ramp_adm_state_change() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 7892 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 7893 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 7894 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 7895 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 7896 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 7897 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 7898 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 7899 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 7900 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 7901 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 7902 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7903 | execute( TC_rsl_modify_encr() ); |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 7904 | execute( TC_rsl_rf_resource_ind() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7905 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7906 | execute( TC_paging_imsi_80percent() ); |
| 7907 | execute( TC_paging_tmsi_80percent() ); |
| 7908 | execute( TC_paging_imsi_200percent() ); |
| 7909 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 7910 | execute( TC_rsl_protocol_error() ); |
| 7911 | execute( TC_rsl_mand_ie_error() ); |
| 7912 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 7913 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 7914 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 7915 | execute( TC_si_sched_2bis() ); |
| 7916 | execute( TC_si_sched_2ter() ); |
| 7917 | execute( TC_si_sched_2ter_2bis() ); |
| 7918 | execute( TC_si_sched_2quater() ); |
| 7919 | execute( TC_si_sched_13() ); |
| 7920 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 7921 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 7922 | execute( TC_ipa_crcx_twice_not_active() ); |
| 7923 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 7924 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 7925 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7926 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7927 | if (mp_pcu_socket != "") { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 7928 | execute( TC_paging_imsi_200percent_with_ps() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7929 | execute( TC_pcu_act_req() ); |
| 7930 | execute( TC_pcu_act_req_wrong_ts() ); |
| 7931 | execute( TC_pcu_act_req_wrong_bts() ); |
| 7932 | execute( TC_pcu_act_req_wrong_trx() ); |
| 7933 | execute( TC_pcu_deact_req() ); |
| 7934 | execute( TC_pcu_deact_req_wrong_ts() ); |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 7935 | execute( TC_pcu_ver_si1() ); |
| 7936 | execute( TC_pcu_ver_si3() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7937 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 7938 | if (mp_l1_supports_gprs) { |
| 7939 | execute( TC_pcu_data_req_pdtch() ); |
| 7940 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 7941 | execute( TC_pcu_data_req_wrong_bts() ); |
| 7942 | execute( TC_pcu_data_req_wrong_trx() ); |
| 7943 | execute( TC_pcu_data_req_wrong_ts() ); |
| 7944 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 7945 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 7946 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7947 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 7948 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7949 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 7950 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 7951 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 7952 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7953 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 7954 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 7955 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 7956 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 7957 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 7958 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 7959 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7960 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7961 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7962 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7963 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7964 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7965 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 7966 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 7967 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 7968 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 7969 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 7970 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 7971 | execute( TC_pcu_info_ind_fh_params() ); |
| 7972 | execute( TC_pcu_socket_nsvc_ipv4() ); |
| 7973 | execute( TC_pcu_socket_nsvc_ipv6() ); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 7974 | execute( TC_pcu_socket_two_nsvc() ); |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 7975 | execute( TC_pcu_interf_ind() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7976 | } else { |
| 7977 | log("PCU socket path not available, skipping PCU tests"); |
| 7978 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7979 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7980 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7981 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 7982 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Pau Espin Pedrol | 8e57ac1 | 2021-06-29 17:04:24 +0200 | [diff] [blame] | 7983 | execute( TC_dyn_osmo_pdch_sdcch8_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 7984 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 7985 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7986 | |
| 7987 | execute( TC_rll_est_ind() ); |
| 7988 | execute( TC_rll_est_req_DCCH_3() ); |
| 7989 | execute( TC_rll_est_req_ACCH_3() ); |
| 7990 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 7991 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 7992 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 7993 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 7994 | execute( TC_rll_rel_req() ); |
| 7995 | execute( TC_rll_unit_data_req_DCCH() ); |
| 7996 | execute( TC_rll_unit_data_req_ACCH() ); |
| 7997 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 7998 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7999 | |
| 8000 | execute( TC_chan_act_a51() ); |
| 8001 | execute( TC_chan_act_a52() ); |
| 8002 | execute( TC_chan_act_a53() ); |
| 8003 | execute( TC_encr_cmd_a51() ); |
| 8004 | execute( TC_encr_cmd_a52() ); |
| 8005 | execute( TC_encr_cmd_a53() ); |
| 8006 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 8007 | execute( TC_err_rep_wrong_mdisc() ); |
| 8008 | execute( TC_err_rep_wrong_msg_type() ); |
| 8009 | execute( TC_err_rep_wrong_sequence() ); |
| 8010 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 8011 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 8012 | |
| 8013 | execute( TC_tch_sign_l2_fill_frame() ); |
| 8014 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 8015 | |
| 8016 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 8017 | execute( TC_chopped_ipa_payload() ); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 8018 | |
| 8019 | execute( TC_ms_pwr_ctrl_constant() ); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8020 | execute( TC_ms_pwr_ctrl_pf_ewma() ); |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 8021 | |
| 8022 | execute( TC_speech_no_rtp_tchf() ); |
| 8023 | execute( TC_speech_no_rtp_tchh() ); |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8024 | execute( TC_speech_rtp_tchf() ); |
| 8025 | execute( TC_speech_rtp_tchh() ); |
Neels Hofmeyr | af9d6ae | 2021-08-15 23:18:47 +0200 | [diff] [blame] | 8026 | |
| 8027 | execute( TC_early_immediate_assignment() ); |
Vadim Yanitskiy | 46f1992 | 2021-10-06 02:36:22 +0600 | [diff] [blame] | 8028 | |
| 8029 | /* BEWARE: these test cases can potentially break the IUT or cause |
| 8030 | * weird/unexpected behavior. Ensure that they are executed last. */ |
| 8031 | execute( TC_dyn_osmo_pdch_tchh_race_act() ); |
| 8032 | execute( TC_dyn_osmo_pdch_sdcch8_race_act() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8033 | } |
| 8034 | |
| 8035 | |
| 8036 | } |