blob: 9c8d68d27cc3427d59aa42d25134370ffd7cb844 [file] [log] [blame]
Harald Welte28d943e2017-11-25 15:00:50 +01001module BSC_Tests {
2
Harald Welte21b46bd2017-12-17 19:46:32 +01003/* Integration Tests for OsmoBSC
Harald Weltea0630032018-03-20 21:09:55 +01004 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte21b46bd2017-12-17 19:46:32 +01005 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
Harald Welte34b5a952019-05-27 11:54:11 +020010 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
Harald Welte21b46bd2017-12-17 19:46:32 +010012 * This test suite tests OsmoBSC while emulating both multiple BTS + MS as
13 * well as the MSC. See README for more details.
14 *
15 * There are test cases that run in so-called 'handler mode' and test cases
16 * that run directly on top of the BSSAP and RSL CodecPorts. The "handler mode"
17 * tests abstract the multiplexing/demultiplexing of multiple SCCP connections
18 * and/or RSL channels and are hence suitable for higher-level test cases, while
19 * the "raw" tests directly on top of the CodecPorts are more suitable for lower-
20 * level testing.
21 */
22
Harald Welte4003d112017-12-09 22:35:39 +010023import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010024import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010025import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010026import from IPL4asp_Types all;
27
Harald Welte6f521d82017-12-11 19:52:02 +010028import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020029import from RAN_Adapter all;
Harald Welteae026692017-12-09 01:03:01 +010030import from BSSAP_CodecPort all;
31import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010032import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010033import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010034import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020035import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010036import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010037import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010038import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010039import from MGCP_Templates all;
40import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020041import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010042
Harald Welte96c94412017-12-09 03:12:45 +010043import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010044import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010045import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010046
Harald Weltebc03c762018-02-12 18:09:38 +010047import from Osmocom_VTY_Functions all;
48import from TELNETasp_PortType all;
49
Harald Welte6f521d82017-12-11 19:52:02 +010050import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010051import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010052import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010053import from L3_Templates all;
54import from GSM_RR_Types all;
55
Stefan Sperlingc307e682018-06-14 15:15:46 +020056import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010057import from BSSMAP_Templates all;
58
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010059import from SCCPasp_Types all;
60
Harald Welte5d1a2202017-12-13 19:51:29 +010061const integer NUM_BTS := 3;
Harald Welteae026692017-12-09 01:03:01 +010062const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010063
Harald Welte799c97b2017-12-14 17:50:30 +010064/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020065const integer NUM_TCHH_PER_BTS := 2;
66const integer NUM_TCHF_PER_BTS := 4;
Harald Weltedd8cbf32018-01-28 12:07:52 +010067const integer NUM_SDCCH_PER_BTS := 4;
Harald Welte799c97b2017-12-14 17:50:30 +010068
Harald Welte4003d112017-12-09 22:35:39 +010069
Harald Welte21b46bd2017-12-17 19:46:32 +010070/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010071type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010072 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010073 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010074}
75
Harald Weltea4ca4462018-02-09 00:17:14 +010076type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +010077 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +010078 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +010079 /* RSL common Channel Port (for RSL_Emulation) */
80 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +010081 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +010082 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +010083 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +020084 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
85 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +010086
Daniel Willmann191e0d92018-01-17 12:44:35 +010087 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +010088 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +010089
Harald Welte6811d102019-04-14 22:23:14 +020090 var RAN_Adapter g_bssap;
Harald Weltea4ca4462018-02-09 00:17:14 +010091 /* for old legacy-tests only */
92 port BSSAP_CODEC_PT BSSAP;
93
Harald Welte21b46bd2017-12-17 19:46:32 +010094 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +010095 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +010096
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +020097 /* Osmux is enabled through VTY */
98 var boolean g_osmux_enabled := false;
99
Harald Welte21b46bd2017-12-17 19:46:32 +0100100 /* global test case guard timer */
Harald Welteae026692017-12-09 01:03:01 +0100101 timer T_guard := 30.0;
102
Harald Welte28d943e2017-11-25 15:00:50 +0100103}
104
105modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100106 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100107 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100108 /* port number to which to establish the IPA OML connections */
109 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100110 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100111 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100112 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100113 integer mp_bsc_ctrl_port := 4249;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100114 /* IP address at which the test binds */
115 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100116
Harald Welte6811d102019-04-14 22:23:14 +0200117 RAN_Configuration mp_bssap_cfg := {
Harald Welte7ef51aa2018-04-16 19:16:01 +0200118 transport := BSSAP_TRANSPORT_AoIP,
Harald Weltea4ca4462018-02-09 00:17:14 +0100119 sccp_service_type := "mtp3_itu",
120 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
121 own_pc := 185,
122 own_ssn := 254,
123 peer_pc := 187,
124 peer_ssn := 254,
Philipp Maier38d68942018-03-29 15:38:09 +0200125 sio := '83'O,
126 rctx := 0
Harald Weltea4ca4462018-02-09 00:17:14 +0100127 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200128
129 /* Whether to enable osmux tests. Can be dropped completely and enable
130 unconditionally once new version of osmo-bsc is released (current
131 version: 1.4.1) */
132 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100133 /* Value set in osmo-bsc.cfg "ms max power" */
134 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100135}
136
Philipp Maier48604732018-10-09 15:00:37 +0200137private function f_gen_test_hdlr_pars() return TestHdlrParams {
138
139 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
140 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
141 pars.aoip := true;
142 } else {
143 pars.aoip := false;
144 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100145 pars.exp_ms_power_level := mp_exp_ms_power_level;
Philipp Maier48604732018-10-09 15:00:37 +0200146
147 return pars;
148}
149
Philipp Maier282ca4b2018-02-27 17:17:00 +0100150private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200151 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100152 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200153 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100154}
155
Harald Weltea4ca4462018-02-09 00:17:14 +0100156private function f_legacy_bssap_reset() runs on test_CT {
157 var BSSAP_N_UNITDATA_ind ud_ind;
158 timer T := 5.0;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200159 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100160 T.start;
161 alt {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200162 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100163 log("Received RESET-ACK in response to RESET, we're ready to go!");
164 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200165 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100166 log("Respoding to inbound RESET with RESET-ACK");
167 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200168 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100169 repeat;
170 }
171 [] BSSAP.receive { repeat; }
172 [] T.timeout { setverdict(fail, "Waiting for RESET-ACK after sending RESET"); }
173 }
Harald Welte28d943e2017-11-25 15:00:50 +0100174}
175
Harald Welteae026692017-12-09 01:03:01 +0100176type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100177 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100178 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100179 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100180 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100181 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100182 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100183 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100184 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100185}
186
Harald Welte21b46bd2017-12-17 19:46:32 +0100187/*! Start the IPA/RSL related bits for one IPA_Client.
188 * \param clnt IPA_Client for which to establish
189 * \param bsc_host IP address / hostname of the BSC
190 * \param bsc_port TCP port number of the BSC
191 * \param i number identifying this BTS
192 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100193function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
194 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100195runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100196 timer T := 10.0;
197
Harald Welte96c94412017-12-09 03:12:45 +0100198 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100199 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
200 clnt.ccm_pars := c_IPA_default_ccm_pars;
201 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
202 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100203 if (handler_mode) {
204 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100205 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100206 }
Harald Welteae026692017-12-09 01:03:01 +0100207
208 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100209 if (handler_mode) {
210 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
211 } else {
212 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
213 }
Harald Welteae026692017-12-09 01:03:01 +0100214
Harald Welte5d1a2202017-12-13 19:51:29 +0100215 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100216 if (handler_mode) {
217 clnt.vc_RSL.start(RSL_Emulation.main());
218 return;
219 }
Harald Welteae026692017-12-09 01:03:01 +0100220
221 /* wait for IPA RSL link to connect and send ID ACK */
222 T.start;
223 alt {
224 [] IPA_RSL[i].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_ID_ACK}) {
225 T.stop;
226 IPA_RSL[i].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23)));
227 }
Harald Welte60e823a2017-12-10 14:10:59 +0100228 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100229 [] IPA_RSL[i].receive { repeat }
230 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100231 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200232 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100233 }
234 }
235}
236
Harald Welte12055472018-03-17 20:10:08 +0100237function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
238 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
239 return;
240 }
241 clnt.vc_IPA.stop;
242 if (isbound(clnt.vc_RSL)) {
243 clnt.vc_RSL.stop;
244 }
245}
246
Harald Welte21b46bd2017-12-17 19:46:32 +0100247/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100248function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
249 timer T := secs_max;
250 T.start;
251 while (true) {
252 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
253 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100254 /* the 'degraded' state exists from OML connection time, and we have to wait
255 * until all MO's are initialized */
256 T.start(1.0);
257 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100258 return;
259 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100260 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100261 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100262 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200263 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100264 }
265 }
266}
267
Harald Welte21b46bd2017-12-17 19:46:32 +0100268/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100269altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100270 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100271 [] T_guard.timeout {
272 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200273 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100274 }
Harald Welte60e823a2017-12-10 14:10:59 +0100275 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200276 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100277 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200278 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100279 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100280 }
Harald Welte28d943e2017-11-25 15:00:50 +0100281}
282
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100283altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200284 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100285 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200286 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100287 }
288}
289
Daniel Willmann191e0d92018-01-17 12:44:35 +0100290function f_init_mgcp(charstring id) runs on test_CT {
291 id := id & "-MGCP";
292
293 var MGCPOps ops := {
294 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
295 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
296 };
297 var MGCP_conn_parameters mgcp_pars := {
298 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100299 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100300 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200301 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200302 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
303 the on with MGCP over IPA forwarded from MSC one) */
304 multi_conn_mode := (mp_bssap_cfg.transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100305 };
306
307 vc_MGCP := MGCP_Emulation_CT.create(id);
308 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
309}
310
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200311/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
312 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
313 * OsmuxCID IE.
314 */
315private function f_vty_allow_osmux(boolean allow) runs on test_CT {
316 f_vty_enter_cfg_msc(BSCVTY, 0);
317 if (allow) {
318 f_vty_transceive(BSCVTY, "osmux on");
319 } else {
320 f_vty_transceive(BSCVTY, "osmux off");
321 }
322 f_vty_transceive(BSCVTY, "exit");
323 f_vty_transceive(BSCVTY, "exit");
324 g_osmux_enabled := allow;
325}
326
Max2253c0b2018-11-06 19:28:05 +0100327function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200328 if (BSCVTY.checkstate("Mapped")) {
329 /* skip initialization if already executed once */
330 return;
331 }
Harald Weltebc03c762018-02-12 18:09:38 +0100332 map(self:BSCVTY, system:BSCVTY);
333 f_vty_set_prompts(BSCVTY);
334 f_vty_transceive(BSCVTY, "enable");
335}
336
Harald Welte21b46bd2017-12-17 19:46:32 +0100337/* global initialization function
338 * \param nr_bts Number of BTSs we should start/bring up
339 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200340function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false) runs on test_CT {
Harald Welte28d943e2017-11-25 15:00:50 +0100341 var integer i;
Harald Welte28d943e2017-11-25 15:00:50 +0100342
Harald Welteae026692017-12-09 01:03:01 +0100343 if (g_initialized) {
344 return;
Harald Welte28d943e2017-11-25 15:00:50 +0100345 }
Harald Welteae026692017-12-09 01:03:01 +0100346 g_initialized := true;
347
Daniel Willmanne68f9272018-11-27 15:15:28 +0100348 T_guard.start;
349 activate(as_Tguard());
350
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200351 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200352 if (mp_enable_osmux_test) {
353 f_vty_allow_osmux(allow_osmux);
354 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200355
Harald Welte6811d102019-04-14 22:23:14 +0200356 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
Harald Welteae026692017-12-09 01:03:01 +0100357 * MSC-side BSSAP emulation */
Harald Welte67089ee2018-01-17 22:19:03 +0100358 if (handler_mode) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200359 var RanOps ranops := MSC_RanOps;
360 ranops.use_osmux := g_osmux_enabled;
361 f_ran_adapter_init(g_bssap, mp_bssap_cfg, "VirtMSC", ranops);
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200362 connect(self:SCCPLITE_IPA_CTRL, g_bssap.vc_RAN:CTRL_CLIENT);
Harald Welte3ca0ce12019-04-23 17:18:48 +0200363 f_ran_adapter_start(g_bssap);
Harald Welte67089ee2018-01-17 22:19:03 +0100364 } else {
Harald Welte3ca0ce12019-04-23 17:18:48 +0200365 f_ran_adapter_init(g_bssap, mp_bssap_cfg, "VirtMSC", omit);
Harald Weltea4ca4462018-02-09 00:17:14 +0100366 connect(self:BSSAP, g_bssap.vc_SCCP:SCCP_SP_PORT);
Harald Welte3ca0ce12019-04-23 17:18:48 +0200367 f_ran_adapter_start(g_bssap);
Harald Weltea4ca4462018-02-09 00:17:14 +0100368 f_legacy_bssap_reset();
Harald Welte67089ee2018-01-17 22:19:03 +0100369 }
Harald Welted5833a82018-05-27 16:52:56 +0200370
Harald Welteffe55fc2018-01-17 22:39:54 +0100371 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +0100372
Daniel Willmann191e0d92018-01-17 12:44:35 +0100373 f_init_mgcp("VirtMSC");
374
Harald Welte89d42e82017-12-17 16:42:41 +0100375 for (i := 0; i < nr_bts; i := i+1) {
Harald Weltea5d2ab22017-12-09 14:21:42 +0100376 /* wait until osmo-bts-omldummy has respawned */
377 f_wait_oml(i, "degraded", 5.0);
378 /* start RSL connection */
Harald Welte624f9632017-12-16 19:26:04 +0100379 f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i, handler_mode);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100380 /* wait until BSC tells us "connected" */
381 f_wait_oml(i, "connected", 5.0);
Harald Welte696ddb62017-12-08 14:01:43 +0100382 }
383
Harald Welte28d943e2017-11-25 15:00:50 +0100384}
385
Maxd4e56962018-10-31 19:08:25 +0100386/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welteae026692017-12-09 01:03:01 +0100387function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
388runs on test_CT return RSL_Message {
389 var ASP_RSL_Unitdata rx_rsl_ud;
390 timer T := t_secs;
391
392 T.start;
393 alt {
394 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud {
395 T.stop;
396 }
397 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +0100398 [] T.timeout {
399 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +0200400 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +0100401 }
Harald Welteae026692017-12-09 01:03:01 +0100402 }
403 return rx_rsl_ud.rsl;
404}
405
Harald Welte21b46bd2017-12-17 19:46:32 +0100406/* helper function to transmit RSL on a given BTS/stream */
Harald Welteae026692017-12-09 01:03:01 +0100407function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
408runs on test_CT {
409 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx));
410}
411
412
Harald Welte4003d112017-12-09 22:35:39 +0100413/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +0100414testcase TC_chan_act_noreply() runs on test_CT {
415 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +0100416 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +0100417
Harald Welte89d42e82017-12-17 16:42:41 +0100418 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +0100419
Harald Welteae026692017-12-09 01:03:01 +0100420 IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +0100421 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welteae026692017-12-09 01:03:01 +0100422 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +0100423}
424
Harald Welte4003d112017-12-09 22:35:39 +0100425/* verify if the "chreq:total" counter increments as expected */
426testcase TC_chan_act_counter() runs on test_CT {
427 var BSSAP_N_UNITDATA_ind ud_ind;
428 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +0100429 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +0100430
Harald Welte89d42e82017-12-17 16:42:41 +0100431 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100432
433 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
434 IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +0100435 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +0100436 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
437
438 setverdict(pass);
439}
440
Harald Welteae026692017-12-09 01:03:01 +0100441/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
442testcase TC_chan_act_ack_noest() runs on test_CT {
443 var RSL_Message rx_rsl;
444
Harald Welte89d42e82017-12-17 16:42:41 +0100445 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100446
447 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100448 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100449
450 /* expect BSC to disable the channel again if there's no RLL EST IND */
451 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
452
453 setverdict(pass);
454}
455
456/* Test behavior if MSC never answers to CR */
457testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +0100458 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
459 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +0100460 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +0100461 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +0100462
Harald Welte89d42e82017-12-17 16:42:41 +0100463 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100464
465 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100466 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100467
468 var octetstring l3 := '00010203040506'O
469 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
470
471 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
472
473 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +0100474 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100475 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +0100476 setverdict(pass);
477}
478
479/* Test behavior if MSC answers with CREF to CR */
480testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
481 var BSSAP_N_CONNECT_ind rx_c_ind;
482 var RSL_Message rx_rsl;
483
Harald Welte89d42e82017-12-17 16:42:41 +0100484 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100485
486 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100487 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100488
489 var octetstring l3 := '00010203040506'O
490 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
491
492 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
493 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
494
495 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100496 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +0100497 setverdict(pass);
498}
499
Harald Welte618ef642017-12-14 14:58:20 +0100500/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
501testcase TC_chan_act_nack() runs on test_CT {
502 var RSL_Message rx_rsl;
503 var integer chact_nack;
504
Harald Welte89d42e82017-12-17 16:42:41 +0100505 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +0100506
507 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
508
509 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
510 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
511 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
512
513 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
514
515 /* wait for some time to hope the NACK arrives before the CTRL GET below */
516 f_sleep(0.5);
517
518 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
519
520 setverdict(pass);
521}
522
Harald Welte799c97b2017-12-14 17:50:30 +0100523/* Test for channel exhaustion due to RACH overload */
524testcase TC_chan_exhaustion() runs on test_CT {
525 var ASP_RSL_Unitdata rsl_ud;
526 var integer i;
527 var integer chreq_total, chreq_nochan;
528
Harald Welte89d42e82017-12-17 16:42:41 +0100529 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +0100530
531 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
532 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
533
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +0100534 /* GSM 04.08 Table 9.9a:
535 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
536 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +0200537 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +0100538 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +0100539 }
540
541 IPA_RSL[0].clear;
542
Harald Weltedd8cbf32018-01-28 12:07:52 +0100543 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200544 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +0100545
546 /* now expect additional channel activations to fail */
547 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
548
549 alt {
550 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
551 tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
552 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
553 }
554 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
555 var GsmRrMessage rr;
556 /* match on IMM ASS REJ */
557 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
558 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
559 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200560 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +0100561 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
562 chreq_nochan+1);
563 setverdict(pass);
564 } else {
565 repeat;
566 }
567 }
568 [] IPA_RSL[0].receive { repeat; }
569 }
570}
571
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +0700572/* Test channel deactivation due to silence from MS */
573testcase TC_chan_deact_silence() runs on test_CT {
574 var RslChannelNr chan_nr;
575
576 f_init(1);
577
578 /* Request for a dedicated channel */
579 chan_nr := f_chreq_act_ack('23'O);
580
581 /* Wait some time until the channel is released */
582 f_sleep(2.0);
583
584 /* Expect CHANnel RELease */
585 alt {
586 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
587 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
588 log("Received CHANnel RELease");
589 setverdict(pass);
590 }
591 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
592 tr_RSL_IMM_ASSIGN(?))) {
593 /* See OS#3709, OsmoBSC should not send Immediate
594 * Assignment Reject since a dedicated channel was
595 * already allocated, and Immediate Assignment was
596 * already sent. */
597 setverdict(fail, "Unexpected Immediate Assignment!");
598 }
599 [] IPA_RSL[0].receive {
600 setverdict(fail, "Unexpected RSL message!");
601 }
602 }
603}
604
Harald Weltecfe2c962017-12-15 12:09:32 +0100605/***********************************************************************
606 * Assignment Testing
607 ***********************************************************************/
608
Neels Hofmeyrda4a6952018-06-14 04:02:49 +0200609/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
610 * except for the inter-BSC handover, MT side) */
Harald Weltecfe2c962017-12-15 12:09:32 +0100611testcase TC_outbound_connect() runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +0100612 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +0100613
Harald Weltea4ca4462018-02-09 00:17:14 +0100614 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +0100615 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
616 setverdict(pass);
617}
618
Harald Welte16a4adf2017-12-14 18:54:01 +0100619/* Test behavior if MSC answers with CREF to CR */
620testcase TC_assignment_cic_only() runs on test_CT {
621 var BSSAP_N_CONNECT_ind rx_c_ind;
622 var RSL_Message rx_rsl;
623 var DchanTuple dt;
624
Harald Welte89d42e82017-12-17 16:42:41 +0100625 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +0100626
627 dt := f_est_dchan('23'O, 23, '00000000'O);
Harald Welte17b27da2018-05-25 20:33:53 +0200628 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
629 /* send assignment without AoIP IEs */
630 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
631 } else {
632 /* Send assignmetn without CIC in IPA case */
633 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
634 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
635 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
636 }
Harald Welte16a4adf2017-12-14 18:54:01 +0100637 alt {
638 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
639 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
640 }
Harald Welte235ebf12017-12-15 14:18:16 +0100641 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +0100642 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
643 setverdict(pass);
644 }
645 [] BSSAP.receive { repeat; }
646 }
647}
648
Harald Welteed848512018-05-24 22:27:58 +0200649/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200650function f_gen_ass_req(boolean osmux_enabled := false) return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200651 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200652 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Harald Welteed848512018-05-24 22:27:58 +0200653 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
654 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
655 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200656 if (osmux_enabled) {
657 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
658 } else {
659 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
660 }
Harald Welteed848512018-05-24 22:27:58 +0200661 } else {
662 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +0200663 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +0200664 }
665 return ass_cmd;
666}
667
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100668function f_gen_handover_req() return PDU_BSSAP {
669 var PDU_BSSAP ho_req;
670 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
671 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
672 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
673 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
674 } else {
675 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
676 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
677 }
678 return ho_req;
679}
680
Harald Welteed848512018-05-24 22:27:58 +0200681/* generate an assignment complete template for either AoIP or SCCPlite */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200682function f_gen_exp_compl(boolean expect_osmux := false) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200683 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200684 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Harald Welteed848512018-05-24 22:27:58 +0200685 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200686 if (expect_osmux) {
687 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
688 } else {
689 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
690 }
Harald Welteed848512018-05-24 22:27:58 +0200691 } else {
692 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +0200693 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +0200694 }
695 return exp_compl;
696}
697
Harald Welte235ebf12017-12-15 14:18:16 +0100698/* Run everything required up to sending a caller-specified assignment command and expect response */
699function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
700runs on test_CT {
701 var BSSAP_N_CONNECT_ind rx_c_ind;
702 var RSL_Message rx_rsl;
703 var DchanTuple dt;
704
Harald Welte89d42e82017-12-17 16:42:41 +0100705 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +0100706
707 dt := f_est_dchan('23'O, 23, '00000000'O);
708 /* send assignment without AoIP IEs */
709 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
710 alt {
711 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
712 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
713 setverdict(pass);
714 } else {
715 setverdict(fail, fail_text);
716 }
717 }
718 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
719 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
720 setverdict(pass);
721 } else {
722 setverdict(fail, fail_text);
723 }
724 }
725 [] BSSAP.receive { repeat; }
726 }
727}
728testcase TC_assignment_csd() runs on test_CT {
729 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200730 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100731 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
732 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
733 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
734}
735
736testcase TC_assignment_ctm() runs on test_CT {
737 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200738 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100739 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
740 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
741 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
742}
743
Harald Welte4003d112017-12-09 22:35:39 +0100744type record DchanTuple {
745 integer sccp_conn_id,
746 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +0100747}
748
Harald Welted6939652017-12-13 21:02:46 +0100749/* Send CHAN RQD and wait for allocation; acknowledge it */
750private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
751runs on test_CT return RslChannelNr {
752 var RSL_Message rx_rsl;
753 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
754 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
755 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
756 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +0200757 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +0100758 return chan_nr;
759}
760
Harald Welte4003d112017-12-09 22:35:39 +0100761/* helper function to establish a dedicated channel via BTS and MSC */
762function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
763runs on test_CT return DchanTuple {
764 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +0100765 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100766
Harald Welte4003d112017-12-09 22:35:39 +0100767 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100768 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +0100769
770 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
771
772 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
773 dt.sccp_conn_id := rx_c_ind.connectionId;
774 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
775
776 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100777}
778
Harald Welte641fcbe2018-06-14 10:58:35 +0200779/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
780private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
781 var RSL_Message rx_rsl;
782 /* expect BSC to disable the channel */
783 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
784 /* respond with CHAN REL ACK */
785 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
786
787 /* expect Clear Complete from BSC */
788 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
789
790 /* MSC disconnects as instructed. */
791 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
792}
793
Harald Welte4003d112017-12-09 22:35:39 +0100794/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
795testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100796 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100797 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +0100798
Harald Welte89d42e82017-12-17 16:42:41 +0100799 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +0100800
Harald Welte4003d112017-12-09 22:35:39 +0100801 dt := f_est_dchan('23'O, 23, '00010203040506'O);
802
803 /* simulate RLL REL IND */
804 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
805
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100806 /* expect Clear Request on MSC side */
807 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
808
809 /* Instruct BSC to clear channel */
810 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
811 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
812
Harald Welte4003d112017-12-09 22:35:39 +0100813 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +0200814 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100815
816 /* wait for SCCP emulation to do its job */
817 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +0100818
819 setverdict(pass);
820}
821
822/* Test behavior of channel release after CONN FAIL IND from BTS */
823testcase TC_chan_rel_conn_fail() runs on test_CT {
824 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100825 var DchanTuple dt;
826
Harald Welte89d42e82017-12-17 16:42:41 +0100827 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100828
829 dt := f_est_dchan('23'O, 23, '00010203040506'O);
830
831 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +0100832 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
Harald Welte4003d112017-12-09 22:35:39 +0100833 /* TODO: different cause values? */
834
Harald Welte4003d112017-12-09 22:35:39 +0100835 /* expect Clear Request from BSC */
836 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
837
838 /* Instruct BSC to clear channel */
839 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
840 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
841
Harald Welte6ff76ea2018-01-28 13:08:01 +0100842 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +0200843 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +0100844
845 /* wait for SCCP emulation to do its job */
846 f_sleep(1.0);
847
848 setverdict(pass);
849}
850
Harald Welte99f3ca02018-06-14 13:40:29 +0200851/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
852/* See also https://www.osmocom.org/issues/3182 */
853testcase TC_early_conn_fail() runs on test_CT {
854 var RSL_Message rx_rsl;
855 var DchanTuple dt;
856
857 f_init(1);
858
859 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
860 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_octstring(1), 23);
861
862 /* BTS->BSC: simulate CONN FAIL IND */
863 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
864
865 /* BTS->BSC: Expect RF channel release from BSC on Abis */
866 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
867
868 /* BTS<-BSC: respond with CHAN REL ACK */
869 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
870
871 setverdict(pass);
872}
873
874/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
875/* See also https://www.osmocom.org/issues/3182 */
876testcase TC_late_conn_fail() runs on test_CT {
877 var RSL_Message rx_rsl;
878 var DchanTuple dt;
879
880 f_init(1);
881
882 dt := f_est_dchan('23'O, 23, '00010203040506'O);
883
884 /* BSC<-MSC: Instruct BSC to clear connection */
885 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
886
887 /* BTS->BSC: expect BSC to deactivate SACCH */
888 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
889
890 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
891 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
892
893 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
894 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
895 /* BTS->BSC: respond with CHAN REL ACK */
896 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
897
898 /* BSC->MSC: expect Clear Complete from BSC */
899 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
900
901 /* BSC<-MSC: MSC disconnects as requested. */
902 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
903
904 setverdict(pass);
905}
906
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +0100907function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100908 boolean expect_deact_sacch := true,
909 boolean expect_rr_chan_rel := true,
910 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +0100911 boolean handle_rll_rel := true,
912 boolean is_csfb := false
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100913 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +0100914
915 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100916 var boolean got_deact_sacch := false;
917 var boolean got_rr_chan_rel := false;
918 var boolean got_rll_rel_req := false;
919 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
920 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +0100921 alt {
Harald Welte91d54a52018-01-28 15:35:07 +0100922 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
923 tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100924 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100925 repeat;
926 }
Harald Welte99787102019-02-04 10:41:36 +0100927 [is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CSFB))) {
928 got_rr_chan_rel := true;
929 repeat;
930 }
931 [not is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100932 got_rr_chan_rel := true;
Neels Hofmeyr211169d2018-11-07 00:37:29 +0100933 repeat;
934 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100935 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
Harald Welte91d54a52018-01-28 15:35:07 +0100936 tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100937 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100938 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100939 if (handle_rll_rel) {
940 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
941 }
Harald Welte91d54a52018-01-28 15:35:07 +0100942 repeat;
943 }
Harald Welte91d54a52018-01-28 15:35:07 +0100944 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
945 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
946 /* respond with CHAN REL ACK */
947 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
948 }
949 /* ignore any user data */
950 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) {
951 repeat;
952 }
953 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100954
955 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
956 " got_rll_rel_req=", got_rll_rel_req);
957
958 if (expect_deact_sacch != got_deact_sacch) {
959 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
960 }
961 if (expect_rr_chan_rel != got_rr_chan_rel) {
962 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
963 }
964 if (expect_rll_rel_req != got_rll_rel_req) {
965 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
966 }
Harald Welte91d54a52018-01-28 15:35:07 +0100967}
968
Harald Welte4003d112017-12-09 22:35:39 +0100969/* Test behavior of channel release after hard Clear Command from MSC */
970testcase TC_chan_rel_hard_clear() runs on test_CT {
971 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100972 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +0100973
Harald Welte89d42e82017-12-17 16:42:41 +0100974 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100975
976 dt := f_est_dchan('23'O, 23, '00010203040506'O);
977
978 /* Instruct BSC to clear channel */
979 var BssmapCause cause := 0;
980 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
981
982 /* expect Clear Complete from BSC on A */
983 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
984 /* release the SCCP connection */
985 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
986 }
987
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100988 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte4003d112017-12-09 22:35:39 +0100989 setverdict(pass);
990}
991
Harald Welte99787102019-02-04 10:41:36 +0100992/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
993testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
994 var BSSAP_N_DATA_ind rx_di;
995 var DchanTuple dt;
996
997 f_init(1);
998
999 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1000
1001 /* Instruct BSC to clear channel */
1002 var BssmapCause cause := 0;
1003 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1004
1005 /* expect Clear Complete from BSC on A */
1006 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1007 /* release the SCCP connection */
1008 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1009 }
1010
1011 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
1012 setverdict(pass);
1013}
1014
Harald Welted8c36cd2017-12-09 23:05:31 +01001015/* Test behavior of channel release after hard RLSD from MSC */
1016testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001017 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001018
Harald Welte89d42e82017-12-17 16:42:41 +01001019 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001020
1021 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1022
1023 /* release the SCCP connection */
1024 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1025
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001026 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welted8c36cd2017-12-09 23:05:31 +01001027 setverdict(pass);
1028}
1029
Harald Welte550daf92018-06-11 19:22:13 +02001030/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1031testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1032 var DchanTuple dt;
1033
1034 f_init(1);
1035
1036 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1037
1038 /* release the SCCP connection */
1039 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1040
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001041 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte550daf92018-06-11 19:22:13 +02001042 setverdict(pass);
1043}
1044
Harald Welte85804d42017-12-10 14:11:58 +01001045/* Test behavior of channel release after BSSMAP RESET from MSC */
1046testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001047 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001048
Harald Welte89d42e82017-12-17 16:42:41 +01001049 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001050
1051 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1052
1053 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1054 IPA_RSL[0].clear;
1055
1056 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001057 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte85804d42017-12-10 14:11:58 +01001058 interleave {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001059 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte85804d42017-12-10 14:11:58 +01001060 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1061 }
1062
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001063 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte85804d42017-12-10 14:11:58 +01001064 setverdict(pass);
1065}
1066
Harald Welte5cd20ed2017-12-13 21:03:20 +01001067/* Test behavior if RSL EST IND for non-active channel */
1068testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1069 timer T := 2.0;
1070
Harald Welte89d42e82017-12-17 16:42:41 +01001071 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001072
1073 var octetstring l3 := '00010203040506'O;
1074 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1075 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1076
1077 T.start;
1078 alt {
1079 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1080 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1081 }
1082 [] BSSAP.receive {}
1083 [] IPA_RSL[0].receive {}
1084 [] T.timeout {}
1085 }
1086
1087 setverdict(pass);
1088}
1089
1090/* Test behavior if RSL EST IND for invalid SAPI */
1091testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1092 var RslChannelNr chan_nr;
1093
Harald Welte89d42e82017-12-17 16:42:41 +01001094 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001095
1096 chan_nr := f_chreq_act_ack()
1097
1098 var octetstring l3 := '00010203040506'O;
1099 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1100
1101 timer T := 2.0;
1102 T.start;
1103 alt {
1104 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1105 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1106 }
1107 [] BSSAP.receive { repeat; }
1108 [] IPA_RSL[0].receive { repeat; }
1109 [] T.timeout {}
1110 }
1111
1112 setverdict(pass);
1113}
1114
1115/* Test behavior if RSL EST IND for invalid SAPI */
1116testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
1117 timer T := 2.0;
1118
Harald Welte89d42e82017-12-17 16:42:41 +01001119 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001120
1121 var RslChannelNr chan_nr := f_chreq_act_ack();
1122
1123 var octetstring l3 := '00010203040506'O;
1124 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
1125
1126 T.start;
1127 alt {
1128 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1129 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
1130 }
1131 [] BSSAP.receive { repeat; }
1132 [] IPA_RSL[0].receive { repeat; }
1133 [] T.timeout {}
1134 }
1135
1136 setverdict(pass);
1137}
1138
1139/* Test behavior if RSL EST IND for invalid SACCH */
1140testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
1141 timer T := 2.0;
1142
Harald Welte89d42e82017-12-17 16:42:41 +01001143 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001144
1145 var RslChannelNr chan_nr := f_chreq_act_ack();
1146
1147 var octetstring l3 := '00010203040506'O;
1148 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
1149
1150 T.start;
1151 alt {
1152 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1153 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
1154 }
1155 [] BSSAP.receive { repeat; }
1156 [] IPA_RSL[0].receive { repeat; }
1157 [] T.timeout {}
1158 }
1159
1160 setverdict(pass);
1161}
1162
1163
1164
Harald Welte4003d112017-12-09 22:35:39 +01001165
1166testcase TC_ctrl_msc_connection_status() runs on test_CT {
1167 var charstring ctrl_resp;
1168
Harald Welte89d42e82017-12-17 16:42:41 +01001169 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001170
1171 /* See https://osmocom.org/issues/2729 */
1172 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
1173 setverdict(pass);
1174}
1175
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001176testcase TC_ctrl_msc0_connection_status() runs on test_CT {
1177 var charstring ctrl_resp;
1178
1179 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001180
1181 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
1182 setverdict(pass);
1183}
1184
Harald Welte4003d112017-12-09 22:35:39 +01001185testcase TC_ctrl() runs on test_CT {
1186 var charstring ctrl_resp;
1187
Harald Welte89d42e82017-12-17 16:42:41 +01001188 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001189
1190 /* all below values must match the osmo-bsc.cfg config file used */
1191
Harald Welte6a129692018-03-17 17:30:14 +01001192 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
1193 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02001194 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01001195
1196 var integer bts_nr := 0;
1197 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
1198 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
1199 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
1200 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
1201 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
1202 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
1203 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
1204
1205 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
1206 f_sleep(2.0);
1207 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
1208 setverdict(fail, "oml-uptime not incrementing as expected");
1209 }
1210 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
1211
1212 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
1213
1214 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +01001215}
1216
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02001217/* Verify that Upon receival of SET "location", BSC forwards a TRAP
1218 "location-state" over the SCCPlite IPA conn */
1219testcase TC_ctrl_location() runs on test_CT {
1220 var MSC_ConnHdlr vc_conn;
1221 var integer bts_nr := 0;
1222
1223 f_init(1, true);
1224 f_sleep(1.0);
1225
1226 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
1227 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
1228 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
1229
1230 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
1231 f_sleep(2.0);
1232
1233 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
1234 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
1235 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
1236
1237 /* should match the one from config */
1238 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
1239
1240 setverdict(pass);
1241}
1242
Harald Welte6f521d82017-12-11 19:52:02 +01001243function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +01001244 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, bssap));
Harald Welte6f521d82017-12-11 19:52:02 +01001245}
1246
1247
1248/***********************************************************************
1249 * Paging Testing
1250 ***********************************************************************/
1251
1252type record Cell_Identity {
1253 GsmMcc mcc,
1254 GsmMnc mnc,
1255 GsmLac lac,
1256 GsmCellId ci
1257};
Harald Welte24135bd2018-03-17 19:27:53 +01001258private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001259private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001260
Harald Welte5d1a2202017-12-13 19:51:29 +01001261type set of integer BtsIdList;
1262
1263private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1264 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1265 if (bts_id == bts_ids[j]) {
1266 return true;
1267 }
1268 }
1269 return false;
1270}
Harald Welte6f521d82017-12-11 19:52:02 +01001271
1272/* core paging test helper function; used by most paging test cases */
1273private function f_pageing_helper(hexstring imsi,
1274 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001275 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001276 template RSL_ChanNeeded rsl_chneed := omit,
1277 template OCT4 tmsi := omit) runs on test_CT
1278{
1279 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
1280 var MobileIdentity mi;
1281 var template octetstring id_enc; /* FIXME */
1282 var RSL_Message rx_rsl;
1283 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001284 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001285
1286 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001287
1288 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001289 for (i := 0; i < NUM_BTS; i := i + 1) {
1290 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001291 }
Harald Welte6f521d82017-12-11 19:52:02 +01001292
1293 if (isvalue(rsl_chneed)) {
1294 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1295 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1296 } else {
1297 bssmap_chneed := omit;
1298 }
1299
1300 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
1301
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02001302/* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder
Harald Welte6f521d82017-12-11 19:52:02 +01001303 if (isvalue(tmsi)) {
1304 mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi))));
1305 } else {
1306 mi := valueof(ts_Osmo_MI_IMSI(imsi));
1307 }
1308 id_enc := enc_MobileIdentity(mi);
1309*/
1310 id_enc := ?;
Harald Welte5d1a2202017-12-13 19:51:29 +01001311 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
1312 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc));
1313 /* check channel type, paging group */
1314 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1315 setverdict(fail, "Paging for wrong paging group");
1316 }
1317 if (ispresent(rsl_chneed) and
1318 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1319 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1320 }
Harald Welte6f521d82017-12-11 19:52:02 +01001321 }
Harald Welte2fccd982018-01-31 15:48:19 +01001322 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001323 /* do a quick check on all not-included BTSs if they received paging */
1324 for (i := 0; i < NUM_BTS; i := i + 1) {
1325 timer T := 0.1;
1326 if (f_bts_in_list(i, bts_ids)) {
1327 continue;
1328 }
1329 T.start;
1330 alt {
1331 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) {
1332 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1333 }
1334 [] IPA_RSL[i].receive { repeat; }
1335 [] T.timeout { }
1336 }
Harald Welte6f521d82017-12-11 19:52:02 +01001337 }
1338
1339 setverdict(pass);
1340}
1341
Harald Welte5d1a2202017-12-13 19:51:29 +01001342const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001343const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001344const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1345const BtsIdList c_BtsId_LAC2 := { 2 };
1346
Harald Welte6f521d82017-12-11 19:52:02 +01001347/* PAGING by IMSI + TMSI */
1348testcase TC_paging_imsi_nochan() runs on test_CT {
1349 var BSSMAP_FIELD_CellIdentificationList cid_list;
1350 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001351 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001352 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001353}
1354
1355/* PAGING by IMSI + TMSI */
1356testcase TC_paging_tmsi_nochan() runs on test_CT {
1357 var BSSMAP_FIELD_CellIdentificationList cid_list;
1358 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001359 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001360 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001361}
1362
1363/* Paging with different "channel needed' values */
1364testcase TC_paging_tmsi_any() runs on test_CT {
1365 var BSSMAP_FIELD_CellIdentificationList cid_list;
1366 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001367 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001368 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001369}
1370testcase TC_paging_tmsi_sdcch() runs on test_CT {
1371 var BSSMAP_FIELD_CellIdentificationList cid_list;
1372 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001373 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001374 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001375}
1376testcase TC_paging_tmsi_tch_f() runs on test_CT {
1377 var BSSMAP_FIELD_CellIdentificationList cid_list;
1378 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001379 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001380 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001381}
1382testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1383 var BSSMAP_FIELD_CellIdentificationList cid_list;
1384 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001385 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001386 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001387}
1388
1389/* Paging by CGI */
1390testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1391 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1392 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001393 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001394 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001395}
1396
1397/* Paging by LAC+CI */
1398testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1399 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1400 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001401 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001402 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001403}
1404
1405/* Paging by CI */
1406testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1407 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1408 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001409 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001410 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001411}
1412
1413/* Paging by LAI */
1414testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1415 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1416 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001417 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001418 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001419}
1420
1421/* Paging by LAC */
1422testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1423 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1424 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001425 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001426 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001427}
1428
1429/* Paging by "all in BSS" */
1430testcase TC_paging_imsi_nochan_all() runs on test_CT {
1431 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1432 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001433 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001434 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001435}
1436
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001437/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001438testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1439 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1440 cid_list := { cIl_PLMN_LAC_RNC := { ts_BSSMAP_CI_PLMN_LAC_RNC(cid.mcc, cid.mnc, cid.lac, 12) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001441 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001442 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001443}
Harald Welte6f521d82017-12-11 19:52:02 +01001444
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001445/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001446testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1447 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1448 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001449 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001450 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001451}
1452
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001453/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001454testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1455 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1456 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001457 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001458 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001459}
1460
Harald Welte6f521d82017-12-11 19:52:02 +01001461/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001462testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1463 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1464 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1465 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001466 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001467}
1468
1469/* Paging on empty list: Verify none of them page */
1470testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1471 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1472 cid_list := { cIl_LAC := { } };
1473 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001474 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001475}
1476
Stefan Sperling049a86e2018-03-20 15:51:00 +01001477/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1478testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1479 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1480 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1481 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1482 f_shutdown_helper();
1483}
1484
Harald Welte6f521d82017-12-11 19:52:02 +01001485/* Verify paging retransmission interval + count */
1486/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001487/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001488
Harald Weltee65d40e2017-12-13 00:09:06 +01001489/* Verify PCH load */
1490testcase TC_paging_imsi_load() runs on test_CT {
1491 var BSSMAP_FIELD_CellIdentificationList cid_list;
1492 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001493 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001494 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001495 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001496
1497 /* tell BSC there is no paging space anymore */
1498 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001499 f_sleep(0.2);
1500 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001501
1502 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1503 * there would be 8 retransmissions during 4 seconds */
1504 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001505 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001506 alt {
1507 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1508 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02001509 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01001510 }
Harald Welte2caa1062018-03-17 18:19:05 +01001511 [] T_retrans.timeout {
1512 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1513 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1514 T_retrans.start;
1515 repeat;
1516 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001517 [] T.timeout {
1518 setverdict(pass);
1519 }
1520 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001521
1522 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001523}
1524
Harald Welte235ebf12017-12-15 14:18:16 +01001525/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001526testcase TC_paging_counter() runs on test_CT {
1527 var BSSMAP_FIELD_CellIdentificationList cid_list;
1528 timer T := 4.0;
1529 var integer i;
1530 var integer paging_attempted_bsc;
1531 var integer paging_attempted_bts[NUM_BTS];
1532 var integer paging_expired_bts[NUM_BTS];
1533 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1534
1535 f_init();
1536
1537 /* read counters before paging */
1538 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1539 for (i := 0; i < NUM_BTS; i := i+1) {
1540 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1541 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1542 }
1543
1544 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1545
1546 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1547 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1548 for (i := 0; i < NUM_BTS; i := i+1) {
1549 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1550 paging_attempted_bts[i]+1);
1551 }
1552
1553 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1554 f_sleep(12.0);
1555 for (i := 0; i < NUM_BTS; i := i+1) {
1556 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1557 paging_expired_bts[i]+1);
1558 }
Harald Welte1ff69992017-12-14 12:31:17 +01001559
Philipp Maier282ca4b2018-02-27 17:17:00 +01001560 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001561}
1562
1563
Harald Welte10985002017-12-12 09:29:15 +01001564/* Verify paging stops after A-RESET */
1565testcase TC_paging_imsi_a_reset() runs on test_CT {
1566 var BSSMAP_FIELD_CellIdentificationList cid_list;
1567 timer T := 3.0;
1568 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001569 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001570
1571 /* Perform a BSSMAP Reset and wait for ACK */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001572 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte10985002017-12-12 09:29:15 +01001573 alt {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001574 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte10985002017-12-12 09:29:15 +01001575 [] BSSAP.receive { repeat; }
1576 }
1577
Daniel Willmanncbef3982018-07-30 09:22:40 +02001578 /* Wait to avoid a possible race condition if a paging message is
1579 * received right before the reset ACK. */
1580 f_sleep(0.2);
1581
Harald Welte10985002017-12-12 09:29:15 +01001582 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001583 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1584 IPA_RSL[i].clear;
1585 }
Harald Welte10985002017-12-12 09:29:15 +01001586
1587 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1588 T.start;
1589 alt {
1590 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1591 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001592 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01001593 }
Harald Welte5d1a2202017-12-13 19:51:29 +01001594 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1595 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001596 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001597 }
1598 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1599 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001600 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001601 }
Harald Welte10985002017-12-12 09:29:15 +01001602 [] T.timeout {
1603 setverdict(pass);
1604 }
1605 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001606
1607 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001608}
Harald Welteae026692017-12-09 01:03:01 +01001609
Philipp Maierf45824a2019-08-14 14:44:10 +02001610/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
1611 * paging response we can not know which MSC is in charge, so we will blindly
1612 * pick the first configured MSC. This behavior is required in order to make
1613 * MT-CSFB calls working because in those cases the BSC can not know that the
1614 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
1615 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001616 */
1617testcase TC_paging_resp_unsol() runs on test_CT {
1618
1619 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02001620 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001621
1622 var BSSAP_N_CONNECT_ind rx_c_ind;
1623 var DchanTuple dt;
1624 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02001625 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001626
1627 /* Send CHAN RQD and wait for allocation; acknowledge it */
1628 dt.rsl_chan_nr := f_chreq_act_ack();
1629
1630 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
1631 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
1632
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001633
Philipp Maierf45824a2019-08-14 14:44:10 +02001634 /* Expevct a CR with a matching Paging response on the A-Interface */
1635 T.start;
1636 alt {
1637 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
1638 setverdict(pass);
1639 }
1640 [] BSSAP.receive {
1641 setverdict(fail, "Received unexpected message on A-Interface!");
1642 }
1643 [] T.timeout {
1644 setverdict(fail, "Received nothing on A-Interface!");
1645 }
1646 }
1647
1648 setverdict(pass);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001649}
1650
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001651/* Test RSL link drop causes counter increment */
1652testcase TC_rsl_drop_counter() runs on test_CT {
1653 var integer rsl_fail;
1654
Harald Welte89d42e82017-12-17 16:42:41 +01001655 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001656
1657 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1658
1659 bts[0].rsl.vc_IPA.stop;
1660
1661 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1662
1663 setverdict(pass);
1664}
1665
1666/* TODO: Test OML link drop causes counter increment */
1667
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001668/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1669function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1670 timer T := 10.0;
1671
1672 bts[0].rsl.id := "IPA-0-RSL";
1673 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1674 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1675 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02001676 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001677
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001678 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1679
1680 f_init_mgcp("VirtMSC");
1681
1682 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1683 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1684 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1685 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1686
1687 /* wait for IPA OML link to connect and then disconnect */
1688 T.start;
1689 alt {
1690 [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) {
1691 T.stop;
1692 return true;
1693 }
1694 [] IPA_RSL[0].receive { repeat }
1695 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02001696 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001697 }
1698 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001699 return false;
1700}
1701
1702/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1703testcase TC_rsl_unknown_unit_id() runs on test_CT {
1704 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1705 setverdict(pass);
1706 } else {
1707 setverdict(fail, "Timeout RSL waiting for connection to close");
1708 }
1709}
1710
1711
1712/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1713testcase TC_oml_unknown_unit_id() runs on test_CT {
1714 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1715 setverdict(pass);
1716 } else {
1717 setverdict(fail, "Timeout OML waiting for connection to close");
1718 }
1719}
1720
1721
Harald Weltec1a2fff2017-12-17 11:06:19 +01001722/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02001723 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01001724 ***********************************************************************/
1725
Harald Welte6811d102019-04-14 22:23:14 +02001726import from RAN_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01001727import from RSL_Emulation all;
1728import from MSC_ConnectionHandler all;
1729
1730type function void_fn(charstring id) runs on MSC_ConnHdlr;
1731
Harald Welte336820c2018-05-31 20:34:52 +02001732/* helper function to create and connect a MSC_ConnHdlr component */
Harald Welteff579f92018-05-31 22:19:39 +02001733private function f_connect_handler(inout MSC_ConnHdlr vc_conn) runs on test_CT {
Harald Welte6811d102019-04-14 22:23:14 +02001734 connect(vc_conn:RAN, g_bssap.vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001735 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001736 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001737 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001738 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001739 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1740 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1741 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02001742 if (isvalue(bts[2])) {
1743 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
1744 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
1745 }
Harald Welte6811d102019-04-14 22:23:14 +02001746 connect(vc_conn:BSSAP, g_bssap.vc_RAN:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001747 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02001748 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Harald Welte336820c2018-05-31 20:34:52 +02001749}
1750
1751function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
1752runs on test_CT return MSC_ConnHdlr {
1753 var charstring id := testcasename();
1754 var MSC_ConnHdlr vc_conn;
1755 vc_conn := MSC_ConnHdlr.create(id);
1756 f_connect_handler(vc_conn);
Harald Weltea0630032018-03-20 21:09:55 +01001757 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001758 return vc_conn;
1759}
1760
Harald Weltea0630032018-03-20 21:09:55 +01001761/* first function inside ConnHdlr component; sets g_pars + starts function */
1762private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1763runs on MSC_ConnHdlr {
1764 if (isvalue(pars)) {
1765 g_pars := valueof(pars);
1766 }
1767 fn.apply(id);
1768}
1769
Harald Welte3c86ea02018-05-10 22:28:05 +02001770/* Establish signalling channel (non-assignment case) followed by cipher mode */
1771private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001772 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1773 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001774 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02001775 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
1776 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
1777 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
1778 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02001779
Philipp Maier23000732018-05-18 11:25:37 +02001780 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02001781}
1782testcase TC_ciph_mode_a5_0() runs on test_CT {
1783 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001784 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001785 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1786
1787 f_init(1, true);
1788 f_sleep(1.0);
1789 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1790 vc_conn.done;
1791}
1792testcase TC_ciph_mode_a5_1() runs on test_CT {
1793 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001794 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001795 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1796
1797 f_init(1, true);
1798 f_sleep(1.0);
1799 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1800 vc_conn.done;
1801}
1802testcase TC_ciph_mode_a5_3() runs on test_CT {
1803 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001804 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001805 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1806
1807 f_init(1, true);
1808 f_sleep(1.0);
1809 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1810 vc_conn.done;
1811}
1812
1813
1814/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001815private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001816 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1817 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001818
Harald Welte552620d2017-12-16 23:21:36 +01001819 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1820 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001821
Harald Weltea0630032018-03-20 21:09:55 +01001822 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001823}
Harald Welte552620d2017-12-16 23:21:36 +01001824testcase TC_assignment_fr_a5_0() runs on test_CT {
1825 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001826 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001827 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001828
Harald Welte89d42e82017-12-17 16:42:41 +01001829 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001830 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001831 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001832 vc_conn.done;
1833}
Harald Welte552620d2017-12-16 23:21:36 +01001834testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001835 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001836 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001837 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001838
Harald Welte89d42e82017-12-17 16:42:41 +01001839 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001840 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001841 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1842 vc_conn.done;
1843}
1844testcase TC_assignment_fr_a5_3() runs on test_CT {
1845 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001846 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001847 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001848
Harald Welte651fcdc2018-05-10 20:23:16 +02001849 f_init(1, true);
1850 f_sleep(1.0);
1851 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001852 vc_conn.done;
1853}
1854
Harald Welte552620d2017-12-16 23:21:36 +01001855/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1856private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001857 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01001858 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001859 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001860 const OCT8 kc := '0001020304050607'O;
1861
1862 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001863 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
1864
Harald Weltea0630032018-03-20 21:09:55 +01001865 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001866}
Harald Welte552620d2017-12-16 23:21:36 +01001867testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1868 var MSC_ConnHdlr vc_conn;
1869
Harald Welte89d42e82017-12-17 16:42:41 +01001870 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001871 f_sleep(1.0);
1872
Harald Welte8863fa12018-05-10 20:15:27 +02001873 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001874 vc_conn.done;
1875}
1876
Harald Welte552620d2017-12-16 23:21:36 +01001877private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001878 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02001879 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1880 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001881 const OCT8 kc := '0001020304050607'O;
1882 const OCT16 kc128 := kc & kc;
1883
1884 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1885 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001886 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001887 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001888 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001889}
Harald Welte552620d2017-12-16 23:21:36 +01001890testcase TC_assignment_fr_a5_4() runs on test_CT {
1891 var MSC_ConnHdlr vc_conn;
1892
Harald Welte89d42e82017-12-17 16:42:41 +01001893 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001894 f_sleep(1.0);
1895
Harald Welte8863fa12018-05-10 20:15:27 +02001896 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001897 vc_conn.done;
1898}
1899
1900
Harald Welte4532e0a2017-12-23 02:05:44 +01001901private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001902 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01001903 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02001904 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01001905 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001906 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001907}
1908
1909testcase TC_assignment_sign() runs on test_CT {
1910 var MSC_ConnHdlr vc_conn;
1911
1912 f_init(1, true);
1913 f_sleep(1.0);
1914
Harald Welte8863fa12018-05-10 20:15:27 +02001915 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001916 vc_conn.done;
1917}
1918
Harald Welte60aa5762018-03-21 19:33:13 +01001919/***********************************************************************
1920 * Codec (list) testing
1921 ***********************************************************************/
1922
1923/* check if the given rsl_mode is compatible with the a_elem */
1924private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1925return boolean {
1926 select (a_elem.codecType) {
1927 case (GSM_FR) {
1928 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1929 return true;
1930 }
1931 }
1932 case (GSM_HR) {
1933 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1934 return true;
1935 }
1936 }
1937 case (GSM_EFR) {
1938 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1939 return true;
1940 }
1941 }
1942 case (FR_AMR) {
1943 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1944 return true;
1945 }
1946 }
1947 case (HR_AMR) {
1948 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1949 return true;
1950 }
1951 }
1952 case else { }
1953 }
1954 return false;
1955}
1956
1957/* check if the given rsl_mode is compatible with the a_list */
1958private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
1959return boolean {
1960 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
1961 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
1962 return true;
1963 }
1964 }
1965 return false;
1966}
1967
1968/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02001969function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01001970return BSSMAP_IE_ChannelType {
1971 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
1972 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
1973 select (a_elem.codecType) {
1974 case (GSM_FR) {
1975 ret.channelRateAndType := ChRate_TCHF;
1976 ret.speechId_DataIndicator := Spdi_TCHF_FR;
1977 }
1978 case (GSM_HR) {
1979 ret.channelRateAndType := ChRate_TCHH;
1980 ret.speechId_DataIndicator := Spdi_TCHH_HR;
1981 }
1982 case (GSM_EFR) {
1983 ret.channelRateAndType := ChRate_TCHF;
1984 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
1985 }
1986 case (FR_AMR) {
1987 ret.channelRateAndType := ChRate_TCHF;
1988 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
1989 }
1990 case (HR_AMR) {
1991 ret.channelRateAndType := ChRate_TCHH;
1992 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
1993 }
1994 case else {
1995 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02001996 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01001997 }
1998 }
1999 return ret;
2000}
2001
Harald Weltea63b9102018-03-22 20:36:16 +01002002private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
2003return template RSL_IE_Body {
2004 var template RSL_IE_Body mode_ie := {
2005 chan_mode := {
2006 len := ?,
2007 reserved := ?,
2008 dtx_d := ?,
2009 dtx_u := ?,
2010 spd_ind := RSL_SPDI_SPEECH,
2011 ch_rate_type := -,
2012 coding_alg_rate := -
2013 }
2014 }
2015
2016 select (a_elem.codecType) {
2017 case (GSM_FR) {
2018 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2019 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2020 }
2021 case (GSM_HR) {
2022 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2023 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2024 }
2025 case (GSM_EFR) {
2026 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2027 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
2028 }
2029 case (FR_AMR) {
2030 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2031 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2032 }
2033 case (HR_AMR) {
2034 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2035 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2036 }
2037 }
2038 return mode_ie;
2039}
2040
Harald Welte60aa5762018-03-21 19:33:13 +01002041type record CodecListTest {
2042 BSSMAP_IE_SpeechCodecList codec_list,
2043 charstring id
2044}
2045type record of CodecListTest CodecListTests
2046
2047private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002048 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
2049 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01002050
2051 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Harald Welte79f3f542018-05-25 20:02:37 +02002052 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2053 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2054 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
2055 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01002056 if (isvalue(g_pars.expect_mr_s0_s7)) {
2057 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
2058 g_pars.expect_mr_s0_s7;
2059 }
Harald Welte79f3f542018-05-25 20:02:37 +02002060 }
Harald Welte60aa5762018-03-21 19:33:13 +01002061 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2062 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01002063 log("expecting ASS COMPL like this: ", exp_compl);
2064
2065 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01002066
2067 /* Verify that the RSL-side activation actually matches our expectations */
2068 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
2069
2070 var RSL_IE_Body mode_ie;
2071 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
2072 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02002073 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01002074 }
2075 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
2076 if (not match(mode_ie, t_mode_ie)) {
2077 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
2078 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002079
2080 var RSL_IE_Body mr_conf;
2081 if (g_pars.expect_mr_conf_ie != omit) {
2082 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
2083 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02002084 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002085 }
2086 log("found RSL MR CONFIG IE: ", mr_conf);
2087
2088 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
2089 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
2090 g_pars.expect_mr_conf_ie);
2091 }
2092 } else {
2093 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
2094 log("found RSL MR CONFIG IE: ", mr_conf);
2095 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02002096 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002097 }
2098 }
Harald Welte60aa5762018-03-21 19:33:13 +01002099}
2100
Philipp Maierd0e64b02019-03-13 14:15:23 +01002101private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
2102
2103 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2104 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2105
2106 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
2107 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2108 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2109 }
2110 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2111 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
2112 log("expecting ASS FAIL like this: ", exp_fail);
2113
2114 f_establish_fully(ass_cmd, exp_fail);
2115}
2116
Harald Welte60aa5762018-03-21 19:33:13 +01002117testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002118 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002119 var MSC_ConnHdlr vc_conn;
2120
2121 f_init(1, true);
2122 f_sleep(1.0);
2123
2124 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002125 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002126 vc_conn.done;
2127}
2128
2129testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002130 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002131 var MSC_ConnHdlr vc_conn;
2132
2133 f_init(1, true);
2134 f_sleep(1.0);
2135
2136 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002137 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002138 vc_conn.done;
2139}
2140
2141testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002142 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002143 var MSC_ConnHdlr vc_conn;
2144
2145 f_init(1, true);
2146 f_sleep(1.0);
2147
2148 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002149 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002150 vc_conn.done;
2151}
2152
Philipp Maierd0e64b02019-03-13 14:15:23 +01002153/* Allow 5,90k only (current default config) */
2154private function f_allow_amr_rate_5_90k() runs on test_CT {
2155 f_vty_enter_cfg_msc(BSCVTY, 0);
2156 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
2157 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2158 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2159 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
2160 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2161 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2162 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2163 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
2164 f_vty_transceive(BSCVTY, "exit");
2165 f_vty_transceive(BSCVTY, "exit");
2166}
2167
2168/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
2169 * ("Config-NB-Code = 1") */
2170private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
2171 f_vty_enter_cfg_msc(BSCVTY, 0);
2172 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
2173 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2174 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2175 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
2176 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2177 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2178 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2179 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
2180 f_vty_transceive(BSCVTY, "exit");
2181 f_vty_transceive(BSCVTY, "exit");
2182}
2183
Harald Welte60aa5762018-03-21 19:33:13 +01002184testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002185 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002186 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002187
2188 /* Note: This setups the codec configuration. The parameter payload in
2189 * mr_conf must be consistant with the parameter codecElements in pars
2190 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002191 var RSL_IE_Body mr_conf := {
2192 other := {
2193 len := 2,
2194 payload := '2804'O
2195 }
2196 };
Harald Welte60aa5762018-03-21 19:33:13 +01002197
Philipp Maier7695a0d2018-09-27 17:52:14 +02002198 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002199 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002200 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
2201 pars.expect_mr_conf_ie := mr_conf;
2202
Harald Welte60aa5762018-03-21 19:33:13 +01002203 f_init(1, true);
2204 f_sleep(1.0);
2205
Harald Welte8863fa12018-05-10 20:15:27 +02002206 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002207 vc_conn.done;
2208}
2209
2210testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002211 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002212 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002213
2214 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002215 var RSL_IE_Body mr_conf := {
2216 other := {
2217 len := 2,
2218 payload := '2804'O
2219 }
2220 };
Harald Welte60aa5762018-03-21 19:33:13 +01002221
Philipp Maier7695a0d2018-09-27 17:52:14 +02002222 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002223 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002224 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2225 pars.expect_mr_conf_ie := mr_conf;
2226
Harald Welte60aa5762018-03-21 19:33:13 +01002227 f_init(1, true);
2228 f_sleep(1.0);
2229
Harald Welte8863fa12018-05-10 20:15:27 +02002230 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002231 vc_conn.done;
2232}
2233
Philipp Maierd0e64b02019-03-13 14:15:23 +01002234function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
2235runs on test_CT {
2236
2237 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2238 var MSC_ConnHdlr vc_conn;
2239
2240 /* See note above */
2241 var RSL_IE_Body mr_conf := {
2242 other := {
2243 len := lengthof(mrconf),
2244 payload := mrconf
2245 }
2246 };
2247
2248 if (fr) {
2249 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2250 } else {
2251 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2252 }
2253 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2254 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2255 pars.expect_mr_conf_ie := mr_conf;
2256 pars.expect_mr_s0_s7 := exp_s8_s0;
2257
2258 f_init(1, true);
2259 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2260 f_sleep(1.0);
2261
2262 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2263 vc_conn.done;
2264 f_allow_amr_rate_5_90k();
2265}
2266
2267function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
2268runs on test_CT {
2269
2270 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2271 var MSC_ConnHdlr vc_conn;
2272
2273 if (fr) {
2274 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2275 } else {
2276 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2277 }
2278 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2279 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2280
2281 f_init(1, true);
2282 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2283 f_sleep(1.0);
2284
2285 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
2286 vc_conn.done;
2287 f_allow_amr_rate_5_90k();
2288}
2289
2290
2291/* Set S1, we expect an AMR multirate configuration IE with all four rates
2292 * set. */
2293testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
2294 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
2295}
2296
2297/* Set S1, we expect an AMR multirate configuration IE with the lower three
2298 * rates set. */
2299testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
2300 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
2301}
2302
2303/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2304 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2305testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
2306 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
2307}
2308
2309/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2310 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2311testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
2312 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
2313}
2314
2315/* The following block of tests selects more and more rates until all four
2316 * possible rates are in the active set (full rate) */
2317testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
2318 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
2319}
2320
2321testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
2322 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
2323}
2324
2325testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
2326 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
2327}
2328
2329testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
2330 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
2331}
2332
2333/* The following block of tests selects more and more rates until all three
2334 * possible rates are in the active set (half rate) */
2335testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
2336 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
2337}
2338
2339testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
2340 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
2341}
2342
2343testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
2344 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
2345}
2346
2347/* The following block tests what happens when the MSC does offer rate
2348 * configurations that are not supported by the BSC. Normally such situations
2349 * should not happen because the MSC gets informed by the BSC in advance via
2350 * the L3 COMPLETE message which rates are applicable. The MSC should not try
2351 * to offer rates that are not applicable anyway. */
2352
2353testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
2354 /* Try to include 12,2k in into the active set even though the channel
2355 * is half rate only. The BSC is expected to remove the 12,0k */
2356 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
2357}
2358
2359testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
2360 /* See what happens when all rates are selected at once. Since then
2361 * Also S1 is selected, this setting will be prefered and we should
2362 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
2363 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
2364}
2365
2366testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
2367 /* Same as above, but with S1 missing, the MSC is then expected to
2368 * select the currently supported rates, which are also 12.2k, 7,40k,
2369 * 5,90k, and 4,75k, into the active set. */
2370 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
2371}
2372
2373testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
2374 /* Try to select no rates at all */
2375 f_TC_assignment_codec_amr_fail(true, '00000000'B);
2376}
2377
2378testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
2379 /* Try to select only unsupported rates */
2380 f_TC_assignment_codec_amr_fail(true, '01101000'B);
2381}
2382
2383testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
2384 /* Try to select 12,2k for half rate */
2385 f_TC_assignment_codec_amr_fail(false, '10000000'B);
2386}
2387
Philipp Maierac09bfc2019-01-08 13:41:39 +01002388private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002389 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
2390 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
2391 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
2392 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002393}
2394
2395private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002396 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
2397 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002398}
2399
2400private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002401 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
2402 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
2403 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
2404 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
2405 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
2406 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002407}
2408
2409/* Allow HR only */
2410private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
2411 g_pars := f_gen_test_hdlr_pars();
2412 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2413 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2414 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2415 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2416 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2417 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2418 f_establish_fully(ass_cmd, exp_compl);
2419}
2420
2421/* Allow FR only */
2422private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
2423 g_pars := f_gen_test_hdlr_pars();
2424 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2425 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2426 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2427 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2428 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2429 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2430 f_establish_fully(ass_cmd, exp_compl);
2431}
2432
2433/* Allow HR only (expect assignment failure) */
2434private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
2435 g_pars := f_gen_test_hdlr_pars();
2436 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2437 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2438 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2439 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2440 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2441 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2442 f_establish_fully(ass_cmd, exp_fail);
2443}
2444
2445/* Allow FR only (expect assignment failure) */
2446private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
2447 g_pars := f_gen_test_hdlr_pars();
2448 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2449 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2450 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2451 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2452 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2453 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2454 f_establish_fully(ass_cmd, exp_fail);
2455}
2456
2457/* Allow FR and HR, but prefer FR */
2458private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2459 g_pars := f_gen_test_hdlr_pars();
2460 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2461 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2462 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2463 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2464 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2465 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2466 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2467 f_establish_fully(ass_cmd, exp_compl);
2468}
2469
2470/* Allow FR and HR, but prefer HR */
2471private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2472 g_pars := f_gen_test_hdlr_pars();
2473 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2474 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2475 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2476 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2477 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2478 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2479 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2480 f_establish_fully(ass_cmd, exp_compl);
2481}
2482
2483/* Allow FR and HR, but prefer FR */
2484private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2485 g_pars := f_gen_test_hdlr_pars();
2486 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2487 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2488 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2489 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2490 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2491 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2492 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2493 f_establish_fully(ass_cmd, exp_compl);
2494}
2495
2496/* Allow FR and HR, but prefer HR */
2497private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2498 g_pars := f_gen_test_hdlr_pars();
2499 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2500 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2501 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2502 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2503 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2504 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2505 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2506 f_establish_fully(ass_cmd, exp_compl);
2507}
2508
2509/* Request a HR channel while all FR channels are exhausted, this is expected
2510 * to work without conflicts */
2511testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
2512 var MSC_ConnHdlr vc_conn;
2513 f_init(1, true);
2514 f_sleep(1.0);
2515 f_enable_all_tch();
2516 f_disable_all_tch_f();
2517 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
2518 vc_conn.done;
2519 f_enable_all_tch();
2520 setverdict(pass);
2521}
2522
2523/* Request a FR channel while all FR channels are exhausted, this is expected
2524 * to fail. */
2525testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
2526 var MSC_ConnHdlr vc_conn;
2527 f_init(1, true);
2528 f_sleep(1.0);
2529 f_enable_all_tch();
2530 f_disable_all_tch_f();
2531 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
2532 vc_conn.done;
2533 f_enable_all_tch();
2534 setverdict(pass);
2535}
2536
2537/* Request a FR (prefered) or alternatively a HR channel while all FR channels
2538 * are exhausted, this is expected to be resolved by selecting a HR channel. */
2539testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
2540 var MSC_ConnHdlr vc_conn;
2541 f_init(1, true);
2542 f_sleep(1.0);
2543 f_enable_all_tch();
2544 f_disable_all_tch_f();
2545 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
2546 vc_conn.done;
2547 f_enable_all_tch();
2548 setverdict(pass);
2549}
2550
2551/* Request a HR (prefered) or alternatively a FR channel while all FR channels
2552 * are exhausted, this is expected to work without conflicts. */
2553testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
2554 var MSC_ConnHdlr vc_conn;
2555 f_init(1, true);
2556 f_sleep(1.0);
2557 f_enable_all_tch();
2558 f_disable_all_tch_f();
2559 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
2560 vc_conn.done;
2561 f_enable_all_tch();
2562 setverdict(pass);
2563}
2564
2565/* Request a FR channel while all HR channels are exhausted, this is expected
2566 * to work without conflicts */
2567testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
2568 var MSC_ConnHdlr vc_conn;
2569 f_init(1, true);
2570 f_sleep(1.0);
2571 f_enable_all_tch();
2572 f_disable_all_tch_h();
2573 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
2574 vc_conn.done;
2575 f_enable_all_tch();
2576 setverdict(pass);
2577}
2578
2579/* Request a HR channel while all HR channels are exhausted, this is expected
2580 * to fail. */
2581testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
2582 var MSC_ConnHdlr vc_conn;
2583 f_init(1, true);
2584 f_sleep(1.0);
2585 f_enable_all_tch();
2586 f_disable_all_tch_h();
2587 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
2588 vc_conn.done;
2589 f_enable_all_tch();
2590 setverdict(pass);
2591}
2592
2593/* Request a HR (prefered) or alternatively a FR channel while all HR channels
2594 * are exhausted, this is expected to be resolved by selecting a FR channel. */
2595testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
2596 var MSC_ConnHdlr vc_conn;
2597 f_init(1, true);
2598 f_sleep(1.0);
2599 f_enable_all_tch();
2600 f_disable_all_tch_h();
2601 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
2602 vc_conn.done;
2603 f_enable_all_tch();
2604 setverdict(pass);
2605}
2606
2607/* Request a FR (prefered) or alternatively a HR channel while all HR channels
2608 * are exhausted, this is expected to work without conflicts. */
2609testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
2610 var MSC_ConnHdlr vc_conn;
2611 f_init(1, true);
2612 f_sleep(1.0);
2613 f_enable_all_tch();
2614 f_disable_all_tch_h();
2615 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
2616 vc_conn.done;
2617 f_enable_all_tch();
2618 setverdict(pass);
2619}
2620
2621/* Allow FR and HR, but prefer HR */
2622private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2623 g_pars := f_gen_test_hdlr_pars();
2624 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2625 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2626 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2627 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2628 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2629 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2630 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2631 f_establish_fully(ass_cmd, exp_compl);
2632}
2633
2634/* Allow FR and HR, but prefer FR */
2635private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2636 g_pars := f_gen_test_hdlr_pars();
2637 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2638 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2639 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2640 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2641 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2642 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2643 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2644 f_establish_fully(ass_cmd, exp_compl);
2645}
2646
2647/* Request a HR (prefered) or alternatively a FR channel, it is expected that
2648 * HR, which is the prefered type, is selected. */
2649testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
2650 var MSC_ConnHdlr vc_conn;
2651 f_init(1, true);
2652 f_sleep(1.0);
2653 f_enable_all_tch();
2654 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
2655 vc_conn.done;
2656 setverdict(pass);
2657}
2658
2659/* Request a FR (prefered) or alternatively a HR channel, it is expected that
2660 * FR, which is the prefered type, is selected. */
2661testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
2662 var MSC_ConnHdlr vc_conn;
2663 f_init(1, true);
2664 f_sleep(1.0);
2665 f_enable_all_tch();
2666 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
2667 vc_conn.done;
2668 setverdict(pass);
2669}
2670
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002671testcase TC_assignment_osmux() runs on test_CT {
2672 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2673 var MSC_ConnHdlr vc_conn;
2674
2675 /* See note above */
2676 var RSL_IE_Body mr_conf := {
2677 other := {
2678 len := 2,
2679 payload := '2804'O
2680 }
2681 };
2682
2683 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2684 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
2685 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2686 pars.expect_mr_conf_ie := mr_conf;
2687 pars.use_osmux := true;
2688
2689 f_init(1, true, true);
2690 f_sleep(1.0);
2691
2692 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2693 vc_conn.done;
2694}
2695
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002696/* test the procedure of the MSC requesting a Classmark Update:
2697 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
2698 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01002699private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002700 g_pars := f_gen_test_hdlr_pars();
2701
Harald Weltea0630032018-03-20 21:09:55 +01002702 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002703 /* we should now have a COMPL_L3 at the MSC */
2704 BSSAP.receive(tr_BSSMAP_ComplL3);
2705
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002706 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
2707 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
2708
Harald Welte898113b2018-01-31 18:32:21 +01002709 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
2710 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
2711 setverdict(pass);
2712}
2713testcase TC_classmark() runs on test_CT {
2714 var MSC_ConnHdlr vc_conn;
2715 f_init(1, true);
2716 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002717 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01002718 vc_conn.done;
2719}
2720
Harald Weltee3bd6582018-01-31 22:51:25 +01002721private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002722 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002723 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002724 /* we should now have a COMPL_L3 at the MSC */
2725 BSSAP.receive(tr_BSSMAP_ComplL3);
2726
Harald Weltee3bd6582018-01-31 22:51:25 +01002727 /* send the single message we want to send */
2728 f_rsl_send_l3(l3);
2729}
2730
2731private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
2732 timer T := sec;
2733 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01002734 T.start;
2735 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01002736 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
2737 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02002738 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01002739 }
2740 [] T.timeout {
2741 setverdict(pass);
2742 }
2743 }
2744}
2745
Harald Weltee3bd6582018-01-31 22:51:25 +01002746/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2747private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
2748 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
2749 f_bssap_expect_nothing();
2750}
Harald Welte898113b2018-01-31 18:32:21 +01002751testcase TC_unsol_ass_fail() runs on test_CT {
2752 var MSC_ConnHdlr vc_conn;
2753 f_init(1, true);
2754 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002755 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01002756 vc_conn.done;
2757}
Harald Welte552620d2017-12-16 23:21:36 +01002758
Harald Welteea99a002018-01-31 20:46:43 +01002759
2760/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
2761private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002762 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
2763 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01002764}
2765testcase TC_unsol_ass_compl() runs on test_CT {
2766 var MSC_ConnHdlr vc_conn;
2767 f_init(1, true);
2768 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002769 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01002770 vc_conn.done;
2771}
2772
2773
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002774/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2775private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002776 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
2777 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002778}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002779testcase TC_unsol_ho_fail() runs on test_CT {
2780 var MSC_ConnHdlr vc_conn;
2781 f_init(1, true);
2782 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002783 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002784 vc_conn.done;
2785}
2786
2787
Harald Weltee3bd6582018-01-31 22:51:25 +01002788/* short message from MS should be ignored */
2789private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002790 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002791 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01002792 /* we should now have a COMPL_L3 at the MSC */
2793 BSSAP.receive(tr_BSSMAP_ComplL3);
2794
2795 /* send short message */
2796 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
2797 f_bssap_expect_nothing();
2798}
2799testcase TC_err_82_short_msg() runs on test_CT {
2800 var MSC_ConnHdlr vc_conn;
2801 f_init(1, true);
2802 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002803 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01002804 vc_conn.done;
2805}
2806
2807
Harald Weltee9e02e42018-01-31 23:36:25 +01002808/* 24.008 8.4 Unknown message must trigger RR STATUS */
2809private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
2810 f_est_single_l3(ts_RRM_UL_REL('00'O));
2811 timer T := 3.0
2812 alt {
2813 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
2814 setverdict(pass);
2815 }
2816 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01002817 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01002818 }
2819}
2820testcase TC_err_84_unknown_msg() runs on test_CT {
2821 var MSC_ConnHdlr vc_conn;
2822 f_init(1, true);
2823 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002824 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01002825 vc_conn.done;
2826}
2827
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002828/***********************************************************************
2829 * Handover
2830 ***********************************************************************/
2831
Harald Welte94e0c342018-04-07 11:33:23 +02002832/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
2833private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
2834runs on test_CT {
2835 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2836 " timeslot "&int2str(ts_nr)&" ";
2837 f_vty_transceive(BSCVTY, cmd & suffix);
2838}
2839
Harald Welte261af4b2018-02-12 21:20:39 +01002840/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
2841private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
2842runs on MSC_ConnHdlr {
2843 /* FIXME: resolve those from component-global state */
2844 var integer ts_nr := chan_nr.tn;
2845 var integer ss_nr;
2846 if (ischosen(chan_nr.u.ch0)) {
2847 ss_nr := 0;
2848 } else if (ischosen(chan_nr.u.lm)) {
2849 ss_nr := chan_nr.u.lm.sub_chan;
2850 } else if (ischosen(chan_nr.u.sdcch4)) {
2851 ss_nr := chan_nr.u.sdcch4.sub_chan;
2852 } else if (ischosen(chan_nr.u.sdcch8)) {
2853 ss_nr := chan_nr.u.sdcch8.sub_chan;
2854 } else {
2855 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02002856 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01002857 }
2858
2859 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2860 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
2861 f_vty_transceive(BSCVTY, cmd & suffix);
2862}
2863
Neels Hofmeyr91401012019-07-11 00:42:35 +02002864/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
2865 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
2866 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
2867 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
2868 * pair, not really to a specific BTS number. */
Harald Welte261af4b2018-02-12 21:20:39 +01002869private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
2870 integer new_bts_nr)
2871runs on MSC_ConnHdlr {
2872 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
2873}
2874
2875/* intra-BSC hand-over between BTS0 and BTS1 */
2876private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002877 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02002878 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2879 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01002880 const OCT8 kc := '0001020304050607'O;
2881
2882 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2883 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2884
Harald Weltea0630032018-03-20 21:09:55 +01002885 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02002886 f_bts_0_cfg({"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01002887
2888 var HandoverState hs := {
2889 rr_ho_cmpl_seen := false,
2890 handover_done := false,
2891 old_chan_nr := -
2892 };
2893 /* issue hand-over command on VTY */
2894 f_vty_handover(0, 0, g_chan_nr, 1);
2895 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2896 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002897
2898 /* From the MGW perspective, a handover is is characterized by
2899 * performing one MDCX operation with the MGW. So we expect to see
2900 * one more MDCX during handover. */
2901 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
2902
Harald Welte261af4b2018-02-12 21:20:39 +01002903 alt {
2904 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01002905 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002906
Philipp Maier4dae0652018-11-12 12:03:26 +01002907 /* Since this is an internal handover we expect the BSC to inform the
2908 * MSC about the event */
2909 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
2910
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002911 /* Check the amount of MGCP transactions is still consistant with the
2912 * test expectation */
2913 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01002914 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01002915}
2916
2917testcase TC_ho_int() runs on test_CT {
2918 var MSC_ConnHdlr vc_conn;
2919 f_init(2, true);
2920 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002921 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002922 vc_conn.done;
2923}
Harald Weltee9e02e42018-01-31 23:36:25 +01002924
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002925/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02002926private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002927 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002928 var template MgcpResponse mgcp_resp;
2929 var MGCP_RecvFrom mrf;
2930 var template MgcpMessage msg_resp;
2931 var template MgcpMessage msg_dlcx := {
2932 command := tr_DLCX()
2933 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002934
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002935 if (g_pars.aoip) {
2936 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002937 log("Got first DLCX: ", mgcp);
2938 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002939 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002940
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002941 MGCP.receive(tr_DLCX()) -> value mgcp {
2942 log("Got second DLCX: ", mgcp);
2943 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
2944 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002945 } else {
2946 /* For SCCPLite, BSC doesn't handle the MSC-side */
2947 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
2948 log("Got first DLCX: ", mrf.msg.command);
2949 msg_resp := {
2950 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
2951 }
2952 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
2953 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002954 }
2955
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02002956 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002957}
2958
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002959private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002960 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002961
2962 var PDU_BSSAP ass_req := f_gen_ass_req();
2963 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2964 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2965 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2966 f_establish_fully(ass_req, exp_compl);
2967
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02002968 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002969 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2970
2971 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2972
2973 f_sleep(0.5);
2974 /* The MSC negotiates Handover Request and Handover Request Ack with
2975 * the other BSS and comes back with a BSSMAP Handover Command
2976 * containing an RR Handover Command coming from the target BSS... */
2977
2978 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
2979 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
2980 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
2981 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
2982 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
2983
2984 /* expect the Handover Command to go out on RR */
2985 var RSL_Message rsl_ho_cmd
2986 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
2987 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
2988 var RSL_IE_Body rsl_ho_cmd_l3;
2989 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
2990 log("RSL message contains no L3 Info IE, expected RR Handover Command");
2991 setverdict(fail);
2992 } else {
2993 log("Found L3 Info: ", rsl_ho_cmd_l3);
2994 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
2995 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
2996 setverdict(fail);
2997 } else {
2998 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
2999 setverdict(pass);
3000 }
3001 }
3002
3003 /* When the other BSS has reported a completed handover, this side is
3004 * torn down. */
3005
3006 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
3007 var BssmapCause cause := enum2int(cause_val);
3008 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3009
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003010 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003011 setverdict(pass);
3012 f_sleep(1.0);
3013}
3014testcase TC_ho_out_of_this_bsc() runs on test_CT {
3015 var MSC_ConnHdlr vc_conn;
3016
3017 f_init(1, true);
3018 f_sleep(1.0);
3019
3020 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
3021 vc_conn.done;
3022}
3023
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003024/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
3025 * simply never sends a BSSMAP Handover Command. */
3026private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003027 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003028
3029 var PDU_BSSAP ass_req := f_gen_ass_req();
3030 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3031 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3032 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3033 f_establish_fully(ass_req, exp_compl);
3034
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003035 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003036 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3037
3038 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3039
3040 /* osmo-bsc should time out 10 seconds after the handover started.
3041 * Let's give it a bit extra. */
3042 f_sleep(15.0);
3043
3044 /* The old lchan and conn should still be active. See that arbitrary L3
3045 * is still going through. */
3046 var octetstring l3 := '0123456789'O;
3047 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3048 var template PDU_BSSAP exp_data := {
3049 discriminator := '1'B,
3050 spare := '0000000'B,
3051 dlci := '00'O,
3052 lengthIndicator := 5,
3053 pdu := {
3054 dtap := l3
3055 }
3056 };
3057 BSSAP.receive(exp_data);
3058 setverdict(pass);
3059 f_sleep(1.0);
3060}
3061testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
3062 var MSC_ConnHdlr vc_conn;
3063
3064 f_init(1, true);
3065 f_sleep(1.0);
3066
3067 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
3068 vc_conn.done;
3069}
3070
3071/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
3072 * RR Handover Failure. */
3073private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003074 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003075
3076 var PDU_BSSAP ass_req := f_gen_ass_req();
3077 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3078 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3079 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3080 f_establish_fully(ass_req, exp_compl);
3081
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003082 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003083 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3084
3085 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3086
3087 f_sleep(0.5);
3088 /* The MSC negotiates Handover Request and Handover Request Ack with
3089 * the other BSS and comes back with a BSSMAP Handover Command
3090 * containing an RR Handover Command coming from the target BSS... */
3091
3092 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3093 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3094 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3095 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3096 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3097
3098 /* expect the Handover Command to go out on RR */
3099 var RSL_Message rsl_ho_cmd
3100 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3101 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3102 var RSL_IE_Body rsl_ho_cmd_l3;
3103 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3104 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3105 setverdict(fail);
3106 } else {
3107 log("Found L3 Info: ", rsl_ho_cmd_l3);
3108 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3109 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3110 setverdict(fail);
3111 } else {
3112 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3113 setverdict(pass);
3114 }
3115 }
3116
3117 f_sleep(0.2);
3118 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3119
3120 /* Should tell the MSC about the failure */
3121 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3122
3123 f_sleep(1.0);
3124
3125 /* The old lchan and conn should still be active. See that arbitrary L3
3126 * is still going through. */
3127 var octetstring l3 := '0123456789'O;
3128 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3129 var template PDU_BSSAP exp_data := {
3130 discriminator := '1'B,
3131 spare := '0000000'B,
3132 dlci := '00'O,
3133 lengthIndicator := 5,
3134 pdu := {
3135 dtap := l3
3136 }
3137 };
3138 BSSAP.receive(exp_data);
3139 setverdict(pass);
3140 f_sleep(1.0);
3141
3142 setverdict(pass);
3143 f_sleep(1.0);
3144}
3145testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
3146 var MSC_ConnHdlr vc_conn;
3147
3148 f_init(1, true);
3149 f_sleep(1.0);
3150
3151 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
3152 vc_conn.done;
3153}
3154
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003155/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
3156 * (neither BSSMAP Clear Command for success nor RR Handover Failure). 48.008 3.1.5.3.3 "Abnormal Conditions" applies
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003157 * and the lchan is released. */
3158private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003159 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003160
3161 var PDU_BSSAP ass_req := f_gen_ass_req();
3162 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3163 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3164 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3165 f_establish_fully(ass_req, exp_compl);
3166
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003167 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003168 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3169
3170 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3171
3172 f_sleep(0.5);
3173 /* The MSC negotiates Handover Request and Handover Request Ack with
3174 * the other BSS and comes back with a BSSMAP Handover Command
3175 * containing an RR Handover Command coming from the target BSS... */
3176
3177 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3178 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3179 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3180 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3181 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3182
3183 /* expect the Handover Command to go out on RR */
3184 var RSL_Message rsl_ho_cmd
3185 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3186 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3187 var RSL_IE_Body rsl_ho_cmd_l3;
3188 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3189 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3190 setverdict(fail);
3191 } else {
3192 log("Found L3 Info: ", rsl_ho_cmd_l3);
3193 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3194 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3195 setverdict(fail);
3196 } else {
3197 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3198 setverdict(pass);
3199 }
3200 }
3201
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003202 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
3203 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
3204 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003205
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003206 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02003207 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
3208 log("Got BSSMAP Clear Request");
3209 /* Instruct BSC to clear channel */
3210 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3211 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3212
3213 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003214 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01003215 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
3216 log("Got Deact SACCH");
3217 }
Harald Welte924b6ea2019-02-04 01:05:34 +01003218 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01003219 log("Got RR Release");
3220 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003221 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
3222 log("Got RF Chan Rel");
3223 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
3224 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003225 }
3226
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003227 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003228
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003229 setverdict(pass);
3230 f_sleep(1.0);
3231}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003232testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003233 var MSC_ConnHdlr vc_conn;
3234
3235 f_init(1, true);
3236 f_sleep(1.0);
3237
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003238 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003239 vc_conn.done;
3240}
3241
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003242private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
3243 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3244 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3245 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3246 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3247 * before we get started. */
3248 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3249 f_rslem_register(0, new_chan_nr);
3250 g_chan_nr := new_chan_nr;
3251 f_sleep(1.0);
3252
3253 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3254 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3255 activate(as_Media());
3256
3257 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3258 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003259 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003260
3261 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3262
3263 var PDU_BSSAP rx_bssap;
3264 var octetstring ho_command_str;
3265
3266 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02003267
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003268 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3269 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3270 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3271 log("L3 Info in HO Request Ack is ", ho_command);
3272
3273 var GsmArfcn arfcn;
3274 var RslChannelNr actual_new_chan_nr;
3275 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3276 actual_new_chan_nr, arfcn);
3277
3278 if (actual_new_chan_nr != new_chan_nr) {
3279 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3280 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3281 setverdict(fail);
3282 return;
3283 }
3284 log("Handover Command chan_nr is", actual_new_chan_nr);
3285
3286 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3287 * tells the MS to handover to the new lchan. Here comes the new MS on
3288 * the new lchan with a Handover RACH: */
3289
3290 /* send handover detect */
3291
3292 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3293
3294 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3295
3296 /* send handover complete over the new channel */
3297
3298 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
3299 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
3300 enc_PDU_ML3_MS_NW(l3_tx)));
3301
3302 BSSAP.receive(tr_BSSMAP_HandoverComplete);
3303 setverdict(pass);
3304}
3305testcase TC_ho_into_this_bsc() runs on test_CT {
3306 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003307 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003308
3309 f_init(1, true);
3310 f_sleep(1.0);
3311
3312 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3313 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3314
3315 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
3316 vc_conn.done;
3317}
3318
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003319private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
3320 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3321 f_rslem_register(0, new_chan_nr);
3322 g_chan_nr := new_chan_nr;
3323 f_sleep(1.0);
3324
3325 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3326 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3327 activate(as_Media());
3328
3329 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3330 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003331 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003332
3333 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3334
3335 var PDU_BSSAP rx_bssap;
3336 var octetstring ho_command_str;
3337
3338 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3339
3340 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3341 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3342 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3343 log("L3 Info in HO Request Ack is ", ho_command);
3344
3345 var GsmArfcn arfcn;
3346 var RslChannelNr actual_new_chan_nr;
3347 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3348 actual_new_chan_nr, arfcn);
3349
3350 if (actual_new_chan_nr != new_chan_nr) {
3351 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3352 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3353 setverdict(fail);
3354 return;
3355 }
3356 log("Handover Command chan_nr is", actual_new_chan_nr);
3357
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02003358 /* For deterministic test results, give some time for the MGW endpoint to be configured */
3359 f_sleep(1.0);
3360
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003361 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3362 * tells the MS to handover to the new lchan. In this case, the MS
3363 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
3364 * Handover Failure to the MSC. The procedure according to 3GPP TS
3365 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
3366 * BSSMAP Clear Command: */
3367
3368 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3369 var BssmapCause cause := enum2int(cause_val);
3370 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3371
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003372 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003373 setverdict(pass);
3374 f_sleep(1.0);
3375
3376 setverdict(pass);
3377}
3378testcase TC_ho_in_fail_msc_clears() runs on test_CT {
3379 var MSC_ConnHdlr vc_conn;
3380 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3381
3382 f_init(1, true);
3383 f_sleep(1.0);
3384
3385 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3386 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3387
3388 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
3389 vc_conn.done;
3390}
3391
3392private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
3393 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3394 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3395 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3396 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3397 * before we get started. */
3398 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3399 f_rslem_register(0, new_chan_nr);
3400 g_chan_nr := new_chan_nr;
3401 f_sleep(1.0);
3402
3403 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3404 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3405 activate(as_Media());
3406
3407 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3408 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003409 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003410
3411 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3412
3413 var PDU_BSSAP rx_bssap;
3414 var octetstring ho_command_str;
3415
3416 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3417
3418 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3419 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3420 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3421 log("L3 Info in HO Request Ack is ", ho_command);
3422
3423 var GsmArfcn arfcn;
3424 var RslChannelNr actual_new_chan_nr;
3425 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3426 actual_new_chan_nr, arfcn);
3427
3428 if (actual_new_chan_nr != new_chan_nr) {
3429 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3430 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3431 setverdict(fail);
3432 return;
3433 }
3434 log("Handover Command chan_nr is", actual_new_chan_nr);
3435
3436 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3437 * tells the MS to handover to the new lchan. Here comes the new MS on
3438 * the new lchan with a Handover RACH: */
3439
3440 /* send handover detect */
3441
3442 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3443
3444 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3445
3446 /* The MSC chooses to clear the connection now, maybe we got the
3447 * Handover RACH on the new cell but the MS still signaled Handover
3448 * Failure to the old BSS? */
3449
3450 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3451 var BssmapCause cause := enum2int(cause_val);
3452 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3453
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003454 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003455 setverdict(pass);
3456 f_sleep(1.0);
3457}
3458testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
3459 var MSC_ConnHdlr vc_conn;
3460 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3461
3462 f_init(1, true);
3463 f_sleep(1.0);
3464
3465 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3466 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3467
3468 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
3469 vc_conn.done;
3470}
3471
3472/* The new BSS's lchan times out before the MSC decides that handover failed. */
3473private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
3474 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3475 f_rslem_register(0, new_chan_nr);
3476 g_chan_nr := new_chan_nr;
3477 f_sleep(1.0);
3478
3479 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3480 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3481 activate(as_Media());
3482
3483 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3484 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003485 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003486
3487 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3488
3489 var PDU_BSSAP rx_bssap;
3490 var octetstring ho_command_str;
3491
3492 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3493
3494 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3495 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3496 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3497 log("L3 Info in HO Request Ack is ", ho_command);
3498
3499 var GsmArfcn arfcn;
3500 var RslChannelNr actual_new_chan_nr;
3501 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3502 actual_new_chan_nr, arfcn);
3503
3504 if (actual_new_chan_nr != new_chan_nr) {
3505 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3506 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3507 setverdict(fail);
3508 return;
3509 }
3510 log("Handover Command chan_nr is", actual_new_chan_nr);
3511
3512 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3513 * tells the MS to handover to the new lchan. But the MS never shows up
3514 * on the new lchan. */
3515
3516 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3517
3518 /* Did osmo-bsc also send a Clear Request? */
3519 timer T := 0.5;
3520 T.start;
3521 alt {
3522 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
3523 [] T.timeout { }
3524 }
3525
3526 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
3527 * asked for it, this is a Handover Failure after all). */
3528
3529 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3530 var BssmapCause cause := enum2int(cause_val);
3531 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3532
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003533 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003534 setverdict(pass);
3535 f_sleep(1.0);
3536
3537 setverdict(pass);
3538}
3539testcase TC_ho_in_fail_no_detect() runs on test_CT {
3540 var MSC_ConnHdlr vc_conn;
3541 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3542
3543 f_init(1, true);
3544 f_sleep(1.0);
3545
3546 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3547 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3548
3549 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
3550 vc_conn.done;
3551}
3552
3553/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
3554private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
3555 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3556 f_rslem_register(0, new_chan_nr);
3557 g_chan_nr := new_chan_nr;
3558 f_sleep(1.0);
3559
3560 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3561 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3562 activate(as_Media());
3563
3564 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3565 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003566 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003567
3568 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3569
3570 var PDU_BSSAP rx_bssap;
3571 var octetstring ho_command_str;
3572
3573 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3574
3575 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3576 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3577 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3578 log("L3 Info in HO Request Ack is ", ho_command);
3579
3580 var GsmArfcn arfcn;
3581 var RslChannelNr actual_new_chan_nr;
3582 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3583 actual_new_chan_nr, arfcn);
3584
3585 if (actual_new_chan_nr != new_chan_nr) {
3586 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3587 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3588 setverdict(fail);
3589 return;
3590 }
3591 log("Handover Command chan_nr is", actual_new_chan_nr);
3592
3593 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3594 * tells the MS to handover to the new lchan. But the MS never shows up
3595 * on the new lchan. */
3596
3597 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3598
3599 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003600 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003601
3602 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003603 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3604 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3605 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003606 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003607 setverdict(pass);
3608 f_sleep(1.0);
3609}
3610testcase TC_ho_in_fail_no_detect2() runs on test_CT {
3611 var MSC_ConnHdlr vc_conn;
3612 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3613
3614 f_init(1, true);
3615 f_sleep(1.0);
3616
3617 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3618 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3619
3620 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
3621 vc_conn.done;
3622}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003623
Neels Hofmeyr91401012019-07-11 00:42:35 +02003624type record of charstring Commands;
3625
3626private function f_bts_0_cfg(Commands cmds := {}) runs on MSC_ConnHdlr
3627{
3628 f_vty_enter_cfg_bts(BSCVTY, 0);
3629 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
3630 f_vty_transceive(BSCVTY, cmds[i]);
3631 }
3632 f_vty_transceive(BSCVTY, "end");
3633}
3634
3635private function f_probe_for_handover(charstring log_label,
3636 charstring log_descr,
3637 charstring handover_vty_cmd,
3638 boolean expect_handover,
3639 boolean is_inter_bsc_handover := false)
3640runs on MSC_ConnHdlr
3641{
3642 var RSL_Message rsl;
3643
3644 var charstring log_msg := " (expecting handover)"
3645 if (not expect_handover) {
3646 log_msg := " (expecting NO handover)";
3647 }
3648 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
3649 f_vty_transceive(BSCVTY, handover_vty_cmd);
3650
3651 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
3652 * lchans to be established on bts 1 or bts 2. */
3653 f_rslem_suspend(RSL1_PROC);
3654 f_rslem_suspend(RSL2_PROC);
3655
3656 timer T := 2.0;
3657 T.start;
3658
3659 alt {
3660 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
3661 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
3662 log("Rx L3 from net: ", l3);
3663 if (ischosen(l3.msgs.rrm.handoverCommand)) {
3664 var RslChannelNr new_chan_nr;
3665 var GsmArfcn arfcn;
3666 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
3667 new_chan_nr, arfcn);
3668 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
3669 log(l3.msgs.rrm.handoverCommand);
3670
3671 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
3672 * matter on which BTS it really is, we're not going to follow through an entire handover
3673 * anyway. */
3674 f_rslem_register(0, new_chan_nr, RSL1_PROC);
3675 f_rslem_resume(RSL1_PROC);
3676 f_rslem_register(0, new_chan_nr, RSL2_PROC);
3677 f_rslem_resume(RSL2_PROC);
3678
3679 if (expect_handover and not is_inter_bsc_handover) {
3680 setverdict(pass);
3681 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
3682 } else {
3683 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
3684 & log_label & ": " & log_descr);
3685 }
3686
3687 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
3688 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
3689 * Handover Failure. */
3690 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3691
3692 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
3693 f_sleep(0.5);
3694 RSL1.clear;
3695 RSL2.clear;
3696 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
3697 break;
3698 } else {
3699 repeat;
3700 }
3701 }
3702 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
3703 if (expect_handover and is_inter_bsc_handover) {
3704 setverdict(pass);
3705 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
3706 } else {
3707 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
3708 & log_label & ": " & log_descr);
3709 }
3710
3711 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
3712
3713 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
3714 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
3715 * setting a short timeout and waiting is the only way. */
3716 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
3717 f_sleep(1.5);
3718 log("f_probe_for_handover(" & log_label & "): ...done");
3719
3720 break;
3721 }
3722 [] T.timeout {
3723 if (expect_handover) {
3724 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
3725 & log_label & ": " & log_descr);
3726 } else {
3727 setverdict(pass);
3728 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
3729 }
3730 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
3731 break;
3732 }
3733 }
3734
3735 f_rslem_resume(RSL1_PROC);
3736 f_rslem_resume(RSL2_PROC);
3737 f_sleep(3.0);
3738 RSL.clear;
3739
3740 log("f_probe_for_handover(" & log_label & "): done clearing");
3741}
3742
3743/* Test the effect of various neighbor configuration scenarios:
3744 *
3745 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
3746 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
3747 */
3748private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
3749 g_pars := f_gen_test_hdlr_pars();
3750 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3751 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3752 const OCT8 kc := '0001020304050607'O;
3753
3754 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3755 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3756
3757 /* Establish lchan at bts 0 */
3758 f_establish_fully(ass_cmd, exp_compl);
3759
3760 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
3761 f_vty_enter_cfg_network(BSCVTY);
3762 f_vty_transceive(BSCVTY, "timer T7 1");
3763 f_vty_transceive(BSCVTY, "end");
3764}
3765
3766private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
3767 f_tc_ho_neighbor_config_start();
3768
3769 /*
3770 * bts 0 ARFCN 871 BSIC 10
3771 * bts 1 ARFCN 871 BSIC 11
3772 * bts 2 ARFCN 871 BSIC 12
3773 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3774 */
3775
3776 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
3777 f_bts_0_cfg({"no neighbors"});
3778 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
3779 "handover any to arfcn 871 bsic 11",
3780 true);
3781
3782 f_probe_for_handover("1.b", "HO to unknown cell does not start",
3783 "handover any to arfcn 13 bsic 39",
3784 false);
3785
3786 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
3787 "handover any to arfcn 871 bsic 12",
3788 false);
3789
3790 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
3791 "handover any to arfcn 871 bsic 11",
3792 true);
3793}
3794private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
3795 f_tc_ho_neighbor_config_start();
3796
3797 /*
3798 * bts 0 ARFCN 871 BSIC 10
3799 * bts 1 ARFCN 871 BSIC 11
3800 * bts 2 ARFCN 871 BSIC 12
3801 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3802 */
3803
3804 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
3805 f_bts_0_cfg({"neighbor bts 1"});
3806 f_sleep(0.5);
3807
3808 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
3809 "handover any to arfcn 871 bsic 11",
3810 true);
3811
3812 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
3813 "handover any to arfcn 871 bsic 12",
3814 false);
3815}
3816private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
3817 f_tc_ho_neighbor_config_start();
3818
3819 /*
3820 * bts 0 ARFCN 871 BSIC 10
3821 * bts 1 ARFCN 871 BSIC 11
3822 * bts 2 ARFCN 871 BSIC 12
3823 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3824 */
3825
3826 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
3827 f_bts_0_cfg({"no neighbors", "neighbor bts 2"});
3828 f_sleep(0.5);
3829
3830 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
3831 "handover any to arfcn 871 bsic 11",
3832 false);
3833 f_probe_for_handover("3.b", "HO to bts 2 works, explicitly listed as neighbor; no ambiguity because bts 3 is not listed as neighbor",
3834 "handover any to arfcn 871 bsic 12",
3835 true);
3836}
3837private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
3838 f_tc_ho_neighbor_config_start();
3839
3840 /*
3841 * bts 0 ARFCN 871 BSIC 10
3842 * bts 1 ARFCN 871 BSIC 11
3843 * bts 2 ARFCN 871 BSIC 12
3844 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3845 */
3846
3847 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
3848 f_bts_0_cfg({"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
3849 f_sleep(0.5);
3850
3851 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
3852 "handover any to arfcn 871 bsic 11",
3853 false);
3854 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
3855 "handover any to arfcn 871 bsic 12",
3856 false);
3857 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
3858 "handover any to arfcn 123 bsic 45",
3859 true, true);
3860}
3861private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
3862 f_tc_ho_neighbor_config_start();
3863
3864 /*
3865 * bts 0 ARFCN 871 BSIC 10
3866 * bts 1 ARFCN 871 BSIC 11
3867 * bts 2 ARFCN 871 BSIC 12
3868 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3869 */
3870
3871 log("f_tc_ho_neighbor_config: 5. explicit remote neighbor re-using ARFCN+BSIC: 'neighbor lac 99 arfcn 871 bsic 12'");
3872 f_bts_0_cfg({"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
3873 f_sleep(0.5);
3874
3875 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
3876 "handover any to arfcn 871 bsic 12",
3877 true, true);
3878}
3879private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
3880 f_tc_ho_neighbor_config_start();
3881
3882 /*
3883 * bts 0 ARFCN 871 BSIC 10
3884 * bts 1 ARFCN 871 BSIC 11
3885 * bts 2 ARFCN 871 BSIC 12
3886 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3887 */
3888
3889 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
3890 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
3891 f_bts_0_cfg({"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
3892 f_sleep(0.5);
3893
3894 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
3895 "handover any to arfcn 871 bsic 12",
3896 false);
3897}
3898private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
3899 f_tc_ho_neighbor_config_start();
3900
3901 /*
3902 * bts 0 ARFCN 871 BSIC 10
3903 * bts 1 ARFCN 871 BSIC 11
3904 * bts 2 ARFCN 871 BSIC 12
3905 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3906 */
3907
3908 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
3909 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
3910 f_bts_0_cfg({"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
3911 f_sleep(0.5);
3912
3913 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
3914 "handover any to arfcn 871 bsic 12",
3915 true);
3916 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
3917 "handover any to arfcn 123 bsic 45",
3918 true, true);
3919}
3920
3921testcase TC_ho_neighbor_config_1() runs on test_CT {
3922 var MSC_ConnHdlr vc_conn;
3923 f_init(3, true);
3924 f_sleep(1.0);
3925 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
3926 vc_conn.done;
3927}
3928testcase TC_ho_neighbor_config_2() runs on test_CT {
3929 var MSC_ConnHdlr vc_conn;
3930 f_init(3, true);
3931 f_sleep(1.0);
3932 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
3933 vc_conn.done;
3934}
3935testcase TC_ho_neighbor_config_3() runs on test_CT {
3936 var MSC_ConnHdlr vc_conn;
3937 f_init(3, true);
3938 f_sleep(1.0);
3939 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
3940 vc_conn.done;
3941}
3942testcase TC_ho_neighbor_config_4() runs on test_CT {
3943 var MSC_ConnHdlr vc_conn;
3944 f_init(3, true);
3945 f_sleep(1.0);
3946 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
3947 vc_conn.done;
3948}
3949testcase TC_ho_neighbor_config_5() runs on test_CT {
3950 var MSC_ConnHdlr vc_conn;
3951 f_init(3, true);
3952 f_sleep(1.0);
3953 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
3954 vc_conn.done;
3955}
3956testcase TC_ho_neighbor_config_6() runs on test_CT {
3957 var MSC_ConnHdlr vc_conn;
3958 f_init(3, true);
3959 f_sleep(1.0);
3960 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
3961 vc_conn.done;
3962}
3963testcase TC_ho_neighbor_config_7() runs on test_CT {
3964 var MSC_ConnHdlr vc_conn;
3965 f_init(3, true);
3966 f_sleep(1.0);
3967 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
3968 vc_conn.done;
3969}
3970
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003971/* OS#3041: Open and close N connections in a normal fashion, and expect no
3972 * BSSMAP Reset just because of that. */
3973testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
3974 var default d;
3975 var integer i;
3976 var DchanTuple dt;
3977
3978 f_init();
3979
3980 /* Wait for initial BSSMAP Reset to pass */
3981 f_sleep(4.0);
3982
3983 d := activate(no_bssmap_reset());
3984
3985 /* Setup up a number of connections and RLSD them again from the MSC
3986 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
3987 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02003988 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003989 /* Since we're doing a lot of runs, give each one a fresh
3990 * T_guard from the top. */
3991 T_guard.start;
3992
3993 /* Setup a BSSAP connection and clear it right away. This is
3994 * the MSC telling the BSC about a planned release, it's not an
3995 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02003996 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003997
3998 /* MSC disconnects (RLSD). */
3999 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
4000 }
4001
4002 /* In the buggy behavior, a timeout of 2 seconds happens between above
4003 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4004 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4005 f_sleep(4.0);
4006
4007 deactivate(d);
4008 f_shutdown_helper();
4009}
Harald Welte552620d2017-12-16 23:21:36 +01004010
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004011/* OS#3041: Open and close N connections in a normal fashion, and expect no
4012 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
4013 * the MSC. */
4014testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
4015 var default d;
4016 var integer i;
4017 var DchanTuple dt;
4018 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004019 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
4020 var BssmapCause cause := enum2int(cause_val);
4021
4022 f_init();
4023
4024 /* Wait for initial BSSMAP Reset to pass */
4025 f_sleep(4.0);
4026
4027 d := activate(no_bssmap_reset());
4028
4029 /* Setup up a number of connections and RLSD them again from the MSC
4030 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4031 * Let's do it some more times for good measure. */
4032 for (i := 0; i < 8; i := i+1) {
4033 /* Since we're doing a lot of runs, give each one a fresh
4034 * T_guard from the top. */
4035 T_guard.start;
4036
4037 /* Setup a BSSAP connection and clear it right away. This is
4038 * the MSC telling the BSC about a planned release, it's not an
4039 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004040 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004041
4042 /* Instruct BSC to clear channel */
4043 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4044
4045 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004046 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004047 }
4048
4049 /* In the buggy behavior, a timeout of 2 seconds happens between above
4050 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4051 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4052 f_sleep(4.0);
4053
4054 deactivate(d);
4055 f_shutdown_helper();
4056}
4057
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004058/* OS#3041: Open and close N connections in a normal fashion, and expect no
4059 * BSSMAP Reset just because of that. Close connections from the MS side with a
4060 * Release Ind on RSL. */
4061testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
4062 var default d;
4063 var integer i;
4064 var DchanTuple dt;
4065 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004066 var integer j;
4067
4068 f_init();
4069
4070 /* Wait for initial BSSMAP Reset to pass */
4071 f_sleep(4.0);
4072
4073 d := activate(no_bssmap_reset());
4074
4075 /* Setup up a number of connections and RLSD them again from the MSC
4076 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4077 * Let's do it some more times for good measure. */
4078 for (i := 0; i < 8; i := i+1) {
4079 /* Since we're doing a lot of runs, give each one a fresh
4080 * T_guard from the top. */
4081 T_guard.start;
4082
4083 /* Setup a BSSAP connection and clear it right away. This is
4084 * the MSC telling the BSC about a planned release, it's not an
4085 * erratic loss of a connection. */
4086 dt := f_est_dchan('23'O, 23, '00010203040506'O);
4087
4088 /* simulate RLL REL IND */
4089 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
4090
4091 /* expect Clear Request on MSC side */
4092 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
4093
4094 /* Instruct BSC to clear channel */
4095 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
4096 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4097
4098 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004099 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004100 }
4101
4102 /* In the buggy behavior, a timeout of 2 seconds happens between above
4103 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4104 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4105 f_sleep(4.0);
4106
4107 deactivate(d);
4108 f_shutdown_helper();
4109}
4110
Harald Welte94e0c342018-04-07 11:33:23 +02004111/***********************************************************************
4112 * IPA style dynamic PDCH
4113 ***********************************************************************/
4114
4115private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4116 template (omit) RSL_Cause nack := omit)
4117runs on test_CT {
4118 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4119 var RSL_Message rsl_unused;
4120 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4121 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
4122 /* expect the BSC to issue the related RSL command */
4123 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4124 if (istemplatekind(nack, "omit")) {
4125 /* respond with a related acknowledgement */
4126 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4127 } else {
4128 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
4129 }
4130}
4131
4132private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4133 template (omit) RSL_Cause nack := omit)
4134runs on test_CT {
4135 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4136 var RSL_Message rsl_unused;
4137 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4138 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
4139 /* expect the BSC to issue the related RSL command */
4140 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
4141 if (istemplatekind(nack, "omit")) {
4142 /* respond with a related acknowledgement */
4143 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
4144 } else {
4145 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
4146 }
4147}
4148
4149private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
4150runs on test_CT return charstring {
4151 var charstring cmd, resp;
4152 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01004153 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02004154}
4155
4156private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
4157 template charstring exp)
4158runs on test_CT {
4159 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
4160 if (not match(mode, exp)) {
4161 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02004162 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02004163 }
4164}
4165
4166private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
4167runs on test_CT {
4168 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
4169 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
4170 f_vty_transceive(BSCVTY, "end");
4171}
4172
4173private const charstring TCHF_MODE := "TCH/F mode";
4174private const charstring TCHH_MODE := "TCH/H mode";
4175private const charstring PDCH_MODE := "PDCH mode";
4176private const charstring NONE_MODE := "NONE mode";
4177
4178/* Test IPA PDCH activation / deactivation triggered by VTY */
4179testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
4180 var RSL_Message rsl_unused;
4181
4182 /* change Timeslot 6 before f_init() starts RSL */
4183 f_init_vty();
4184 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4185 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4186
4187 f_init(1, false);
4188 f_sleep(1.0);
4189
4190 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4191
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004192 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004193 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4194 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4195 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4196 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4197 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004198 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004199 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4200
4201 /* De-activate it via VTY */
4202 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4203 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004204 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004205 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4206
4207 /* re-activate it via VTY */
4208 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
4209 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004210 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004211 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4212
4213 /* and finally de-activate it again */
4214 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4215 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004216 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004217 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4218
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004219 /* clean up config */
4220 f_ts_set_chcomb(0, 0, 6, "PDCH");
4221
Harald Welte94e0c342018-04-07 11:33:23 +02004222 setverdict(pass);
4223}
4224
4225/* Test IPA PDCH activation NACK */
4226testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
4227 var RSL_Message rsl_unused;
4228
4229 /* change Timeslot 6 before f_init() starts RSL */
4230 f_init_vty();
4231 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4232 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4233
4234 f_init(1, false);
4235 f_sleep(1.0);
4236
4237 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4238
4239 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4240 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4241 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4242 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4243 f_sleep(1.0);
4244 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4245
4246 /* De-activate it via VTY */
4247 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4248 f_sleep(1.0);
4249 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4250
4251 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
4252 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
4253 f_sleep(1.0);
4254 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4255
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004256 /* clean up config */
4257 f_ts_set_chcomb(0, 0, 6, "PDCH");
4258
Harald Welte94e0c342018-04-07 11:33:23 +02004259 setverdict(pass);
4260}
4261
4262
4263/***********************************************************************
4264 * Osmocom style dynamic PDCH
4265 ***********************************************************************/
4266
4267private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4268 template (omit) RSL_Cause nack := omit)
4269runs on test_CT {
4270 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4271 var RSL_Message rsl_unused;
4272 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4273 /* FIXME: no VTY command to activate Osmocom PDCH !! */
4274 /* expect the BSC to issue the related RSL command */
4275 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
4276 if (istemplatekind(nack, "omit")) {
4277 /* respond with a related acknowledgement */
4278 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
4279 } else {
4280 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
4281 }
4282}
4283
4284private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4285 template (omit) RSL_Cause nack := omit)
4286runs on test_CT {
4287 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4288 var RSL_Message rsl_unused;
4289 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4290 /* FIXME: no VTY command to activate Osmocom PDCH !! */
4291 /* expect the BSC to issue the related RSL command */
4292 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
4293 if (istemplatekind(nack, "omit")) {
4294 /* respond with a related acknowledgement */
4295 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
4296 } else {
4297 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
4298 }
4299}
4300
4301/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
4302testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
4303 var RSL_Message rsl_unused;
4304
4305 /* change Timeslot 6 before f_init() starts RSL */
4306 f_init_vty();
4307 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
4308 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4309
4310 f_init(1, false);
4311 f_sleep(1.0);
4312
4313 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
4314
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004315 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004316 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4317 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4318 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
4319
4320 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
4321 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004322 log("TCH/F_TCH/H_PDCH requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
Harald Welte94e0c342018-04-07 11:33:23 +02004323 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4324
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004325 /* clean up config */
4326 f_ts_set_chcomb(0, 0, 6, "PDCH");
4327
Harald Welte94e0c342018-04-07 11:33:23 +02004328 setverdict(pass);
4329}
4330
4331/* Test Osmocom dyn PDCH activation NACK behavior */
4332testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
4333 var RSL_Message rsl_unused;
4334
4335 /* change Timeslot 6 before f_init() starts RSL */
4336 f_init_vty();
4337 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
4338 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4339
4340 f_init(1, false);
4341 f_sleep(1.0);
4342
4343 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
4344
4345 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4346 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4347 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
4348
4349 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
4350 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
4351 f_sleep(1.0);
4352 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4353
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004354 /* clean up config */
4355 f_ts_set_chcomb(0, 0, 6, "PDCH");
4356
Harald Welte94e0c342018-04-07 11:33:23 +02004357 setverdict(pass);
4358}
4359
Stefan Sperling0796a822018-10-05 13:01:39 +02004360testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02004361 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02004362 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
4363 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
4364 }
4365}
4366
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004367testcase TC_chopped_ipa_payload() runs on test_CT {
4368 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
4369 /* TODO: mp_bsc_ctrl_port does not work yet */};
4370 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
4371 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
4372 }
4373}
4374
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01004375/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
4376 the BTS does autonomous MS power control loop */
4377testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
4378 var MSC_ConnHdlr vc_conn;
4379 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4380 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
4381 pars.exp_ms_power_params := true;
4382
4383 f_init(1, true);
4384 f_sleep(1.0);
4385 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
4386 vc_conn.done;
4387}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004388
Harald Welte0ea2d5e2018-04-07 21:40:29 +02004389/* Dyn PDCH todo:
4390 * activate OSMO as TCH/F
4391 * activate OSMO as TCH/H
4392 * does the BSC-located PCU socket get the updated INFO?
4393 * what if no PCU is connected at the time?
4394 * is the info correct on delayed PCU (re)connect?
4395 */
Harald Welte94e0c342018-04-07 11:33:23 +02004396
Harald Welte28d943e2017-11-25 15:00:50 +01004397control {
Harald Welte898113b2018-01-31 18:32:21 +01004398 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01004399 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01004400 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01004401 execute( TC_ctrl() );
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02004402 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
4403 execute( TC_ctrl_location() );
4404 }
Harald Welte898113b2018-01-31 18:32:21 +01004405
4406 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01004407 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01004408 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01004409 execute( TC_chan_act_ack_noest() );
4410 execute( TC_chan_act_ack_est_ind_noreply() );
4411 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01004412 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01004413 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07004414 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01004415 execute( TC_chan_rel_rll_rel_ind() );
4416 execute( TC_chan_rel_conn_fail() );
4417 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01004418 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01004419 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02004420 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01004421 execute( TC_chan_rel_a_reset() );
Harald Welte6f521d82017-12-11 19:52:02 +01004422
Harald Weltecfe2c962017-12-15 12:09:32 +01004423 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01004424
4425 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01004426 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01004427 execute( TC_assignment_csd() );
4428 execute( TC_assignment_ctm() );
4429 execute( TC_assignment_sign() );
4430 execute( TC_assignment_fr_a5_0() );
4431 execute( TC_assignment_fr_a5_1() );
Harald Welte8f67d1d2018-05-25 20:38:42 +02004432 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
4433 execute( TC_assignment_fr_a5_1_codec_missing() );
4434 }
Harald Welte235ebf12017-12-15 14:18:16 +01004435 execute( TC_assignment_fr_a5_3() );
4436 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02004437 execute( TC_ciph_mode_a5_0() );
4438 execute( TC_ciph_mode_a5_1() );
4439 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01004440
Harald Welte60aa5762018-03-21 19:33:13 +01004441 execute( TC_assignment_codec_fr() );
4442 execute( TC_assignment_codec_hr() );
4443 execute( TC_assignment_codec_efr() );
4444 execute( TC_assignment_codec_amr_f() );
4445 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01004446
4447 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
4448 execute( TC_assignment_codec_amr_f_S1() );
4449 execute( TC_assignment_codec_amr_h_S1() );
4450 execute( TC_assignment_codec_amr_f_S124() );
4451 execute( TC_assignment_codec_amr_h_S124() );
4452 execute( TC_assignment_codec_amr_f_S0() );
4453 execute( TC_assignment_codec_amr_f_S02() );
4454 execute( TC_assignment_codec_amr_f_S024() );
4455 execute( TC_assignment_codec_amr_f_S0247() );
4456 execute( TC_assignment_codec_amr_h_S0() );
4457 execute( TC_assignment_codec_amr_h_S02() );
4458 execute( TC_assignment_codec_amr_h_S024() );
4459 execute( TC_assignment_codec_amr_h_S0247() );
4460 execute( TC_assignment_codec_amr_f_S01234567() );
4461 execute( TC_assignment_codec_amr_f_S0234567() );
4462 execute( TC_assignment_codec_amr_f_zero() );
4463 execute( TC_assignment_codec_amr_f_unsupp() );
4464 execute( TC_assignment_codec_amr_h_S7() );
4465 }
Harald Welte60aa5762018-03-21 19:33:13 +01004466
Philipp Maierac09bfc2019-01-08 13:41:39 +01004467 execute( TC_assignment_codec_fr_exhausted_req_hr() );
4468 execute( TC_assignment_codec_fr_exhausted_req_fr() );
4469 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
4470 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
4471 execute( TC_assignment_codec_hr_exhausted_req_fr() );
4472 execute( TC_assignment_codec_hr_exhausted_req_hr() );
4473 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
4474 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
4475 execute( TC_assignment_codec_req_hr_fr() );
4476 execute( TC_assignment_codec_req_fr_hr() );
4477
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02004478 if (mp_enable_osmux_test) {
4479 execute( TC_assignment_osmux() );
4480 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004481
Harald Welte898113b2018-01-31 18:32:21 +01004482 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01004483 execute( TC_rll_est_ind_inact_lchan() );
4484 execute( TC_rll_est_ind_inval_sapi1() );
4485 execute( TC_rll_est_ind_inval_sapi3() );
4486 execute( TC_rll_est_ind_inval_sacch() );
4487
Harald Welte898113b2018-01-31 18:32:21 +01004488 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01004489 execute( TC_paging_imsi_nochan() );
4490 execute( TC_paging_tmsi_nochan() );
4491 execute( TC_paging_tmsi_any() );
4492 execute( TC_paging_tmsi_sdcch() );
4493 execute( TC_paging_tmsi_tch_f() );
4494 execute( TC_paging_tmsi_tch_hf() );
4495 execute( TC_paging_imsi_nochan_cgi() );
4496 execute( TC_paging_imsi_nochan_lac_ci() );
4497 execute( TC_paging_imsi_nochan_ci() );
4498 execute( TC_paging_imsi_nochan_lai() );
4499 execute( TC_paging_imsi_nochan_lac() );
4500 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01004501 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
4502 execute( TC_paging_imsi_nochan_rnc() );
4503 execute( TC_paging_imsi_nochan_lac_rnc() );
4504 execute( TC_paging_imsi_nochan_lacs() );
4505 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01004506 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01004507 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01004508 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01004509 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01004510 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01004511
4512 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01004513 execute( TC_rsl_unknown_unit_id() );
4514
4515 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01004516
4517 execute( TC_classmark() );
4518 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01004519 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004520 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01004521 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01004522 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004523
Harald Welte261af4b2018-02-12 21:20:39 +01004524 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004525
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004526 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004527 execute( TC_ho_out_fail_no_msc_response() );
4528 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004529 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004530
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004531 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004532 execute( TC_ho_in_fail_msc_clears() );
4533 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
4534 execute( TC_ho_in_fail_no_detect() );
4535 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004536
Neels Hofmeyr91401012019-07-11 00:42:35 +02004537 execute( TC_ho_neighbor_config_1() );
4538 execute( TC_ho_neighbor_config_2() );
4539 execute( TC_ho_neighbor_config_3() );
4540 execute( TC_ho_neighbor_config_4() );
4541 execute( TC_ho_neighbor_config_5() );
4542 execute( TC_ho_neighbor_config_6() );
4543 execute( TC_ho_neighbor_config_7() );
4544
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004545 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004546 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004547 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02004548
4549 execute( TC_dyn_pdch_ipa_act_deact() );
4550 execute( TC_dyn_pdch_ipa_act_nack() );
4551 execute( TC_dyn_pdch_osmo_act_deact() );
4552 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004553
Stefan Sperling0796a822018-10-05 13:01:39 +02004554 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004555 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02004556
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01004557 /* Power control related */
4558 execute( TC_assignment_verify_ms_power_params_ie() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004559 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
4560 execute( TC_early_conn_fail() );
4561 execute( TC_late_conn_fail() );
4562
Harald Welte28d943e2017-11-25 15:00:50 +01004563}
4564
4565}