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