Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1 | module BTS_Tests { |
| 2 | |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 3 | /* Integration Tests for OsmoBTS |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 4 | * (C) 2018-2019 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 5 | * contributions by Vadim Yanitskiy and sysmocom - s.f.m.c. GmbH |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | * |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 13 | * This test suite tests OsmoBTS by attaching to the external interfaces |
| 14 | * such as Abis RSL, PCU, VTY as well as by attaching to a MS L1 implementation |
| 15 | * using the L1CTL protocol/interface. |
| 16 | * |
| 17 | * You can run the tests with |
| 18 | * a) osmo-bts-trx + trxcon + fake_trx (without any hardware) |
| 19 | * b) any osmo-bts-* + OsmocomBB layer1 + osmocon (with real BTS hardware) |
| 20 | * c) osmo-bts-virtual + virt_phy (without any hardware) |
| 21 | * |
| 22 | * Some of the tests will only run on a subset of those three configurations |
| 23 | * due to limitations in the respective L1. |
| 24 | */ |
| 25 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 26 | import from Misc_Helpers all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 27 | import from General_Types all; |
| 28 | import from GSM_Types all; |
| 29 | import from GSM_RR_Types all; |
| 30 | import from Osmocom_Types all; |
| 31 | import from GSM_Types all; |
Vadim Yanitskiy | 5d2cf44 | 2020-05-02 16:49:17 +0700 | [diff] [blame] | 32 | import from GSM_RestOctets all; |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 33 | import from GSM_SystemInformation all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 34 | import from L1CTL_PortType all; |
| 35 | import from L1CTL_Types all; |
| 36 | import from LAPDm_Types all; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 37 | import from LAPDm_RAW_PT all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 38 | import from Osmocom_CTRL_Adapter all; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 39 | import from Osmocom_CTRL_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 40 | |
| 41 | import from RSL_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 42 | import from IPA_Types all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 43 | import from IPA_Emulation all; |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 44 | import from IPA_Testing all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 45 | import from RSL_Emulation all; |
| 46 | |
| 47 | import from IPL4asp_Types all; |
| 48 | import from TRXC_Types all; |
| 49 | import from TRXC_CodecPort all; |
| 50 | import from TRXC_CodecPort_CtrlFunct all; |
| 51 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 52 | import from PCUIF_Types all; |
| 53 | import from PCUIF_CodecPort all; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 54 | import from UD_Types all; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 55 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 56 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 57 | import from MobileL3_RRM_Types all; |
| 58 | import from MobileL3_Types all; |
| 59 | import from L3_Templates all; |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 60 | import from L3_Common all; |
| 61 | import from MobileL3_GMM_SM_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 62 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 63 | import from Osmocom_VTY_Functions all; |
| 64 | import from TELNETasp_PortType all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 65 | import from BTS_Tests_LAPDm all; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 66 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 67 | friend module BTS_Tests_SMSCB; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 68 | friend module BTS_Tests_virtphy; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 69 | friend module BTS_Tests_LAPDm; |
Pau Espin Pedrol | 5a012ee | 2020-02-06 19:33:22 +0100 | [diff] [blame] | 70 | friend module BTS_Tests_perf; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 71 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 72 | /* The tests assume a BTS with the following timeslot configuration: |
| 73 | * TS0 : Combined CCCH + SDCCH/4 |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 74 | * TS1 : TCH/F |
| 75 | * TS2 : TCH/F |
| 76 | * TS3 : TCH/F_PDCH (IPA Style) |
| 77 | * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 78 | * TS5 : TCH/H |
| 79 | * TS6 : SDCCH/8 |
| 80 | * TS7 : PDCH |
| 81 | */ |
| 82 | |
| 83 | modulepar { |
| 84 | charstring mp_rsl_ip := "127.0.0.2"; |
| 85 | integer mp_rsl_port := 3003; |
| 86 | integer mp_trx0_arfcn := 871; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 87 | integer mp_trx1_arfcn := 873; |
| 88 | integer mp_trx2_arfcn := 875; |
| 89 | integer mp_trx3_arfcn := 877; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 90 | charstring mp_bts_trxc_ip := "127.0.0.1"; |
| 91 | integer mp_bts_trxc_port := 5701; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 92 | charstring mp_pcu_socket := PCU_SOCK_DEFAULT; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 93 | charstring mp_ctrl_ip := "127.0.0.1"; |
| 94 | integer mp_ctrl_port := 4238; |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 95 | charstring mp_bsc_ctrl_ip := "127.0.0.1"; |
| 96 | integer mp_bsc_ctrl_port := 4249; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 97 | integer mp_tolerance_rxqual := 1; |
| 98 | integer mp_tolerance_rxlev := 3; |
| 99 | integer mp_tolerance_timing_offset_256syms := 0; |
Pau Espin Pedrol | 752ffd5 | 2018-06-07 13:55:45 +0200 | [diff] [blame] | 100 | integer mp_rxlev_exp := 57; |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 101 | integer mp_ul_rxlev_exp := 10; |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 102 | integer mp_ms_power_level_exp := 7; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 103 | integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */ |
| 104 | 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] | 105 | integer mp_ms_actual_ta_exp := 0; |
| 106 | integer mp_timing_offset_256syms_exp := 512; |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 107 | /* Time to wait for RSL conn from BTS during startup of test */ |
Philipp Maier | 12567e4 | 2019-04-17 14:10:05 +0200 | [diff] [blame] | 108 | float mp_ipa_up_timeout := 15.0; |
Philipp Maier | e63229e | 2019-04-26 12:21:37 +0200 | [diff] [blame] | 109 | float mp_ipa_up_delay := 0.0; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 110 | /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */ |
| 111 | boolean mp_l1_supports_gprs := false; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 112 | } |
| 113 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 114 | type record of RslChannelNr ChannelNrs; |
| 115 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 116 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 117 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 118 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 119 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 120 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 121 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 122 | port RSL_CCHAN_PT RSL_CCHAN; |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 123 | timer g_rslem_up_timer; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 124 | |
| 125 | /* L1CTL port (for classic tests) */ |
| 126 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 127 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 128 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 129 | port TRXC_CODEC_PT BTS_TRXC; |
| 130 | var integer g_bts_trxc_conn_id; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 131 | |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 132 | /* VTY connections to both BTS and BSC */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 133 | port TELNETasp_PT BTSVTY; |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 134 | port TELNETasp_PT BSCVTY; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 135 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 136 | /* PCU Interface of BTS */ |
| 137 | port PCUIF_CODEC_PT PCU; |
| 138 | var integer g_pcu_conn_id; |
| 139 | /* Last PCU INFO IND we received */ |
| 140 | var PCUIF_Message g_pcu_last_info; |
| 141 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 142 | /* SI configuration */ |
| 143 | var SystemInformationConfig si_cfg := { |
| 144 | bcch_extended := false, |
| 145 | si1_present := false, |
| 146 | si2bis_present := false, |
| 147 | si2ter_present := false, |
| 148 | si2quater_present := false, |
| 149 | si7_present := false, |
| 150 | si8_present := false, |
| 151 | si9_present := false, |
| 152 | si13_present := false, |
| 153 | si13alt_present := false, |
| 154 | si15_present := false, |
| 155 | si16_present := false, |
| 156 | si17_present := false, |
| 157 | si2n_present := false, |
| 158 | si21_present := false, |
| 159 | si22_present := false |
| 160 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 161 | |
| 162 | /* all logical channels available on the BTS */ |
| 163 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 164 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | /* an individual call / channel */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 168 | type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 169 | port L1CTL_PT L1CTL; |
| 170 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 171 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 172 | port TRXC_CODEC_PT BTS_TRXC; |
| 173 | var integer g_bts_trxc_conn_id; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 174 | |
| 175 | timer g_Tguard; |
| 176 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 177 | |
| 178 | var ConnHdlrPars g_pars; |
| 179 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 180 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 181 | |
| 182 | /* PCU Interface of BTS */ |
| 183 | port PCUIF_CODEC_PT PCU; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 184 | } |
| 185 | |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 186 | private altstep as_rsl_init_guard() runs on test_CT { |
| 187 | [] g_rslem_up_timer.timeout { |
| 188 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 189 | "Timeout waiting for RSL bring up"); |
| 190 | } |
Vadim Yanitskiy | 96e8c80 | 2020-06-10 14:14:12 +0700 | [diff] [blame] | 191 | /* osmo-bts may send us CCCH LOAD INDication or whatever else */ |
| 192 | [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; } |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 193 | } |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 194 | |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 195 | function f_init_rsl(charstring id) runs on test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 196 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 197 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 198 | |
| 199 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 200 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 201 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 202 | |
| 203 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 204 | vc_RSL.start(RSL_Emulation.main(false)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 205 | |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 206 | /* TTCN-3 offers no way to guard 'interleave' statements */ |
| 207 | g_rslem_up_timer.start(mp_ipa_up_timeout); |
| 208 | var default d := activate(as_rsl_init_guard()); |
| 209 | |
| 210 | /* We expect all 4 transceivers to connect here (separate IPA/RSL connections). |
| 211 | * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */ |
| 212 | interleave { |
| 213 | /* These events are sent by the RSL_Emulation_CT */ |
| 214 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, IPAC_PROTO_RSL_TRX0)); |
| 215 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, IPAC_PROTO_RSL_TRX1)); |
| 216 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, IPAC_PROTO_RSL_TRX2)); |
| 217 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, IPAC_PROTO_RSL_TRX3)); |
| 218 | /* These messages (RF RESource INDication) are sent by the IUT itself */ |
| 219 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, IPAC_PROTO_RSL_TRX0)); |
| 220 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, IPAC_PROTO_RSL_TRX1)); |
| 221 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, IPAC_PROTO_RSL_TRX2)); |
| 222 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, IPAC_PROTO_RSL_TRX3)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 223 | } |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 224 | |
| 225 | g_rslem_up_timer.stop; |
| 226 | deactivate(d); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | type record ConnHdlrPars { |
| 230 | RslChannelNr chan_nr, |
| 231 | RSL_IE_ChannelMode chan_mode, |
| 232 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 233 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 234 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 235 | RSL_IE_EncryptionInfo encr optional, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 236 | BtsBand bts0_band optional, |
| 237 | |
| 238 | /* Frequency hopping parameters (disabled if absent) */ |
| 239 | MaioHsn maio_hsn optional, |
| 240 | /* MA bitmap to be indicated in RR Immediate Assignment */ |
| 241 | MobileAllocation ma_map, |
| 242 | /* The actual Mobile Allocation (ARFCN list) to be used */ |
| 243 | L1ctlMA ma |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | /* Test-specific parameters */ |
| 247 | type union TestSpecUnion { |
| 248 | RllTestCase rll |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 249 | } |
| 250 | |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 251 | template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 252 | max_retrans := RACH_MAX_RETRANS_7, |
| 253 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 254 | cell_barr_access := false, |
| 255 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 256 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 257 | }; |
| 258 | |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 259 | template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 260 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 261 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 262 | acs := '0'B, |
| 263 | neci := true, |
| 264 | rxlev_access_min := 0 |
| 265 | } |
| 266 | |
| 267 | template (value) LocationAreaIdentification ts_LAI_default := { |
| 268 | mcc_mnc := '262F42'H, |
| 269 | lac := 42 |
| 270 | } |
| 271 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 272 | private template (value) GPRSIndicator ts_GPRSIndicator_def := { |
| 273 | ra_colour := 0, |
| 274 | si13_pos := '0'B |
| 275 | } |
| 276 | |
| 277 | private template (value) SI3RestOctets ts_SI3RestOctets_def |
| 278 | modifies ts_SI3RestOctets := { |
| 279 | gprs_ind := { |
| 280 | presence := CSN1_H, |
| 281 | ind := ts_GPRSIndicator_def |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | private template (value) SI4RestOctets ts_SI4RestOctets_def |
| 286 | modifies ts_SI4RestOctets := { |
| 287 | gprs_ind := { |
Vadim Yanitskiy | ab5363f | 2020-05-05 00:30:22 +0700 | [diff] [blame] | 288 | presence := CSN1_H, |
| 289 | ind := ts_GPRSIndicator_def |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 290 | } |
| 291 | } |
| 292 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 293 | /* Default SYSTEM INFORMATION 3 */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 294 | template (value) SystemInformation ts_SI3_default := { |
| 295 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 296 | payload := { |
| 297 | si3 := { |
| 298 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 299 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 300 | ctrl_chan_desc := { |
| 301 | msc_r99 := true, |
| 302 | att := true, |
| 303 | bs_ag_blks_res := 1, |
| 304 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 305 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 306 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 307 | spare := '00'B, |
| 308 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 309 | t3212 := 1 /* 6 minutes */ |
| 310 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 311 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 312 | dn_ind := false, |
| 313 | pwrc := false, |
| 314 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 315 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 316 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 317 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 318 | rach_control := ts_RachCtrl_default, |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 319 | rest_octets := enc_SI3RestOctets(valueof(ts_SI3RestOctets_def)) |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 320 | } |
| 321 | } |
| 322 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 323 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 324 | template (value) SystemInformation ts_SI2_default := { |
| 325 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 326 | payload := { |
| 327 | si2 := { |
| 328 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 329 | ncc_permitted := '11111111'B, |
| 330 | rach_control := ts_RachCtrl_default |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 335 | template (value) SystemInformation ts_SI4_default := { |
| 336 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 337 | payload := { |
| 338 | si4 := { |
| 339 | lai := ts_LAI_default, |
| 340 | cell_sel_par := ts_CellSelPar_default, |
| 341 | rach_control := ts_RachCtrl_default, |
| 342 | cbch_chan_desc := omit, |
| 343 | cbch_mobile_alloc := omit, |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 344 | rest_octets := enc_SI4RestOctets(valueof(ts_SI4RestOctets_def)) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 345 | } |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc) |
| 350 | runs on test_CT { |
| 351 | log("Setting ", rsl_si_type, ": ", si_enc); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 352 | 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] | 353 | } |
| 354 | |
| 355 | function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec) |
| 356 | runs on test_CT { |
| 357 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 358 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 359 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 360 | } |
| 361 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 362 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 363 | map(self:BTSVTY, system:BTSVTY); |
| 364 | f_vty_set_prompts(BTSVTY); |
| 365 | f_vty_transceive(BTSVTY, "enable"); |
| 366 | } |
| 367 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 368 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 369 | map(self:BSCVTY, system:BSCVTY); |
| 370 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 371 | f_vty_transceive(BSCVTY, "enable"); |
| 372 | } |
| 373 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 374 | /* PCU socket may at any time receive a new INFO.ind */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 375 | private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id, |
| 376 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 377 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 378 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 379 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 380 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 381 | [] 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] | 382 | 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] | 383 | } |
| 384 | } |
| 385 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 386 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 387 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 388 | timer T := 2.0; |
| 389 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 390 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 391 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 392 | return; |
| 393 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 394 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 395 | |
| 396 | T.start; |
| 397 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 398 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 399 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 400 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 401 | } |
| 402 | } |
| 403 | } |
| 404 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 405 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 406 | out integer trxc_conn_id) { |
| 407 | var Result res; |
| 408 | |
| 409 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 410 | "", -1, -1, { udp := {} }, {}); |
| 411 | if (not ispresent(res.connId)) { |
| 412 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 413 | "Could not connect to the control (TRXC) interface " & |
| 414 | "of FakeTRX, check your configuration"); |
| 415 | } |
| 416 | trxc_conn_id := res.connId; |
| 417 | } |
| 418 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 419 | /* global init function */ |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 420 | function f_init() runs on test_CT { |
| 421 | var charstring id := testcasename(); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 422 | g_AllChannels := { |
| 423 | /* TS 1..4: TCH/F */ |
| 424 | valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)), |
| 425 | valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)), |
| 426 | /* TS 5: TCH/H */ |
| 427 | valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)), |
| 428 | /* TS 0: SDCCH/4 */ |
| 429 | valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)), |
| 430 | valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)), |
| 431 | /* TS 6: SDCCH/8 */ |
| 432 | valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)), |
| 433 | valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)), |
| 434 | valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)), |
| 435 | valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7)) |
| 436 | }; |
| 437 | |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 438 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 439 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 440 | g_AllChanTypes := { |
| 441 | /* TS 1..4: TCH/F */ |
| 442 | valueof(ts_RslChanNr_Bm(1)), |
| 443 | /* TS 5: TCH/H */ |
| 444 | valueof(ts_RslChanNr_Lm(5,1)), |
| 445 | /* TS 0: SDCCH/4 */ |
| 446 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 447 | /* TS 6: SDCCH/8 */ |
| 448 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 449 | }; |
| 450 | } else { |
| 451 | g_AllChanTypes := { |
| 452 | /* TS 1..4: TCH/F */ |
| 453 | valueof(ts_RslChanNr_Bm(1)), |
| 454 | /* TS 0: SDCCH/4 */ |
| 455 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 456 | /* TS 6: SDCCH/8 */ |
| 457 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 458 | }; |
| 459 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 460 | f_init_rsl(id); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 461 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 462 | f_init_vty(id); |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 463 | f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 464 | |
| 465 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 466 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 467 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 468 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 469 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 470 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 471 | map(self:PCU, system:PCU); |
| 472 | f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 473 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 474 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 475 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 476 | |
| 477 | /* Init TRXC interface to FakeTRX */ |
| 478 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 479 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 480 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 481 | /* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 482 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256))); |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 483 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(-60))); |
Vadim Yanitskiy | de535e0 | 2019-07-26 16:29:27 +0700 | [diff] [blame] | 484 | /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */ |
| 485 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_CI(60))); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 486 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 487 | |
| 488 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 489 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 490 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 491 | } |
| 492 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 493 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
| 494 | function f_init_l1ctl() runs on test_CT { |
| 495 | map(self:L1CTL, system:L1CTL); |
| 496 | f_connect_reset(L1CTL); |
| 497 | } |
| 498 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 499 | type function void_fn(charstring id) runs on ConnHdlr; |
| 500 | |
| 501 | /* create a new test component */ |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 502 | function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 503 | boolean pcu_comp := false, |
| 504 | boolean trxc_comp := false) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 505 | runs on test_CT return ConnHdlr { |
| 506 | var charstring id := testcasename(); |
| 507 | var ConnHdlr vc_conn; |
| 508 | |
| 509 | vc_conn := ConnHdlr.create(id); |
| 510 | /* connect to RSL Emulation main component */ |
| 511 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 512 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 513 | |
| 514 | /* The ConnHdlr component may want to talk to some ports directly, |
| 515 | * so we disconnect it from the test_CT and connect it to the component. |
| 516 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 517 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 518 | unmap(self:PCU, system:PCU); |
| 519 | map(vc_conn:PCU, system:PCU); |
| 520 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 521 | if (trxc_comp) { |
| 522 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 523 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 524 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 525 | |
| 526 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 527 | return vc_conn; |
| 528 | } |
| 529 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 530 | private altstep as_Tguard() runs on ConnHdlr { |
| 531 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 532 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 533 | } |
| 534 | } |
| 535 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 536 | friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) { |
| 537 | f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, ccch_mode, mp_rxlev_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 538 | } |
| 539 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 540 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 541 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 542 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 543 | } |
| 544 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 545 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 546 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 547 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | /* first function started in ConnHdlr component */ |
| 551 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 552 | runs on ConnHdlr { |
| 553 | g_pars := pars; |
| 554 | g_chan_nr := pars.chan_nr; |
| 555 | |
| 556 | map(self:L1CTL, system:L1CTL); |
| 557 | f_connect_reset(L1CTL); |
| 558 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 559 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 560 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 561 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 562 | |
| 563 | g_Tguard.start(pars.t_guard); |
| 564 | activate(as_Tguard()); |
| 565 | |
| 566 | f_rslem_register(0, pars.chan_nr); |
| 567 | |
| 568 | /* call the user-supplied test case function */ |
| 569 | fn.apply(id); |
| 570 | } |
| 571 | |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 572 | function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id, |
| 573 | boolean ignore_other := false) |
| 574 | runs on ConnHdlr return RSL_Message { |
| 575 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 576 | timer T := 3.0; |
| 577 | RSL.send(tx); |
| 578 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 579 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 580 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 581 | T.stop; |
| 582 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 583 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 584 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 585 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 586 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 587 | [not ignore_other] as_l1_sacch(); |
| 588 | [not ignore_other] as_meas_res(); |
| 589 | [not ignore_other] as_l1_dcch(); |
| 590 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 591 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 592 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 593 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 594 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 595 | return rx; |
| 596 | } |
| 597 | |
| 598 | function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id, |
| 599 | boolean ignore_other := false) |
| 600 | runs on ConnHdlr { |
| 601 | 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] | 602 | } |
| 603 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 604 | function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false, RSL_IE_List more_ies := {}, |
| 605 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) runs on ConnHdlr { |
| 606 | 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] | 607 | if (encr_enable) { |
| 608 | /* append encryption related IEs, if requested */ |
| 609 | var RSL_IE_EncryptionInfo encr_info; |
| 610 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 611 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 612 | encr_info})) }; |
| 613 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 614 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 615 | 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] | 616 | } |
| 617 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 618 | function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 619 | 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] | 620 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 621 | } |
| 622 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 623 | /* Default Mobile Allocation to be used for frequency hopping */ |
| 624 | private const L1ctlMA l1ctl_ma_def := { { false, mp_trx0_arfcn }, { false, mp_trx1_arfcn }, |
| 625 | { false, mp_trx2_arfcn }, { false, mp_trx3_arfcn } }; |
| 626 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 627 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 628 | template RSL_IE_ChannelMode chan_mode, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 629 | template (omit) MaioHsn maio_hsn := omit, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 630 | float t_guard := 20.0) := { |
| 631 | chan_nr := valueof(chan_nr), |
| 632 | chan_mode := valueof(chan_mode), |
| 633 | t_guard := t_guard, |
| 634 | l1_pars := { |
| 635 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 636 | toa256_enabled := false, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 637 | meas_ul := { |
| 638 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 639 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 640 | rxqual := 0 |
| 641 | }, |
| 642 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 643 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 644 | rxqual := 0 |
| 645 | } |
| 646 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 647 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 648 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 649 | ms_power_level := mp_ms_power_level_exp, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 650 | ms_actual_ta := mp_ms_actual_ta_exp |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 651 | }, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 652 | spec := omit, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 653 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 654 | bts0_band := omit, |
| 655 | maio_hsn := maio_hsn, |
| 656 | ma_map := c_MA_null, |
| 657 | ma := l1ctl_ma_def |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 658 | } |
| 659 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 660 | /*********************************************************************** |
| 661 | * Channel Activation / Deactivation |
| 662 | ***********************************************************************/ |
| 663 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 664 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
| 665 | function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
| 666 | for (var integer i := 0; i < 500; i := i+1) { |
| 667 | f_rsl_chan_act(g_pars.chan_mode); |
| 668 | f_rsl_chan_deact(); |
| 669 | } |
| 670 | setverdict(pass); |
| 671 | } |
| 672 | testcase TC_chan_act_stress() runs on test_CT { |
| 673 | var ConnHdlr vc_conn; |
| 674 | 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] | 675 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 676 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 677 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 678 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | /* Test if re-activation of an already active channel fails as expected */ |
| 682 | function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
| 683 | f_rsl_chan_act(g_pars.chan_mode); |
| 684 | /* attempt to activate the same lchan again -> expect reject */ |
| 685 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 686 | alt { |
| 687 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 688 | 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] | 689 | } |
| 690 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 691 | setverdict(pass); |
| 692 | } |
| 693 | } |
| 694 | f_rsl_chan_deact(); |
| 695 | } |
| 696 | testcase TC_chan_act_react() runs on test_CT { |
| 697 | var ConnHdlr vc_conn; |
| 698 | 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] | 699 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 700 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 701 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 702 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | /* Attempt to de-activate a channel that's not active */ |
| 706 | function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr { |
| 707 | timer T := 3.0; |
| 708 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 709 | T.start; |
| 710 | alt { |
| 711 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 712 | setverdict(pass); |
| 713 | } |
| 714 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 715 | 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] | 716 | } |
| 717 | } |
| 718 | } |
| 719 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 720 | 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] | 721 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 722 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 723 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 724 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
| 728 | function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr { |
| 729 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 730 | alt { |
| 731 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 732 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 733 | } |
| 734 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 735 | setverdict(pass); |
| 736 | } |
| 737 | } |
| 738 | } |
| 739 | private type record WrongChanNrCase { |
| 740 | RslChannelNr chan_nr, |
| 741 | charstring description |
| 742 | } |
| 743 | private type record of WrongChanNrCase WrongChanNrCases; |
| 744 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 745 | chan_nr := chan_nr, |
| 746 | description := desc |
| 747 | } |
| 748 | |
| 749 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 750 | var ConnHdlr vc_conn; |
| 751 | var ConnHdlrPars pars; |
| 752 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 753 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 754 | |
| 755 | var WrongChanNrCases wrong := { |
| 756 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 757 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 758 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 759 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 760 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 761 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 762 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 763 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 764 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 765 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 766 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 767 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 768 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 769 | }; |
| 770 | |
| 771 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 772 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 773 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 774 | vc_conn.done; |
| 775 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 776 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 777 | } |
| 778 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 779 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 780 | 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] | 781 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 782 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 783 | |
| 784 | /* test on each of the channels we have */ |
| 785 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 786 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 787 | |
| 788 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 789 | vc_conn := f_start_handler(fn, pars); |
| 790 | vc_conn.done; |
| 791 | } |
| 792 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 793 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 794 | } |
| 795 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 796 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 797 | * SACCH handling |
| 798 | ***********************************************************************/ |
| 799 | |
| 800 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 801 | timer T_sacch := 3.0; |
| 802 | T_sacch.start; |
| 803 | alt { |
| 804 | [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] | 805 | 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] | 806 | } |
| 807 | [not exp] T_sacch.timeout { |
| 808 | setverdict(pass); |
| 809 | } |
| 810 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 811 | setverdict(pass); |
| 812 | } |
| 813 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 814 | 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] | 815 | } |
| 816 | [] L1CTL.receive { repeat; } |
| 817 | [] RSL.receive { repeat; } |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 822 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 823 | f_l1_tune(L1CTL); |
| 824 | RSL.clear; |
| 825 | |
| 826 | /* activate the logical channel */ |
| 827 | f_est_dchan(); |
| 828 | L1CTL.clear; |
| 829 | |
| 830 | /* check that SACCH actually are received as expected */ |
| 831 | f_exp_sacch(true); |
| 832 | |
| 833 | /* deactivate SACCH on the logical channel */ |
| 834 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 835 | f_sleep(1.0); |
| 836 | L1CTL.clear; |
| 837 | |
| 838 | /* check that no SACCH are received anymore */ |
| 839 | f_exp_sacch(false); |
| 840 | |
| 841 | /* release the channel */ |
| 842 | f_rsl_chan_deact(); |
| 843 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 844 | } |
| 845 | testcase TC_deact_sacch() runs on test_CT { |
| 846 | var ConnHdlr vc_conn; |
| 847 | var ConnHdlrPars pars; |
| 848 | f_init(); |
| 849 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 850 | //for (var integer i := 0; i < 1; i := i+1) { |
| 851 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 852 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 853 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 854 | vc_conn.done; |
| 855 | } |
| 856 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 857 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 858 | } |
| 859 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 860 | /* verify that given SACCH payload is present */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 861 | private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr { |
| 862 | var L1ctlDlMessage dl; |
| 863 | /* check that the specified SI5 value is actually sent */ |
| 864 | timer T_sacch := 3.0; |
| 865 | L1CTL.clear; |
| 866 | T_sacch.start; |
| 867 | alt { |
| 868 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 869 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 870 | if (match(l3, l3_exp)) { |
| 871 | setverdict(pass); |
| 872 | } else { |
| 873 | repeat; |
| 874 | } |
| 875 | } |
| 876 | [] L1CTL.receive { repeat; } |
| 877 | [] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 878 | 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] | 879 | } |
| 880 | } |
| 881 | } |
| 882 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 883 | /* verify that given SACCH payload is not present */ |
| 884 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 885 | var L1ctlDlMessage dl; |
| 886 | /* check that the specified SI5 value is actually sent */ |
| 887 | timer T_sacch := 3.0; |
| 888 | L1CTL.clear; |
| 889 | T_sacch.start; |
| 890 | alt { |
| 891 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 892 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 893 | if (match(l3, l3_exp)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 894 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl)); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 895 | } else { |
| 896 | repeat; |
| 897 | } |
| 898 | } |
| 899 | [] L1CTL.receive { repeat; } |
| 900 | [] T_sacch.timeout { |
| 901 | setverdict(pass); |
| 902 | } |
| 903 | } |
| 904 | } |
| 905 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 906 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 907 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 908 | /* Set a known default SACCH filling for SI5 */ |
| 909 | var octetstring si5 := f_rnd_octstring(19); |
| 910 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 911 | |
| 912 | f_l1_tune(L1CTL); |
| 913 | RSL.clear; |
| 914 | |
| 915 | /* activate the logical channel */ |
| 916 | f_est_dchan(); |
| 917 | |
| 918 | /* check that the specified SI5 value is actually sent */ |
| 919 | f_sacch_present(si5); |
| 920 | |
| 921 | /* release the channel */ |
| 922 | RSL.clear; |
| 923 | f_rsl_chan_deact(); |
| 924 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 925 | } |
| 926 | testcase TC_sacch_filling() runs on test_CT { |
| 927 | var ConnHdlr vc_conn; |
| 928 | var ConnHdlrPars pars; |
| 929 | f_init(); |
| 930 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 931 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 932 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 933 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 934 | vc_conn.done; |
| 935 | } |
| 936 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 937 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 938 | } |
| 939 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 940 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 941 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 942 | /* Set a known default SACCH filling for SI5 */ |
| 943 | var octetstring si5 := f_rnd_octstring(19); |
| 944 | var octetstring si5_diff := f_rnd_octstring(19); |
| 945 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 946 | |
| 947 | f_l1_tune(L1CTL); |
| 948 | RSL.clear; |
| 949 | |
| 950 | log("Activating channel, expecting standard SI5"); |
| 951 | /* activate the logical channel */ |
| 952 | f_est_dchan(); |
| 953 | /* check that the specified SI5 value is actually sent */ |
| 954 | f_sacch_present(si5); |
| 955 | |
| 956 | /* set channel-specific different SI5 */ |
| 957 | log("Setting channel specific SACCH INFO, expecting it"); |
| 958 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 959 | /* check that the specified lchan-specific value is now used */ |
| 960 | f_sacch_present(si5_diff); |
| 961 | |
| 962 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 963 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 964 | f_rsl_chan_deact(); |
| 965 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 966 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 967 | f_sacch_present(si5); |
| 968 | |
| 969 | /* release the channel */ |
| 970 | RSL.clear; |
| 971 | f_rsl_chan_deact(); |
| 972 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 973 | } |
| 974 | testcase TC_sacch_info_mod() runs on test_CT { |
| 975 | var ConnHdlr vc_conn; |
| 976 | var ConnHdlrPars pars; |
| 977 | f_init(); |
| 978 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 979 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 980 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 981 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 982 | vc_conn.done; |
| 983 | } |
| 984 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 985 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 986 | } |
| 987 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 988 | /* Test SACCH scheduling of multiple different SI message types */ |
| 989 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 990 | var octetstring si5 := f_rnd_octstring(19); |
| 991 | var octetstring si5bis := f_rnd_octstring(19); |
| 992 | var octetstring si5ter := f_rnd_octstring(19); |
| 993 | var octetstring si6 := f_rnd_octstring(19); |
| 994 | |
| 995 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 996 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 997 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 998 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 999 | |
| 1000 | f_l1_tune(L1CTL); |
| 1001 | RSL.clear; |
| 1002 | |
| 1003 | /* activate the logical channel */ |
| 1004 | f_est_dchan(); |
| 1005 | L1CTL.clear; |
| 1006 | |
| 1007 | /* check that SACCH actually are received as expected */ |
| 1008 | f_sacch_present(si5); |
| 1009 | f_sacch_present(si5bis); |
| 1010 | f_sacch_present(si5ter); |
| 1011 | f_sacch_present(si6); |
| 1012 | |
| 1013 | /* release the channel */ |
| 1014 | f_rsl_chan_deact(); |
| 1015 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1016 | } |
| 1017 | testcase TC_sacch_multi() runs on test_CT { |
| 1018 | var ConnHdlr vc_conn; |
| 1019 | var ConnHdlrPars pars; |
| 1020 | f_init(); |
| 1021 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1022 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1023 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1024 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 1025 | vc_conn.done; |
| 1026 | } |
| 1027 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1028 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1029 | } |
| 1030 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1031 | /* Test if SACH information is modified as expected */ |
| 1032 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1033 | var octetstring si5 := f_rnd_octstring(19); |
| 1034 | var octetstring si6 := f_rnd_octstring(19); |
| 1035 | |
| 1036 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1037 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1038 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1039 | |
| 1040 | f_l1_tune(L1CTL); |
| 1041 | RSL.clear; |
| 1042 | |
| 1043 | /* activate the logical channel */ |
| 1044 | f_est_dchan(); |
| 1045 | L1CTL.clear; |
| 1046 | |
| 1047 | /* check that SACCH actually are received as expected */ |
| 1048 | f_sacch_present(si5); |
| 1049 | f_sacch_present(si6); |
| 1050 | |
| 1051 | /* disable SI6 */ |
| 1052 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1053 | |
| 1054 | /* check that SI5 is still transmitted */ |
| 1055 | f_sacch_present(si5); |
| 1056 | /* check if SI6 is now gone */ |
| 1057 | f_sacch_missing(si6); |
| 1058 | |
| 1059 | /* release the channel */ |
| 1060 | f_rsl_chan_deact(); |
| 1061 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1062 | } |
| 1063 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1064 | var ConnHdlr vc_conn; |
| 1065 | var ConnHdlrPars pars; |
| 1066 | f_init(); |
| 1067 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1068 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1069 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1070 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1071 | vc_conn.done; |
| 1072 | } |
| 1073 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1074 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1075 | } |
| 1076 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1077 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1078 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1079 | var octetstring si5 := f_rnd_octstring(19); |
| 1080 | var octetstring si6 := f_rnd_octstring(19); |
| 1081 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1082 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1083 | |
| 1084 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1085 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1086 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1087 | |
| 1088 | f_l1_tune(L1CTL); |
| 1089 | RSL.clear; |
| 1090 | |
| 1091 | /* activate channel with different SACCH filling */ |
| 1092 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1093 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1094 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1095 | })); |
| 1096 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1097 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1098 | f_est_dchan(more_ies := addl_ies); |
| 1099 | |
| 1100 | /* check that SACCH actually are received as expected */ |
| 1101 | f_sacch_present(si5_specific); |
| 1102 | f_sacch_present(si6_specific); |
| 1103 | |
| 1104 | /* release the channel */ |
| 1105 | f_rsl_chan_deact(); |
| 1106 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1107 | } |
| 1108 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1109 | var ConnHdlr vc_conn; |
| 1110 | var ConnHdlrPars pars; |
| 1111 | f_init(); |
| 1112 | |
| 1113 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1114 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1115 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1116 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1117 | vc_conn.done; |
| 1118 | } |
| 1119 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1120 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1121 | } |
| 1122 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1123 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1124 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1125 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1126 | var octetstring si5 := f_rnd_octstring(19); |
| 1127 | |
| 1128 | f_l1_tune(L1CTL); |
| 1129 | RSL.clear; |
| 1130 | |
| 1131 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1132 | |
| 1133 | /* Activate channel on BTS side */ |
| 1134 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1135 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1136 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1137 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1138 | |
| 1139 | /* Verify that no DL SACCH is being received */ |
| 1140 | f_sacch_missing(?); |
| 1141 | |
| 1142 | f_rsl_chan_deact(); |
| 1143 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1144 | |
| 1145 | |
| 1146 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1147 | |
| 1148 | /* Activate channel on BTS side */ |
| 1149 | var RSL_IE_List addl_ies := { |
| 1150 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1151 | }; |
| 1152 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1153 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1154 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1155 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1156 | |
| 1157 | /* Verify that DL SACCH is being received */ |
| 1158 | f_sacch_present(si5); |
| 1159 | |
| 1160 | f_rsl_chan_deact(); |
| 1161 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1162 | } |
| 1163 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1164 | var ConnHdlr vc_conn; |
| 1165 | var ConnHdlrPars pars; |
| 1166 | f_init(); |
| 1167 | |
| 1168 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1169 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1170 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1171 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1172 | vc_conn.done; |
| 1173 | } |
| 1174 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1175 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1176 | } |
| 1177 | |
| 1178 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1179 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1180 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1181 | var octetstring si5 := f_rnd_octstring(19); |
| 1182 | var RSL_IE_List addl_ies; |
| 1183 | |
| 1184 | f_l1_tune(L1CTL); |
| 1185 | RSL.clear; |
| 1186 | |
| 1187 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1188 | |
| 1189 | /* Activate channel on BTS side */ |
| 1190 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1191 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1192 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1193 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1194 | |
| 1195 | /* Verify that no DL SACCH is being received */ |
| 1196 | f_sacch_missing(?); |
| 1197 | |
| 1198 | f_rsl_chan_deact(); |
| 1199 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1200 | |
| 1201 | |
| 1202 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1203 | |
| 1204 | /* Activate channel on BTS side */ |
| 1205 | addl_ies := { |
| 1206 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1207 | }; |
| 1208 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1209 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1210 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1211 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1212 | |
| 1213 | /* Verify that no DL SACCH is being received */ |
| 1214 | f_sacch_missing(?); |
| 1215 | |
| 1216 | f_rsl_chan_deact(); |
| 1217 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1218 | |
| 1219 | |
| 1220 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1221 | |
| 1222 | /* Activate channel on BTS side */ |
| 1223 | addl_ies := { |
| 1224 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1225 | }; |
| 1226 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1227 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1228 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1229 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1230 | |
| 1231 | /* Verify that no DL SACCH is being received */ |
| 1232 | f_sacch_missing(?); |
| 1233 | |
| 1234 | f_rsl_chan_deact(); |
| 1235 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1236 | |
| 1237 | |
| 1238 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1239 | |
| 1240 | /* Activate channel on BTS side */ |
| 1241 | addl_ies := { |
| 1242 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1243 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1244 | }; |
| 1245 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1246 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1247 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1248 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1249 | |
| 1250 | /* Verify that DL SACCH is being received */ |
| 1251 | f_sacch_present(si5); |
| 1252 | |
| 1253 | f_rsl_chan_deact(); |
| 1254 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1255 | } |
| 1256 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1257 | var ConnHdlr vc_conn; |
| 1258 | var ConnHdlrPars pars; |
| 1259 | f_init(); |
| 1260 | |
| 1261 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1262 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1263 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1264 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1265 | vc_conn.done; |
| 1266 | } |
| 1267 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1268 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1269 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1270 | |
| 1271 | |
| 1272 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1273 | * RACH Handling |
| 1274 | ***********************************************************************/ |
| 1275 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1276 | /* like L1SAP_IS_PACKET_RACH */ |
| 1277 | private function ra_is_ps(OCT1 ra) return boolean { |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1278 | if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1279 | return true; |
| 1280 | } |
| 1281 | return false; |
| 1282 | } |
| 1283 | |
| 1284 | /* generate a random RACH for circuit-switched */ |
| 1285 | private function f_rnd_ra_cs() return OCT1 { |
| 1286 | var OCT1 ra; |
| 1287 | do { |
| 1288 | ra := f_rnd_octstring(1); |
| 1289 | } while (ra_is_ps(ra)); |
| 1290 | return ra; |
| 1291 | } |
| 1292 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 1293 | /* generate a random RACH for packet-switched */ |
| 1294 | private function f_rnd_ra_ps() return OCT1 { |
| 1295 | var OCT1 ra; |
| 1296 | do { |
| 1297 | ra := f_rnd_octstring(1); |
| 1298 | } while (not ra_is_ps(ra)); |
| 1299 | return ra; |
| 1300 | } |
| 1301 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 1302 | /* generate a random 11-bit RA (packet-switched only) */ |
| 1303 | private function f_rnd_ra11_ps() return BIT11 { |
| 1304 | var integer ra11 := f_rnd_int(bit2int('11111111111'B)); |
| 1305 | return int2bit(ra11, 11); |
| 1306 | } |
| 1307 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1308 | /* Send 1000 RACH requests and check their RA+FN on the RSL side */ |
| 1309 | testcase TC_rach_content() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1310 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1311 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1312 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1313 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1314 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1315 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1316 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1317 | var OCT1 ra := f_rnd_ra_cs(); |
| 1318 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1319 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1320 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1321 | } |
| 1322 | fn_last := fn; |
| 1323 | |
| 1324 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1325 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1326 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1327 | [] 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] | 1328 | T.stop; |
| 1329 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1330 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1331 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1332 | } |
| 1333 | [] RSL_CCHAN.receive { repeat; } |
| 1334 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1335 | test_failed := true; |
| 1336 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1337 | } |
| 1338 | } |
| 1339 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1340 | if (test_failed) { |
| 1341 | 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] | 1342 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1343 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1344 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1345 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1346 | |
| 1347 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1348 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1349 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1350 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1351 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1352 | f_l1_tune(L1CTL); |
| 1353 | |
| 1354 | var GsmFrameNumber fn_last := 0; |
| 1355 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1356 | var OCT1 ra := f_rnd_ra_cs(); |
| 1357 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1358 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1359 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1360 | } |
| 1361 | fn_last := fn; |
| 1362 | } |
| 1363 | var integer rsl_chrqd := 0; |
| 1364 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1365 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1366 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1367 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1368 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1369 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1370 | repeat; |
| 1371 | } |
| 1372 | [] RSL_CCHAN.receive { repeat; } |
| 1373 | [] T.timeout { } |
| 1374 | } |
| 1375 | if (rsl_chrqd == 1000) { |
| 1376 | setverdict(pass); |
| 1377 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1378 | 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] | 1379 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1380 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1381 | } |
| 1382 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1383 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1384 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1385 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1386 | } |
| 1387 | |
| 1388 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1389 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1390 | |
| 1391 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1392 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1393 | var ASP_RSL_Unitdata rx_ud; |
| 1394 | |
| 1395 | f_init_vty_bsc(); |
| 1396 | /* send load indications even at 0% load */ |
| 1397 | f_vty_load_ind_thresh(0); |
| 1398 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1399 | f_sleep(2.0); |
| 1400 | |
| 1401 | f_init(); |
| 1402 | |
| 1403 | timer T := 5.0; |
| 1404 | T.start; |
| 1405 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1406 | [] 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] | 1407 | setverdict(pass); |
| 1408 | repeat; |
| 1409 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1410 | [] 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] | 1411 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1412 | repeat; |
| 1413 | } |
| 1414 | [] RSL_CCHAN.receive { |
| 1415 | repeat; |
| 1416 | } |
| 1417 | [] T.timeout { } |
| 1418 | } |
| 1419 | |
| 1420 | f_vty_load_ind_thresh(10); |
| 1421 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1422 | } |
| 1423 | |
| 1424 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1425 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1426 | var ASP_RSL_Unitdata rx_ud; |
| 1427 | |
| 1428 | f_init_vty_bsc(); |
| 1429 | f_init(); |
| 1430 | |
| 1431 | timer T := 5.0; |
| 1432 | T.start; |
| 1433 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1434 | [] 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] | 1435 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1436 | repeat; |
| 1437 | } |
| 1438 | [] RSL_CCHAN.receive { |
| 1439 | repeat; |
| 1440 | } |
| 1441 | [] T.timeout { |
| 1442 | setverdict(pass); |
| 1443 | } |
| 1444 | } |
| 1445 | |
| 1446 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1447 | } |
| 1448 | |
| 1449 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1450 | testcase TC_rach_load_count() runs on test_CT { |
| 1451 | var ASP_RSL_Unitdata rx_ud; |
| 1452 | var integer load_access_count := 0; |
| 1453 | |
| 1454 | f_init_vty_bsc(); |
| 1455 | /* send load indications even at 0% load */ |
| 1456 | f_vty_load_ind_thresh(0); |
| 1457 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1458 | f_sleep(2.0); |
| 1459 | f_init(); |
| 1460 | |
| 1461 | f_init_l1ctl(); |
| 1462 | f_sleep(1.0); |
| 1463 | f_l1_tune(L1CTL); |
| 1464 | |
| 1465 | var GsmFrameNumber fn_last := 0; |
| 1466 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1467 | var OCT1 ra := f_rnd_ra_cs(); |
| 1468 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1469 | if (fn == fn_last) { |
| 1470 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1471 | } |
| 1472 | fn_last := fn; |
| 1473 | } |
| 1474 | |
| 1475 | timer T := 5.0; |
| 1476 | T.start; |
| 1477 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1478 | [] 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] | 1479 | -> value rx_ud { |
| 1480 | var RSL_IE_Body ie; |
| 1481 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1482 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1483 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1484 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1485 | } |
| 1486 | repeat; |
| 1487 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1488 | [] 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] | 1489 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1490 | repeat; |
| 1491 | } |
| 1492 | [] RSL_CCHAN.receive { |
| 1493 | repeat; |
| 1494 | } |
| 1495 | [] T.timeout { } |
| 1496 | } |
| 1497 | if (load_access_count == 1000) { |
| 1498 | setverdict(pass); |
| 1499 | } else { |
| 1500 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1501 | } |
| 1502 | |
| 1503 | f_vty_load_ind_thresh(10); |
| 1504 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1505 | } |
| 1506 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1507 | 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] | 1508 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1509 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1510 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256))); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1511 | f_sleep(0.5); |
| 1512 | |
| 1513 | /* Transmit RACH request + wait for confirmation */ |
| 1514 | var OCT1 ra := f_rnd_ra_cs(); |
| 1515 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1516 | |
| 1517 | /* Check for expected result */ |
| 1518 | timer T := 1.5; |
| 1519 | T.start; |
| 1520 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1521 | [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] | 1522 | setverdict(pass); |
| 1523 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1524 | [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] | 1525 | 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] | 1526 | } |
| 1527 | [] RSL_CCHAN.receive { repeat; } |
| 1528 | [not expect_pass] T.timeout { |
| 1529 | setverdict(pass); |
| 1530 | } |
| 1531 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1532 | 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] | 1533 | } |
| 1534 | } |
| 1535 | } |
| 1536 | |
| 1537 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1538 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1539 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1540 | f_init_l1ctl(); |
| 1541 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1542 | f_sleep(1.0); |
| 1543 | |
| 1544 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1545 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1546 | /* We allow early arrival up to 2 symbols */ |
| 1547 | f_rach_toffs(-1*256, true); |
| 1548 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1549 | f_rach_toffs(-10*256, false); |
| 1550 | |
| 1551 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1552 | f_rach_toffs(0, true); |
| 1553 | f_rach_toffs(32*256, true); |
| 1554 | f_rach_toffs(63*256, true); |
| 1555 | |
| 1556 | /* more than 63 bits is not legal / permitted */ |
| 1557 | f_rach_toffs(64*256, false); |
| 1558 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1559 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1560 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1561 | |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1562 | function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
| 1563 | var GsmFrameNumber fn; |
| 1564 | var RSL_Message rm; |
| 1565 | |
| 1566 | f_l1_tune(L1CTL); |
| 1567 | RSL.clear; |
| 1568 | |
| 1569 | /* Generate a random Handover Reference */ |
| 1570 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1571 | |
| 1572 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1573 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1574 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1575 | |
| 1576 | /* Activate a channel on the BTS side (no encryption) */ |
| 1577 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1578 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1579 | |
| 1580 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1581 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1582 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1583 | |
| 1584 | /* Send handover Access Burst */ |
| 1585 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1586 | |
| 1587 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1588 | |
| 1589 | /* Wait for handover detection */ |
| 1590 | timer T := 3.0; |
| 1591 | T.start; |
| 1592 | alt { |
| 1593 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1594 | log("Handover RACH has been detected: ", rm); |
| 1595 | setverdict(pass); |
| 1596 | } |
| 1597 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1598 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1599 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1600 | } |
| 1601 | [] RSL.receive { repeat; } |
| 1602 | [] T.timeout { |
| 1603 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1604 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1605 | } |
| 1606 | } |
| 1607 | |
| 1608 | /* Release the channel */ |
| 1609 | f_rsl_chan_deact(); |
| 1610 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1611 | } |
| 1612 | |
| 1613 | /* Test handover RACH detection */ |
| 1614 | testcase TC_ho_rach() runs on test_CT { |
| 1615 | var ConnHdlrPars pars; |
| 1616 | var ConnHdlr vc_conn; |
| 1617 | |
| 1618 | f_init(); |
| 1619 | |
| 1620 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 1621 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1622 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1623 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 1624 | vc_conn.done; |
| 1625 | } |
| 1626 | |
| 1627 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1628 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1629 | } |
| 1630 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1631 | /*********************************************************************** |
| 1632 | * Measurement Processing / Reporting |
| 1633 | ***********************************************************************/ |
| 1634 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1635 | template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := { |
| 1636 | spare := '0'B, |
| 1637 | lpd := 0, |
| 1638 | sapi := sapi, |
| 1639 | c_r := c_r, |
| 1640 | ea := true |
| 1641 | } |
| 1642 | |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1643 | template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1644 | addr := ts_LapdmAddr(sapi, c_r), |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1645 | ctrl := ts_LapdmCtrlUI(p), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1646 | len := 0, /* overwritten */ |
| 1647 | m := false, |
| 1648 | el := 1, |
| 1649 | payload := pl |
| 1650 | } |
| 1651 | |
| 1652 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
| 1653 | altstep as_l1_sacch() runs on ConnHdlr { |
| 1654 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1655 | [] 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] | 1656 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 1657 | var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, mp_rxlev_exp, mp_rxlev_exp, 0, 0, omit)); |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1658 | var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1659 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 1660 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 1661 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
| 1662 | g_pars.l1_pars.ms_power_level, false, |
| 1663 | g_pars.l1_pars.ms_actual_ta); |
| 1664 | |
| 1665 | /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */ |
| 1666 | var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O); |
| 1667 | |
| 1668 | log("Sending Measurement Report: ", l1h, l2); |
| 1669 | 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] | 1670 | repeat; |
| 1671 | } |
| 1672 | } |
| 1673 | |
| 1674 | altstep as_l1_dcch() runs on ConnHdlr { |
| 1675 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1676 | [] 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] | 1677 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 1678 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 1679 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1680 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1681 | repeat; |
| 1682 | } |
| 1683 | } |
| 1684 | |
| 1685 | type record MeasElem { |
| 1686 | uint6_t rxlev, |
| 1687 | uint3_t rxqual |
| 1688 | } |
| 1689 | |
| 1690 | type record MeasElemFS { |
| 1691 | MeasElem full, |
| 1692 | MeasElem sub |
| 1693 | } |
| 1694 | |
| 1695 | type record ConnL1Pars { |
| 1696 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1697 | boolean toa256_enabled, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1698 | MeasElemFS meas_ul, |
| 1699 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 1700 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1701 | uint5_t ms_power_level, |
| 1702 | uint8_t ms_actual_ta |
| 1703 | } |
| 1704 | |
| 1705 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 1706 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 1707 | return 63 + (toffs256s/256); |
| 1708 | } |
| 1709 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1710 | private function f_max(integer a, integer b) return integer { |
| 1711 | if (a > b) { |
| 1712 | return a; |
| 1713 | } else { |
| 1714 | return b; |
| 1715 | } |
| 1716 | } |
| 1717 | |
| 1718 | private function f_min(integer a, integer b) return integer { |
| 1719 | if (a < b) { |
| 1720 | return a; |
| 1721 | } else { |
| 1722 | return b; |
| 1723 | } |
| 1724 | } |
| 1725 | |
| 1726 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 1727 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 1728 | val := val - tolerance; |
| 1729 | return f_max(val, min); |
| 1730 | } |
| 1731 | |
| 1732 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 1733 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 1734 | val := val + tolerance; |
| 1735 | return f_min(val, max); |
| 1736 | } |
| 1737 | |
| 1738 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 1739 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 1740 | return template integer { |
| 1741 | var template integer ret; |
| 1742 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 1743 | return ret; |
| 1744 | } |
| 1745 | |
| 1746 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1747 | /* build a template for matching measurement results against */ |
| 1748 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 1749 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1750 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1751 | len := 3, |
| 1752 | rfu := '0'B, |
| 1753 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1754 | 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] | 1755 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1756 | 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] | 1757 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1758 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 1759 | 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] | 1760 | supp_meas_info := omit |
| 1761 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1762 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 1763 | ul_meas.len := (3+8); |
| 1764 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1765 | 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] | 1766 | toa256_min := ?, |
| 1767 | toa256_max := ?, |
| 1768 | toa256_std_dev := ? |
| 1769 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1770 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1771 | var template RSL_IE_BS_Power bs_power := { |
| 1772 | reserved := 0, |
| 1773 | epc := false, |
| 1774 | fpc := false, |
| 1775 | power_level := l1p.bs_power_level |
| 1776 | }; |
| 1777 | var template RSL_IE_L1Info l1_info := { |
| 1778 | ms_power_lvl := l1p.ms_power_level, |
| 1779 | fpc := false, |
| 1780 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1781 | 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] | 1782 | }; |
| 1783 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1784 | 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] | 1785 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 1786 | ?, t_toffs); |
| 1787 | } |
| 1788 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1789 | /* build a template for matching measurement results that do not contain any |
| 1790 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 1791 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 1792 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1793 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1794 | len := 3, |
| 1795 | rfu := '0'B, |
| 1796 | dtx_d := l1p.dtx_enabled, |
| 1797 | rxlev_f_u := ?, |
| 1798 | reserved1 := '00'B, |
| 1799 | rxlev_s_u := ?, |
| 1800 | reserved2 := '00'B, |
| 1801 | rxq_f_u := ?, |
| 1802 | rxq_s_u := ?, |
| 1803 | supp_meas_info := omit |
| 1804 | }; |
| 1805 | if (l1p.toa256_enabled) { |
| 1806 | ul_meas.len := (3+8); |
| 1807 | ul_meas.supp_meas_info := { |
| 1808 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 1809 | toa256_min := ?, |
| 1810 | toa256_max := ?, |
| 1811 | toa256_std_dev := ? |
| 1812 | } |
| 1813 | } |
| 1814 | var template RSL_IE_BS_Power bs_power := { |
| 1815 | reserved := 0, |
| 1816 | epc := false, |
| 1817 | fpc := false, |
| 1818 | power_level := l1p.bs_power_level |
| 1819 | }; |
| 1820 | |
| 1821 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 1822 | } |
| 1823 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1824 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 1825 | altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1826 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1827 | var boolean chan_est := false; |
| 1828 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 1829 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1830 | |
| 1831 | /* Receive osmocom specific measurement reports. This is the normal |
| 1832 | * case. Here we verify that the measurement reports we sent are |
| 1833 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1834 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 1835 | /* increment counter of next to-be-expected meas rep */ |
| 1836 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1837 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1838 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1839 | |
| 1840 | /* The following two cases may only happen in the beginning |
| 1841 | * of the channel establishment phase. Once we have received |
| 1842 | * the "our" measurement report the first time, the channel |
| 1843 | * is established and empty or hardcoded TRXCON reports must |
| 1844 | * not occur anymore. */ |
| 1845 | chan_est := true; |
| 1846 | |
| 1847 | repeat; |
| 1848 | } |
| 1849 | |
| 1850 | /* When the BTS has established the channel, the MS might need slightly |
| 1851 | * more time to establish the channel and actually start sending. The |
| 1852 | * result is then a measurement report that just lacks the measurement |
| 1853 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 1854 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 1855 | /* increment counter of next to-be-expected meas rep */ |
| 1856 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1857 | /* Re-start the timer expecting the next MEAS RES */ |
| 1858 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1859 | repeat; |
| 1860 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1861 | |
| 1862 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 1863 | * measurements if the TTCN3 side does not supply measurement input in |
| 1864 | * time. In those cases TRXCON will either use a cached measurement |
| 1865 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 1866 | * report the templates above will not match. We tolerate this |
| 1867 | * behavior, but only once. */ |
| 1868 | [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] | 1869 | /* increment counter of next to-be-expected meas rep */ |
| 1870 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1871 | if (g_first_meas_res) { |
| 1872 | g_first_meas_res := false; |
| 1873 | repeat; |
| 1874 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1875 | 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] | 1876 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1877 | } |
| 1878 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1879 | 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] | 1880 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 1881 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1882 | 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] | 1883 | } |
| 1884 | } |
| 1885 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1886 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 1887 | select (rsl_alg_id) { |
| 1888 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 1889 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 1890 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 1891 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 1892 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 1893 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 1894 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 1895 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 1896 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1897 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 1898 | /* Make compiler happy by calling mtc.stop here. It is already |
| 1899 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 1900 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1901 | } |
| 1902 | } |
| 1903 | } |
| 1904 | |
| 1905 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 1906 | select (rsl_alg_id) { |
| 1907 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 1908 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 1909 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 1910 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 1911 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 1912 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 1913 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 1914 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1915 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 1916 | /* Make compiler happy by calling mtc.stop here. It is already |
| 1917 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 1918 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1919 | } |
| 1920 | } |
| 1921 | } |
| 1922 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 1923 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 1924 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 1925 | var GsmFrameNumber fn; |
| 1926 | timer T := 8.0; |
| 1927 | |
| 1928 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 1929 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 1930 | |
| 1931 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 1932 | /* Send the actual RACH */ |
| 1933 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 1934 | |
| 1935 | T.start; |
| 1936 | alt { |
| 1937 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 1938 | [] T.timeout { |
| 1939 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 1940 | } |
| 1941 | } |
| 1942 | T.stop |
| 1943 | return fn; |
| 1944 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1945 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1946 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1947 | 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] | 1948 | var GsmFrameNumber fn; |
| 1949 | var ImmediateAssignment imm_ass; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 1950 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1951 | var integer ra := 23; |
| 1952 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 1953 | /* Send RACH request and wait for ChanReq */ |
| 1954 | fn := f_rach_req_wait_chan_rqd(ra); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1955 | |
| 1956 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1957 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1958 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 1959 | /* Craft channel description (with or without frequency hopping parameters) */ |
| 1960 | if (ispresent(g_pars.maio_hsn)) { |
| 1961 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, maio_hsn := g_pars.maio_hsn)); |
| 1962 | } else { |
| 1963 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr)); |
| 1964 | } |
| 1965 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1966 | /* Send IMM.ASS via CCHAN */ |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 1967 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.ma_map)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1968 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 1969 | |
| 1970 | /* receive IMM.ASS on MS side */ |
| 1971 | var ImmediateAssignment ia_um; |
| 1972 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 1973 | |
| 1974 | /* Make sure that IMM.ASS contains hopping parameters (if enabled) */ |
| 1975 | if (ch_desc.h != ia_um.chan_desc.h) { |
| 1976 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch"); |
| 1977 | } |
| 1978 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1979 | /* enable dedicated mode */ |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 1980 | f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um, ma := g_pars.ma); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1981 | /* enable encryption, if requested */ |
| 1982 | if (encr_enable) { |
| 1983 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 1984 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 1985 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 1986 | |
| 1987 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1988 | } |
| 1989 | |
| 1990 | /* establish DChan, verify existance + contents of measurement reports */ |
| 1991 | function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1992 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1993 | RSL.clear; |
| 1994 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1995 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 1996 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 1997 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1998 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1999 | |
| 2000 | f_est_dchan(); |
| 2001 | |
| 2002 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2003 | * RSL measurement reports on Abis side */ |
| 2004 | timer T := 8.0; |
| 2005 | T.start; |
| 2006 | alt { |
| 2007 | [] as_l1_sacch(); |
| 2008 | [] as_meas_res(); |
| 2009 | [] as_l1_dcch(); |
| 2010 | [] L1CTL.receive { repeat; } |
| 2011 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2012 | /* 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] | 2013 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2014 | setverdict(pass); |
| 2015 | } |
| 2016 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2017 | 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] | 2018 | } |
| 2019 | } |
| 2020 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2021 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2022 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2023 | |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2024 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
| 2025 | function f_TC_tx_power_start_ramp_up_bcch(charstring id) runs on ConnHdlr { |
| 2026 | var L1ctlDlMessage l1_dl; |
| 2027 | f_l1_tune(L1CTL); |
| 2028 | RSL.clear; |
| 2029 | |
| 2030 | var integer initial_rx_lvl := -1; |
| 2031 | var integer last_rx_lvl := -1; |
| 2032 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2033 | |
| 2034 | timer T := 2.0; |
| 2035 | alt { |
| 2036 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2037 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2038 | log("Received rx_level=", rx_lvl); |
| 2039 | if (initial_rx_lvl == -1) { |
| 2040 | initial_rx_lvl := rx_lvl; |
| 2041 | last_rx_lvl := rx_lvl; |
| 2042 | |
| 2043 | /* Expect a somehow low value during first received messages */ |
| 2044 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2045 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2046 | log2str("Detected high initial tx power during ramp up: ", |
| 2047 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2048 | } |
| 2049 | } |
| 2050 | |
| 2051 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2052 | if (rx_lvl > max_rx_lvl) { |
| 2053 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2054 | log2str("Detected Tx power higher than full power: ", |
| 2055 | rx_lvl , " > ", max_rx_lvl)); |
| 2056 | } |
| 2057 | |
| 2058 | /* Make sure it never decreases, since we are rumping up */ |
| 2059 | if (last_rx_lvl > rx_lvl) { |
| 2060 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2061 | log2str("Detected Tx power decrease during ramp up: ", |
| 2062 | last_rx_lvl , " -> ", rx_lvl)); |
| 2063 | } |
| 2064 | |
| 2065 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2066 | /* We reached the maximum power, start timer and receive |
| 2067 | /* a few more to make sure we don't surpass it */ |
| 2068 | log("Reached full power, wating a bit more until success"); |
| 2069 | T.start; |
| 2070 | } |
| 2071 | |
| 2072 | last_rx_lvl := rx_lvl; |
| 2073 | repeat; |
| 2074 | } |
| 2075 | [] L1CTL.receive { repeat; } |
| 2076 | [] T.timeout { } |
| 2077 | } |
| 2078 | |
| 2079 | /* We didn't increase tx power during ramp up */ |
| 2080 | if (initial_rx_lvl < last_rx_lvl) { |
| 2081 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2082 | } else { |
| 2083 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2084 | log2str("No Tx power increase during whole ramp up: ", |
| 2085 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2086 | } |
| 2087 | |
| 2088 | setverdict(pass); |
| 2089 | } |
| 2090 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2091 | var ConnHdlr vc_conn; |
| 2092 | var ConnHdlrPars pars; |
| 2093 | f_init(); |
| 2094 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2095 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2096 | pcu_comp := false, trxc_comp := true); |
| 2097 | vc_conn.done; |
| 2098 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2099 | } |
| 2100 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2101 | function f_check_meas_bs_power_level(integer level) runs on ConnHdlr { |
| 2102 | timer T := 8.0; |
| 2103 | T.start; |
| 2104 | var RSL_Message rsl; |
| 2105 | alt { |
| 2106 | [] as_l1_sacch(); |
| 2107 | [] L1CTL.receive { repeat; } |
| 2108 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 2109 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 2110 | setverdict(pass) |
| 2111 | } else { |
| 2112 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 2113 | } |
| 2114 | } |
| 2115 | [] T.timeout { |
| 2116 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 2117 | } |
| 2118 | } |
| 2119 | } |
| 2120 | |
| 2121 | /* see if the rsl meas res contains our expeced bs power level |
| 2122 | bs power set during assignment */ |
| 2123 | function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr { |
| 2124 | f_l1_tune(L1CTL); |
| 2125 | RSL.clear; |
| 2126 | |
| 2127 | if (mp_bts_trxc_port != -1) { |
| 2128 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2129 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2130 | } |
| 2131 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2132 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2133 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2134 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 2135 | |
| 2136 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2137 | |
| 2138 | f_check_meas_bs_power_level(pwr_var); |
| 2139 | |
| 2140 | f_rsl_chan_deact(); |
| 2141 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2142 | } |
| 2143 | |
| 2144 | /* see if the rsl meas res contains our expeced bs power level |
| 2145 | bs power set after assignment */ |
| 2146 | function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr { |
| 2147 | f_l1_tune(L1CTL); |
| 2148 | RSL.clear; |
| 2149 | |
| 2150 | if (mp_bts_trxc_port != -1) { |
| 2151 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2152 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2153 | } |
| 2154 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2155 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2156 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2157 | |
| 2158 | f_est_dchan(); |
| 2159 | |
| 2160 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 2161 | |
| 2162 | f_check_meas_bs_power_level(pwr_var); |
| 2163 | |
| 2164 | f_rsl_chan_deact(); |
| 2165 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2166 | } |
| 2167 | |
| 2168 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 2169 | var ConnHdlr vc_conn; |
| 2170 | var ConnHdlrPars pars; |
| 2171 | f_init(); |
| 2172 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2173 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2174 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 2175 | pcu_comp := false, trxc_comp := true); |
| 2176 | vc_conn.done; |
| 2177 | } |
| 2178 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2179 | } |
| 2180 | |
| 2181 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 2182 | var ConnHdlr vc_conn; |
| 2183 | var ConnHdlrPars pars; |
| 2184 | f_init(); |
| 2185 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2186 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2187 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 2188 | pcu_comp := false, trxc_comp := true); |
| 2189 | vc_conn.done; |
| 2190 | } |
| 2191 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2192 | } |
| 2193 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2194 | /* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 2195 | second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds, |
| 2196 | These power levels are valid for all bands and require no special handling */ |
| 2197 | function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr { |
| 2198 | var uint5_t pwr_var := 7; |
| 2199 | var L1ctlDlMessage l1_dl; |
| 2200 | |
| 2201 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2202 | f_l1_tune(L1CTL); |
| 2203 | RSL.clear; |
| 2204 | |
| 2205 | var RSL_IE_List addl_ies; |
| 2206 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2207 | |
| 2208 | addl_ies := { |
| 2209 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2210 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2211 | }; |
| 2212 | |
| 2213 | /* establish with power parameters */ |
| 2214 | f_est_dchan(more_ies := addl_ies); |
| 2215 | |
| 2216 | /* set a high value to ensure L1 power control level increases */ |
| 2217 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2218 | |
| 2219 | timer T2 := 6.0; |
| 2220 | T2.start; |
| 2221 | alt { |
| 2222 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2223 | /* Update sent MS power to follow what BTS requests */ |
| 2224 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2225 | if (oct2int(l1_dl.payload.data_ind.payload[0]) < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2226 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2227 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2228 | T2.stop; |
| 2229 | } |
| 2230 | [] L1CTL.receive { repeat; } |
| 2231 | [] T2.timeout { |
| 2232 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2233 | "Power Level in L1 header has not increased sufficiently"); |
| 2234 | } |
| 2235 | } |
| 2236 | |
| 2237 | /* set a low value to ensure L1 power control level decreases */ |
| 2238 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 2239 | |
| 2240 | timer T4 := 6.0; |
| 2241 | T4.start; |
| 2242 | alt { |
| 2243 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2244 | /* Update sent MS power to follow what BTS requests */ |
| 2245 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2246 | if (oct2int(l1_dl.payload.data_ind.payload[0]) > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2247 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2248 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2249 | T4.stop; |
| 2250 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 2251 | } |
| 2252 | [] L1CTL.receive { repeat; } |
| 2253 | [] T4.timeout { |
| 2254 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2255 | "Power Level in L1 header has not decreased sufficiently"); |
| 2256 | } |
| 2257 | } |
| 2258 | |
| 2259 | f_rsl_chan_deact(); |
| 2260 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2261 | |
| 2262 | } |
| 2263 | |
| 2264 | /* check that we do not exceed the max power */ |
| 2265 | function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr { |
| 2266 | var uint5_t pwr_var := 7; |
| 2267 | var L1ctlDlMessage l1_dl; |
| 2268 | |
| 2269 | /* set a low value to ensure power increases */ |
| 2270 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2271 | f_l1_tune(L1CTL); |
| 2272 | RSL.clear; |
| 2273 | |
| 2274 | var RSL_IE_List addl_ies; |
| 2275 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2276 | |
| 2277 | addl_ies := { |
| 2278 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2279 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2280 | }; |
| 2281 | |
| 2282 | /* establish with power parameters */ |
| 2283 | f_est_dchan(more_ies := addl_ies); |
| 2284 | |
| 2285 | timer T1 := 10.0; |
| 2286 | T1.start; |
| 2287 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2288 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2289 | /* Update sent MS power to follow what BTS requests */ |
| 2290 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2291 | repeat; |
| 2292 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2293 | [] L1CTL.receive { repeat; } |
| 2294 | [] T1.timeout { |
| 2295 | if( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var){ |
| 2296 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 2297 | } |
| 2298 | } |
| 2299 | } |
| 2300 | |
| 2301 | f_rsl_chan_deact(); |
| 2302 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2303 | |
| 2304 | } |
| 2305 | |
| 2306 | /* see if we reach the band max power */ |
| 2307 | function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr { |
| 2308 | var L1ctlDlMessage l1_dl; |
| 2309 | var uint5_t pwr_var := 15; |
| 2310 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 2311 | |
| 2312 | /* set a low value to ensure power increases */ |
| 2313 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2314 | f_l1_tune(L1CTL); |
| 2315 | RSL.clear; |
| 2316 | |
| 2317 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2318 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2319 | |
| 2320 | /* establish with fixed power level */ |
| 2321 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2322 | |
| 2323 | /* check our initial power level */ |
| 2324 | f_wait_for_l1_power_level(pwr_var); |
| 2325 | |
| 2326 | /* update power param to enable power loop |
| 2327 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 2328 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 2329 | |
| 2330 | /* wait, then check that our power level was reduced */ |
| 2331 | timer T1 := 10.0; |
| 2332 | T1.start; |
| 2333 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2334 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2335 | /* Update sent MS power to follow what BTS requests */ |
| 2336 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2337 | repeat; |
| 2338 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2339 | [] L1CTL.receive { repeat; } |
| 2340 | [] T1.timeout { |
| 2341 | var int8_t rcv := oct2int(l1_dl.payload.data_ind.payload[0]); |
| 2342 | if( f_power_level_is_highest_dbm(rcv) ){ |
| 2343 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 2344 | } else { |
| 2345 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2346 | log2str("Power Level in L1 header did not reach the expected value, e:",pwr_max_var," r:",rcv)); |
| 2347 | } |
| 2348 | } |
| 2349 | } |
| 2350 | |
| 2351 | f_rsl_chan_deact(); |
| 2352 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2353 | |
| 2354 | } |
| 2355 | |
| 2356 | /* see if we reach the band min power */ |
| 2357 | function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr { |
| 2358 | var L1ctlDlMessage l1_dl; |
| 2359 | |
| 2360 | /* set a high value to ensure power decreases */ |
| 2361 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2362 | f_l1_tune(L1CTL); |
| 2363 | RSL.clear; |
| 2364 | |
| 2365 | var uint5_t pwr_var := 5; |
| 2366 | var uint5_t pwr_target_val := 15; |
| 2367 | |
| 2368 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2369 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2370 | |
| 2371 | /* establish with fixed power level */ |
| 2372 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2373 | |
| 2374 | /* check our initial power level */ |
| 2375 | f_wait_for_l1_power_level(pwr_var); |
| 2376 | |
| 2377 | /* update power param to enable power loop |
| 2378 | 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] | 2379 | 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] | 2380 | |
| 2381 | /* wait, then check that our power level was increased */ |
| 2382 | timer T1 := 10.0; |
| 2383 | T1.start; |
| 2384 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2385 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2386 | /* Update sent MS power to follow what BTS requests */ |
| 2387 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2388 | repeat; |
| 2389 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2390 | [] L1CTL.receive { repeat; } |
| 2391 | [] T1.timeout { |
| 2392 | if( f_power_level_is_lowest_dbm(oct2int(l1_dl.payload.data_ind.payload[0])) ){ |
| 2393 | setverdict(pass, "Power level in L1 header increased to lowest power value"); |
| 2394 | } else { |
| 2395 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2396 | "Power level in L1 header NOT increased to lowest power value"); |
| 2397 | } |
| 2398 | } |
| 2399 | } |
| 2400 | |
| 2401 | f_rsl_chan_deact(); |
| 2402 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2403 | |
| 2404 | } |
| 2405 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2406 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2407 | rsl chan act WITHOUT power parameters */ |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2408 | function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr { |
| 2409 | var L1ctlDlMessage l1_dl; |
| 2410 | |
| 2411 | /* set a high value to ensure power decreases */ |
| 2412 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2413 | f_l1_tune(L1CTL); |
| 2414 | RSL.clear; |
| 2415 | |
| 2416 | var uint5_t pwr_var := 5; |
| 2417 | |
| 2418 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2419 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2420 | |
| 2421 | /* establish with fixed power level */ |
| 2422 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2423 | |
| 2424 | /* check our initial power level */ |
| 2425 | f_wait_for_l1_power_level(pwr_var); |
| 2426 | |
| 2427 | /* wait, then check that our power level did not change */ |
| 2428 | timer T1 := 10.0; |
| 2429 | T1.start; |
| 2430 | alt { |
| 2431 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2432 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2433 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2434 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2435 | } |
| 2436 | repeat; |
| 2437 | } |
| 2438 | [] L1CTL.receive { repeat; } |
| 2439 | [] T1.timeout { setverdict(pass); } |
| 2440 | } |
| 2441 | |
| 2442 | f_rsl_chan_deact(); |
| 2443 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2444 | |
| 2445 | } |
| 2446 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2447 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2448 | ms power control WITHOUT power parameters */ |
| 2449 | function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr { |
| 2450 | var L1ctlDlMessage l1_dl; |
| 2451 | |
| 2452 | /* set a high value to ensure power decreases */ |
| 2453 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2454 | f_l1_tune(L1CTL); |
| 2455 | RSL.clear; |
| 2456 | |
| 2457 | var uint5_t pwr_var := 5; |
| 2458 | |
| 2459 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2460 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2461 | |
| 2462 | /* establish with fixed power level */ |
| 2463 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2464 | |
| 2465 | /* check our initial power level */ |
| 2466 | f_wait_for_l1_power_level(pwr_var); |
| 2467 | |
| 2468 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 2469 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2470 | |
| 2471 | /* wait, then check that our power level did not change */ |
| 2472 | timer T1 := 10.0; |
| 2473 | T1.start; |
| 2474 | alt { |
| 2475 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2476 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2477 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2478 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2479 | } |
| 2480 | repeat; |
| 2481 | } |
| 2482 | [] L1CTL.receive { repeat; } |
| 2483 | [] T1.timeout { setverdict(pass); } |
| 2484 | } |
| 2485 | |
| 2486 | f_rsl_chan_deact(); |
| 2487 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2488 | |
| 2489 | } |
| 2490 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2491 | function f_wait_for_l1_power_level(integer level) runs on ConnHdlr { |
| 2492 | var L1ctlDlMessage l1_dl; |
| 2493 | timer T0 := 10.0; |
| 2494 | T0.start; |
| 2495 | alt { |
| 2496 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2497 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(level, 1))) { |
| 2498 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2499 | "Power level in L1 header != signaled (RSL) power level."); |
| 2500 | } |
| 2501 | } |
| 2502 | [] L1CTL.receive { repeat; } |
| 2503 | [] T0.timeout { |
| 2504 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2505 | "Timeout waiting for initial power level"); |
| 2506 | } |
| 2507 | } |
| 2508 | T0.stop; |
| 2509 | } |
| 2510 | |
| 2511 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2512 | var IntegerRecord min_dbm_level; |
| 2513 | var IntegerRecord max_dbm_level; |
| 2514 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2515 | |
| 2516 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 2517 | if (min_dbm_level[i] == level) { |
| 2518 | return true; |
| 2519 | } |
| 2520 | } |
| 2521 | return false; |
| 2522 | } |
| 2523 | |
| 2524 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2525 | var IntegerRecord min_dbm_level; |
| 2526 | var IntegerRecord max_dbm_level; |
| 2527 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2528 | |
| 2529 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 2530 | if (max_dbm_level[i] == level) { |
| 2531 | return true; |
| 2532 | } |
| 2533 | } |
| 2534 | return false; |
| 2535 | } |
| 2536 | |
| 2537 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 2538 | var IntegerRecord min_dbm_level; |
| 2539 | var IntegerRecord max_dbm_level; |
| 2540 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2541 | return max_dbm_level[0]; |
| 2542 | } |
| 2543 | |
| 2544 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
| 2545 | template charstring BtsBand_allGSM:= pattern "GSM???"; |
| 2546 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 2547 | // 45.005 4.1.1 |
| 2548 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 2549 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 2550 | 2, 1, 0}; |
| 2551 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 2552 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 2553 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 2554 | var IntegerRecord rv; |
| 2555 | |
| 2556 | select(band){ |
| 2557 | case (BtsBand_allGSM){ |
| 2558 | rv := gsm_power; |
| 2559 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 2560 | max_dbm_level := {2, 1, 0}; |
| 2561 | } |
| 2562 | case("DCS1800"){ |
| 2563 | rv := dcs_power; |
| 2564 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 2565 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 2566 | } |
| 2567 | case("PCS1900"){ |
| 2568 | rv := pcs_power; |
| 2569 | min_dbm_level := {15}; |
| 2570 | max_dbm_level := {30}; |
| 2571 | } |
| 2572 | } |
| 2573 | |
| 2574 | return rv; |
| 2575 | } |
| 2576 | |
| 2577 | private function f_vty_get_bts0_band() runs on test_CT return BtsBand { |
| 2578 | return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of \w+ type in band (\w+),*", 0); |
| 2579 | } |
| 2580 | |
| 2581 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 2582 | var ConnHdlr vc_conn; |
| 2583 | var ConnHdlrPars pars; |
| 2584 | f_init(); |
| 2585 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2586 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2587 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2588 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2589 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 2590 | vc_conn.done; |
| 2591 | } |
| 2592 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2593 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2594 | } |
| 2595 | |
| 2596 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 2597 | var ConnHdlr vc_conn; |
| 2598 | var ConnHdlrPars pars; |
| 2599 | f_init(); |
| 2600 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2601 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2602 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2603 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2604 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 2605 | vc_conn.done; |
| 2606 | } |
| 2607 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2608 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2609 | } |
| 2610 | |
| 2611 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 2612 | var ConnHdlr vc_conn; |
| 2613 | var ConnHdlrPars pars; |
| 2614 | f_init(); |
| 2615 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2616 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2617 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2618 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2619 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 2620 | vc_conn.done; |
| 2621 | } |
| 2622 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2623 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2624 | } |
| 2625 | |
| 2626 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 2627 | var ConnHdlr vc_conn; |
| 2628 | var ConnHdlrPars pars; |
| 2629 | f_init(); |
| 2630 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2631 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2632 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2633 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2634 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 2635 | vc_conn.done; |
| 2636 | } |
| 2637 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2638 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2639 | } |
| 2640 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2641 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 2642 | var ConnHdlr vc_conn; |
| 2643 | var ConnHdlrPars pars; |
| 2644 | f_init(); |
| 2645 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2646 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2647 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2648 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2649 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 2650 | vc_conn.done; |
| 2651 | } |
| 2652 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2653 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2654 | } |
| 2655 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2656 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 2657 | var ConnHdlr vc_conn; |
| 2658 | var ConnHdlrPars pars; |
| 2659 | f_init(); |
| 2660 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2661 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2662 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2663 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2664 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 2665 | vc_conn.done; |
| 2666 | } |
| 2667 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2668 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2669 | } |
| 2670 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2671 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 2672 | var ConnHdlr vc_conn; |
| 2673 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2674 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2675 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2676 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 2677 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2678 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2679 | vc_conn.done; |
| 2680 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2681 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2682 | } |
| 2683 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 2684 | var ConnHdlr vc_conn; |
| 2685 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2686 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2687 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 2688 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
Eric Wild | 5b9ef14 | 2019-07-11 19:28:02 +0200 | [diff] [blame] | 2689 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2690 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2691 | vc_conn.done; |
| 2692 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2693 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2694 | } |
| 2695 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 2696 | var ConnHdlr vc_conn; |
| 2697 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2698 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2699 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 2700 | 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] | 2701 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2702 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2703 | vc_conn.done; |
| 2704 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2705 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2706 | } |
| 2707 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 2708 | var ConnHdlr vc_conn; |
| 2709 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2710 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2711 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 2712 | 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] | 2713 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2714 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2715 | vc_conn.done; |
| 2716 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2717 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2718 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2719 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 2720 | var ConnHdlr vc_conn; |
| 2721 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2722 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2723 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 2724 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 2725 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
| 2726 | pars.l1_pars.toa256_enabled := true; |
| 2727 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 2728 | vc_conn.done; |
| 2729 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2730 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2731 | } |
| 2732 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 2733 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 2734 | * the BTS is forwarding those values to the MS via the SACCH L1 header. */ |
| 2735 | function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr { |
| 2736 | var L1ctlDlMessage l1_dl; |
| 2737 | var RSL_IE_MS_Power ms_power; |
| 2738 | var RSL_Message rsl; |
| 2739 | var uint5_t power_level := 0; |
| 2740 | |
| 2741 | f_l1_tune(L1CTL); |
| 2742 | RSL.clear; |
| 2743 | |
| 2744 | f_est_dchan(); |
| 2745 | |
| 2746 | ms_power.reserved := 0; |
| 2747 | ms_power.fpc_epc := false; |
| 2748 | |
| 2749 | /* Send the first power control command. This will disable any BTS/TRX |
| 2750 | * internal power control and switch the MS (which is not in scope of |
| 2751 | * this test) to a constant power level. We start with a power level |
| 2752 | * of 0 */ |
| 2753 | ms_power.power_level := power_level; |
| 2754 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2755 | RSL.send(rsl); |
| 2756 | |
| 2757 | alt { |
| 2758 | |
| 2759 | /* Pick all SACCH blocks for checking */ |
| 2760 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2761 | |
| 2762 | /* The first byte of the L1 header contains the power level. |
| 2763 | * The reserved bits and the fpc bit is set to 0, so we may |
| 2764 | * compare directly. */ |
| 2765 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) { |
| 2766 | setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level."); |
| 2767 | } |
| 2768 | |
| 2769 | /* Signal a new power level via RSL for the next turn. */ |
| 2770 | if (power_level < 31) { |
| 2771 | power_level := power_level + 1; |
| 2772 | ms_power.power_level := power_level; |
| 2773 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2774 | RSL.send(rsl); |
| 2775 | repeat; |
| 2776 | } |
| 2777 | |
| 2778 | } |
| 2779 | |
| 2780 | /* Ignore all other blocks */ |
| 2781 | [] L1CTL.receive { repeat; } |
| 2782 | |
| 2783 | } |
| 2784 | |
| 2785 | f_rsl_chan_deact(); |
| 2786 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2787 | |
| 2788 | setverdict(pass); |
| 2789 | } |
| 2790 | |
| 2791 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 2792 | var ConnHdlr vc_conn; |
| 2793 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2794 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 2795 | |
| 2796 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2797 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2798 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 2799 | vc_conn.done; |
| 2800 | } |
| 2801 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2802 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2803 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 2804 | /* 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] | 2805 | TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */ |
| 2806 | function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr { |
| 2807 | var L1ctlDlMessage l1_dl; |
| 2808 | var uint5_t ta_to_test := 16; |
| 2809 | |
| 2810 | |
| 2811 | f_l1_tune(L1CTL); |
| 2812 | RSL.clear; |
| 2813 | |
| 2814 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2815 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2816 | |
| 2817 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 2818 | |
| 2819 | |
| 2820 | alt { |
| 2821 | |
| 2822 | /* Pick all SACCH blocks for checking */ |
| 2823 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2824 | |
| 2825 | /* The second byte of the L1 header contains the TA. */ |
| 2826 | if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) { |
| 2827 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 2828 | } |
| 2829 | |
| 2830 | } |
| 2831 | |
| 2832 | /* Ignore all other blocks */ |
| 2833 | [] L1CTL.receive { repeat; } |
| 2834 | |
| 2835 | } |
| 2836 | |
| 2837 | f_rsl_chan_deact(); |
| 2838 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2839 | |
| 2840 | setverdict(pass); |
| 2841 | } |
| 2842 | |
| 2843 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 2844 | var ConnHdlr vc_conn; |
| 2845 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2846 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2847 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 2848 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 2849 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2850 | vc_conn.done; |
| 2851 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2852 | } |
| 2853 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 2854 | /* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */ |
| 2855 | function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr { |
| 2856 | var L1ctlDlMessage l1_dl; |
| 2857 | var uint5_t ms_power_level := 7; |
| 2858 | |
| 2859 | var RSL_IE_MS_Power ms_power; |
| 2860 | ms_power.reserved := 0; |
| 2861 | ms_power.fpc_epc := false; |
| 2862 | ms_power.power_level := ms_power_level; |
| 2863 | |
| 2864 | f_l1_tune(L1CTL); |
| 2865 | RSL.clear; |
| 2866 | |
| 2867 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 2868 | |
| 2869 | timer T := 1.0; |
| 2870 | T.start; |
| 2871 | alt { |
| 2872 | /* Pick all SACCH blocks for checking */ |
| 2873 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2874 | /* The first byte of the L1 header contains the power level.. */ |
| 2875 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) { |
| 2876 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 2877 | } |
| 2878 | } |
| 2879 | /* Ignore all other blocks */ |
| 2880 | [] L1CTL.receive { repeat; } |
| 2881 | [] T.timeout { |
| 2882 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 2883 | } |
| 2884 | } |
| 2885 | |
| 2886 | f_rsl_chan_deact(); |
| 2887 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2888 | setverdict(pass); |
| 2889 | } |
| 2890 | |
| 2891 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 2892 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 2893 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 2894 | } |
| 2895 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2896 | /* 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] | 2897 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2898 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2899 | RSL.clear; |
| 2900 | |
| 2901 | f_est_dchan(); |
| 2902 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2903 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2904 | |
| 2905 | timer T := 40.0; |
| 2906 | T.start; |
| 2907 | alt { |
| 2908 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 2909 | setverdict(pass) |
| 2910 | } |
| 2911 | [] RSL.receive { repeat }; |
| 2912 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2913 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2914 | } |
| 2915 | } |
| 2916 | f_rsl_chan_deact(); |
| 2917 | } |
| 2918 | testcase TC_conn_fail_crit() runs on test_CT { |
| 2919 | var ConnHdlr vc_conn; |
| 2920 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2921 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2922 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 2923 | pars.t_guard := 60.0; |
| 2924 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 2925 | vc_conn.done; |
| 2926 | } |
| 2927 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 2928 | /*********************************************************************** |
| 2929 | * Paging |
| 2930 | ***********************************************************************/ |
| 2931 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2932 | function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
| 2933 | if (tmsi == 'FFFFFFFF'O) { |
| 2934 | return true; |
| 2935 | } else { |
| 2936 | return false; |
| 2937 | } |
| 2938 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2939 | |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 2940 | type record allowedFn { integer frame_nr } |
| 2941 | template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 2942 | template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 2943 | template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 2944 | template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 2945 | template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 2946 | template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 2947 | template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 2948 | template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 2949 | function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT |
| 2950 | { |
| 2951 | var integer frame_nr_51; |
| 2952 | frame_nr_51 := frame_nr mod 51 |
| 2953 | |
| 2954 | var allowedFn fn_check; |
| 2955 | fn_check.frame_nr := frame_nr_51; |
| 2956 | |
| 2957 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2958 | 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] | 2959 | return; |
| 2960 | } |
| 2961 | |
| 2962 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 2963 | return; |
| 2964 | } |
| 2965 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 2966 | return; |
| 2967 | } |
| 2968 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 2969 | return; |
| 2970 | } |
| 2971 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 2972 | return; |
| 2973 | } |
| 2974 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 2975 | return; |
| 2976 | } |
| 2977 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 2978 | return; |
| 2979 | } |
| 2980 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 2981 | return; |
| 2982 | } |
| 2983 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 2984 | return; |
| 2985 | } |
| 2986 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2987 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 2988 | return; |
| 2989 | } |
| 2990 | |
| 2991 | altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, inout integer num_paging_rcv_ids, PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2992 | runs on test_CT { |
| 2993 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2994 | [] 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] | 2995 | repeat; |
| 2996 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2997 | [] 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] | 2998 | var octetstring without_plen := |
| 2999 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 3000 | 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] | 3001 | |
| 3002 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 3003 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 3004 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 3005 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 3006 | * TODO: does it make sense to count them? */ |
| 3007 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3008 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3009 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3010 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3011 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3012 | } |
| 3013 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 3014 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3015 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 3016 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3017 | } |
| 3018 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 3019 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3020 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3021 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3022 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3023 | } |
| 3024 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 3025 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3026 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 3027 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3028 | } |
| 3029 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 3030 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3031 | } |
| 3032 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 3033 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3034 | } |
| 3035 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 3036 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3037 | } |
| 3038 | } |
| 3039 | repeat; |
| 3040 | } |
| 3041 | } |
| 3042 | |
| 3043 | type record PagingTestCfg { |
| 3044 | boolean combined_ccch, |
| 3045 | integer bs_ag_blks_res, |
| 3046 | float load_factor, |
| 3047 | boolean exp_load_ind, |
| 3048 | boolean exp_overload, |
| 3049 | boolean use_tmsi |
| 3050 | } |
| 3051 | |
| 3052 | type record PagingTestState { |
| 3053 | integer num_paging_sent, |
| 3054 | integer num_paging_rcv_msgs, |
| 3055 | integer num_paging_rcv_ids, |
| 3056 | integer num_overload |
| 3057 | } |
| 3058 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3059 | /* Helper function for paging related testing */ |
| 3060 | private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3061 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3062 | f_init_l1ctl(); |
| 3063 | f_l1_tune(L1CTL); |
| 3064 | |
| 3065 | var PagingTestState st := { |
| 3066 | num_paging_sent := 0, |
| 3067 | num_paging_rcv_msgs := 0, |
| 3068 | num_paging_rcv_ids := 0, |
| 3069 | num_overload := 0 |
| 3070 | }; |
| 3071 | |
| 3072 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 3073 | var float max_pch_imsi_per_sec; |
| 3074 | if (cfg.use_tmsi) { |
| 3075 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 3076 | } else { |
| 3077 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 3078 | } |
| 3079 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 3080 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3081 | var float time_total := 20.0; |
| 3082 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 3083 | 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] | 3084 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3085 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 3086 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3087 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3088 | timer T_itv := 0.0; |
| 3089 | T_itv.start; |
| 3090 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3091 | alt { |
| 3092 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3093 | [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] | 3094 | st.num_overload := st.num_overload + 1; |
| 3095 | repeat; |
| 3096 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3097 | [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] | 3098 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3099 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3100 | [cfg.exp_load_ind] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3101 | log("Rx LOAD_IND"); |
| 3102 | /* FIXME: analyze/verify interval + contents */ |
| 3103 | repeat; |
| 3104 | } |
| 3105 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3106 | [] 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] | 3107 | [] L1CTL.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3108 | [] T_itv.timeout { |
| 3109 | /* Send paging cmds based on elapsed time */ |
| 3110 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 3111 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3112 | var MobileIdentityV mi; |
| 3113 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3114 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3115 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3116 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3117 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3118 | 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] | 3119 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3120 | |
| 3121 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3122 | 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] | 3123 | |
| 3124 | st.num_paging_sent := st.num_paging_sent + 1; |
| 3125 | } |
| 3126 | if (st.num_paging_sent < pkt_total) { |
| 3127 | /* Wait for interval to next PAGING COMMAND */ |
| 3128 | var float time_now := T_total.read; |
| 3129 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 3130 | if (next_sched > time_now) { |
| 3131 | T_itv.start(next_sched - time_now); |
| 3132 | } else { |
| 3133 | T_itv.start(0.0); |
| 3134 | } |
| 3135 | } else { |
| 3136 | /* We are done, no need to keep counting */ |
| 3137 | T_total.stop; |
| 3138 | } |
| 3139 | } |
| 3140 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3141 | } |
| 3142 | } |
| 3143 | |
| 3144 | /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */ |
| 3145 | timer T_wait := 18.0; |
| 3146 | T_wait.start; |
| 3147 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3148 | [] 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] | 3149 | [] L1CTL.receive { repeat; } |
| 3150 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3151 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
| 3152 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3153 | [] T_wait.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3154 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3155 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3156 | } |
| 3157 | |
| 3158 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 3159 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 3160 | return st; |
| 3161 | } |
| 3162 | |
| 3163 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 3164 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3165 | * - that CCCH LOAD IND (PCH) are being generated |
| 3166 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3167 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3168 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3169 | var PagingTestCfg cfg := { |
| 3170 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3171 | 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] | 3172 | load_factor := 0.8, |
| 3173 | exp_load_ind := true, |
| 3174 | exp_overload := false, |
| 3175 | use_tmsi := false |
| 3176 | }; |
| 3177 | var PagingTestState st := f_TC_paging(cfg); |
| 3178 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3179 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3180 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3181 | } else { |
| 3182 | setverdict(pass); |
| 3183 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3184 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3185 | } |
| 3186 | |
| 3187 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 3188 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3189 | * - that CCCH LOAD IND (PCH) are being generated |
| 3190 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3191 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3192 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3193 | var PagingTestCfg cfg := { |
| 3194 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3195 | 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] | 3196 | load_factor := 0.8, |
| 3197 | exp_load_ind := true, |
| 3198 | exp_overload := false, |
| 3199 | use_tmsi := true |
| 3200 | }; |
| 3201 | var PagingTestState st := f_TC_paging(cfg); |
| 3202 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3203 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3204 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3205 | } else { |
| 3206 | setverdict(pass); |
| 3207 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3208 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3209 | } |
| 3210 | |
| 3211 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 3212 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3213 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3214 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3215 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3216 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3217 | var PagingTestCfg cfg := { |
| 3218 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3219 | 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] | 3220 | load_factor := 2.0, |
| 3221 | exp_load_ind := true, |
| 3222 | exp_overload := true, |
| 3223 | use_tmsi := false |
| 3224 | }; |
| 3225 | var PagingTestState st := f_TC_paging(cfg); |
| 3226 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 3227 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3228 | 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] | 3229 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3230 | 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] | 3231 | } else { |
| 3232 | setverdict(pass); |
| 3233 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3234 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3235 | } |
| 3236 | |
| 3237 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 3238 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3239 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3240 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3241 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3242 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3243 | var PagingTestCfg cfg := { |
| 3244 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3245 | 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] | 3246 | load_factor := 2.0, |
| 3247 | exp_load_ind := true, |
| 3248 | exp_overload := true, |
| 3249 | use_tmsi := true |
| 3250 | }; |
| 3251 | var PagingTestState st := f_TC_paging(cfg); |
| 3252 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 3253 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3254 | 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] | 3255 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3256 | 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] | 3257 | } else { |
| 3258 | setverdict(pass); |
| 3259 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3260 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3261 | } |
| 3262 | |
| 3263 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3264 | /*********************************************************************** |
| 3265 | * Immediate Assignment / AGCH |
| 3266 | ***********************************************************************/ |
Vadim Yanitskiy | a9eeb7b | 2020-05-27 01:42:49 +0700 | [diff] [blame] | 3267 | private const MobileAllocation c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3268 | len := 0, |
| 3269 | ma := ''B |
| 3270 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3271 | |
Vadim Yanitskiy | 9248456 | 2020-05-27 02:05:04 +0700 | [diff] [blame] | 3272 | template (value) ChannelDescription ts_ChanDescH0(template (value) RslChannelNr chan_nr, uint3_t tsc := 7, |
Vadim Yanitskiy | e9f68be | 2020-05-27 02:08:35 +0700 | [diff] [blame] | 3273 | uint12_t arfcn := mp_trx0_arfcn) := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3274 | chan_nr := chan_nr, |
| 3275 | tsc := tsc, |
| 3276 | h := false, |
| 3277 | arfcn := arfcn, |
| 3278 | maio_hsn := omit |
| 3279 | } |
| 3280 | |
Vadim Yanitskiy | 9248456 | 2020-05-27 02:05:04 +0700 | [diff] [blame] | 3281 | template (value) ChannelDescription ts_ChanDescH1(template (value) RslChannelNr chan_nr, uint3_t tsc := 7, |
| 3282 | template (value) MaioHsn maio_hsn) := { |
| 3283 | chan_nr := chan_nr, |
| 3284 | tsc := tsc, |
| 3285 | h := true, |
| 3286 | arfcn := omit, |
| 3287 | maio_hsn := maio_hsn |
| 3288 | } |
| 3289 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3290 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 3291 | return int2str(num_tx) & " sent, " |
| 3292 | & int2str(num_rx) & " received, " |
| 3293 | & int2str(num_del) & " deleted"; |
| 3294 | } |
| 3295 | |
| 3296 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 3297 | var L1ctlDlMessage l1_dl; |
| 3298 | timer T := 10.0; |
| 3299 | var integer num_tx := 0; |
| 3300 | var integer num_rx := 0; |
| 3301 | var integer num_del := 0; |
| 3302 | var charstring res_str; |
| 3303 | var float rx_ratio; |
| 3304 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3305 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3306 | f_init_l1ctl(); |
| 3307 | f_l1_tune(L1CTL); |
| 3308 | |
| 3309 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | 9248456 | 2020-05-27 02:05:04 +0700 | [diff] [blame] | 3310 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(valueof(t_RslChanNr_SDCCH4(0, 0)))); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3311 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 3312 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3313 | 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] | 3314 | num_tx := num_tx+1; |
| 3315 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3316 | } |
| 3317 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3318 | T.start; |
| 3319 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3320 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3321 | num_del := num_del+1; |
| 3322 | repeat; |
| 3323 | } |
| 3324 | [] RSL_CCHAN.receive { |
| 3325 | repeat; |
| 3326 | } |
| 3327 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl { |
| 3328 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 3329 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 3330 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 3331 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3332 | //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] | 3333 | } else { |
| 3334 | num_rx := num_rx+1; |
| 3335 | } |
| 3336 | repeat; |
| 3337 | } |
| 3338 | [] L1CTL.receive { repeat; } |
| 3339 | [] T.timeout { } |
| 3340 | } |
| 3341 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 3342 | log("AGCH test: " & res_str); |
| 3343 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3344 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3345 | } |
| 3346 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 3347 | 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] | 3348 | 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] | 3349 | } else { |
| 3350 | setverdict(pass); |
| 3351 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3352 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3353 | } |
| 3354 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3355 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 3356 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 3357 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 3358 | } |
| 3359 | |
| 3360 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 3361 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 3362 | f_TC_imm_ass(200, 0.0, 0.05); |
| 3363 | } |
| 3364 | |
| 3365 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 3366 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 3367 | f_TC_imm_ass(150, 0.076, 1.00); |
| 3368 | } |
| 3369 | |
| 3370 | |
| 3371 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3372 | /*********************************************************************** |
| 3373 | * BCCH |
| 3374 | ***********************************************************************/ |
| 3375 | |
| 3376 | /* tuple of Frame Number + decoded SI */ |
| 3377 | type record SystemInformationFn { |
| 3378 | GsmFrameNumber frame_number, |
| 3379 | SystemInformation si |
| 3380 | } |
| 3381 | |
| 3382 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
| 3383 | type record of SystemInformationFn SystemInformationVector; |
| 3384 | |
| 3385 | /* an array of SI-vectors indexed by TC value */ |
| 3386 | type SystemInformationVector SystemInformationVectorPerTc[8]; |
| 3387 | |
| 3388 | /* determine if a given SI vector contains given SI type at least once */ |
| 3389 | function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 3390 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3391 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3392 | if (not bcch_ext and fn_mod51 == 2 or |
| 3393 | bcch_ext and fn_mod51 == 6) { |
| 3394 | if (arr[i].si.header.message_type == key) { |
| 3395 | return true; |
| 3396 | } |
| 3397 | } |
| 3398 | } |
| 3399 | return false; |
| 3400 | } |
| 3401 | |
| 3402 | /* ensure a given TC slot of the SI vector contains given SI type at least once at TC */ |
| 3403 | function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 3404 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3405 | 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] | 3406 | } |
| 3407 | } |
| 3408 | |
| 3409 | /* check if a given SI vector contains given SI type at least once on any TC */ |
| 3410 | function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean { |
| 3411 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 3412 | if (f_si_vecslot_contains(arr[tc], key) or |
| 3413 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 3414 | return true; |
| 3415 | } |
| 3416 | } |
| 3417 | return false; |
| 3418 | } |
| 3419 | |
| 3420 | /* determine if a given SI vector contains given SI type at least N of M times */ |
| 3421 | function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean { |
| 3422 | var integer count := 0; |
| 3423 | if (sizeof(arr) < m) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3424 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3425 | } |
| 3426 | for (var integer i:= 0; i < m; i := i + 1) { |
| 3427 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3428 | if (not bcch_ext and fn_mod51 == 2 or |
| 3429 | bcch_ext and fn_mod51 == 6) { |
| 3430 | if (arr[i].si.header.message_type == key) { |
| 3431 | count := count + 1; |
| 3432 | } |
| 3433 | } |
| 3434 | } |
| 3435 | if (count >= n) { |
| 3436 | return true; |
| 3437 | } else { |
| 3438 | return false; |
| 3439 | } |
| 3440 | } |
| 3441 | |
| 3442 | /* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */ |
| 3443 | function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) { |
| 3444 | 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] | 3445 | 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] | 3446 | } |
| 3447 | } |
| 3448 | |
| 3449 | /* determine if a given SI vector contains given SI type at least once */ |
| 3450 | function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 3451 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3452 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3453 | if (not bcch_ext and fn_mod51 == 2 or |
| 3454 | bcch_ext and fn_mod51 == 6) { |
| 3455 | if (arr[i].si.header.message_type != key) { |
| 3456 | return false; |
| 3457 | } |
| 3458 | } |
| 3459 | } |
| 3460 | return true; |
| 3461 | } |
| 3462 | |
| 3463 | /* ensure a given TC slot of the SI vector contains only given SI type */ |
| 3464 | function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 3465 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3466 | 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] | 3467 | } |
| 3468 | } |
| 3469 | |
| 3470 | /* SI configuration of cell, against which we validate actual SI messages */ |
| 3471 | type set SystemInformationConfig { |
| 3472 | boolean bcch_extended, |
| 3473 | boolean si1_present, |
| 3474 | boolean si2bis_present, |
| 3475 | boolean si2ter_present, |
| 3476 | boolean si2quater_present, |
| 3477 | boolean si7_present, |
| 3478 | boolean si8_present, |
| 3479 | boolean si9_present, |
| 3480 | boolean si13_present, |
| 3481 | boolean si13alt_present, |
| 3482 | boolean si15_present, |
| 3483 | boolean si16_present, |
| 3484 | boolean si17_present, |
| 3485 | boolean si2n_present, |
| 3486 | boolean si21_present, |
| 3487 | boolean si22_present |
| 3488 | } |
| 3489 | |
| 3490 | /* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */ |
| 3491 | function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) { |
| 3492 | var integer i; |
| 3493 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 3494 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3495 | 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] | 3496 | } |
| 3497 | } |
| 3498 | if (cfg.si1_present) { |
| 3499 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 3500 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 3501 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 3502 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3503 | /* make sure *ALL* contain SI1 */ |
| 3504 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3505 | } |
| 3506 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 3507 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 3508 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 3509 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 3510 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 3511 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 3512 | |
| 3513 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 3514 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 3515 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 3516 | * consecutive occurrences of TC = 4. */ |
| 3517 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 3518 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3519 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 3520 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 3521 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 3522 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3523 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 3524 | } |
| 3525 | |
| 3526 | if (cfg.si7_present or cfg.si8_present) { |
| 3527 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 3528 | * if System Information type 4 does not contain all information needed for cell |
| 3529 | * selection and reselection. */ |
| 3530 | if (not cfg.bcch_extended) { |
| 3531 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 3532 | } |
| 3533 | if (cfg.si7_present) { |
| 3534 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 3535 | } |
| 3536 | if (cfg.si8_present) { |
| 3537 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 3538 | } |
| 3539 | } |
| 3540 | |
| 3541 | if (cfg.si2quater_present) { |
| 3542 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 3543 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 3544 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 3545 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 3546 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 3547 | if (not (cfg.bcch_extended)) { |
| 3548 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 3549 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 3550 | } else { |
| 3551 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 3552 | } |
| 3553 | } else { |
| 3554 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 3555 | } |
| 3556 | } |
| 3557 | if (cfg.si9_present) { |
| 3558 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 3559 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 3560 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 3561 | } |
| 3562 | if (cfg.si13_present) { |
| 3563 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 3564 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 3565 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 3566 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 3567 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 3568 | * within any of 4 consecutive occurrences of TC=4. */ |
| 3569 | if (not cfg.bcch_extended) { |
| 3570 | log("not-bccch-extended"); |
| 3571 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 3572 | } else { |
| 3573 | log("bccch-extended"); |
| 3574 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 3575 | } |
| 3576 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3577 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3578 | } |
| 3579 | } |
| 3580 | if (cfg.si16_present or cfg.si17_present) { |
| 3581 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 3582 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 3583 | if (cfg.si22_present) { |
| 3584 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3585 | } |
| 3586 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3587 | 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] | 3588 | } |
| 3589 | if (not cfg.bcch_extended) { |
| 3590 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 3591 | } |
| 3592 | if (cfg.si16_present) { |
| 3593 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 3594 | } |
| 3595 | if (cfg.si17_present) { |
| 3596 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 3597 | } |
| 3598 | } |
| 3599 | |
| 3600 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 3601 | * broadcast information. The frequency with which they are sent is determined by the |
| 3602 | * system operator. System Information type 9 identifies the scheduling of System |
| 3603 | * Information type 18 and 20 messages. */ |
| 3604 | |
| 3605 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 3606 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 3607 | * Information Type 9. */ |
| 3608 | |
| 3609 | if (cfg.si15_present) { |
| 3610 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 3611 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 3612 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 3613 | * 4 consecutive occurrences of TC = 1. */ |
| 3614 | if (not cfg.bcch_extended) { |
| 3615 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 3616 | } else { |
| 3617 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 3618 | } |
| 3619 | } |
| 3620 | if (cfg.si13alt_present) { |
| 3621 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 3622 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 3623 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 3624 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 3625 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 3626 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 3627 | * of TC = 4. */ |
| 3628 | if (cfg.si13_present) { |
| 3629 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 3630 | } |
| 3631 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3632 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3633 | } |
| 3634 | if (not cfg.bcch_extended) { |
| 3635 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 3636 | } else { |
| 3637 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 3638 | } |
| 3639 | } |
| 3640 | if (cfg.si2n_present) { |
| 3641 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 3642 | * as determined by the system operator. In the case that the message is sent on the |
| 3643 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 3644 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 3645 | * consecutive occurrences of TC = 4. */ |
| 3646 | if (not cfg.bcch_extended) { |
| 3647 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 3648 | } else { |
| 3649 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 3650 | } |
| 3651 | } |
| 3652 | if (cfg.si21_present) { |
| 3653 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 3654 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 3655 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 3656 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 3657 | * cell then this message shall only be sent on BCCH Ext. */ |
| 3658 | if (not cfg.bcch_extended) { |
| 3659 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 3660 | } else { |
| 3661 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 3662 | 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] | 3663 | 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] | 3664 | } |
| 3665 | } |
| 3666 | } |
| 3667 | if (cfg.si22_present) { |
| 3668 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 3669 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 3670 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 3671 | * =2 and TC=6. */ |
| 3672 | if (cfg.si16_present or cfg.si17_present) { |
| 3673 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3674 | } |
| 3675 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 3676 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3677 | 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] | 3678 | } |
| 3679 | if (not cfg.bcch_extended) { |
| 3680 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 3681 | } else { |
| 3682 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 3683 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 3684 | } |
| 3685 | } |
| 3686 | } |
| 3687 | |
| 3688 | /* sample Systme Information for specified duration via L1CTL */ |
| 3689 | function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc { |
| 3690 | timer T := duration; |
| 3691 | var SystemInformationVectorPerTc si_per_tc; |
| 3692 | var L1ctlDlMessage l1_dl; |
| 3693 | |
| 3694 | /* initialize all per-TC vectors empty */ |
| 3695 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 3696 | si_per_tc[i] := {}; |
| 3697 | } |
| 3698 | |
| 3699 | /* flush all previous L1 queued msgs */ |
| 3700 | pt.clear; |
| 3701 | |
| 3702 | T.start; |
| 3703 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3704 | [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3705 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 3706 | if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) { |
| 3707 | log("Ignoring non-RR SI ", l1_dl); |
| 3708 | repeat; |
| 3709 | } |
| 3710 | var SystemInformationFn sig := { |
| 3711 | frame_number := l1_dl.dl_info.frame_nr, |
| 3712 | si := dec_SystemInformation(l1_dl.payload.data_ind.payload) |
| 3713 | } |
| 3714 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 3715 | log("SI received at TC=", tc, ": ", sig.si); |
| 3716 | /* append to the per-TC bucket */ |
| 3717 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 3718 | repeat; |
| 3719 | } |
| 3720 | [] pt.receive { repeat; } |
| 3721 | [] T.timeout { } |
| 3722 | } |
| 3723 | |
| 3724 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 3725 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 3726 | } |
| 3727 | log("si_per_tc=", si_per_tc); |
| 3728 | return si_per_tc; |
| 3729 | } |
| 3730 | |
| 3731 | /* helper function: Set given SI via RSL + validate scheduling. |
| 3732 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
| 3733 | function f_TC_si_sched() runs on test_CT { |
| 3734 | var SystemInformationVectorPerTc si_per_tc; |
| 3735 | f_init_l1ctl(); |
| 3736 | f_l1_tune(L1CTL); |
| 3737 | |
| 3738 | /* Sample + Validate Scheduling */ |
| 3739 | si_per_tc := f_l1_sample_si(L1CTL); |
| 3740 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 3741 | |
| 3742 | setverdict(pass); |
| 3743 | } |
| 3744 | |
| 3745 | testcase TC_si_sched_default() runs on test_CT { |
| 3746 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 3747 | /* 2+3+4 are mandatory and set in f_init() */ |
| 3748 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3749 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 3750 | } |
| 3751 | |
| 3752 | testcase TC_si_sched_1() runs on test_CT { |
| 3753 | f_init(); |
| 3754 | si_cfg.si1_present := true; |
| 3755 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3756 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3757 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3758 | } |
| 3759 | |
| 3760 | testcase TC_si_sched_2bis() runs on test_CT { |
| 3761 | f_init(); |
| 3762 | si_cfg.si2bis_present := true; |
| 3763 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3764 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3765 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3766 | } |
| 3767 | |
| 3768 | testcase TC_si_sched_2ter() runs on test_CT { |
| 3769 | f_init(); |
| 3770 | si_cfg.si2ter_present := true; |
| 3771 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3772 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3773 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3774 | } |
| 3775 | |
| 3776 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 3777 | f_init(); |
| 3778 | si_cfg.si2bis_present := true; |
| 3779 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3780 | si_cfg.si2ter_present := true; |
| 3781 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3782 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3783 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3784 | } |
| 3785 | |
| 3786 | testcase TC_si_sched_2quater() runs on test_CT { |
| 3787 | f_init(); |
| 3788 | si_cfg.si2quater_present := true; |
| 3789 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 3790 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3791 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3792 | } |
| 3793 | |
| 3794 | testcase TC_si_sched_13() runs on test_CT { |
| 3795 | f_init(); |
| 3796 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 3797 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3798 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3799 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3800 | } |
| 3801 | |
| 3802 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
| 3803 | f_init(); |
| 3804 | si_cfg.si2bis_present := true; |
| 3805 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3806 | si_cfg.si2ter_present := true; |
| 3807 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3808 | si_cfg.si2quater_present := true; |
| 3809 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 3810 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 3811 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3812 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3813 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3814 | } |
| 3815 | |
| 3816 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3817 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3818 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3819 | /* FIXME: enable / disable individual BCCH info */ |
| 3820 | //ts_RSL_BCCH_INFO(si_type, info); |
| 3821 | /* expect no ERROR REPORT after either of them * |
| 3822 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3823 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3824 | } |
| 3825 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3826 | /*********************************************************************** |
| 3827 | * Low-Level Protocol Errors / ERROR REPORT |
| 3828 | ***********************************************************************/ |
| 3829 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3830 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 3831 | timer T := 5.0; |
| 3832 | T.start; |
| 3833 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3834 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3835 | setverdict(pass); |
| 3836 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3837 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3838 | 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] | 3839 | } |
| 3840 | [] RSL_CCHAN.receive { |
| 3841 | repeat; |
| 3842 | } |
| 3843 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3844 | 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] | 3845 | } |
| 3846 | } |
| 3847 | } |
| 3848 | |
| 3849 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 3850 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3851 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3852 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3853 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3854 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3855 | |
| 3856 | f_exp_err_rep(RSL_ERR_PROTO); |
| 3857 | } |
| 3858 | |
| 3859 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 3860 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3861 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3862 | |
| 3863 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3864 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3865 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3866 | |
| 3867 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 3868 | } |
| 3869 | |
| 3870 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 3871 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3872 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3873 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3874 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3875 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3876 | |
| 3877 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 3878 | } |
| 3879 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3880 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 3881 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 3882 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 3883 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 3884 | RSL.send(rsl); |
| 3885 | f_rslem_unregister(0, g_chan_nr); |
| 3886 | } |
| 3887 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 3888 | var ConnHdlr vc_conn; |
| 3889 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 3890 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3891 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3892 | |
| 3893 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 3894 | vc_conn.done; |
| 3895 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 3896 | |
| 3897 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3898 | } |
| 3899 | |
| 3900 | /* Send messages with wrong message type */ |
| 3901 | function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr { |
| 3902 | var template (value) RSL_Message rsl_tx; |
| 3903 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 3904 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 3905 | RSL.send(rsl_tx); |
| 3906 | f_rslem_unregister(0, g_chan_nr); |
| 3907 | } |
| 3908 | function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr { |
| 3909 | var template (value) RSL_Message rsl_tx; |
| 3910 | /* we first have to activate the dedicated channel */ |
| 3911 | f_rsl_chan_act(g_pars.chan_mode); |
| 3912 | /* ... to then send an invalid RLL message */ |
| 3913 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 3914 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 3915 | RSL.send(rsl_tx); |
| 3916 | f_rslem_unregister(0, g_chan_nr); |
| 3917 | } |
| 3918 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 3919 | var ConnHdlr vc_conn; |
| 3920 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 3921 | var template (value) RSL_Message rsl_tx; |
| 3922 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3923 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3924 | |
| 3925 | /* Common Channel with wrong message type */ |
| 3926 | RSL_CCHAN.clear; |
| 3927 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3928 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3929 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3930 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3931 | |
| 3932 | /* TRX Management */ |
| 3933 | RSL_CCHAN.clear; |
| 3934 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 3935 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3936 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3937 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3938 | |
| 3939 | /* Dedicated Channel */ |
| 3940 | RSL_CCHAN.clear; |
| 3941 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 3942 | vc_conn.done; |
| 3943 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3944 | |
| 3945 | /* RLL */ |
| 3946 | RSL_CCHAN.clear; |
| 3947 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 3948 | vc_conn.done; |
| 3949 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3950 | } |
| 3951 | |
| 3952 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
| 3953 | function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr { |
| 3954 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 3955 | f_rslem_unregister(0, g_chan_nr); |
| 3956 | } |
| 3957 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 3958 | var ConnHdlr vc_conn; |
| 3959 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 3960 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3961 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3962 | |
| 3963 | RSL_CCHAN.clear; |
| 3964 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 3965 | vc_conn.done; |
| 3966 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 3967 | } |
| 3968 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3969 | /*********************************************************************** |
| 3970 | * IPA CRCX/MDCX/DLCS media stream handling |
| 3971 | ***********************************************************************/ |
| 3972 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 3973 | /* Send IPA DLCX to inactive lchan */ |
| 3974 | function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 3975 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 3976 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 3977 | } |
| 3978 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 3979 | 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] | 3980 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 3981 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 3982 | vc_conn.done; |
| 3983 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3984 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3985 | /* Send IPA CRCX twice to inactive lchan */ |
| 3986 | function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr { |
| 3987 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 3988 | "IPA CRCX ACK"); |
| 3989 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 3990 | "IPA CRCX NACK"); |
| 3991 | } |
| 3992 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 3993 | 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] | 3994 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3995 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 3996 | vc_conn.done; |
| 3997 | } |
| 3998 | |
| 3999 | /* Regular sequence of CRCX/MDCX/DLCX */ |
| 4000 | function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
| 4001 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4002 | "IPA CRCX ACK"); |
| 4003 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4004 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4005 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4006 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4007 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4008 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4009 | "IPA MDCX ACK"); |
| 4010 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4011 | "IPA DLCX ACK"); |
| 4012 | } |
| 4013 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4014 | 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] | 4015 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4016 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 4017 | vc_conn.done; |
| 4018 | } |
| 4019 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4020 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
| 4021 | function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
| 4022 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4023 | "IPA CRCX ACK"); |
| 4024 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4025 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4026 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4027 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4028 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4029 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4030 | "IPA MDCX ACK"); |
| 4031 | /* Second MDCX */ |
| 4032 | remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4033 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 4034 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4035 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4036 | "IPA MDCX ACK"); |
| 4037 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4038 | "IPA DLCX ACK"); |
| 4039 | } |
| 4040 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4041 | 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] | 4042 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4043 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 4044 | vc_conn.done; |
| 4045 | } |
| 4046 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4047 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
| 4048 | function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr { |
| 4049 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 4050 | "IPA CRCX NACK"); |
| 4051 | } |
| 4052 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 4053 | var ConnHdlrPars pars; |
| 4054 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4055 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4056 | |
| 4057 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 4058 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4059 | vc_conn.done; |
| 4060 | |
| 4061 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 4062 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4063 | vc_conn.done; |
| 4064 | } |
| 4065 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4066 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4067 | /*********************************************************************** |
| 4068 | * PCU Socket related tests |
| 4069 | ***********************************************************************/ |
| 4070 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4071 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4072 | 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] | 4073 | runs on test_CT { |
| 4074 | timer T := 3.0; |
| 4075 | |
| 4076 | /* we don't expect any RTS.req before PDCH are active */ |
| 4077 | T.start; |
| 4078 | alt { |
| 4079 | [] 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] | 4080 | 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] | 4081 | } |
| 4082 | [] PCU.receive { repeat; } |
| 4083 | [] T.timeout { } |
| 4084 | } |
| 4085 | |
| 4086 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4087 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 4088 | |
| 4089 | /* we now expect RTS.req for this timeslot (only) */ |
| 4090 | T.start; |
| 4091 | alt { |
| 4092 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 4093 | setverdict(pass); |
| 4094 | } |
| 4095 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4096 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4097 | 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] | 4098 | } |
| 4099 | [] 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] | 4100 | 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] | 4101 | } |
| 4102 | [] PCU.receive { repeat; } |
| 4103 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4104 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4105 | } |
| 4106 | [not exp_success] T.timeout { |
| 4107 | setverdict(pass); |
| 4108 | } |
| 4109 | } |
| 4110 | } |
| 4111 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4112 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4113 | 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] | 4114 | runs on test_CT { |
| 4115 | timer T := 3.0; |
| 4116 | |
| 4117 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4118 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 4119 | |
| 4120 | PCU.clear; |
| 4121 | /* we now expect no RTS.req for this timeslot */ |
| 4122 | T.start; |
| 4123 | alt { |
| 4124 | [] 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] | 4125 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4126 | } |
| 4127 | [] PCU.receive { repeat; } |
| 4128 | [] T.timeout { |
| 4129 | setverdict(pass); |
| 4130 | } |
| 4131 | } |
| 4132 | } |
| 4133 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4134 | friend function f_init_pcu_test() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4135 | f_init(); |
| 4136 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 4137 | } |
| 4138 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4139 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 4140 | testcase TC_pcu_act_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4141 | f_init_pcu_test(); |
| 4142 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4143 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4144 | } |
| 4145 | |
| 4146 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 4147 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4148 | f_init_pcu_test(); |
| 4149 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4150 | f_TC_pcu_act_req(0, 0, 1, false); |
| 4151 | } |
| 4152 | |
| 4153 | /* PDCH activation via PCU socket on wrong BTS */ |
| 4154 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4155 | f_init_pcu_test(); |
| 4156 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4157 | f_TC_pcu_act_req(23, 0, 7, false); |
| 4158 | } |
| 4159 | |
| 4160 | /* PDCH activation via PCU socket on wrong TRX */ |
| 4161 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4162 | f_init_pcu_test(); |
| 4163 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4164 | f_TC_pcu_act_req(0, 23, 7, false); |
| 4165 | } |
| 4166 | |
| 4167 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 4168 | testcase TC_pcu_deact_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4169 | f_init_pcu_test(); |
| 4170 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4171 | /* Activate PDCH */ |
| 4172 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4173 | f_sleep(1.0); |
| 4174 | /* and De-Activate again */ |
| 4175 | f_TC_pcu_deact_req(0, 0, 7); |
| 4176 | } |
| 4177 | |
| 4178 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 4179 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4180 | f_init_pcu_test(); |
| 4181 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4182 | f_TC_pcu_deact_req(0, 0, 1); |
| 4183 | } |
| 4184 | |
| 4185 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 4186 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 4187 | const octetstring si13 := '00010203040506070909'O; |
| 4188 | var PCUIF_send_data sd; |
| 4189 | timer T:= 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4190 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4191 | |
| 4192 | /* Set SI13 via RSL */ |
| 4193 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4194 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4195 | T.start; |
| 4196 | alt { |
| 4197 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
| 4198 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) { |
| 4199 | setverdict(pass); |
| 4200 | } else { |
| 4201 | repeat; |
| 4202 | } |
| 4203 | } |
| 4204 | [] PCU.receive { repeat; } |
| 4205 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4206 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4207 | } |
| 4208 | } |
| 4209 | } |
| 4210 | |
| 4211 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 4212 | |
| 4213 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4214 | 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] | 4215 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 4216 | runs on test_CT |
| 4217 | { |
| 4218 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 4219 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 4220 | } |
| 4221 | |
| 4222 | /* 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] | 4223 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 4224 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4225 | runs on test_CT |
| 4226 | { |
| 4227 | var PCUIF_send_data sd; |
| 4228 | |
| 4229 | timer T := 3.0; |
| 4230 | T.start; |
| 4231 | alt { |
| 4232 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4233 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 4234 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 4235 | sd.data.u.rts_req.fn, sapi, data); |
| 4236 | } |
| 4237 | [] PCU.receive { repeat; } |
| 4238 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4239 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4240 | } |
| 4241 | } |
| 4242 | } |
| 4243 | |
| 4244 | /* Send DATA.req on invalid BTS */ |
| 4245 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4246 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4247 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4248 | |
| 4249 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4250 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4251 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4252 | f_TfiUsfArrSet(tua, 7, 0); |
| 4253 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4254 | f_sleep(1.0); |
| 4255 | |
| 4256 | 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] | 4257 | } |
| 4258 | |
| 4259 | /* Send DATA.req on invalid TRX */ |
| 4260 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4261 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4262 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4263 | |
| 4264 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4265 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4266 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4267 | f_TfiUsfArrSet(tua, 7, 0); |
| 4268 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4269 | f_sleep(1.0); |
| 4270 | |
| 4271 | 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] | 4272 | } |
| 4273 | |
| 4274 | /* Send DATA.req on invalid timeslot */ |
| 4275 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4276 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4277 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4278 | |
| 4279 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4280 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4281 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4282 | f_TfiUsfArrSet(tua, 7, 0); |
| 4283 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4284 | f_sleep(1.0); |
| 4285 | |
| 4286 | 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] | 4287 | } |
| 4288 | |
| 4289 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 4290 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4291 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4292 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4293 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4294 | f_virtphy_common(); |
| 4295 | |
| 4296 | f_TfiUsfArrSet(tua, 7, 0); |
| 4297 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4298 | f_sleep(1.0); |
| 4299 | |
| 4300 | 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] | 4301 | } |
| 4302 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4303 | 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] | 4304 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 4305 | boolean wait_rts := true) |
| 4306 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4307 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4308 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4309 | |
| 4310 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4311 | if (wait_rts) { |
| 4312 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 4313 | } else { |
| 4314 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 4315 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4316 | |
| 4317 | T.start; |
| 4318 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4319 | [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] | 4320 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 4321 | setverdict(pass); |
| 4322 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4323 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 4324 | setverdict(fail, "Received unexpected ", rx_dl); |
| 4325 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4326 | [] L1CTL.receive { |
| 4327 | repeat; |
| 4328 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4329 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4330 | setverdict(fail, "Timeout waiting for ", data); |
| 4331 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4332 | [not expect_data] T.timeout { |
| 4333 | setverdict(pass); |
| 4334 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4335 | } |
| 4336 | } |
| 4337 | |
| 4338 | private function f_disable_dynamic_ts() runs on test_CT |
| 4339 | { |
| 4340 | f_init_vty_bsc(); |
| 4341 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 4342 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 4343 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 4344 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F"); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4345 | f_init_pcu_test(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4346 | } |
| 4347 | |
| 4348 | private function f_virtphy_common() runs on test_CT { |
| 4349 | f_disable_dynamic_ts(); |
| 4350 | f_init_l1ctl(); |
| 4351 | f_l1_tune(L1CTL); |
| 4352 | } |
| 4353 | |
| 4354 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 4355 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4356 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4357 | |
| 4358 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4359 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4360 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4361 | f_TfiUsfArrSet(tua, 7, 0); |
| 4362 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4363 | f_sleep(1.0); |
| 4364 | |
| 4365 | 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] | 4366 | } |
| 4367 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4368 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4369 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4370 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4371 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4372 | |
| 4373 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4374 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4375 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4376 | f_TfiUsfArrSet(tua, 7, 0); |
| 4377 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4378 | f_sleep(1.0); |
| 4379 | |
| 4380 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4381 | } |
| 4382 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4383 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 4384 | runs on test_CT { |
| 4385 | var template PCUIF_Message pcu_rach_ind; |
| 4386 | var PCUIF_send_data sd; |
| 4387 | var GsmFrameNumber fn; |
| 4388 | timer T; |
| 4389 | |
| 4390 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 4391 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 4392 | chan_nr := ts_RslChanNr_PDCH(7), |
| 4393 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 4394 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4395 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 4396 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4397 | |
| 4398 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 4399 | T.start(52.0 * 4.615 / 1000.0); |
| 4400 | alt { |
| 4401 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 4402 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 4403 | setverdict(pass); |
| 4404 | T.stop; |
| 4405 | } |
| 4406 | [] PCU.receive { repeat; } |
| 4407 | [] T.timeout { |
| 4408 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 4409 | /* Keep going, that's not the end of the world */ |
| 4410 | } |
| 4411 | } |
| 4412 | } |
| 4413 | |
| 4414 | testcase TC_pcu_ptcch() runs on test_CT { |
| 4415 | var L1ctlDlMessage dl; |
| 4416 | var octetstring data; |
| 4417 | timer T; |
| 4418 | |
| 4419 | f_init_pcu_test(); |
| 4420 | f_init_l1ctl(); |
| 4421 | f_l1_tune(L1CTL); |
| 4422 | |
| 4423 | /* Activate PDCH channel on TS7 */ |
| 4424 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4425 | |
| 4426 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 4427 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(ts_RslChanNr_PDCH(7), 7, mp_trx0_arfcn)); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4428 | |
| 4429 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 4430 | for (var integer i := 0; i < 16; i := i + 1) { |
| 4431 | log("Sending an Access Burst towards the L1CTL interface"); |
| 4432 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 4433 | } |
| 4434 | |
| 4435 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 4436 | data := f_rnd_octstring(23); |
| 4437 | |
| 4438 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 4439 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 4440 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 4441 | |
| 4442 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 4443 | * let's give it more time in case if we miss the beginning. */ |
| 4444 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 4445 | alt { |
| 4446 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 4447 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4448 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4449 | frame := data)) -> value dl { |
| 4450 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 4451 | setverdict(pass); |
| 4452 | T.stop; |
| 4453 | } |
| 4454 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 4455 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4456 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4457 | l2_data := data)) -> value dl { |
| 4458 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 4459 | setverdict(pass); |
| 4460 | T.stop; |
| 4461 | } |
| 4462 | [] L1CTL.receive { repeat; } |
| 4463 | [] T.timeout { |
| 4464 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 4465 | } |
| 4466 | } |
| 4467 | } |
| 4468 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4469 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4470 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 4471 | timer T := 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4472 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4473 | f_init_l1ctl(); |
| 4474 | f_l1_tune(L1CTL); |
| 4475 | |
| 4476 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4477 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 4478 | |
| 4479 | T.start; |
| 4480 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4481 | [] 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] | 4482 | setverdict(pass); |
| 4483 | } |
| 4484 | [] L1CTL.receive { repeat; } |
| 4485 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4486 | 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] | 4487 | } |
| 4488 | } |
| 4489 | } |
| 4490 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 4491 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4492 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 4493 | timer T := 3.0; |
| 4494 | f_init_pcu_test(); |
| 4495 | f_init_l1ctl(); |
| 4496 | f_l1_tune(L1CTL); |
| 4497 | |
| 4498 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4499 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 4500 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 4501 | |
| 4502 | T.start; |
| 4503 | alt { |
| 4504 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 4505 | setverdict(pass); |
| 4506 | } |
| 4507 | [] L1CTL.receive { repeat; } |
| 4508 | [] T.timeout { |
| 4509 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 4510 | } |
| 4511 | } |
| 4512 | } |
| 4513 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4514 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 4515 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 4516 | var octetstring imm_ass := f_rnd_octstring(23); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4517 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4518 | f_init_l1ctl(); |
| 4519 | f_l1_tune(L1CTL); |
| 4520 | |
| 4521 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 4522 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 4523 | |
| 4524 | timer T := 0.5; |
| 4525 | T.start; |
| 4526 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4527 | [] 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] | 4528 | /* TODO: verify paging group */ |
| 4529 | setverdict(pass); |
| 4530 | } |
| 4531 | [] L1CTL.receive { repeat; } |
| 4532 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4533 | 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] | 4534 | } |
| 4535 | } |
| 4536 | } |
| 4537 | |
| 4538 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 4539 | testcase TC_pcu_rach_content() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4540 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4541 | f_init_l1ctl(); |
| 4542 | f_l1_tune(L1CTL); |
| 4543 | |
| 4544 | var GsmFrameNumber fn_last := 0; |
| 4545 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4546 | var OCT1 ra := f_rnd_ra_ps(); |
| 4547 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 4548 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4549 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4550 | } |
| 4551 | fn_last := fn; |
| 4552 | |
| 4553 | timer T := 2.0; |
| 4554 | T.start; |
| 4555 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4556 | [] 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] | 4557 | T.stop; |
| 4558 | } |
| 4559 | [] 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] | 4560 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4561 | } |
| 4562 | [] PCU.receive { repeat; } |
| 4563 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4564 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4565 | } |
| 4566 | } |
| 4567 | } |
| 4568 | setverdict(pass); |
| 4569 | } |
| 4570 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 4571 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 4572 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 4573 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 4574 | var template PCUIF_Message pcu_rach_ind; |
| 4575 | var GsmFrameNumber fn_last := 0; |
| 4576 | var L1ctlRachSynchSeq synch_seq; |
| 4577 | var PCUIF_BurstType pcu_bt; |
| 4578 | var GsmFrameNumber fn; |
| 4579 | var BIT11 ra11; |
| 4580 | |
| 4581 | f_init_pcu_test(); |
| 4582 | f_init_l1ctl(); |
| 4583 | f_l1_tune(L1CTL); |
| 4584 | |
| 4585 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4586 | /* We need to test both TS1 & TS2 */ |
| 4587 | if (i rem 2 == 0) { |
| 4588 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 4589 | pcu_bt := BURST_TYPE_1; |
| 4590 | } else { |
| 4591 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 4592 | pcu_bt := BURST_TYPE_2; |
| 4593 | } |
| 4594 | |
| 4595 | ra11 := f_rnd_ra11_ps(); |
| 4596 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 4597 | if (fn == fn_last) { |
| 4598 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4599 | "Two RACH in same FN?!?"); |
| 4600 | } |
| 4601 | fn_last := fn; |
| 4602 | |
| 4603 | /* Compose the expected message */ |
| 4604 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4605 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 4606 | ra := bit2int(ra11), |
| 4607 | is_11bit := 1, |
| 4608 | burst_type := pcu_bt, |
| 4609 | fn := fn); |
| 4610 | |
| 4611 | timer T := 2.0; |
| 4612 | T.start; |
| 4613 | alt { |
| 4614 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 4615 | T.stop; |
| 4616 | } |
| 4617 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 4618 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 4619 | } |
| 4620 | [] PCU.receive { repeat; } |
| 4621 | [] T.timeout { |
| 4622 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 4623 | } |
| 4624 | } |
| 4625 | } |
| 4626 | setverdict(pass); |
| 4627 | } |
| 4628 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 4629 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 4630 | runs on test_CT { |
| 4631 | var template PCUIF_send_data sdt; |
| 4632 | var PCUIF_send_data sd; |
| 4633 | var int16_t lqual_cb; |
| 4634 | timer T := 1.0; |
| 4635 | |
| 4636 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 4637 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 4638 | |
| 4639 | /* Send a random PDTCH frame over Um */ |
| 4640 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 4641 | '0000'O & f_rnd_octstring(21))); |
| 4642 | |
| 4643 | T.start; |
| 4644 | alt { |
| 4645 | /* If expected link quality is above the threshold */ |
| 4646 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 4647 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 4648 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 4649 | |
| 4650 | /* Make sure the actual link quality matches the expected value */ |
| 4651 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 4652 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 4653 | "expected value ", lqual_cb_exp)); |
| 4654 | } else { |
| 4655 | setverdict(pass); |
| 4656 | } |
| 4657 | } |
| 4658 | /* If expected link quality is below the threshold */ |
| 4659 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 4660 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4661 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 4662 | } |
| 4663 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 4664 | [] PCU.receive { repeat; } |
| 4665 | [lqual_cb_exp < thresh] T.timeout { |
| 4666 | log("Rx nothing, as expected"); |
| 4667 | setverdict(pass); |
| 4668 | } |
| 4669 | [lqual_cb_exp >= thresh] T.timeout { |
| 4670 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4671 | "Timeout waiting for PCUIF_DATA.ind"); |
| 4672 | } |
| 4673 | } |
| 4674 | } |
| 4675 | |
| 4676 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 4677 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
| 4678 | f_init_pcu_test(); |
| 4679 | PCU.clear; |
| 4680 | |
| 4681 | f_init_l1ctl(); |
| 4682 | f_l1_tune(L1CTL); |
| 4683 | |
| 4684 | /* Activate a PDCH channel on TS7 */ |
| 4685 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4686 | |
| 4687 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 4688 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(ts_RslChanNr_PDCH(7), 7, mp_trx0_arfcn)); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 4689 | |
| 4690 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 4691 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 4692 | var TrxcMessage ret; |
| 4693 | |
| 4694 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 4695 | valueof(ts_TRXC_FAKE_CI(i))); |
| 4696 | |
| 4697 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 4698 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 4699 | } |
| 4700 | } |
| 4701 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4702 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 4703 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4704 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4705 | |
| 4706 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4707 | var MobileIdentityLV mi_lv; |
| 4708 | var octetstring mi_lv_enc; |
| 4709 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4710 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4711 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4712 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4713 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4714 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4715 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4716 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4717 | |
| 4718 | /* Fancy encoding for PCUIF */ |
| 4719 | mi_lv := valueof(ts_MI_LV(mi)); |
| 4720 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 4721 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4722 | |
| 4723 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4724 | 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] | 4725 | T.start; |
| 4726 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4727 | [] 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] | 4728 | } |
| 4729 | [] 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] | 4730 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4731 | } |
| 4732 | [] PCU.receive { repeat; } |
| 4733 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4734 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4735 | } |
| 4736 | } |
| 4737 | } |
| 4738 | setverdict(pass); |
| 4739 | } |
| 4740 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 4741 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 4742 | testcase TC_pcu_time_ind() runs on test_CT { |
| 4743 | var PCUIF_send_data pcu_sd; |
| 4744 | var integer num_time_ind := 0; |
| 4745 | var integer first_fn, last_fn; |
| 4746 | var float test_duration := 5.0; |
| 4747 | timer T; |
| 4748 | |
| 4749 | f_init_pcu_test(); |
| 4750 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4751 | |
| 4752 | PCU.clear; |
| 4753 | T.start(test_duration); |
| 4754 | alt { |
| 4755 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 4756 | num_time_ind := num_time_ind + 1; |
| 4757 | if (not isbound(first_fn)) { |
| 4758 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 4759 | } |
| 4760 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 4761 | repeat; |
| 4762 | } |
| 4763 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 4764 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 4765 | repeat; |
| 4766 | } |
| 4767 | [] PCU.receive { |
| 4768 | repeat; |
| 4769 | } |
| 4770 | [] T.timeout {} |
| 4771 | } |
| 4772 | var integer fn_expired := last_fn - first_fn; |
| 4773 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 4774 | |
| 4775 | /* verify the number of frames expired matches our expectation */ |
| 4776 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 4777 | 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] | 4778 | 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] | 4779 | if (not match(fn_expired, t_fn_expected)) { |
| 4780 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 4781 | } |
| 4782 | |
| 4783 | /* There are three TIME.ind in every fn MOD 13 */ |
| 4784 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 4785 | /* Add some tolerance */ |
| 4786 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 4787 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 4788 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 4789 | } |
| 4790 | |
| 4791 | setverdict(pass); |
| 4792 | } |
| 4793 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 4794 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 4795 | testcase TC_pcu_rts_req() runs on test_CT { |
| 4796 | var PCUIF_send_data pcu_sd; |
| 4797 | var integer first_fn, last_fn; |
| 4798 | var integer num_rts_pdtch := 0; |
| 4799 | var integer num_rts_ptcch := 0; |
| 4800 | var float test_duration := 5.0; |
| 4801 | timer T; |
| 4802 | |
| 4803 | f_init_pcu_test(); |
| 4804 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4805 | |
| 4806 | PCU.clear; |
| 4807 | T.start(test_duration); |
| 4808 | alt { |
| 4809 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 4810 | -> value pcu_sd { |
| 4811 | num_rts_pdtch := num_rts_pdtch + 1; |
| 4812 | if (not isbound(first_fn)) { |
| 4813 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 4814 | } |
| 4815 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 4816 | repeat; |
| 4817 | } |
| 4818 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 4819 | -> value pcu_sd { |
| 4820 | num_rts_ptcch := num_rts_ptcch + 1; |
| 4821 | if (not isbound(first_fn)) { |
| 4822 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 4823 | } |
| 4824 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 4825 | repeat; |
| 4826 | } |
| 4827 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 4828 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 4829 | repeat; |
| 4830 | } |
| 4831 | [] PCU.receive { |
| 4832 | repeat; |
| 4833 | } |
| 4834 | [] T.timeout {} |
| 4835 | } |
| 4836 | var integer fn_expired := last_fn - first_fn; |
| 4837 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 4838 | ", num_rts_ptcch=", num_rts_ptcch); |
| 4839 | |
| 4840 | /* verify the number of frames expired matches our expectation */ |
| 4841 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 4842 | 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] | 4843 | 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] | 4844 | if (not match(fn_expired, t_fn_expected)) { |
| 4845 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 4846 | } |
| 4847 | |
| 4848 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 4849 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 4850 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 4851 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 4852 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 4853 | t_ptcch_exp); |
| 4854 | } |
| 4855 | |
| 4856 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 4857 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 4858 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 4859 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 4860 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 4861 | t_pdtch_exp); |
| 4862 | } |
| 4863 | |
| 4864 | setverdict(pass); |
| 4865 | } |
| 4866 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4867 | /* test for generating Abis side OML ALERT from the PCU */ |
| 4868 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 4869 | var PCUIF_send_data pcu_sd; |
| 4870 | var integer num_time_ind := 0; |
| 4871 | var integer first_fn, last_fn; |
| 4872 | var float test_duration := 5.0; |
| 4873 | timer T; |
| 4874 | |
| 4875 | f_init_pcu_test(); |
| 4876 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4877 | |
| 4878 | /* re-connect CTRL port from BTS to BSC */ |
| 4879 | f_ipa_ctrl_stop(); |
| 4880 | f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port); |
| 4881 | |
| 4882 | /* Send that OML Alert */ |
| 4883 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 4884 | |
| 4885 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 4886 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 4887 | setverdict(pass); |
| 4888 | } |
| 4889 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 4890 | template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli, |
| 4891 | template (value) RoutingAreaIdentificationV rai, |
| 4892 | template (value) OCT1 cause) := { |
| 4893 | discriminator := '0000'B, /* overwritten */ |
| 4894 | tiOrSkip := { |
| 4895 | skipIndicator := '0000'B |
| 4896 | }, |
| 4897 | msgs := { |
| 4898 | rrm := { |
| 4899 | gPRS_suspensionRequest := { |
| 4900 | messageType := '00110100'B, |
| 4901 | tLLI := tlli, |
| 4902 | routingAreaIdentification := rai, |
| 4903 | suspensionCause := cause, |
| 4904 | service_Support := omit |
| 4905 | } |
| 4906 | } |
| 4907 | } |
| 4908 | } |
| 4909 | |
| 4910 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 4911 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 4912 | var PCUIF_Message first_info; |
| 4913 | var integer pcu_conn_id := -1; |
| 4914 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 4915 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 4916 | var OCT4 tlli := '01020304'O; |
| 4917 | var OCT1 cause := '23'O; |
| 4918 | timer T := 5.0; |
| 4919 | |
| 4920 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 4921 | |
| 4922 | f_l1_tune(L1CTL); |
| 4923 | RSL.clear; |
| 4924 | |
| 4925 | f_est_dchan(); |
| 4926 | L1CTL.clear; |
| 4927 | |
| 4928 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 4929 | |
| 4930 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 4931 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 4932 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 4933 | |
| 4934 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 4935 | T.start; |
| 4936 | alt { |
| 4937 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 4938 | setverdict(pass); |
| 4939 | } |
| 4940 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 4941 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 4942 | } |
| 4943 | [] PCU.receive { |
| 4944 | repeat; |
| 4945 | } |
| 4946 | [] T.timeout { |
| 4947 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 4948 | } |
| 4949 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 4950 | |
| 4951 | /* release the channel */ |
| 4952 | f_rsl_chan_deact(); |
| 4953 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 4954 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 4955 | } |
| 4956 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 4957 | var ConnHdlrPars pars; |
| 4958 | var ConnHdlr vc_conn; |
| 4959 | |
| 4960 | f_init(); |
| 4961 | |
| 4962 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 4963 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 4964 | vc_conn.done; |
| 4965 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4966 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 4967 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 4968 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
| 4969 | timer T := 5.0; |
| 4970 | |
| 4971 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 4972 | f_init(); |
| 4973 | |
| 4974 | /* try to establish a second connection, expect it to fail */ |
| 4975 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 4976 | T.start; |
| 4977 | alt { |
| 4978 | [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) { |
| 4979 | setverdict(pass); |
| 4980 | } |
| 4981 | [] PCU.receive(UD_connect_result:?) { |
| 4982 | setverdict(fail, "Unexpected unix domain connect result"); |
| 4983 | } |
| 4984 | [] T.timeout { |
| 4985 | setverdict(pass); |
| 4986 | } |
| 4987 | } |
| 4988 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4989 | } |
| 4990 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 4991 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 4992 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 4993 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 4994 | f_init(); |
| 4995 | |
| 4996 | f_sleep(1.0); |
| 4997 | |
| 4998 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 4999 | g_pcu_conn_id := -1; |
| 5000 | |
| 5001 | f_sleep(1.0); |
| 5002 | |
| 5003 | /* re-connect */ |
| 5004 | PCU.clear; |
| 5005 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5006 | setverdict(pass); |
| 5007 | |
| 5008 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5009 | } |
| 5010 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5011 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5012 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 5013 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5014 | var L1ctlDlMessage l1_dl; |
| 5015 | var SystemInformation si; |
| 5016 | timer T := 5.0; |
| 5017 | T.start; |
| 5018 | alt { |
| 5019 | [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 5020 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 5021 | if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) { |
| 5022 | log("Ignoring non-RR SI ", l1_dl); |
| 5023 | repeat; |
| 5024 | } |
| 5025 | si := dec_SystemInformation(l1_dl.payload.data_ind.payload) |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5026 | if (si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5027 | repeat; |
| 5028 | } |
| 5029 | } |
| 5030 | [] pt.receive { |
| 5031 | repeat; |
| 5032 | } |
| 5033 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5034 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5035 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5036 | } |
| 5037 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5038 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5039 | } |
| 5040 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5041 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 5042 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 5043 | runs on test_CT return boolean { |
| 5044 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 5045 | |
| 5046 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
| 5047 | var RestOctets ro := si.payload.si3.rest_octets; |
| 5048 | var SI3RestOctets rest := dec_SI3RestOctets(ro); |
| 5049 | return rest.gprs_ind.presence == '1'B; |
| 5050 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
| 5051 | var RestOctets ro := si.payload.si4.rest_octets; |
| 5052 | var SI4RestOctets rest := dec_SI4RestOctets(ro); |
| 5053 | return rest.gprs_ind.presence == '1'B; |
| 5054 | } |
| 5055 | |
| 5056 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 5057 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5058 | } |
| 5059 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5060 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 5061 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 5062 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5063 | /* don't call f_init() as this would connect PCU socket */ |
| 5064 | f_init_rsl(testcasename()); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5065 | |
| 5066 | /* Send both System Information Type 3 and 4 (with GPRS Indicator) */ |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5067 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5068 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5069 | |
| 5070 | f_init_l1ctl(); |
| 5071 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5072 | f_sleep(2.0); |
| 5073 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5074 | |
| 5075 | if (f_si_has_gprs_indicator(si_type)) { |
| 5076 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5077 | } else { |
| 5078 | setverdict(pass); |
| 5079 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5080 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5081 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5082 | } |
| 5083 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5084 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 5085 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5086 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5087 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5088 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 5089 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5090 | } |
| 5091 | |
| 5092 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 5093 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 5094 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5095 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5096 | f_init(); |
| 5097 | f_init_l1ctl(); |
| 5098 | f_l1_tune(L1CTL); |
| 5099 | |
| 5100 | f_sleep(2.0); |
| 5101 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5102 | |
| 5103 | if (not f_si_has_gprs_indicator(si_type)) { |
| 5104 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5105 | } else { |
| 5106 | setverdict(pass); |
| 5107 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5108 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5109 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5110 | } |
| 5111 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5112 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 5113 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 5114 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5115 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5116 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 5117 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 5118 | } |
| 5119 | |
| 5120 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 5121 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 5122 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5123 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5124 | f_init(); |
| 5125 | f_init_l1ctl(); |
| 5126 | f_l1_tune(L1CTL); |
| 5127 | |
| 5128 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5129 | g_pcu_conn_id := -1; |
| 5130 | |
| 5131 | f_sleep(1.0); |
| 5132 | |
| 5133 | /* re-connect */ |
| 5134 | PCU.clear; |
| 5135 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5136 | |
| 5137 | f_sleep(2.0); |
| 5138 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5139 | |
| 5140 | if (f_si_has_gprs_indicator(si_type)) { |
| 5141 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5142 | } else { |
| 5143 | setverdict(pass); |
| 5144 | } |
| 5145 | |
| 5146 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5147 | } |
| 5148 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5149 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 5150 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5151 | } |
| 5152 | |
| 5153 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 5154 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5155 | } |
| 5156 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5157 | /* 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) */ |
| 5158 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 5159 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 5160 | |
| 5161 | f_init(); |
| 5162 | |
| 5163 | /* Verify cell_id */ |
| 5164 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 5165 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 5166 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 5167 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 5168 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 5169 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5170 | } |
| 5171 | |
| 5172 | /* Verify LAC */ |
| 5173 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 5174 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 5175 | if (lac_si3 != lac_pcu) { |
| 5176 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 5177 | } |
| 5178 | |
| 5179 | setverdict(pass); |
| 5180 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5181 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5182 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5183 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5184 | ***********************************************************************/ |
| 5185 | |
| 5186 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5187 | runs on ConnHdlr { |
| 5188 | var PCUIF_send_data sd; |
| 5189 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5190 | PCU.clear; |
| 5191 | f_rsl_chan_act(g_pars.chan_mode); |
| 5192 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5193 | timer T_wait := 2.0; |
| 5194 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5195 | alt { |
| 5196 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5197 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) { |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5198 | log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn, |
| 5199 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5200 | repeat; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5201 | } |
| 5202 | } |
| 5203 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5204 | [] T_wait.timeout { |
| 5205 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5206 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5207 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5208 | } |
| 5209 | /* try to activate this PDCH from the PCU point of view */ |
| 5210 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5211 | /* FIXME: is there a response? */ |
| 5212 | } |
| 5213 | |
| 5214 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5215 | runs on ConnHdlr { |
| 5216 | var PCUIF_send_data sd; |
| 5217 | /* Send RSL CHAN REL (deactivate) */ |
| 5218 | PCU.clear; |
| 5219 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5220 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5221 | timer T_wait := 2.0; |
| 5222 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5223 | alt { |
| 5224 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5225 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) { |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5226 | log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn, |
| 5227 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5228 | repeat; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5229 | } |
| 5230 | } |
| 5231 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5232 | [] T_wait.timeout { |
| 5233 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5234 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5235 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5236 | } |
| 5237 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5238 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5239 | alt { |
| 5240 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 5241 | setverdict(pass); |
| 5242 | } |
| 5243 | [] RSL.receive { repeat; } |
| 5244 | } |
| 5245 | } |
| 5246 | |
| 5247 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
| 5248 | function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr { |
| 5249 | var PCUIF_Message first_info; |
| 5250 | var integer ts_nr := g_chan_nr.tn; |
| 5251 | var integer trx_nr := 0; |
| 5252 | var integer bts_nr := 0; |
| 5253 | var integer pcu_conn_id := -1; |
| 5254 | |
| 5255 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5256 | |
| 5257 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5258 | f_sleep(3.0); |
| 5259 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5260 | setverdict(pass); |
| 5261 | } |
| 5262 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 5263 | var ConnHdlrPars pars; |
| 5264 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5265 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5266 | |
| 5267 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5268 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 5269 | vc_conn.done; |
| 5270 | } |
| 5271 | |
| 5272 | /* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */ |
| 5273 | function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr { |
| 5274 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5275 | var integer pcu_conn_id := -1; |
| 5276 | |
| 5277 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5278 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 5279 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5280 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 5281 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5282 | setverdict(pass); |
| 5283 | } |
| 5284 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 5285 | var ConnHdlrPars pars; |
| 5286 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5287 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5288 | |
| 5289 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5290 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 5291 | vc_conn.done; |
| 5292 | } |
| 5293 | |
| 5294 | /* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */ |
| 5295 | function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr { |
| 5296 | var PCUIF_Message first_info; |
| 5297 | var integer ts_nr := g_chan_nr.tn; |
| 5298 | var integer trx_nr := 0; |
| 5299 | var integer bts_nr := 0; |
| 5300 | var integer pcu_conn_id := -1; |
| 5301 | |
| 5302 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5303 | |
| 5304 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 5305 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 5306 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5307 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5308 | setverdict(pass); |
| 5309 | } |
| 5310 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 5311 | var ConnHdlrPars pars; |
| 5312 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5313 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5314 | |
| 5315 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5316 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 5317 | vc_conn.done; |
| 5318 | } |
| 5319 | |
| 5320 | /* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */ |
| 5321 | function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr { |
| 5322 | var PCUIF_Message first_info; |
| 5323 | var integer ts_nr := g_chan_nr.tn; |
| 5324 | var integer trx_nr := 0; |
| 5325 | var integer bts_nr := 0; |
| 5326 | var integer pcu_conn_id := -1; |
| 5327 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 5328 | |
| 5329 | /* register for the TCH/F channel number */ |
| 5330 | f_rslem_register(0, chan_nr); |
| 5331 | |
| 5332 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5333 | |
| 5334 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 5335 | "RSL CHAN ACT"); |
| 5336 | setverdict(pass); |
| 5337 | } |
| 5338 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 5339 | var ConnHdlrPars pars; |
| 5340 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5341 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5342 | |
| 5343 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5344 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 5345 | vc_conn.done; |
| 5346 | } |
| 5347 | |
| 5348 | /* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */ |
| 5349 | function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr { |
| 5350 | var PCUIF_Message first_info; |
| 5351 | var integer ts_nr := g_chan_nr.tn; |
| 5352 | var integer trx_nr := 0; |
| 5353 | var integer bts_nr := 0; |
| 5354 | var integer pcu_conn_id := -1; |
| 5355 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 5356 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 5357 | |
| 5358 | /* register for the TCH/H channel numbers */ |
| 5359 | f_rslem_register(0, chan_nr[0]); |
| 5360 | f_rslem_register(0, chan_nr[1]); |
| 5361 | |
| 5362 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5363 | |
| 5364 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 5365 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 5366 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 5367 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 5368 | setverdict(pass); |
| 5369 | } |
| 5370 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 5371 | var ConnHdlrPars pars; |
| 5372 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5373 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5374 | |
| 5375 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5376 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 5377 | vc_conn.done; |
| 5378 | } |
| 5379 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5380 | /*********************************************************************** |
| 5381 | * IPA Style Dynamic Timeslot Support |
| 5382 | ***********************************************************************/ |
| 5383 | |
| 5384 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5385 | runs on ConnHdlr { |
| 5386 | var PCUIF_send_data sd; |
| 5387 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5388 | PCU.clear; |
| 5389 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5390 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5391 | timer T_wait := 2.0; |
| 5392 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5393 | alt { |
| 5394 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5395 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) { |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5396 | log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn, |
| 5397 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5398 | repeat; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5399 | } |
| 5400 | } |
| 5401 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5402 | [] T_wait.timeout { |
| 5403 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5404 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5405 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5406 | } |
| 5407 | /* try to activate this PDCH from the PCU point of view */ |
| 5408 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5409 | /* FIXME: is there a response? */ |
| 5410 | |
| 5411 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 5412 | } |
| 5413 | |
| 5414 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5415 | runs on ConnHdlr { |
| 5416 | var PCUIF_send_data sd; |
| 5417 | /* Send RSL CHAN REL (deactivate) */ |
| 5418 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 5419 | PCU.clear; |
| 5420 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5421 | timer T_wait := 2.0; |
| 5422 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5423 | alt { |
| 5424 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5425 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) { |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5426 | log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn, |
| 5427 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5428 | repeat; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5429 | } |
| 5430 | } |
| 5431 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5432 | [] T_wait.timeout { |
| 5433 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5434 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5435 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5436 | } |
| 5437 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5438 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5439 | alt { |
| 5440 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 5441 | setverdict(pass); |
| 5442 | } |
| 5443 | [] RSL.receive { repeat; } |
| 5444 | } |
| 5445 | } |
| 5446 | |
| 5447 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
| 5448 | function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr { |
| 5449 | var PCUIF_Message first_info; |
| 5450 | var integer ts_nr := g_chan_nr.tn; |
| 5451 | var integer trx_nr := 0; |
| 5452 | var integer bts_nr := 0; |
| 5453 | var integer pcu_conn_id := -1; |
| 5454 | |
| 5455 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5456 | |
| 5457 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5458 | f_sleep(3.0); |
| 5459 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5460 | |
| 5461 | setverdict(pass); |
| 5462 | |
| 5463 | } |
| 5464 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 5465 | var ConnHdlrPars pars; |
| 5466 | var ConnHdlr vc_conn; |
| 5467 | f_init(); |
| 5468 | |
| 5469 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5470 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 5471 | vc_conn.done; |
| 5472 | } |
| 5473 | |
| 5474 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */ |
| 5475 | function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr { |
| 5476 | var PCUIF_Message first_info; |
| 5477 | var integer ts_nr := g_chan_nr.tn; |
| 5478 | var integer trx_nr := 0; |
| 5479 | var integer bts_nr := 0; |
| 5480 | var integer pcu_conn_id := -1; |
| 5481 | |
| 5482 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5483 | |
| 5484 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5485 | "RSL CHAN ACT"); |
| 5486 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5487 | "RF CHAN REL", true); |
| 5488 | setverdict(pass); |
| 5489 | } |
| 5490 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 5491 | var ConnHdlrPars pars; |
| 5492 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5493 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5494 | |
| 5495 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5496 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 5497 | vc_conn.done; |
| 5498 | } |
| 5499 | |
| 5500 | /* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */ |
| 5501 | function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr { |
| 5502 | var PCUIF_Message first_info; |
| 5503 | var integer ts_nr := g_chan_nr.tn; |
| 5504 | var integer trx_nr := 0; |
| 5505 | var integer bts_nr := 0; |
| 5506 | var integer pcu_conn_id := -1; |
| 5507 | |
| 5508 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5509 | |
| 5510 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5511 | "RSL CHAN ACT"); |
| 5512 | |
| 5513 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5514 | alt { |
| 5515 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 5516 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5517 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5518 | } |
| 5519 | [] RSL.receive { repeat; } |
| 5520 | } |
| 5521 | |
| 5522 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5523 | "RF CHAN REL", true); |
| 5524 | setverdict(pass); |
| 5525 | } |
| 5526 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 5527 | var ConnHdlrPars pars; |
| 5528 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5529 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5530 | |
| 5531 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5532 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 5533 | vc_conn.done; |
| 5534 | } |
| 5535 | |
| 5536 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */ |
| 5537 | function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr { |
| 5538 | var PCUIF_Message first_info; |
| 5539 | var integer ts_nr := g_chan_nr.tn; |
| 5540 | var integer trx_nr := 0; |
| 5541 | var integer bts_nr := 0; |
| 5542 | var integer pcu_conn_id := -1; |
| 5543 | |
| 5544 | /* register for the TCH/F channel number */ |
| 5545 | f_rslem_register(0, g_chan_nr); |
| 5546 | |
| 5547 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5548 | |
| 5549 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5550 | |
| 5551 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5552 | "RSL CHAN ACT"); |
| 5553 | |
| 5554 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5555 | |
| 5556 | setverdict(pass); |
| 5557 | } |
| 5558 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 5559 | var ConnHdlrPars pars; |
| 5560 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5561 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5562 | |
| 5563 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5564 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 5565 | vc_conn.done; |
| 5566 | } |
| 5567 | |
| 5568 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5569 | /*********************************************************************** |
| 5570 | * LAPDm / RLL related |
| 5571 | ***********************************************************************/ |
| 5572 | |
| 5573 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 5574 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 5575 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5576 | var template (value) SacchL1Header l1h; |
| 5577 | |
| 5578 | /* 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] | 5579 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5580 | /* Compose dummy L1 header */ |
| 5581 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta); |
| 5582 | 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] | 5583 | } else { |
| 5584 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5585 | 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] | 5586 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5587 | } |
| 5588 | |
| 5589 | type record RllTestCase { |
| 5590 | uint3_t sapi, |
| 5591 | RslLinkId link_id, |
| 5592 | octetstring l3, |
| 5593 | boolean exp |
| 5594 | } |
| 5595 | type record of RllTestCase RllTestCases; |
| 5596 | template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := { |
| 5597 | sapi := sapi, |
| 5598 | link_id := id, |
| 5599 | l3 := l3, |
| 5600 | exp := exp |
| 5601 | } |
| 5602 | |
| 5603 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 5604 | * variety of logical channels */ |
| 5605 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 5606 | var ConnHdlrPars pars; |
| 5607 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5608 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5609 | |
| 5610 | /* test on each of the channels we have */ |
| 5611 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 5612 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 5613 | |
| 5614 | /* test each of the test cases on the current channel */ |
| 5615 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 5616 | pars.spec.rll := tcs[j]; |
| 5617 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 5618 | vc_conn := f_start_handler(fn, pars); |
| 5619 | vc_conn.done; |
| 5620 | } |
| 5621 | } |
| 5622 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5623 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5624 | } |
| 5625 | |
| 5626 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 5627 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 5628 | var RllTestCase tc := g_pars.spec.rll; |
| 5629 | timer T := 3.0; |
| 5630 | |
| 5631 | f_l1_tune(L1CTL); |
| 5632 | RSL.clear; |
| 5633 | |
| 5634 | /* activate the logical channel */ |
| 5635 | f_est_dchan(); |
| 5636 | L1CTL.clear; |
| 5637 | |
| 5638 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 5639 | T.start; |
| 5640 | alt { |
| 5641 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 5642 | if (tc.exp) { |
| 5643 | setverdict(pass); |
| 5644 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5645 | 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] | 5646 | } |
| 5647 | } |
| 5648 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 5649 | if (tc.exp) { |
| 5650 | setverdict(pass); |
| 5651 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5652 | 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] | 5653 | } |
| 5654 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 5655 | /* We also expect to receive the measurements */ |
| 5656 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5657 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5658 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5659 | } |
| 5660 | [not tc.exp] T.timeout { |
| 5661 | setverdict(pass); |
| 5662 | } |
| 5663 | } |
| 5664 | |
| 5665 | f_rsl_chan_deact(); |
| 5666 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5667 | f_rslem_unregister(0, g_chan_nr); |
| 5668 | } |
| 5669 | testcase TC_rll_est_ind() runs on test_CT { |
| 5670 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 5671 | /* SAPI0 establishment (contention resolution) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5672 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 5673 | /* normal SAPI0 establishment */ |
| 5674 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5675 | /* SAPI 3 doesn't support contention resolution */ |
| 5676 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)), |
| 5677 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)), |
| 5678 | /* normal SAPI3 establishment on main DCCH */ |
| 5679 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 5680 | /* normal SAPI3 establishment on SACCH */ |
| 5681 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5682 | }; |
| 5683 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 5684 | } |
| 5685 | |
| 5686 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 5687 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 5688 | var RllTestCase tc := g_pars.spec.rll; |
| 5689 | var L1ctlDlMessage dl; |
| 5690 | timer T := 3.0; |
| 5691 | |
| 5692 | f_l1_tune(L1CTL); |
| 5693 | RSL.clear; |
| 5694 | |
| 5695 | /* activate the logical channel */ |
| 5696 | f_est_dchan(); |
| 5697 | L1CTL.clear; |
| 5698 | |
| 5699 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 5700 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 5701 | T.start; |
| 5702 | alt { |
| 5703 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 5704 | var LapdmFrame lapdm; |
| 5705 | var octetstring l2 := dl.payload.data_ind.payload; |
| 5706 | if (dl.dl_info.link_id.c == SACCH) { |
| 5707 | /* remove L1 header */ |
| 5708 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 5709 | } |
| 5710 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 5711 | if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) { |
| 5712 | setverdict(pass); |
| 5713 | } else { |
| 5714 | repeat; |
| 5715 | } |
| 5716 | } |
| 5717 | [] L1CTL.receive { repeat; } |
| 5718 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5719 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5720 | } |
| 5721 | } |
| 5722 | |
| 5723 | f_rsl_chan_deact(); |
| 5724 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5725 | f_rslem_unregister(0, g_chan_nr); |
| 5726 | } |
| 5727 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 5728 | var RllTestCases tcs := { |
| 5729 | /* normal SAPI3 establishment on main DCCH */ |
| 5730 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//, |
| 5731 | }; |
| 5732 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 5733 | } |
| 5734 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 5735 | var RllTestCases tcs := { |
| 5736 | /* normal SAPI3 establishment on SACCH */ |
| 5737 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5738 | } |
| 5739 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 5740 | } |
| 5741 | |
| 5742 | /* altstep to receive a LAPDm frame matching the given template */ |
| 5743 | private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
| 5744 | var L1ctlDlMessage dl; |
| 5745 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 5746 | var LapdmFrame lapdm; |
| 5747 | var octetstring l2 := dl.payload.data_ind.payload; |
| 5748 | if (dl.dl_info.link_id.c == SACCH) { |
| 5749 | /* remove L1 header */ |
| 5750 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 5751 | } |
| 5752 | if (ischosen(exp.ab)) { |
| 5753 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 5754 | } else if (ischosen(exp.b4)) { |
| 5755 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 5756 | } else if (ischosen(exp.bbis)) { |
| 5757 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 5758 | } |
| 5759 | log("Rx LAPDm ", lapdm); |
| 5760 | if (match(lapdm, exp)) { |
| 5761 | setverdict(pass); |
| 5762 | } else { |
| 5763 | repeat; |
| 5764 | } |
| 5765 | } |
| 5766 | [] L1CTL.receive { repeat; } |
| 5767 | } |
| 5768 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 5769 | timer T := t; |
| 5770 | T.start; |
| 5771 | alt { |
| 5772 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5773 | 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] | 5774 | } |
| 5775 | [] as_l1_exp_lapdm(exp); |
| 5776 | } |
| 5777 | } |
| 5778 | |
| 5779 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 5780 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 5781 | /* send SABM from MS -> BTS */ |
| 5782 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 5783 | /* expect RLL EST IND on Abis */ |
| 5784 | alt { |
| 5785 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 5786 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 5787 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5788 | 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] | 5789 | } |
| 5790 | [] RSL.receive { repeat; } |
| 5791 | } |
| 5792 | /* expect UA from BTS -> MS */ |
| 5793 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 5794 | } |
| 5795 | |
| 5796 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 5797 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 5798 | var RllTestCase tc := g_pars.spec.rll; |
| 5799 | |
| 5800 | f_l1_tune(L1CTL); |
| 5801 | RSL.clear; |
| 5802 | |
| 5803 | /* activate the logical channel */ |
| 5804 | f_est_dchan(); |
| 5805 | L1CTL.clear; |
| 5806 | |
| 5807 | /* first establish the link-layer */ |
| 5808 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 5809 | |
| 5810 | /* then send the DISC */ |
| 5811 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 5812 | /* ... and expect the REL IND on the RSL side */ |
| 5813 | alt { |
| 5814 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 5815 | setverdict(pass); |
| 5816 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 5817 | /* We also expect to receive the measurements */ |
| 5818 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5819 | } |
| 5820 | |
| 5821 | /* release the channel */ |
| 5822 | f_rsl_chan_deact(); |
| 5823 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5824 | f_rslem_unregister(0, g_chan_nr); |
| 5825 | } |
| 5826 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 5827 | var RllTestCases tcs := { |
| 5828 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)) |
| 5829 | }; |
| 5830 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5831 | } |
| 5832 | |
| 5833 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 5834 | var RllTestCases tcs := { |
| 5835 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)) |
| 5836 | }; |
| 5837 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5838 | } |
| 5839 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 5840 | var RllTestCases tcs := { |
| 5841 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)) |
| 5842 | }; |
| 5843 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5844 | } |
| 5845 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 5846 | var RllTestCases tcs := { |
| 5847 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5848 | }; |
| 5849 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5850 | } |
| 5851 | |
| 5852 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 5853 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 5854 | var RllTestCase tc := g_pars.spec.rll; |
| 5855 | f_l1_tune(L1CTL); |
| 5856 | RSL.clear; |
| 5857 | |
| 5858 | /* activate the logical channel */ |
| 5859 | f_est_dchan(); |
| 5860 | L1CTL.clear; |
| 5861 | |
| 5862 | /* first establish the link-layer */ |
| 5863 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 5864 | |
| 5865 | /* then send the REL REQ via RSL */ |
| 5866 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 5867 | /* ... and expect the DISC on the Um side */ |
| 5868 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 5869 | [] 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] | 5870 | /* FIXME: send a UA in resposne to the DISC */ |
| 5871 | } |
| 5872 | } |
| 5873 | |
| 5874 | /* release the channel */ |
| 5875 | f_rsl_chan_deact(); |
| 5876 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5877 | f_rslem_unregister(0, g_chan_nr); |
| 5878 | } |
| 5879 | testcase TC_rll_rel_req() runs on test_CT { |
| 5880 | var RllTestCases tcs := { |
| 5881 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
| 5882 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)), |
| 5883 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 5884 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5885 | }; |
| 5886 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 5887 | } |
| 5888 | |
| 5889 | /* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */ |
| 5890 | testcase TC_rll_data_req() runs on test_CT { |
| 5891 | } |
| 5892 | |
| 5893 | /* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */ |
| 5894 | testcase TC_rll_data_ind() runs on test_CT { |
| 5895 | } |
| 5896 | |
| 5897 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 5898 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 5899 | var RllTestCase tc := g_pars.spec.rll; |
| 5900 | |
| 5901 | f_l1_tune(L1CTL); |
| 5902 | RSL.clear; |
| 5903 | |
| 5904 | f_est_dchan(); |
| 5905 | L1CTL.clear; |
| 5906 | |
| 5907 | /* Send UNITDATA REQ on RSL side */ |
| 5908 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 5909 | /* Expect it to arrive on the other side */ |
| 5910 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5911 | 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] | 5912 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5913 | 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] | 5914 | } |
| 5915 | |
| 5916 | /* release the channel */ |
| 5917 | f_rsl_chan_deact(); |
| 5918 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5919 | f_rslem_unregister(0, g_chan_nr); |
| 5920 | } |
| 5921 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 5922 | var octetstring l3 := f_rnd_octstring(15); |
| 5923 | var RllTestCases tcs := { |
| 5924 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 5925 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 5926 | }; |
| 5927 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 5928 | } |
| 5929 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 5930 | var octetstring l3 := f_rnd_octstring(19); |
| 5931 | var RllTestCases tcs := { |
| 5932 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 5933 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 5934 | }; |
| 5935 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 5936 | } |
| 5937 | |
| 5938 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 5939 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 5940 | var RllTestCase tc := g_pars.spec.rll; |
| 5941 | |
| 5942 | f_l1_tune(L1CTL); |
| 5943 | RSL.clear; |
| 5944 | |
| 5945 | f_est_dchan(); |
| 5946 | L1CTL.clear; |
| 5947 | |
| 5948 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5949 | 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] | 5950 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 5951 | alt { |
| 5952 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 5953 | setverdict(pass); |
| 5954 | } |
| 5955 | [] RSL.receive { repeat; } |
| 5956 | } |
| 5957 | |
| 5958 | /* release the channel */ |
| 5959 | f_rsl_chan_deact(); |
| 5960 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5961 | f_rslem_unregister(0, g_chan_nr); |
| 5962 | } |
| 5963 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 5964 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5965 | var RllTestCases tcs := { |
| 5966 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 5967 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 5968 | }; |
| 5969 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 5970 | } |
| 5971 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 5972 | var octetstring l3 := f_rnd_octstring(18); |
| 5973 | var RllTestCases tcs := { |
| 5974 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 5975 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 5976 | }; |
| 5977 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 5978 | } |
| 5979 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5980 | /*********************************************************************** |
| 5981 | * Encryption Related |
| 5982 | ***********************************************************************/ |
| 5983 | |
| 5984 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 5985 | function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 5986 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 5987 | if (link_id.c == SACCH) { |
| 5988 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 5989 | } else { |
| 5990 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 5991 | } |
| 5992 | } |
| 5993 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 5994 | /* Expect (or not expect) other kinds of messages */ |
| 5995 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 5996 | [exp_any] RSL.receive { repeat; } |
| 5997 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5998 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 5999 | } |
| 6000 | } |
| 6001 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6002 | /* 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] | 6003 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6004 | RslLinkId link_id, |
| 6005 | octetstring l3, |
| 6006 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6007 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6008 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6009 | timer T := 3.0; |
| 6010 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 6011 | T.start; |
| 6012 | /* Expect RLL UNITDATA IND on RSL side */ |
| 6013 | alt { |
| 6014 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 6015 | setverdict(pass); |
| 6016 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6017 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6018 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6019 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6020 | 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] | 6021 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6022 | } |
| 6023 | } |
| 6024 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6025 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 6026 | private function f_data_mo( |
| 6027 | RslLinkId link_id, |
| 6028 | boolean p, uint3_t nr, uint3_t ns, |
| 6029 | octetstring l3, |
| 6030 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6031 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6032 | ) runs on ConnHdlr { |
| 6033 | timer T := 3.0; |
| 6034 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 6035 | T.start; |
| 6036 | /* Expect RLL DATA IND on RSL side */ |
| 6037 | alt { |
| 6038 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 6039 | setverdict(pass); |
| 6040 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6041 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6042 | [] as_rsl_any_ind(exp_any); |
| 6043 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6044 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6045 | } |
| 6046 | } |
| 6047 | } |
| 6048 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6049 | /* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */ |
| 6050 | function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
| 6051 | f_l1_tune(L1CTL); |
| 6052 | f_est_dchan(true); |
| 6053 | |
| 6054 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6055 | var L1ctlDlMessage dl; |
| 6056 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 6057 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6058 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6059 | |
| 6060 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6061 | f_unitdata_mt(link_id, l3); |
| 6062 | |
| 6063 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6064 | f_unitdata_mo(link_id, l3); |
| 6065 | |
| 6066 | /* release the channel */ |
| 6067 | f_rsl_chan_deact(); |
| 6068 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6069 | f_rslem_unregister(0, g_chan_nr); |
| 6070 | } |
| 6071 | testcase TC_chan_act_a51() runs on test_CT { |
| 6072 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6073 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6074 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6075 | } |
| 6076 | testcase TC_chan_act_a52() runs on test_CT { |
| 6077 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6078 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6079 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6080 | } |
| 6081 | testcase TC_chan_act_a53() runs on test_CT { |
| 6082 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6083 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6084 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6085 | } |
| 6086 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6087 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 6088 | which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/ |
| 6089 | function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
| 6090 | f_l1_tune(L1CTL); |
| 6091 | f_est_dchan(true); |
| 6092 | |
| 6093 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6094 | var L1ctlDlMessage dl; |
| 6095 | |
| 6096 | var octetstring l3 := f_rnd_octstring(20); |
| 6097 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6098 | |
| 6099 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6100 | f_unitdata_mt(link_id, l3); |
| 6101 | |
| 6102 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6103 | f_unitdata_mo(link_id, l3); |
| 6104 | |
| 6105 | var RSL_Message rsl; |
| 6106 | rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, valueof(ts_RSL_ChanMode_SIGN(false)))); |
| 6107 | |
| 6108 | /* modify key to break proper encryption */ |
| 6109 | g_pars.encr.key := f_rnd_octstring(8); |
| 6110 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 6111 | rsl.ies := rsl.ies & { ei }; |
| 6112 | RSL.send(rsl); |
| 6113 | |
| 6114 | timer T0 := 1.0; |
| 6115 | T0.start; |
| 6116 | /* Expect RSL MODIFY ACK */ |
| 6117 | alt { |
| 6118 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 6119 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 6120 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 6121 | } |
| 6122 | [] T0.timeout { |
| 6123 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 6124 | } |
| 6125 | } |
| 6126 | |
| 6127 | var octetstring l3msg := f_rnd_octstring(15); |
| 6128 | timer T1 := 3.0; |
| 6129 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 6130 | due to broken encryption */ |
| 6131 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 6132 | T1.start; |
| 6133 | alt { |
| 6134 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 6135 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 6136 | } |
| 6137 | [] T1.timeout { |
| 6138 | setverdict(pass); |
| 6139 | } |
| 6140 | } |
| 6141 | |
| 6142 | /* release the channel */ |
| 6143 | f_rsl_chan_deact(); |
| 6144 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6145 | f_rslem_unregister(0, g_chan_nr); |
| 6146 | } |
| 6147 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 6148 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6149 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6150 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 6151 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6152 | |
| 6153 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
| 6154 | function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
| 6155 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 6156 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 6157 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 6158 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6159 | |
| 6160 | f_l1_tune(L1CTL); |
| 6161 | |
| 6162 | /* first establish a dedicated channel in the clear */ |
| 6163 | f_est_dchan(false); |
| 6164 | |
| 6165 | /* Establish ABM */ |
| 6166 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 6167 | |
| 6168 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 6169 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 6170 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 6171 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 6172 | |
| 6173 | /* configure L1 to apply ciphering */ |
| 6174 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 6175 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 6176 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6177 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 6178 | 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] | 6179 | |
| 6180 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 6181 | * and hence enable encryption also on the downlink */ |
| 6182 | |
| 6183 | /* expect bi-directional communication work in encrypted mode */ |
| 6184 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 6185 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 6186 | |
| 6187 | /* release the channel */ |
| 6188 | f_rsl_chan_deact(); |
| 6189 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6190 | f_rslem_unregister(0, g_chan_nr); |
| 6191 | } |
| 6192 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 6193 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6194 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6195 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6196 | } |
| 6197 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 6198 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6199 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6200 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6201 | } |
| 6202 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 6203 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6204 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6205 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6206 | } |
| 6207 | |
| 6208 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 6209 | var LapdmFrame lf; |
| 6210 | var octetstring reenc; |
| 6211 | |
| 6212 | /* decode the LAPDm frame */ |
| 6213 | if (ischosen(exp_match.ab)) { |
| 6214 | lf.ab := dec_LapdmFrameAB(enc); |
| 6215 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6216 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6217 | } |
| 6218 | |
| 6219 | /* check if decoder result matches expectation */ |
| 6220 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6221 | 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] | 6222 | } else { |
| 6223 | log(name, ": matched"); |
| 6224 | setverdict(pass); |
| 6225 | } |
| 6226 | |
| 6227 | /* test if re-encoded frame equals original input */ |
| 6228 | reenc := enc_LapdmFrame(lf); |
| 6229 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6230 | 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] | 6231 | } else { |
| 6232 | setverdict(pass); |
| 6233 | } |
| 6234 | } |
| 6235 | |
| 6236 | testcase TC_lapdm_selftest() runs on test_CT { |
| 6237 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 6238 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 6239 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 6240 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 6241 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 6242 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 6243 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 6244 | } |
| 6245 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6246 | /*********************************************************************** |
| 6247 | * DTX Related (see GSM 05.08, section 8.3) |
| 6248 | ***********************************************************************/ |
| 6249 | |
| 6250 | /* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */ |
| 6251 | function f_g_chan_is_tchf() runs on ConnHdlr return boolean { |
| 6252 | return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or |
| 6253 | g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or |
| 6254 | g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or |
| 6255 | g_chan_nr == valueof(ts_RslChanNr_Bm(4))); |
| 6256 | } |
| 6257 | function f_g_chan_is_tchh() runs on ConnHdlr return boolean { |
| 6258 | return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or |
| 6259 | g_chan_nr == valueof(ts_RslChanNr_Lm(5,1))); |
| 6260 | } |
| 6261 | function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean { |
| 6262 | return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or |
| 6263 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or |
| 6264 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or |
| 6265 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3))); |
| 6266 | } |
| 6267 | function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean { |
| 6268 | return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or |
| 6269 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or |
| 6270 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or |
| 6271 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or |
| 6272 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or |
| 6273 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or |
| 6274 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or |
| 6275 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7))); |
| 6276 | } |
| 6277 | |
| 6278 | function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr { |
| 6279 | var L1ctlDlMessage dl; |
| 6280 | var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O; |
| 6281 | var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2); |
| 6282 | var GsmFrameNumber first_fn; |
| 6283 | var boolean is_first_frame := true; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6284 | var integer nfill_frames_sacch := 0; |
| 6285 | var integer nfill_frames_nonsacch := 0; |
| 6286 | 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] | 6287 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 6288 | 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] | 6289 | const integer frame_dtx_tchf_mod := 104; |
| 6290 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 6291 | * which operates in terms of blocks rather than frames. */ |
| 6292 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 6293 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6294 | timer T := 5.0; |
| 6295 | |
| 6296 | f_l1_tune(L1CTL); |
| 6297 | RSL.clear; |
| 6298 | L1CTL.clear; |
| 6299 | |
| 6300 | /* activate TCHF signalling channel */ |
| 6301 | f_est_dchan(false); |
| 6302 | |
| 6303 | T.start; |
| 6304 | alt { |
| 6305 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6306 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
| 6307 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6308 | |
| 6309 | if (is_first_frame) { |
| 6310 | is_first_frame := false; |
| 6311 | first_fn := dl.dl_info.frame_nr; |
| 6312 | } |
| 6313 | |
| 6314 | if (dl.dl_info.link_id.c == SACCH) { |
| 6315 | l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */ |
| 6316 | if (not match(l2_fill_frame_sacch, l2)) { |
| 6317 | repeat; |
| 6318 | } |
| 6319 | } else if (not match(l2_fill_frame, l2)) { |
| 6320 | repeat; |
| 6321 | } |
| 6322 | |
| 6323 | if (dtxd) { |
| 6324 | if (not f_g_chan_is_tchf()) { |
| 6325 | T.stop; |
| 6326 | f_rsl_chan_deact(); |
| 6327 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6328 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received fill frame on non-TCH/F channel; DTX is only allowed on TCH/F!"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6329 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6330 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6331 | T.stop; |
| 6332 | f_rsl_chan_deact(); |
| 6333 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6334 | |
| 6335 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. |
| 6336 | * 2 SACCH, 1 TCH/F */ |
| 6337 | expected_fill_frames := 3; |
| 6338 | |
| 6339 | if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) { |
| 6340 | log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch, |
| 6341 | " (SACCH+other) out of ", expected_fill_frames, " expected fill frames"); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6342 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6343 | } else { |
| 6344 | setverdict(pass); |
| 6345 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6346 | } else { |
| 6347 | if (dl.dl_info.link_id.c == SACCH) { |
| 6348 | nfill_frames_sacch := nfill_frames_sacch + 1; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6349 | repeat; |
| 6350 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6351 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 6352 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 6353 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 6354 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 6355 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 6356 | if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) { |
| 6357 | nfill_frames_nonsacch := nfill_frames_nonsacch + 1; |
| 6358 | repeat; |
| 6359 | } |
| 6360 | } |
| 6361 | log("Received DTX TCH fill frame with bad frame number: ", fn, |
| 6362 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 6363 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
| 6364 | f_rsl_chan_deact(); |
| 6365 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6366 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6367 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6368 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6369 | if (dl.dl_info.link_id.c == SACCH) { |
| 6370 | nfill_frames_sacch := nfill_frames_sacch + 1; |
| 6371 | } else { |
| 6372 | nfill_frames_nonsacch := nfill_frames_nonsacch + 1; |
| 6373 | } |
| 6374 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6375 | T.stop; |
| 6376 | if (f_g_chan_is_tchf()) { |
| 6377 | /* Without DTX we can expect 25 fill frames for every 104 frames. |
| 6378 | * (24 FACCH + 1 SACCH filling) */ |
| 6379 | expected_fill_frames := 25; |
| 6380 | } else if (f_g_chan_is_tchh()) { |
| 6381 | /* We can expect 2 fill frames for every 104 frames. */ |
| 6382 | expected_fill_frames := 2; |
| 6383 | } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) { |
| 6384 | /* We can expect 5 fill frames for every 104 frames. */ |
| 6385 | expected_fill_frames := 5; |
| 6386 | } else { |
| 6387 | f_rsl_chan_deact(); |
| 6388 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6389 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6390 | } |
| 6391 | |
| 6392 | f_rsl_chan_deact(); |
| 6393 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6394 | |
| 6395 | if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6396 | setverdict(pass); |
| 6397 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6398 | log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch, |
| 6399 | " (SACCH+other) out of ", expected_fill_frames, " expected fill frames"); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6400 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6401 | } |
| 6402 | } else { |
| 6403 | repeat; |
| 6404 | } |
| 6405 | } |
| 6406 | } |
| 6407 | [] L1CTL.receive { repeat; } |
| 6408 | [] T.timeout { |
| 6409 | f_rsl_chan_deact(); |
| 6410 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6411 | 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] | 6412 | } |
| 6413 | } |
| 6414 | } |
| 6415 | |
| 6416 | function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr { |
| 6417 | f_test_l2_fill_frames(false); |
| 6418 | } |
| 6419 | |
| 6420 | function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr { |
| 6421 | f_test_l2_fill_frames(true); |
| 6422 | } |
| 6423 | |
| 6424 | function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT { |
| 6425 | var ConnHdlr vc_conn; |
| 6426 | var ConnHdlrPars pars; |
| 6427 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6428 | f_init(); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6429 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 6430 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd))); |
| 6431 | if (dtxd) { |
| 6432 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 6433 | break; |
| 6434 | } |
| 6435 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars); |
| 6436 | } else { |
| 6437 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars); |
| 6438 | } |
| 6439 | vc_conn.done; |
| 6440 | } |
| 6441 | } |
| 6442 | |
| 6443 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 6444 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 6445 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 6446 | f_tch_sign_l2_fill_frame(false); |
| 6447 | } |
| 6448 | |
| 6449 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 6450 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 6451 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 6452 | f_tch_sign_l2_fill_frame(true); |
| 6453 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6454 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6455 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 6456 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6457 | } |
| 6458 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6459 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 6460 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6461 | } |
| 6462 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6463 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 6464 | /* protocol error as per 44.006 */ |
| 6465 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 6466 | /* repetition of SABM or DISC N200 times without ACK */ |
| 6467 | /* receptiom of SABM in multi-frame established state */ |
| 6468 | |
| 6469 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6470 | /* TODO Areas: |
| 6471 | |
| 6472 | * channel activation |
| 6473 | ** with BS_Power / MS_Power, bypassing power control loop |
| 6474 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6475 | ** with timing advance from initial activation on |
| 6476 | * mode modify |
| 6477 | ** encryption |
| 6478 | ** multirate |
| 6479 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6480 | ** unsupported algorithm |
| 6481 | * handover detection |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6482 | * BS Power Control |
| 6483 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6484 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6485 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6486 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6487 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6488 | ** DATA_IND from BTS->PCU |
| 6489 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6490 | |
| 6491 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6492 | |
| 6493 | control { |
| 6494 | execute( TC_chan_act_stress() ); |
| 6495 | execute( TC_chan_act_react() ); |
| 6496 | execute( TC_chan_deact_not_active() ); |
| 6497 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 6498 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 6499 | execute( TC_sacch_filling() ); |
| 6500 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 6501 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 6502 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 6503 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 6504 | execute( TC_sacch_chan_act_ho_async() ); |
| 6505 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 6506 | execute( TC_rach_content() ); |
| 6507 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 6508 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 6509 | execute( TC_ho_rach() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 6510 | execute( TC_rach_load_idle_thresh0() ); |
| 6511 | execute( TC_rach_load_idle_below_thresh() ); |
| 6512 | execute( TC_rach_load_count() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6513 | execute( TC_meas_res_sign_tchf() ); |
| 6514 | execute( TC_meas_res_sign_tchh() ); |
| 6515 | execute( TC_meas_res_sign_sdcch4() ); |
| 6516 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 6517 | execute( TC_meas_res_sign_tchh_toa256() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 6518 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 6519 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 6520 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 6521 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 6522 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 6523 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 6524 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 6525 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 6526 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 6527 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 6528 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 6529 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6530 | execute( TC_rsl_modify_encr() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6531 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6532 | execute( TC_paging_imsi_80percent() ); |
| 6533 | execute( TC_paging_tmsi_80percent() ); |
| 6534 | execute( TC_paging_imsi_200percent() ); |
| 6535 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 6536 | execute( TC_rsl_protocol_error() ); |
| 6537 | execute( TC_rsl_mand_ie_error() ); |
| 6538 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 6539 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 6540 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 6541 | execute( TC_si_sched_2bis() ); |
| 6542 | execute( TC_si_sched_2ter() ); |
| 6543 | execute( TC_si_sched_2ter_2bis() ); |
| 6544 | execute( TC_si_sched_2quater() ); |
| 6545 | execute( TC_si_sched_13() ); |
| 6546 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 6547 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 6548 | execute( TC_ipa_crcx_twice_not_active() ); |
| 6549 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 6550 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 6551 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6552 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6553 | if (mp_pcu_socket != "") { |
| 6554 | execute( TC_pcu_act_req() ); |
| 6555 | execute( TC_pcu_act_req_wrong_ts() ); |
| 6556 | execute( TC_pcu_act_req_wrong_bts() ); |
| 6557 | execute( TC_pcu_act_req_wrong_trx() ); |
| 6558 | execute( TC_pcu_deact_req() ); |
| 6559 | execute( TC_pcu_deact_req_wrong_ts() ); |
| 6560 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 6561 | if (mp_l1_supports_gprs) { |
| 6562 | execute( TC_pcu_data_req_pdtch() ); |
| 6563 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 6564 | execute( TC_pcu_data_req_wrong_bts() ); |
| 6565 | execute( TC_pcu_data_req_wrong_trx() ); |
| 6566 | execute( TC_pcu_data_req_wrong_ts() ); |
| 6567 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 6568 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 6569 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6570 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 6571 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6572 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 6573 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 6574 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 6575 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6576 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 6577 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 6578 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6579 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6580 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6581 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6582 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6583 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6584 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6585 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6586 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6587 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6588 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6589 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 6590 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 6591 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 6592 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 6593 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
| 6594 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6595 | } else { |
| 6596 | log("PCU socket path not available, skipping PCU tests"); |
| 6597 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6598 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6599 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6600 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 6601 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6602 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 6603 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6604 | |
| 6605 | execute( TC_rll_est_ind() ); |
| 6606 | execute( TC_rll_est_req_DCCH_3() ); |
| 6607 | execute( TC_rll_est_req_ACCH_3() ); |
| 6608 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 6609 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 6610 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 6611 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 6612 | execute( TC_rll_rel_req() ); |
| 6613 | execute( TC_rll_unit_data_req_DCCH() ); |
| 6614 | execute( TC_rll_unit_data_req_ACCH() ); |
| 6615 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 6616 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6617 | |
| 6618 | execute( TC_chan_act_a51() ); |
| 6619 | execute( TC_chan_act_a52() ); |
| 6620 | execute( TC_chan_act_a53() ); |
| 6621 | execute( TC_encr_cmd_a51() ); |
| 6622 | execute( TC_encr_cmd_a52() ); |
| 6623 | execute( TC_encr_cmd_a53() ); |
| 6624 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 6625 | execute( TC_err_rep_wrong_mdisc() ); |
| 6626 | execute( TC_err_rep_wrong_msg_type() ); |
| 6627 | execute( TC_err_rep_wrong_sequence() ); |
| 6628 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6629 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6630 | |
| 6631 | execute( TC_tch_sign_l2_fill_frame() ); |
| 6632 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6633 | |
| 6634 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6635 | execute( TC_chopped_ipa_payload() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6636 | } |
| 6637 | |
| 6638 | |
| 6639 | } |