blob: d020d953827b58dc0eb2326014b550c05cc80ce6 [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
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100100 /*Configure T(tias) over VTY, seconds */
101 var integer g_bsc_sccp_timer_ias := 7 * 60;
102 /*Configure T(tiar) over VTY, seconds */
103 var integer g_bsc_sccp_timer_iar := 15 * 60;
104
Harald Welte21b46bd2017-12-17 19:46:32 +0100105 /* global test case guard timer */
Harald Welteae026692017-12-09 01:03:01 +0100106 timer T_guard := 30.0;
107
Harald Welte28d943e2017-11-25 15:00:50 +0100108}
109
110modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100111 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100112 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100113 /* port number to which to establish the IPA OML connections */
114 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100115 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100116 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100117 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100118 integer mp_bsc_ctrl_port := 4249;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100119 /* IP address at which the test binds */
120 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100121
Harald Welte6811d102019-04-14 22:23:14 +0200122 RAN_Configuration mp_bssap_cfg := {
Harald Welte7ef51aa2018-04-16 19:16:01 +0200123 transport := BSSAP_TRANSPORT_AoIP,
Harald Weltea4ca4462018-02-09 00:17:14 +0100124 sccp_service_type := "mtp3_itu",
125 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
126 own_pc := 185,
127 own_ssn := 254,
128 peer_pc := 187,
129 peer_ssn := 254,
Philipp Maier38d68942018-03-29 15:38:09 +0200130 sio := '83'O,
131 rctx := 0
Harald Weltea4ca4462018-02-09 00:17:14 +0100132 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200133
134 /* Whether to enable osmux tests. Can be dropped completely and enable
135 unconditionally once new version of osmo-bsc is released (current
136 version: 1.4.1) */
137 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100138 /* Value set in osmo-bsc.cfg "ms max power" */
139 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100140}
141
Philipp Maier48604732018-10-09 15:00:37 +0200142private function f_gen_test_hdlr_pars() return TestHdlrParams {
143
144 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
145 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
146 pars.aoip := true;
147 } else {
148 pars.aoip := false;
149 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100150 pars.exp_ms_power_level := mp_exp_ms_power_level;
Philipp Maier48604732018-10-09 15:00:37 +0200151
152 return pars;
153}
154
Philipp Maier282ca4b2018-02-27 17:17:00 +0100155private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200156 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100157 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200158 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100159}
160
Harald Weltea4ca4462018-02-09 00:17:14 +0100161private function f_legacy_bssap_reset() runs on test_CT {
162 var BSSAP_N_UNITDATA_ind ud_ind;
163 timer T := 5.0;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200164 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 +0100165 T.start;
166 alt {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200167 [] 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 +0100168 log("Received RESET-ACK in response to RESET, we're ready to go!");
169 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200170 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100171 log("Respoding to inbound RESET with RESET-ACK");
172 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200173 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100174 repeat;
175 }
176 [] BSSAP.receive { repeat; }
177 [] T.timeout { setverdict(fail, "Waiting for RESET-ACK after sending RESET"); }
178 }
Harald Welte28d943e2017-11-25 15:00:50 +0100179}
180
Harald Welteae026692017-12-09 01:03:01 +0100181type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100182 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100183 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100184 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100185 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100186 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100187 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100188 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100189 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100190}
191
Harald Welte21b46bd2017-12-17 19:46:32 +0100192/*! Start the IPA/RSL related bits for one IPA_Client.
193 * \param clnt IPA_Client for which to establish
194 * \param bsc_host IP address / hostname of the BSC
195 * \param bsc_port TCP port number of the BSC
196 * \param i number identifying this BTS
197 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100198function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
199 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100200runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100201 timer T := 10.0;
202
Harald Welte96c94412017-12-09 03:12:45 +0100203 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100204 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
205 clnt.ccm_pars := c_IPA_default_ccm_pars;
206 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
207 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100208 if (handler_mode) {
209 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100210 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100211 }
Harald Welteae026692017-12-09 01:03:01 +0100212
213 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100214 if (handler_mode) {
215 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
216 } else {
217 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
218 }
Harald Welteae026692017-12-09 01:03:01 +0100219
Harald Welte5d1a2202017-12-13 19:51:29 +0100220 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100221 if (handler_mode) {
222 clnt.vc_RSL.start(RSL_Emulation.main());
223 return;
224 }
Harald Welteae026692017-12-09 01:03:01 +0100225
226 /* wait for IPA RSL link to connect and send ID ACK */
227 T.start;
228 alt {
229 [] IPA_RSL[i].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_ID_ACK}) {
230 T.stop;
231 IPA_RSL[i].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23)));
232 }
Harald Welte60e823a2017-12-10 14:10:59 +0100233 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100234 [] IPA_RSL[i].receive { repeat }
235 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100236 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200237 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100238 }
239 }
240}
241
Harald Welte12055472018-03-17 20:10:08 +0100242function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
243 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
244 return;
245 }
246 clnt.vc_IPA.stop;
247 if (isbound(clnt.vc_RSL)) {
248 clnt.vc_RSL.stop;
249 }
250}
251
Harald Welte21b46bd2017-12-17 19:46:32 +0100252/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100253function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
254 timer T := secs_max;
255 T.start;
256 while (true) {
257 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
258 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100259 /* the 'degraded' state exists from OML connection time, and we have to wait
260 * until all MO's are initialized */
261 T.start(1.0);
262 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100263 return;
264 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100265 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100266 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100267 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200268 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100269 }
270 }
271}
272
Harald Welte21b46bd2017-12-17 19:46:32 +0100273/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100274altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100275 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100276 [] T_guard.timeout {
277 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200278 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100279 }
Harald Welte60e823a2017-12-10 14:10:59 +0100280 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200281 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100282 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200283 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100284 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100285 }
Harald Welte28d943e2017-11-25 15:00:50 +0100286}
287
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100288altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200289 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100290 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200291 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100292 }
293}
294
Daniel Willmann191e0d92018-01-17 12:44:35 +0100295function f_init_mgcp(charstring id) runs on test_CT {
296 id := id & "-MGCP";
297
298 var MGCPOps ops := {
299 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
300 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
301 };
302 var MGCP_conn_parameters mgcp_pars := {
303 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100304 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100305 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200306 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200307 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
308 the on with MGCP over IPA forwarded from MSC one) */
309 multi_conn_mode := (mp_bssap_cfg.transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100310 };
311
312 vc_MGCP := MGCP_Emulation_CT.create(id);
313 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
314}
315
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200316/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
317 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
318 * OsmuxCID IE.
319 */
320private function f_vty_allow_osmux(boolean allow) runs on test_CT {
321 f_vty_enter_cfg_msc(BSCVTY, 0);
322 if (allow) {
323 f_vty_transceive(BSCVTY, "osmux on");
324 } else {
325 f_vty_transceive(BSCVTY, "osmux off");
326 }
327 f_vty_transceive(BSCVTY, "exit");
328 f_vty_transceive(BSCVTY, "exit");
329 g_osmux_enabled := allow;
330}
331
Max2253c0b2018-11-06 19:28:05 +0100332function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200333 if (BSCVTY.checkstate("Mapped")) {
334 /* skip initialization if already executed once */
335 return;
336 }
Harald Weltebc03c762018-02-12 18:09:38 +0100337 map(self:BSCVTY, system:BSCVTY);
338 f_vty_set_prompts(BSCVTY);
339 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100340 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
341 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100342}
343
Harald Welte21b46bd2017-12-17 19:46:32 +0100344/* global initialization function
345 * \param nr_bts Number of BTSs we should start/bring up
346 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200347function 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 +0100348 var integer i;
Harald Welte28d943e2017-11-25 15:00:50 +0100349
Harald Welteae026692017-12-09 01:03:01 +0100350 if (g_initialized) {
351 return;
Harald Welte28d943e2017-11-25 15:00:50 +0100352 }
Harald Welteae026692017-12-09 01:03:01 +0100353 g_initialized := true;
354
Daniel Willmanne68f9272018-11-27 15:15:28 +0100355 T_guard.start;
356 activate(as_Tguard());
357
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200358 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200359 if (mp_enable_osmux_test) {
360 f_vty_allow_osmux(allow_osmux);
361 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200362
Harald Welte6811d102019-04-14 22:23:14 +0200363 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
Harald Welteae026692017-12-09 01:03:01 +0100364 * MSC-side BSSAP emulation */
Harald Welte67089ee2018-01-17 22:19:03 +0100365 if (handler_mode) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200366 var RanOps ranops := MSC_RanOps;
367 ranops.use_osmux := g_osmux_enabled;
368 f_ran_adapter_init(g_bssap, mp_bssap_cfg, "VirtMSC", ranops);
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200369 connect(self:SCCPLITE_IPA_CTRL, g_bssap.vc_RAN:CTRL_CLIENT);
Harald Welte3ca0ce12019-04-23 17:18:48 +0200370 f_ran_adapter_start(g_bssap);
Harald Welte67089ee2018-01-17 22:19:03 +0100371 } else {
Harald Welte3ca0ce12019-04-23 17:18:48 +0200372 f_ran_adapter_init(g_bssap, mp_bssap_cfg, "VirtMSC", omit);
Harald Weltea4ca4462018-02-09 00:17:14 +0100373 connect(self:BSSAP, g_bssap.vc_SCCP:SCCP_SP_PORT);
Harald Welte3ca0ce12019-04-23 17:18:48 +0200374 f_ran_adapter_start(g_bssap);
Harald Weltea4ca4462018-02-09 00:17:14 +0100375 f_legacy_bssap_reset();
Harald Welte67089ee2018-01-17 22:19:03 +0100376 }
Harald Welted5833a82018-05-27 16:52:56 +0200377
Harald Welteffe55fc2018-01-17 22:39:54 +0100378 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +0100379
Daniel Willmann191e0d92018-01-17 12:44:35 +0100380 f_init_mgcp("VirtMSC");
381
Harald Welte89d42e82017-12-17 16:42:41 +0100382 for (i := 0; i < nr_bts; i := i+1) {
Harald Weltea5d2ab22017-12-09 14:21:42 +0100383 /* wait until osmo-bts-omldummy has respawned */
384 f_wait_oml(i, "degraded", 5.0);
385 /* start RSL connection */
Harald Welte624f9632017-12-16 19:26:04 +0100386 f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i, handler_mode);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100387 /* wait until BSC tells us "connected" */
388 f_wait_oml(i, "connected", 5.0);
Harald Welte696ddb62017-12-08 14:01:43 +0100389 }
390
Harald Welte28d943e2017-11-25 15:00:50 +0100391}
392
Maxd4e56962018-10-31 19:08:25 +0100393/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welteae026692017-12-09 01:03:01 +0100394function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
395runs on test_CT return RSL_Message {
396 var ASP_RSL_Unitdata rx_rsl_ud;
397 timer T := t_secs;
398
399 T.start;
400 alt {
401 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud {
402 T.stop;
403 }
404 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +0100405 [] T.timeout {
406 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +0200407 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +0100408 }
Harald Welteae026692017-12-09 01:03:01 +0100409 }
410 return rx_rsl_ud.rsl;
411}
412
Harald Welte21b46bd2017-12-17 19:46:32 +0100413/* helper function to transmit RSL on a given BTS/stream */
Harald Welteae026692017-12-09 01:03:01 +0100414function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
415runs on test_CT {
416 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx));
417}
418
419
Harald Welte4003d112017-12-09 22:35:39 +0100420/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +0100421testcase TC_chan_act_noreply() runs on test_CT {
422 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +0100423 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +0100424
Harald Welte89d42e82017-12-17 16:42:41 +0100425 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +0100426
Harald Welteae026692017-12-09 01:03:01 +0100427 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 +0100428 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welteae026692017-12-09 01:03:01 +0100429 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +0100430}
431
Harald Welte4003d112017-12-09 22:35:39 +0100432/* verify if the "chreq:total" counter increments as expected */
433testcase TC_chan_act_counter() runs on test_CT {
434 var BSSAP_N_UNITDATA_ind ud_ind;
435 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +0100436 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +0100437
Harald Welte89d42e82017-12-17 16:42:41 +0100438 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100439
440 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
441 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 +0100442 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +0100443 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
444
445 setverdict(pass);
446}
447
Harald Welteae026692017-12-09 01:03:01 +0100448/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
449testcase TC_chan_act_ack_noest() runs on test_CT {
450 var RSL_Message rx_rsl;
451
Harald Welte89d42e82017-12-17 16:42:41 +0100452 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100453
454 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100455 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100456
457 /* expect BSC to disable the channel again if there's no RLL EST IND */
458 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
459
460 setverdict(pass);
461}
462
463/* Test behavior if MSC never answers to CR */
464testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +0100465 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
466 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +0100467 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +0100468 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +0100469
Harald Welte89d42e82017-12-17 16:42:41 +0100470 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100471
472 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100473 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100474
475 var octetstring l3 := '00010203040506'O
476 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
477
478 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
479
480 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +0100481 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100482 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +0100483 setverdict(pass);
484}
485
486/* Test behavior if MSC answers with CREF to CR */
487testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
488 var BSSAP_N_CONNECT_ind rx_c_ind;
489 var RSL_Message rx_rsl;
490
Harald Welte89d42e82017-12-17 16:42:41 +0100491 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100492
493 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100494 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100495
496 var octetstring l3 := '00010203040506'O
497 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
498
499 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
500 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
501
502 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100503 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +0100504 setverdict(pass);
505}
506
Harald Welte618ef642017-12-14 14:58:20 +0100507/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
508testcase TC_chan_act_nack() runs on test_CT {
509 var RSL_Message rx_rsl;
510 var integer chact_nack;
511
Harald Welte89d42e82017-12-17 16:42:41 +0100512 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +0100513
514 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
515
516 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
517 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
518 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
519
520 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
521
522 /* wait for some time to hope the NACK arrives before the CTRL GET below */
523 f_sleep(0.5);
524
525 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
526
527 setverdict(pass);
528}
529
Harald Welte799c97b2017-12-14 17:50:30 +0100530/* Test for channel exhaustion due to RACH overload */
531testcase TC_chan_exhaustion() runs on test_CT {
532 var ASP_RSL_Unitdata rsl_ud;
533 var integer i;
534 var integer chreq_total, chreq_nochan;
535
Harald Welte89d42e82017-12-17 16:42:41 +0100536 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +0100537
538 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
539 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
540
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +0100541 /* GSM 04.08 Table 9.9a:
542 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
543 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +0200544 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 +0100545 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +0100546 }
547
548 IPA_RSL[0].clear;
549
Harald Weltedd8cbf32018-01-28 12:07:52 +0100550 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200551 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +0100552
553 /* now expect additional channel activations to fail */
554 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
555
556 alt {
557 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
558 tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
559 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
560 }
561 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
562 var GsmRrMessage rr;
563 /* match on IMM ASS REJ */
564 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
565 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
566 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200567 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +0100568 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
569 chreq_nochan+1);
570 setverdict(pass);
571 } else {
572 repeat;
573 }
574 }
575 [] IPA_RSL[0].receive { repeat; }
576 }
577}
578
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +0700579/* Test channel deactivation due to silence from MS */
580testcase TC_chan_deact_silence() runs on test_CT {
581 var RslChannelNr chan_nr;
582
583 f_init(1);
584
585 /* Request for a dedicated channel */
586 chan_nr := f_chreq_act_ack('23'O);
587
588 /* Wait some time until the channel is released */
589 f_sleep(2.0);
590
591 /* Expect CHANnel RELease */
592 alt {
593 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
594 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
595 log("Received CHANnel RELease");
596 setverdict(pass);
597 }
598 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
599 tr_RSL_IMM_ASSIGN(?))) {
600 /* See OS#3709, OsmoBSC should not send Immediate
601 * Assignment Reject since a dedicated channel was
602 * already allocated, and Immediate Assignment was
603 * already sent. */
604 setverdict(fail, "Unexpected Immediate Assignment!");
605 }
606 [] IPA_RSL[0].receive {
607 setverdict(fail, "Unexpected RSL message!");
608 }
609 }
610}
611
Harald Weltecfe2c962017-12-15 12:09:32 +0100612/***********************************************************************
613 * Assignment Testing
614 ***********************************************************************/
615
Neels Hofmeyrda4a6952018-06-14 04:02:49 +0200616/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
617 * except for the inter-BSC handover, MT side) */
Harald Weltecfe2c962017-12-15 12:09:32 +0100618testcase TC_outbound_connect() runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +0100619 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +0100620
Harald Weltea4ca4462018-02-09 00:17:14 +0100621 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 +0100622 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
623 setverdict(pass);
624}
625
Harald Welte16a4adf2017-12-14 18:54:01 +0100626/* Test behavior if MSC answers with CREF to CR */
627testcase TC_assignment_cic_only() runs on test_CT {
628 var BSSAP_N_CONNECT_ind rx_c_ind;
629 var RSL_Message rx_rsl;
630 var DchanTuple dt;
631
Harald Welte89d42e82017-12-17 16:42:41 +0100632 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +0100633
634 dt := f_est_dchan('23'O, 23, '00000000'O);
Harald Welte17b27da2018-05-25 20:33:53 +0200635 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
636 /* send assignment without AoIP IEs */
637 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
638 } else {
639 /* Send assignmetn without CIC in IPA case */
640 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
641 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
642 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
643 }
Harald Welte16a4adf2017-12-14 18:54:01 +0100644 alt {
645 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
646 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
647 }
Harald Welte235ebf12017-12-15 14:18:16 +0100648 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +0100649 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
650 setverdict(pass);
651 }
652 [] BSSAP.receive { repeat; }
653 }
654}
655
Harald Welteed848512018-05-24 22:27:58 +0200656/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200657function f_gen_ass_req(boolean osmux_enabled := false) return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200658 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200659 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Harald Welteed848512018-05-24 22:27:58 +0200660 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
661 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
662 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200663 if (osmux_enabled) {
664 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
665 } else {
666 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
667 }
Harald Welteed848512018-05-24 22:27:58 +0200668 } else {
669 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +0200670 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +0200671 }
672 return ass_cmd;
673}
674
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100675function f_gen_handover_req() return PDU_BSSAP {
676 var PDU_BSSAP ho_req;
677 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
678 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
679 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
680 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
681 } else {
682 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
683 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
684 }
685 return ho_req;
686}
687
Harald Welteed848512018-05-24 22:27:58 +0200688/* generate an assignment complete template for either AoIP or SCCPlite */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200689function f_gen_exp_compl(boolean expect_osmux := false) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200690 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200691 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Harald Welteed848512018-05-24 22:27:58 +0200692 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200693 if (expect_osmux) {
694 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
695 } else {
696 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
697 }
Harald Welteed848512018-05-24 22:27:58 +0200698 } else {
699 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +0200700 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +0200701 }
702 return exp_compl;
703}
704
Harald Welte235ebf12017-12-15 14:18:16 +0100705/* Run everything required up to sending a caller-specified assignment command and expect response */
706function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
707runs on test_CT {
708 var BSSAP_N_CONNECT_ind rx_c_ind;
709 var RSL_Message rx_rsl;
710 var DchanTuple dt;
711
Harald Welte89d42e82017-12-17 16:42:41 +0100712 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +0100713
714 dt := f_est_dchan('23'O, 23, '00000000'O);
715 /* send assignment without AoIP IEs */
716 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
717 alt {
718 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
719 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
720 setverdict(pass);
721 } else {
722 setverdict(fail, fail_text);
723 }
724 }
725 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
726 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
727 setverdict(pass);
728 } else {
729 setverdict(fail, fail_text);
730 }
731 }
732 [] BSSAP.receive { repeat; }
733 }
734}
735testcase TC_assignment_csd() runs on test_CT {
736 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200737 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100738 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
739 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
740 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
741}
742
743testcase TC_assignment_ctm() runs on test_CT {
744 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200745 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100746 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
747 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
748 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
749}
750
Harald Welte4003d112017-12-09 22:35:39 +0100751type record DchanTuple {
752 integer sccp_conn_id,
753 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +0100754}
755
Harald Welted6939652017-12-13 21:02:46 +0100756/* Send CHAN RQD and wait for allocation; acknowledge it */
757private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
758runs on test_CT return RslChannelNr {
759 var RSL_Message rx_rsl;
760 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
761 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
762 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
763 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +0200764 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +0100765 return chan_nr;
766}
767
Harald Welte4003d112017-12-09 22:35:39 +0100768/* helper function to establish a dedicated channel via BTS and MSC */
769function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
770runs on test_CT return DchanTuple {
771 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +0100772 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100773
Harald Welte4003d112017-12-09 22:35:39 +0100774 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100775 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +0100776
777 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
778
779 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
780 dt.sccp_conn_id := rx_c_ind.connectionId;
781 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
782
783 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100784}
785
Harald Welte641fcbe2018-06-14 10:58:35 +0200786/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
787private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
788 var RSL_Message rx_rsl;
789 /* expect BSC to disable the channel */
790 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
791 /* respond with CHAN REL ACK */
792 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
793
794 /* expect Clear Complete from BSC */
795 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
796
797 /* MSC disconnects as instructed. */
798 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
799}
800
Harald Welte4003d112017-12-09 22:35:39 +0100801/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
802testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100803 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100804 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +0100805
Harald Welte89d42e82017-12-17 16:42:41 +0100806 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +0100807
Harald Welte4003d112017-12-09 22:35:39 +0100808 dt := f_est_dchan('23'O, 23, '00010203040506'O);
809
810 /* simulate RLL REL IND */
811 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
812
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100813 /* expect Clear Request on MSC side */
814 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
815
816 /* Instruct BSC to clear channel */
817 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
818 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
819
Harald Welte4003d112017-12-09 22:35:39 +0100820 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +0200821 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100822
823 /* wait for SCCP emulation to do its job */
824 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +0100825
826 setverdict(pass);
827}
828
829/* Test behavior of channel release after CONN FAIL IND from BTS */
830testcase TC_chan_rel_conn_fail() runs on test_CT {
831 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100832 var DchanTuple dt;
833
Harald Welte89d42e82017-12-17 16:42:41 +0100834 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100835
836 dt := f_est_dchan('23'O, 23, '00010203040506'O);
837
838 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +0100839 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 +0100840 /* TODO: different cause values? */
841
Harald Welte4003d112017-12-09 22:35:39 +0100842 /* expect Clear Request from BSC */
843 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
844
845 /* Instruct BSC to clear channel */
846 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
847 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
848
Harald Welte6ff76ea2018-01-28 13:08:01 +0100849 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +0200850 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +0100851
852 /* wait for SCCP emulation to do its job */
853 f_sleep(1.0);
854
855 setverdict(pass);
856}
857
Harald Welte99f3ca02018-06-14 13:40:29 +0200858/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
859/* See also https://www.osmocom.org/issues/3182 */
860testcase TC_early_conn_fail() runs on test_CT {
861 var RSL_Message rx_rsl;
862 var DchanTuple dt;
863
864 f_init(1);
865
866 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
867 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_octstring(1), 23);
868
869 /* BTS->BSC: simulate CONN FAIL IND */
870 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
871
872 /* BTS->BSC: Expect RF channel release from BSC on Abis */
873 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
874
875 /* BTS<-BSC: respond with CHAN REL ACK */
876 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
877
878 setverdict(pass);
879}
880
881/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
882/* See also https://www.osmocom.org/issues/3182 */
883testcase TC_late_conn_fail() runs on test_CT {
884 var RSL_Message rx_rsl;
885 var DchanTuple dt;
886
887 f_init(1);
888
889 dt := f_est_dchan('23'O, 23, '00010203040506'O);
890
891 /* BSC<-MSC: Instruct BSC to clear connection */
892 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
893
894 /* BTS->BSC: expect BSC to deactivate SACCH */
895 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
896
897 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
898 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
899
900 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
901 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
902 /* BTS->BSC: respond with CHAN REL ACK */
903 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
904
905 /* BSC->MSC: expect Clear Complete from BSC */
906 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
907
908 /* BSC<-MSC: MSC disconnects as requested. */
909 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
910
911 setverdict(pass);
912}
913
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +0100914function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100915 boolean expect_deact_sacch := true,
916 boolean expect_rr_chan_rel := true,
917 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +0100918 boolean handle_rll_rel := true,
919 boolean is_csfb := false
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100920 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +0100921
922 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100923 var boolean got_deact_sacch := false;
924 var boolean got_rr_chan_rel := false;
925 var boolean got_rll_rel_req := false;
926 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
927 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +0100928 alt {
Harald Welte91d54a52018-01-28 15:35:07 +0100929 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
930 tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100931 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100932 repeat;
933 }
Harald Welte99787102019-02-04 10:41:36 +0100934 [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))) {
935 got_rr_chan_rel := true;
936 repeat;
937 }
938 [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 +0100939 got_rr_chan_rel := true;
Neels Hofmeyr211169d2018-11-07 00:37:29 +0100940 repeat;
941 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100942 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
Harald Welte91d54a52018-01-28 15:35:07 +0100943 tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100944 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100945 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100946 if (handle_rll_rel) {
947 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
948 }
Harald Welte91d54a52018-01-28 15:35:07 +0100949 repeat;
950 }
Harald Welte91d54a52018-01-28 15:35:07 +0100951 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
952 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
953 /* respond with CHAN REL ACK */
954 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
955 }
956 /* ignore any user data */
957 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) {
958 repeat;
959 }
960 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100961
962 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
963 " got_rll_rel_req=", got_rll_rel_req);
964
965 if (expect_deact_sacch != got_deact_sacch) {
966 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
967 }
968 if (expect_rr_chan_rel != got_rr_chan_rel) {
969 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
970 }
971 if (expect_rll_rel_req != got_rll_rel_req) {
972 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
973 }
Harald Welte91d54a52018-01-28 15:35:07 +0100974}
975
Harald Welte4003d112017-12-09 22:35:39 +0100976/* Test behavior of channel release after hard Clear Command from MSC */
977testcase TC_chan_rel_hard_clear() runs on test_CT {
978 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100979 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +0100980
Harald Welte89d42e82017-12-17 16:42:41 +0100981 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100982
983 dt := f_est_dchan('23'O, 23, '00010203040506'O);
984
985 /* Instruct BSC to clear channel */
986 var BssmapCause cause := 0;
987 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
988
989 /* expect Clear Complete from BSC on A */
990 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
991 /* release the SCCP connection */
992 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
993 }
994
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100995 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte4003d112017-12-09 22:35:39 +0100996 setverdict(pass);
997}
998
Harald Welte99787102019-02-04 10:41:36 +0100999/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1000testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1001 var BSSAP_N_DATA_ind rx_di;
1002 var DchanTuple dt;
1003
1004 f_init(1);
1005
1006 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1007
1008 /* Instruct BSC to clear channel */
1009 var BssmapCause cause := 0;
1010 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1011
1012 /* expect Clear Complete from BSC on A */
1013 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1014 /* release the SCCP connection */
1015 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1016 }
1017
1018 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
1019 setverdict(pass);
1020}
1021
Harald Welted8c36cd2017-12-09 23:05:31 +01001022/* Test behavior of channel release after hard RLSD from MSC */
1023testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001024 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001025
Harald Welte89d42e82017-12-17 16:42:41 +01001026 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001027
1028 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1029
1030 /* release the SCCP connection */
1031 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1032
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001033 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welted8c36cd2017-12-09 23:05:31 +01001034 setverdict(pass);
1035}
1036
Harald Welte550daf92018-06-11 19:22:13 +02001037/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1038testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1039 var DchanTuple dt;
1040
1041 f_init(1);
1042
1043 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1044
1045 /* release the SCCP connection */
1046 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1047
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001048 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte550daf92018-06-11 19:22:13 +02001049 setverdict(pass);
1050}
1051
Harald Welte85804d42017-12-10 14:11:58 +01001052/* Test behavior of channel release after BSSMAP RESET from MSC */
1053testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001054 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001055
Harald Welte89d42e82017-12-17 16:42:41 +01001056 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001057
1058 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1059
1060 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1061 IPA_RSL[0].clear;
1062
1063 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001064 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 +01001065 interleave {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001066 [] 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 +01001067 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1068 }
1069
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001070 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte85804d42017-12-10 14:11:58 +01001071 setverdict(pass);
1072}
1073
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001074/* Verify T(iar) triggers and releases the channel */
1075testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1076 var DchanTuple dt;
1077
1078 /* Set T(iar) in BSC low enough that it will trigger before other side
1079 has time to keep alive with a T(ias). Keep recommended ratio of
1080 T(iar) >= T(ias)*2 */
1081 g_bsc_sccp_timer_ias := 2;
1082 g_bsc_sccp_timer_iar := 5;
1083
1084 f_init(1);
1085
1086 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1087 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
1088 setverdict(pass);
1089}
1090
Harald Welte5cd20ed2017-12-13 21:03:20 +01001091/* Test behavior if RSL EST IND for non-active channel */
1092testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1093 timer T := 2.0;
1094
Harald Welte89d42e82017-12-17 16:42:41 +01001095 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001096
1097 var octetstring l3 := '00010203040506'O;
1098 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1099 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1100
1101 T.start;
1102 alt {
1103 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1104 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1105 }
1106 [] BSSAP.receive {}
1107 [] IPA_RSL[0].receive {}
1108 [] T.timeout {}
1109 }
1110
1111 setverdict(pass);
1112}
1113
1114/* Test behavior if RSL EST IND for invalid SAPI */
1115testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1116 var RslChannelNr chan_nr;
1117
Harald Welte89d42e82017-12-17 16:42:41 +01001118 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001119
1120 chan_nr := f_chreq_act_ack()
1121
1122 var octetstring l3 := '00010203040506'O;
1123 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1124
1125 timer T := 2.0;
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 1");
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 SAPI */
1140testcase TC_rll_est_ind_inval_sapi3() 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_DCCH(3)), 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 SAPI 3");
1154 }
1155 [] BSSAP.receive { repeat; }
1156 [] IPA_RSL[0].receive { repeat; }
1157 [] T.timeout {}
1158 }
1159
1160 setverdict(pass);
1161}
1162
1163/* Test behavior if RSL EST IND for invalid SACCH */
1164testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
1165 timer T := 2.0;
1166
Harald Welte89d42e82017-12-17 16:42:41 +01001167 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001168
1169 var RslChannelNr chan_nr := f_chreq_act_ack();
1170
1171 var octetstring l3 := '00010203040506'O;
1172 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
1173
1174 T.start;
1175 alt {
1176 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1177 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
1178 }
1179 [] BSSAP.receive { repeat; }
1180 [] IPA_RSL[0].receive { repeat; }
1181 [] T.timeout {}
1182 }
1183
1184 setverdict(pass);
1185}
1186
1187
1188
Harald Welte4003d112017-12-09 22:35:39 +01001189
1190testcase TC_ctrl_msc_connection_status() runs on test_CT {
1191 var charstring ctrl_resp;
1192
Harald Welte89d42e82017-12-17 16:42:41 +01001193 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001194
1195 /* See https://osmocom.org/issues/2729 */
1196 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
1197 setverdict(pass);
1198}
1199
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001200testcase TC_ctrl_msc0_connection_status() runs on test_CT {
1201 var charstring ctrl_resp;
1202
1203 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001204
1205 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
1206 setverdict(pass);
1207}
1208
Harald Welte4003d112017-12-09 22:35:39 +01001209testcase TC_ctrl() runs on test_CT {
1210 var charstring ctrl_resp;
1211
Harald Welte89d42e82017-12-17 16:42:41 +01001212 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001213
1214 /* all below values must match the osmo-bsc.cfg config file used */
1215
Harald Welte6a129692018-03-17 17:30:14 +01001216 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
1217 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02001218 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01001219
1220 var integer bts_nr := 0;
1221 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
1222 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
1223 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
1224 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
1225 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
1226 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
1227 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
1228
1229 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
1230 f_sleep(2.0);
1231 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
1232 setverdict(fail, "oml-uptime not incrementing as expected");
1233 }
1234 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
1235
1236 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
1237
1238 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +01001239}
1240
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02001241/* Verify that Upon receival of SET "location", BSC forwards a TRAP
1242 "location-state" over the SCCPlite IPA conn */
1243testcase TC_ctrl_location() runs on test_CT {
1244 var MSC_ConnHdlr vc_conn;
1245 var integer bts_nr := 0;
1246
1247 f_init(1, true);
1248 f_sleep(1.0);
1249
1250 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
1251 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
1252 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
1253
1254 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
1255 f_sleep(2.0);
1256
1257 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
1258 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
1259 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
1260
1261 /* should match the one from config */
1262 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
1263
1264 setverdict(pass);
1265}
1266
Harald Welte6f521d82017-12-11 19:52:02 +01001267function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +01001268 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, bssap));
Harald Welte6f521d82017-12-11 19:52:02 +01001269}
1270
1271
1272/***********************************************************************
1273 * Paging Testing
1274 ***********************************************************************/
1275
1276type record Cell_Identity {
1277 GsmMcc mcc,
1278 GsmMnc mnc,
1279 GsmLac lac,
1280 GsmCellId ci
1281};
Harald Welte24135bd2018-03-17 19:27:53 +01001282private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001283private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001284
Harald Welte5d1a2202017-12-13 19:51:29 +01001285type set of integer BtsIdList;
1286
1287private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1288 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1289 if (bts_id == bts_ids[j]) {
1290 return true;
1291 }
1292 }
1293 return false;
1294}
Harald Welte6f521d82017-12-11 19:52:02 +01001295
1296/* core paging test helper function; used by most paging test cases */
1297private function f_pageing_helper(hexstring imsi,
1298 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001299 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001300 template RSL_ChanNeeded rsl_chneed := omit,
1301 template OCT4 tmsi := omit) runs on test_CT
1302{
1303 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
1304 var MobileIdentity mi;
1305 var template octetstring id_enc; /* FIXME */
1306 var RSL_Message rx_rsl;
1307 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001308 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001309
1310 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001311
1312 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001313 for (i := 0; i < NUM_BTS; i := i + 1) {
1314 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001315 }
Harald Welte6f521d82017-12-11 19:52:02 +01001316
1317 if (isvalue(rsl_chneed)) {
1318 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1319 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1320 } else {
1321 bssmap_chneed := omit;
1322 }
1323
1324 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
1325
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02001326/* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder
Harald Welte6f521d82017-12-11 19:52:02 +01001327 if (isvalue(tmsi)) {
1328 mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi))));
1329 } else {
1330 mi := valueof(ts_Osmo_MI_IMSI(imsi));
1331 }
1332 id_enc := enc_MobileIdentity(mi);
1333*/
1334 id_enc := ?;
Harald Welte5d1a2202017-12-13 19:51:29 +01001335 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
1336 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc));
1337 /* check channel type, paging group */
1338 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1339 setverdict(fail, "Paging for wrong paging group");
1340 }
1341 if (ispresent(rsl_chneed) and
1342 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1343 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1344 }
Harald Welte6f521d82017-12-11 19:52:02 +01001345 }
Harald Welte2fccd982018-01-31 15:48:19 +01001346 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001347 /* do a quick check on all not-included BTSs if they received paging */
1348 for (i := 0; i < NUM_BTS; i := i + 1) {
1349 timer T := 0.1;
1350 if (f_bts_in_list(i, bts_ids)) {
1351 continue;
1352 }
1353 T.start;
1354 alt {
1355 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) {
1356 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1357 }
1358 [] IPA_RSL[i].receive { repeat; }
1359 [] T.timeout { }
1360 }
Harald Welte6f521d82017-12-11 19:52:02 +01001361 }
1362
1363 setverdict(pass);
1364}
1365
Harald Welte5d1a2202017-12-13 19:51:29 +01001366const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001367const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001368const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1369const BtsIdList c_BtsId_LAC2 := { 2 };
1370
Harald Welte6f521d82017-12-11 19:52:02 +01001371/* PAGING by IMSI + TMSI */
1372testcase TC_paging_imsi_nochan() runs on test_CT {
1373 var BSSMAP_FIELD_CellIdentificationList cid_list;
1374 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001375 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001376 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001377}
1378
1379/* PAGING by IMSI + TMSI */
1380testcase TC_paging_tmsi_nochan() runs on test_CT {
1381 var BSSMAP_FIELD_CellIdentificationList cid_list;
1382 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001383 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001384 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001385}
1386
1387/* Paging with different "channel needed' values */
1388testcase TC_paging_tmsi_any() runs on test_CT {
1389 var BSSMAP_FIELD_CellIdentificationList cid_list;
1390 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001391 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001392 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001393}
1394testcase TC_paging_tmsi_sdcch() runs on test_CT {
1395 var BSSMAP_FIELD_CellIdentificationList cid_list;
1396 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001397 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001398 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001399}
1400testcase TC_paging_tmsi_tch_f() runs on test_CT {
1401 var BSSMAP_FIELD_CellIdentificationList cid_list;
1402 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001403 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001404 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001405}
1406testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1407 var BSSMAP_FIELD_CellIdentificationList cid_list;
1408 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001409 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001410 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001411}
1412
1413/* Paging by CGI */
1414testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1415 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1416 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001417 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001418 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001419}
1420
1421/* Paging by LAC+CI */
1422testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1423 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1424 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001425 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001426 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001427}
1428
1429/* Paging by CI */
1430testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1431 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1432 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001433 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001434 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001435}
1436
1437/* Paging by LAI */
1438testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1439 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1440 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001441 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001442 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001443}
1444
1445/* Paging by LAC */
1446testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1447 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1448 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001449 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001450 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001451}
1452
1453/* Paging by "all in BSS" */
1454testcase TC_paging_imsi_nochan_all() runs on test_CT {
1455 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1456 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001457 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001458 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001459}
1460
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001461/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001462testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1463 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1464 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 +01001465 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001466 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001467}
Harald Welte6f521d82017-12-11 19:52:02 +01001468
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001469/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001470testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1471 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1472 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001473 f_pageing_helper('001010000000013'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 Sperling7b5e1782018-03-20 19:32:43 +01001477/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001478testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1479 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1480 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001481 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001482 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001483}
1484
Harald Welte6f521d82017-12-11 19:52:02 +01001485/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001486testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1487 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1488 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1489 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001490 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001491}
1492
1493/* Paging on empty list: Verify none of them page */
1494testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1495 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1496 cid_list := { cIl_LAC := { } };
1497 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001498 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001499}
1500
Stefan Sperling049a86e2018-03-20 15:51:00 +01001501/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1502testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1503 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1504 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1505 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1506 f_shutdown_helper();
1507}
1508
Harald Welte6f521d82017-12-11 19:52:02 +01001509/* Verify paging retransmission interval + count */
1510/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001511/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001512
Harald Weltee65d40e2017-12-13 00:09:06 +01001513/* Verify PCH load */
1514testcase TC_paging_imsi_load() runs on test_CT {
1515 var BSSMAP_FIELD_CellIdentificationList cid_list;
1516 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001517 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001518 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001519 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001520
1521 /* tell BSC there is no paging space anymore */
1522 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001523 f_sleep(0.2);
1524 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001525
1526 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1527 * there would be 8 retransmissions during 4 seconds */
1528 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001529 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001530 alt {
1531 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1532 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02001533 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01001534 }
Harald Welte2caa1062018-03-17 18:19:05 +01001535 [] T_retrans.timeout {
1536 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1537 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1538 T_retrans.start;
1539 repeat;
1540 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001541 [] T.timeout {
1542 setverdict(pass);
1543 }
1544 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001545
1546 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001547}
1548
Harald Welte235ebf12017-12-15 14:18:16 +01001549/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001550testcase TC_paging_counter() runs on test_CT {
1551 var BSSMAP_FIELD_CellIdentificationList cid_list;
1552 timer T := 4.0;
1553 var integer i;
1554 var integer paging_attempted_bsc;
1555 var integer paging_attempted_bts[NUM_BTS];
1556 var integer paging_expired_bts[NUM_BTS];
1557 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1558
1559 f_init();
1560
1561 /* read counters before paging */
1562 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1563 for (i := 0; i < NUM_BTS; i := i+1) {
1564 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1565 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1566 }
1567
1568 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1569
1570 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1571 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1572 for (i := 0; i < NUM_BTS; i := i+1) {
1573 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1574 paging_attempted_bts[i]+1);
1575 }
1576
1577 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1578 f_sleep(12.0);
1579 for (i := 0; i < NUM_BTS; i := i+1) {
1580 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1581 paging_expired_bts[i]+1);
1582 }
Harald Welte1ff69992017-12-14 12:31:17 +01001583
Philipp Maier282ca4b2018-02-27 17:17:00 +01001584 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001585}
1586
1587
Harald Welte10985002017-12-12 09:29:15 +01001588/* Verify paging stops after A-RESET */
1589testcase TC_paging_imsi_a_reset() runs on test_CT {
1590 var BSSMAP_FIELD_CellIdentificationList cid_list;
1591 timer T := 3.0;
1592 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001593 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001594
1595 /* Perform a BSSMAP Reset and wait for ACK */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001596 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 +01001597 alt {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001598 [] 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 +01001599 [] BSSAP.receive { repeat; }
1600 }
1601
Daniel Willmanncbef3982018-07-30 09:22:40 +02001602 /* Wait to avoid a possible race condition if a paging message is
1603 * received right before the reset ACK. */
1604 f_sleep(0.2);
1605
Harald Welte10985002017-12-12 09:29:15 +01001606 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001607 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1608 IPA_RSL[i].clear;
1609 }
Harald Welte10985002017-12-12 09:29:15 +01001610
1611 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1612 T.start;
1613 alt {
1614 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1615 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001616 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01001617 }
Harald Welte5d1a2202017-12-13 19:51:29 +01001618 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1619 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001620 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001621 }
1622 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1623 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001624 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001625 }
Harald Welte10985002017-12-12 09:29:15 +01001626 [] T.timeout {
1627 setverdict(pass);
1628 }
1629 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001630
1631 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001632}
Harald Welteae026692017-12-09 01:03:01 +01001633
Philipp Maierf45824a2019-08-14 14:44:10 +02001634/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
1635 * paging response we can not know which MSC is in charge, so we will blindly
1636 * pick the first configured MSC. This behavior is required in order to make
1637 * MT-CSFB calls working because in those cases the BSC can not know that the
1638 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
1639 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001640 */
1641testcase TC_paging_resp_unsol() runs on test_CT {
1642
1643 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02001644 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001645
1646 var BSSAP_N_CONNECT_ind rx_c_ind;
1647 var DchanTuple dt;
1648 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02001649 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001650
1651 /* Send CHAN RQD and wait for allocation; acknowledge it */
1652 dt.rsl_chan_nr := f_chreq_act_ack();
1653
1654 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
1655 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
1656
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001657
Philipp Maierf45824a2019-08-14 14:44:10 +02001658 /* Expevct a CR with a matching Paging response on the A-Interface */
1659 T.start;
1660 alt {
1661 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
1662 setverdict(pass);
1663 }
1664 [] BSSAP.receive {
1665 setverdict(fail, "Received unexpected message on A-Interface!");
1666 }
1667 [] T.timeout {
1668 setverdict(fail, "Received nothing on A-Interface!");
1669 }
1670 }
1671
1672 setverdict(pass);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001673}
1674
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001675/* Test RSL link drop causes counter increment */
1676testcase TC_rsl_drop_counter() runs on test_CT {
1677 var integer rsl_fail;
1678
Harald Welte89d42e82017-12-17 16:42:41 +01001679 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001680
1681 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1682
1683 bts[0].rsl.vc_IPA.stop;
1684
1685 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1686
1687 setverdict(pass);
1688}
1689
1690/* TODO: Test OML link drop causes counter increment */
1691
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001692/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1693function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1694 timer T := 10.0;
1695
1696 bts[0].rsl.id := "IPA-0-RSL";
1697 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1698 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1699 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02001700 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001701
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001702 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1703
1704 f_init_mgcp("VirtMSC");
1705
1706 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1707 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1708 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1709 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1710
1711 /* wait for IPA OML link to connect and then disconnect */
1712 T.start;
1713 alt {
1714 [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) {
1715 T.stop;
1716 return true;
1717 }
1718 [] IPA_RSL[0].receive { repeat }
1719 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02001720 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001721 }
1722 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001723 return false;
1724}
1725
1726/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1727testcase TC_rsl_unknown_unit_id() runs on test_CT {
1728 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1729 setverdict(pass);
1730 } else {
1731 setverdict(fail, "Timeout RSL waiting for connection to close");
1732 }
1733}
1734
1735
1736/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1737testcase TC_oml_unknown_unit_id() runs on test_CT {
1738 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1739 setverdict(pass);
1740 } else {
1741 setverdict(fail, "Timeout OML waiting for connection to close");
1742 }
1743}
1744
1745
Harald Weltec1a2fff2017-12-17 11:06:19 +01001746/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02001747 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01001748 ***********************************************************************/
1749
Harald Welte6811d102019-04-14 22:23:14 +02001750import from RAN_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01001751import from RSL_Emulation all;
1752import from MSC_ConnectionHandler all;
1753
1754type function void_fn(charstring id) runs on MSC_ConnHdlr;
1755
Harald Welte336820c2018-05-31 20:34:52 +02001756/* helper function to create and connect a MSC_ConnHdlr component */
Harald Welteff579f92018-05-31 22:19:39 +02001757private function f_connect_handler(inout MSC_ConnHdlr vc_conn) runs on test_CT {
Harald Welte6811d102019-04-14 22:23:14 +02001758 connect(vc_conn:RAN, g_bssap.vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001759 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001760 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001761 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001762 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001763 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1764 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1765 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02001766 if (isvalue(bts[2])) {
1767 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
1768 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
1769 }
Harald Welte6811d102019-04-14 22:23:14 +02001770 connect(vc_conn:BSSAP, g_bssap.vc_RAN:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001771 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02001772 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Harald Welte336820c2018-05-31 20:34:52 +02001773}
1774
1775function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
1776runs on test_CT return MSC_ConnHdlr {
1777 var charstring id := testcasename();
1778 var MSC_ConnHdlr vc_conn;
1779 vc_conn := MSC_ConnHdlr.create(id);
1780 f_connect_handler(vc_conn);
Harald Weltea0630032018-03-20 21:09:55 +01001781 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001782 return vc_conn;
1783}
1784
Harald Weltea0630032018-03-20 21:09:55 +01001785/* first function inside ConnHdlr component; sets g_pars + starts function */
1786private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1787runs on MSC_ConnHdlr {
1788 if (isvalue(pars)) {
1789 g_pars := valueof(pars);
1790 }
1791 fn.apply(id);
1792}
1793
Harald Welte3c86ea02018-05-10 22:28:05 +02001794/* Establish signalling channel (non-assignment case) followed by cipher mode */
1795private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001796 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1797 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001798 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02001799 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
1800 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
1801 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
1802 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02001803
Philipp Maier23000732018-05-18 11:25:37 +02001804 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02001805}
1806testcase TC_ciph_mode_a5_0() runs on test_CT {
1807 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001808 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001809 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1810
1811 f_init(1, true);
1812 f_sleep(1.0);
1813 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1814 vc_conn.done;
1815}
1816testcase TC_ciph_mode_a5_1() runs on test_CT {
1817 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001818 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001819 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1820
1821 f_init(1, true);
1822 f_sleep(1.0);
1823 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1824 vc_conn.done;
1825}
1826testcase TC_ciph_mode_a5_3() runs on test_CT {
1827 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001828 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001829 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1830
1831 f_init(1, true);
1832 f_sleep(1.0);
1833 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1834 vc_conn.done;
1835}
1836
1837
1838/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001839private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001840 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1841 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001842
Harald Welte552620d2017-12-16 23:21:36 +01001843 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1844 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001845
Harald Weltea0630032018-03-20 21:09:55 +01001846 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001847}
Harald Welte552620d2017-12-16 23:21:36 +01001848testcase TC_assignment_fr_a5_0() runs on test_CT {
1849 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001850 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001851 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001852
Harald Welte89d42e82017-12-17 16:42:41 +01001853 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001854 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001855 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001856 vc_conn.done;
1857}
Harald Welte552620d2017-12-16 23:21:36 +01001858testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001859 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001860 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001861 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001862
Harald Welte89d42e82017-12-17 16:42:41 +01001863 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001864 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001865 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1866 vc_conn.done;
1867}
1868testcase TC_assignment_fr_a5_3() runs on test_CT {
1869 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001870 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001871 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001872
Harald Welte651fcdc2018-05-10 20:23:16 +02001873 f_init(1, true);
1874 f_sleep(1.0);
1875 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001876 vc_conn.done;
1877}
1878
Harald Welte552620d2017-12-16 23:21:36 +01001879/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1880private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001881 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01001882 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001883 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001884 const OCT8 kc := '0001020304050607'O;
1885
1886 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001887 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
1888
Harald Weltea0630032018-03-20 21:09:55 +01001889 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001890}
Harald Welte552620d2017-12-16 23:21:36 +01001891testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1892 var MSC_ConnHdlr vc_conn;
1893
Harald Welte89d42e82017-12-17 16:42:41 +01001894 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001895 f_sleep(1.0);
1896
Harald Welte8863fa12018-05-10 20:15:27 +02001897 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001898 vc_conn.done;
1899}
1900
Harald Welte552620d2017-12-16 23:21:36 +01001901private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001902 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02001903 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1904 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001905 const OCT8 kc := '0001020304050607'O;
1906 const OCT16 kc128 := kc & kc;
1907
1908 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1909 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001910 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001911 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001912 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001913}
Harald Welte552620d2017-12-16 23:21:36 +01001914testcase TC_assignment_fr_a5_4() runs on test_CT {
1915 var MSC_ConnHdlr vc_conn;
1916
Harald Welte89d42e82017-12-17 16:42:41 +01001917 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001918 f_sleep(1.0);
1919
Harald Welte8863fa12018-05-10 20:15:27 +02001920 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001921 vc_conn.done;
1922}
1923
1924
Harald Welte4532e0a2017-12-23 02:05:44 +01001925private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001926 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01001927 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02001928 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01001929 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001930 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001931}
1932
1933testcase TC_assignment_sign() runs on test_CT {
1934 var MSC_ConnHdlr vc_conn;
1935
1936 f_init(1, true);
1937 f_sleep(1.0);
1938
Harald Welte8863fa12018-05-10 20:15:27 +02001939 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001940 vc_conn.done;
1941}
1942
Harald Welte60aa5762018-03-21 19:33:13 +01001943/***********************************************************************
1944 * Codec (list) testing
1945 ***********************************************************************/
1946
1947/* check if the given rsl_mode is compatible with the a_elem */
1948private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1949return boolean {
1950 select (a_elem.codecType) {
1951 case (GSM_FR) {
1952 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1953 return true;
1954 }
1955 }
1956 case (GSM_HR) {
1957 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1958 return true;
1959 }
1960 }
1961 case (GSM_EFR) {
1962 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1963 return true;
1964 }
1965 }
1966 case (FR_AMR) {
1967 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1968 return true;
1969 }
1970 }
1971 case (HR_AMR) {
1972 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1973 return true;
1974 }
1975 }
1976 case else { }
1977 }
1978 return false;
1979}
1980
1981/* check if the given rsl_mode is compatible with the a_list */
1982private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
1983return boolean {
1984 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
1985 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
1986 return true;
1987 }
1988 }
1989 return false;
1990}
1991
1992/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02001993function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01001994return BSSMAP_IE_ChannelType {
1995 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
1996 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
1997 select (a_elem.codecType) {
1998 case (GSM_FR) {
1999 ret.channelRateAndType := ChRate_TCHF;
2000 ret.speechId_DataIndicator := Spdi_TCHF_FR;
2001 }
2002 case (GSM_HR) {
2003 ret.channelRateAndType := ChRate_TCHH;
2004 ret.speechId_DataIndicator := Spdi_TCHH_HR;
2005 }
2006 case (GSM_EFR) {
2007 ret.channelRateAndType := ChRate_TCHF;
2008 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
2009 }
2010 case (FR_AMR) {
2011 ret.channelRateAndType := ChRate_TCHF;
2012 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
2013 }
2014 case (HR_AMR) {
2015 ret.channelRateAndType := ChRate_TCHH;
2016 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
2017 }
2018 case else {
2019 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02002020 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01002021 }
2022 }
2023 return ret;
2024}
2025
Harald Weltea63b9102018-03-22 20:36:16 +01002026private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
2027return template RSL_IE_Body {
2028 var template RSL_IE_Body mode_ie := {
2029 chan_mode := {
2030 len := ?,
2031 reserved := ?,
2032 dtx_d := ?,
2033 dtx_u := ?,
2034 spd_ind := RSL_SPDI_SPEECH,
2035 ch_rate_type := -,
2036 coding_alg_rate := -
2037 }
2038 }
2039
2040 select (a_elem.codecType) {
2041 case (GSM_FR) {
2042 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2043 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2044 }
2045 case (GSM_HR) {
2046 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2047 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2048 }
2049 case (GSM_EFR) {
2050 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2051 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
2052 }
2053 case (FR_AMR) {
2054 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2055 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2056 }
2057 case (HR_AMR) {
2058 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2059 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2060 }
2061 }
2062 return mode_ie;
2063}
2064
Harald Welte60aa5762018-03-21 19:33:13 +01002065type record CodecListTest {
2066 BSSMAP_IE_SpeechCodecList codec_list,
2067 charstring id
2068}
2069type record of CodecListTest CodecListTests
2070
2071private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002072 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
2073 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01002074
2075 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Harald Welte79f3f542018-05-25 20:02:37 +02002076 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2077 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2078 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
2079 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01002080 if (isvalue(g_pars.expect_mr_s0_s7)) {
2081 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
2082 g_pars.expect_mr_s0_s7;
2083 }
Harald Welte79f3f542018-05-25 20:02:37 +02002084 }
Harald Welte60aa5762018-03-21 19:33:13 +01002085 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2086 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01002087 log("expecting ASS COMPL like this: ", exp_compl);
2088
2089 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01002090
2091 /* Verify that the RSL-side activation actually matches our expectations */
2092 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
2093
2094 var RSL_IE_Body mode_ie;
2095 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
2096 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02002097 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01002098 }
2099 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
2100 if (not match(mode_ie, t_mode_ie)) {
2101 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
2102 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002103
2104 var RSL_IE_Body mr_conf;
2105 if (g_pars.expect_mr_conf_ie != omit) {
2106 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
2107 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02002108 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002109 }
2110 log("found RSL MR CONFIG IE: ", mr_conf);
2111
2112 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
2113 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
2114 g_pars.expect_mr_conf_ie);
2115 }
2116 } else {
2117 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
2118 log("found RSL MR CONFIG IE: ", mr_conf);
2119 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02002120 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002121 }
2122 }
Harald Welte60aa5762018-03-21 19:33:13 +01002123}
2124
Philipp Maierd0e64b02019-03-13 14:15:23 +01002125private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
2126
2127 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2128 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2129
2130 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
2131 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2132 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2133 }
2134 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2135 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
2136 log("expecting ASS FAIL like this: ", exp_fail);
2137
2138 f_establish_fully(ass_cmd, exp_fail);
2139}
2140
Harald Welte60aa5762018-03-21 19:33:13 +01002141testcase TC_assignment_codec_fr() 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_CodecFR}));
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
2153testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002154 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002155 var MSC_ConnHdlr vc_conn;
2156
2157 f_init(1, true);
2158 f_sleep(1.0);
2159
2160 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002161 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002162 vc_conn.done;
2163}
2164
2165testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002166 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002167 var MSC_ConnHdlr vc_conn;
2168
2169 f_init(1, true);
2170 f_sleep(1.0);
2171
2172 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002173 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002174 vc_conn.done;
2175}
2176
Philipp Maierd0e64b02019-03-13 14:15:23 +01002177/* Allow 5,90k only (current default config) */
2178private function f_allow_amr_rate_5_90k() runs on test_CT {
2179 f_vty_enter_cfg_msc(BSCVTY, 0);
2180 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
2181 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2182 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2183 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
2184 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2185 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2186 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2187 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
2188 f_vty_transceive(BSCVTY, "exit");
2189 f_vty_transceive(BSCVTY, "exit");
2190}
2191
2192/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
2193 * ("Config-NB-Code = 1") */
2194private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
2195 f_vty_enter_cfg_msc(BSCVTY, 0);
2196 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
2197 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2198 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2199 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
2200 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2201 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2202 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2203 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
2204 f_vty_transceive(BSCVTY, "exit");
2205 f_vty_transceive(BSCVTY, "exit");
2206}
2207
Harald Welte60aa5762018-03-21 19:33:13 +01002208testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002209 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002210 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002211
2212 /* Note: This setups the codec configuration. The parameter payload in
2213 * mr_conf must be consistant with the parameter codecElements in pars
2214 * and also must match the amr-config in osmo-bsc.cfg! */
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_F}));
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 := '01010111'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
2234testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002235 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002236 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002237
2238 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002239 var RSL_IE_Body mr_conf := {
2240 other := {
2241 len := 2,
2242 payload := '2804'O
2243 }
2244 };
Harald Welte60aa5762018-03-21 19:33:13 +01002245
Philipp Maier7695a0d2018-09-27 17:52:14 +02002246 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002247 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002248 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2249 pars.expect_mr_conf_ie := mr_conf;
2250
Harald Welte60aa5762018-03-21 19:33:13 +01002251 f_init(1, true);
2252 f_sleep(1.0);
2253
Harald Welte8863fa12018-05-10 20:15:27 +02002254 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002255 vc_conn.done;
2256}
2257
Philipp Maierd0e64b02019-03-13 14:15:23 +01002258function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
2259runs on test_CT {
2260
2261 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2262 var MSC_ConnHdlr vc_conn;
2263
2264 /* See note above */
2265 var RSL_IE_Body mr_conf := {
2266 other := {
2267 len := lengthof(mrconf),
2268 payload := mrconf
2269 }
2270 };
2271
2272 if (fr) {
2273 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2274 } else {
2275 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2276 }
2277 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2278 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2279 pars.expect_mr_conf_ie := mr_conf;
2280 pars.expect_mr_s0_s7 := exp_s8_s0;
2281
2282 f_init(1, true);
2283 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2284 f_sleep(1.0);
2285
2286 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2287 vc_conn.done;
2288 f_allow_amr_rate_5_90k();
2289}
2290
2291function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
2292runs on test_CT {
2293
2294 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2295 var MSC_ConnHdlr vc_conn;
2296
2297 if (fr) {
2298 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2299 } else {
2300 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2301 }
2302 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2303 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2304
2305 f_init(1, true);
2306 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2307 f_sleep(1.0);
2308
2309 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
2310 vc_conn.done;
2311 f_allow_amr_rate_5_90k();
2312}
2313
2314
2315/* Set S1, we expect an AMR multirate configuration IE with all four rates
2316 * set. */
2317testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
2318 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
2319}
2320
2321/* Set S1, we expect an AMR multirate configuration IE with the lower three
2322 * rates set. */
2323testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
2324 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
2325}
2326
2327/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2328 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2329testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
2330 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
2331}
2332
2333/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2334 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2335testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
2336 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
2337}
2338
2339/* The following block of tests selects more and more rates until all four
2340 * possible rates are in the active set (full rate) */
2341testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
2342 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
2343}
2344
2345testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
2346 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
2347}
2348
2349testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
2350 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
2351}
2352
2353testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
2354 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
2355}
2356
2357/* The following block of tests selects more and more rates until all three
2358 * possible rates are in the active set (half rate) */
2359testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
2360 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
2361}
2362
2363testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
2364 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
2365}
2366
2367testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
2368 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
2369}
2370
2371/* The following block tests what happens when the MSC does offer rate
2372 * configurations that are not supported by the BSC. Normally such situations
2373 * should not happen because the MSC gets informed by the BSC in advance via
2374 * the L3 COMPLETE message which rates are applicable. The MSC should not try
2375 * to offer rates that are not applicable anyway. */
2376
2377testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
2378 /* Try to include 12,2k in into the active set even though the channel
2379 * is half rate only. The BSC is expected to remove the 12,0k */
2380 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
2381}
2382
2383testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
2384 /* See what happens when all rates are selected at once. Since then
2385 * Also S1 is selected, this setting will be prefered and we should
2386 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
2387 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
2388}
2389
2390testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
2391 /* Same as above, but with S1 missing, the MSC is then expected to
2392 * select the currently supported rates, which are also 12.2k, 7,40k,
2393 * 5,90k, and 4,75k, into the active set. */
2394 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
2395}
2396
2397testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
2398 /* Try to select no rates at all */
2399 f_TC_assignment_codec_amr_fail(true, '00000000'B);
2400}
2401
2402testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
2403 /* Try to select only unsupported rates */
2404 f_TC_assignment_codec_amr_fail(true, '01101000'B);
2405}
2406
2407testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
2408 /* Try to select 12,2k for half rate */
2409 f_TC_assignment_codec_amr_fail(false, '10000000'B);
2410}
2411
Philipp Maierac09bfc2019-01-08 13:41:39 +01002412private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002413 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
2414 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
2415 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
2416 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002417}
2418
2419private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002420 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
2421 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002422}
2423
2424private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002425 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
2426 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
2427 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
2428 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
2429 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
2430 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002431}
2432
2433/* Allow HR only */
2434private function f_TC_assignment_codec_xr_exhausted_req_hr(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_compl := f_gen_exp_compl();
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_compl);
2443}
2444
2445/* Allow FR only */
2446private function f_TC_assignment_codec_xr_exhausted_req_fr(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_compl := f_gen_exp_compl();
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_compl);
2455}
2456
2457/* Allow HR only (expect assignment failure) */
2458private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(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_fail := tr_BSSMAP_AssignmentFail;
2462 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2463 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2464 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2465 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2466 f_establish_fully(ass_cmd, exp_fail);
2467}
2468
2469/* Allow FR only (expect assignment failure) */
2470private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
2471 g_pars := f_gen_test_hdlr_pars();
2472 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2473 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2474 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2475 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2476 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2477 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2478 f_establish_fully(ass_cmd, exp_fail);
2479}
2480
2481/* Allow FR and HR, but prefer FR */
2482private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2483 g_pars := f_gen_test_hdlr_pars();
2484 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2485 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2486 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2487 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2488 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2489 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2490 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2491 f_establish_fully(ass_cmd, exp_compl);
2492}
2493
2494/* Allow FR and HR, but prefer HR */
2495private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2496 g_pars := f_gen_test_hdlr_pars();
2497 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2498 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2499 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2500 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2501 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2502 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2503 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2504 f_establish_fully(ass_cmd, exp_compl);
2505}
2506
2507/* Allow FR and HR, but prefer FR */
2508private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2509 g_pars := f_gen_test_hdlr_pars();
2510 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2511 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2512 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2513 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2514 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2515 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2516 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2517 f_establish_fully(ass_cmd, exp_compl);
2518}
2519
2520/* Allow FR and HR, but prefer HR */
2521private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2522 g_pars := f_gen_test_hdlr_pars();
2523 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2524 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2525 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2526 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2527 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2528 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2529 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2530 f_establish_fully(ass_cmd, exp_compl);
2531}
2532
2533/* Request a HR channel while all FR channels are exhausted, this is expected
2534 * to work without conflicts */
2535testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
2536 var MSC_ConnHdlr vc_conn;
2537 f_init(1, true);
2538 f_sleep(1.0);
2539 f_enable_all_tch();
2540 f_disable_all_tch_f();
2541 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
2542 vc_conn.done;
2543 f_enable_all_tch();
2544 setverdict(pass);
2545}
2546
2547/* Request a FR channel while all FR channels are exhausted, this is expected
2548 * to fail. */
2549testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
2550 var MSC_ConnHdlr vc_conn;
2551 f_init(1, true);
2552 f_sleep(1.0);
2553 f_enable_all_tch();
2554 f_disable_all_tch_f();
2555 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
2556 vc_conn.done;
2557 f_enable_all_tch();
2558 setverdict(pass);
2559}
2560
2561/* Request a FR (prefered) or alternatively a HR channel while all FR channels
2562 * are exhausted, this is expected to be resolved by selecting a HR channel. */
2563testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
2564 var MSC_ConnHdlr vc_conn;
2565 f_init(1, true);
2566 f_sleep(1.0);
2567 f_enable_all_tch();
2568 f_disable_all_tch_f();
2569 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
2570 vc_conn.done;
2571 f_enable_all_tch();
2572 setverdict(pass);
2573}
2574
2575/* Request a HR (prefered) or alternatively a FR channel while all FR channels
2576 * are exhausted, this is expected to work without conflicts. */
2577testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
2578 var MSC_ConnHdlr vc_conn;
2579 f_init(1, true);
2580 f_sleep(1.0);
2581 f_enable_all_tch();
2582 f_disable_all_tch_f();
2583 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
2584 vc_conn.done;
2585 f_enable_all_tch();
2586 setverdict(pass);
2587}
2588
2589/* Request a FR channel while all HR channels are exhausted, this is expected
2590 * to work without conflicts */
2591testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
2592 var MSC_ConnHdlr vc_conn;
2593 f_init(1, true);
2594 f_sleep(1.0);
2595 f_enable_all_tch();
2596 f_disable_all_tch_h();
2597 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
2598 vc_conn.done;
2599 f_enable_all_tch();
2600 setverdict(pass);
2601}
2602
2603/* Request a HR channel while all HR channels are exhausted, this is expected
2604 * to fail. */
2605testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
2606 var MSC_ConnHdlr vc_conn;
2607 f_init(1, true);
2608 f_sleep(1.0);
2609 f_enable_all_tch();
2610 f_disable_all_tch_h();
2611 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
2612 vc_conn.done;
2613 f_enable_all_tch();
2614 setverdict(pass);
2615}
2616
2617/* Request a HR (prefered) or alternatively a FR channel while all HR channels
2618 * are exhausted, this is expected to be resolved by selecting a FR channel. */
2619testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
2620 var MSC_ConnHdlr vc_conn;
2621 f_init(1, true);
2622 f_sleep(1.0);
2623 f_enable_all_tch();
2624 f_disable_all_tch_h();
2625 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
2626 vc_conn.done;
2627 f_enable_all_tch();
2628 setverdict(pass);
2629}
2630
2631/* Request a FR (prefered) or alternatively a HR channel while all HR channels
2632 * are exhausted, this is expected to work without conflicts. */
2633testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
2634 var MSC_ConnHdlr vc_conn;
2635 f_init(1, true);
2636 f_sleep(1.0);
2637 f_enable_all_tch();
2638 f_disable_all_tch_h();
2639 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
2640 vc_conn.done;
2641 f_enable_all_tch();
2642 setverdict(pass);
2643}
2644
2645/* Allow FR and HR, but prefer HR */
2646private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2647 g_pars := f_gen_test_hdlr_pars();
2648 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2649 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2650 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2651 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2652 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2653 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2654 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2655 f_establish_fully(ass_cmd, exp_compl);
2656}
2657
2658/* Allow FR and HR, but prefer FR */
2659private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2660 g_pars := f_gen_test_hdlr_pars();
2661 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2662 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2663 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2664 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2665 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2666 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2667 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2668 f_establish_fully(ass_cmd, exp_compl);
2669}
2670
2671/* Request a HR (prefered) or alternatively a FR channel, it is expected that
2672 * HR, which is the prefered type, is selected. */
2673testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
2674 var MSC_ConnHdlr vc_conn;
2675 f_init(1, true);
2676 f_sleep(1.0);
2677 f_enable_all_tch();
2678 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
2679 vc_conn.done;
2680 setverdict(pass);
2681}
2682
2683/* Request a FR (prefered) or alternatively a HR channel, it is expected that
2684 * FR, which is the prefered type, is selected. */
2685testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
2686 var MSC_ConnHdlr vc_conn;
2687 f_init(1, true);
2688 f_sleep(1.0);
2689 f_enable_all_tch();
2690 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
2691 vc_conn.done;
2692 setverdict(pass);
2693}
2694
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002695testcase TC_assignment_osmux() runs on test_CT {
2696 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2697 var MSC_ConnHdlr vc_conn;
2698
2699 /* See note above */
2700 var RSL_IE_Body mr_conf := {
2701 other := {
2702 len := 2,
2703 payload := '2804'O
2704 }
2705 };
2706
2707 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2708 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
2709 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2710 pars.expect_mr_conf_ie := mr_conf;
2711 pars.use_osmux := true;
2712
2713 f_init(1, true, true);
2714 f_sleep(1.0);
2715
2716 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2717 vc_conn.done;
2718}
2719
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002720/* test the procedure of the MSC requesting a Classmark Update:
2721 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
2722 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01002723private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002724 g_pars := f_gen_test_hdlr_pars();
2725
Harald Weltea0630032018-03-20 21:09:55 +01002726 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002727 /* we should now have a COMPL_L3 at the MSC */
2728 BSSAP.receive(tr_BSSMAP_ComplL3);
2729
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002730 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
2731 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
2732
Harald Welte898113b2018-01-31 18:32:21 +01002733 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
2734 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
2735 setverdict(pass);
2736}
2737testcase TC_classmark() runs on test_CT {
2738 var MSC_ConnHdlr vc_conn;
2739 f_init(1, true);
2740 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002741 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01002742 vc_conn.done;
2743}
2744
Harald Weltee3bd6582018-01-31 22:51:25 +01002745private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002746 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002747 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002748 /* we should now have a COMPL_L3 at the MSC */
2749 BSSAP.receive(tr_BSSMAP_ComplL3);
2750
Harald Weltee3bd6582018-01-31 22:51:25 +01002751 /* send the single message we want to send */
2752 f_rsl_send_l3(l3);
2753}
2754
2755private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
2756 timer T := sec;
2757 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01002758 T.start;
2759 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01002760 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
2761 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02002762 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01002763 }
2764 [] T.timeout {
2765 setverdict(pass);
2766 }
2767 }
2768}
2769
Harald Weltee3bd6582018-01-31 22:51:25 +01002770/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2771private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
2772 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
2773 f_bssap_expect_nothing();
2774}
Harald Welte898113b2018-01-31 18:32:21 +01002775testcase TC_unsol_ass_fail() runs on test_CT {
2776 var MSC_ConnHdlr vc_conn;
2777 f_init(1, true);
2778 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002779 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01002780 vc_conn.done;
2781}
Harald Welte552620d2017-12-16 23:21:36 +01002782
Harald Welteea99a002018-01-31 20:46:43 +01002783
2784/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
2785private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002786 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
2787 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01002788}
2789testcase TC_unsol_ass_compl() runs on test_CT {
2790 var MSC_ConnHdlr vc_conn;
2791 f_init(1, true);
2792 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002793 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01002794 vc_conn.done;
2795}
2796
2797
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002798/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2799private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002800 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
2801 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002802}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002803testcase TC_unsol_ho_fail() runs on test_CT {
2804 var MSC_ConnHdlr vc_conn;
2805 f_init(1, true);
2806 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002807 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002808 vc_conn.done;
2809}
2810
2811
Harald Weltee3bd6582018-01-31 22:51:25 +01002812/* short message from MS should be ignored */
2813private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002814 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002815 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01002816 /* we should now have a COMPL_L3 at the MSC */
2817 BSSAP.receive(tr_BSSMAP_ComplL3);
2818
2819 /* send short message */
2820 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
2821 f_bssap_expect_nothing();
2822}
2823testcase TC_err_82_short_msg() runs on test_CT {
2824 var MSC_ConnHdlr vc_conn;
2825 f_init(1, true);
2826 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002827 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01002828 vc_conn.done;
2829}
2830
2831
Harald Weltee9e02e42018-01-31 23:36:25 +01002832/* 24.008 8.4 Unknown message must trigger RR STATUS */
2833private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
2834 f_est_single_l3(ts_RRM_UL_REL('00'O));
2835 timer T := 3.0
2836 alt {
2837 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
2838 setverdict(pass);
2839 }
2840 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01002841 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01002842 }
2843}
2844testcase TC_err_84_unknown_msg() runs on test_CT {
2845 var MSC_ConnHdlr vc_conn;
2846 f_init(1, true);
2847 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002848 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01002849 vc_conn.done;
2850}
2851
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002852/***********************************************************************
2853 * Handover
2854 ***********************************************************************/
2855
Harald Welte94e0c342018-04-07 11:33:23 +02002856/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
2857private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
2858runs on test_CT {
2859 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2860 " timeslot "&int2str(ts_nr)&" ";
2861 f_vty_transceive(BSCVTY, cmd & suffix);
2862}
2863
Harald Welte261af4b2018-02-12 21:20:39 +01002864/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
2865private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
2866runs on MSC_ConnHdlr {
2867 /* FIXME: resolve those from component-global state */
2868 var integer ts_nr := chan_nr.tn;
2869 var integer ss_nr;
2870 if (ischosen(chan_nr.u.ch0)) {
2871 ss_nr := 0;
2872 } else if (ischosen(chan_nr.u.lm)) {
2873 ss_nr := chan_nr.u.lm.sub_chan;
2874 } else if (ischosen(chan_nr.u.sdcch4)) {
2875 ss_nr := chan_nr.u.sdcch4.sub_chan;
2876 } else if (ischosen(chan_nr.u.sdcch8)) {
2877 ss_nr := chan_nr.u.sdcch8.sub_chan;
2878 } else {
2879 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02002880 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01002881 }
2882
2883 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2884 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
2885 f_vty_transceive(BSCVTY, cmd & suffix);
2886}
2887
Neels Hofmeyr91401012019-07-11 00:42:35 +02002888/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
2889 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
2890 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
2891 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
2892 * pair, not really to a specific BTS number. */
Harald Welte261af4b2018-02-12 21:20:39 +01002893private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
2894 integer new_bts_nr)
2895runs on MSC_ConnHdlr {
2896 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
2897}
2898
2899/* intra-BSC hand-over between BTS0 and BTS1 */
2900private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002901 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02002902 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2903 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01002904 const OCT8 kc := '0001020304050607'O;
2905
2906 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2907 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2908
Harald Weltea0630032018-03-20 21:09:55 +01002909 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02002910 f_bts_0_cfg({"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01002911
2912 var HandoverState hs := {
2913 rr_ho_cmpl_seen := false,
2914 handover_done := false,
2915 old_chan_nr := -
2916 };
2917 /* issue hand-over command on VTY */
2918 f_vty_handover(0, 0, g_chan_nr, 1);
2919 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2920 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002921
2922 /* From the MGW perspective, a handover is is characterized by
2923 * performing one MDCX operation with the MGW. So we expect to see
2924 * one more MDCX during handover. */
2925 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
2926
Harald Welte261af4b2018-02-12 21:20:39 +01002927 alt {
2928 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01002929 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002930
Philipp Maier4dae0652018-11-12 12:03:26 +01002931 /* Since this is an internal handover we expect the BSC to inform the
2932 * MSC about the event */
2933 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
2934
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002935 /* Check the amount of MGCP transactions is still consistant with the
2936 * test expectation */
2937 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01002938 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01002939}
2940
2941testcase TC_ho_int() runs on test_CT {
2942 var MSC_ConnHdlr vc_conn;
2943 f_init(2, true);
2944 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002945 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002946 vc_conn.done;
2947}
Harald Weltee9e02e42018-01-31 23:36:25 +01002948
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002949/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02002950private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002951 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002952 var template MgcpResponse mgcp_resp;
2953 var MGCP_RecvFrom mrf;
2954 var template MgcpMessage msg_resp;
2955 var template MgcpMessage msg_dlcx := {
2956 command := tr_DLCX()
2957 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002958
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002959 if (g_pars.aoip) {
2960 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002961 log("Got first DLCX: ", mgcp);
2962 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002963 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002964
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002965 MGCP.receive(tr_DLCX()) -> value mgcp {
2966 log("Got second DLCX: ", mgcp);
2967 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
2968 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002969 } else {
2970 /* For SCCPLite, BSC doesn't handle the MSC-side */
2971 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
2972 log("Got first DLCX: ", mrf.msg.command);
2973 msg_resp := {
2974 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
2975 }
2976 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
2977 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002978 }
2979
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02002980 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002981}
2982
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002983private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002984 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002985
2986 var PDU_BSSAP ass_req := f_gen_ass_req();
2987 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2988 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2989 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2990 f_establish_fully(ass_req, exp_compl);
2991
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02002992 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002993 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2994
2995 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2996
2997 f_sleep(0.5);
2998 /* The MSC negotiates Handover Request and Handover Request Ack with
2999 * the other BSS and comes back with a BSSMAP Handover Command
3000 * containing an RR Handover Command coming from the target BSS... */
3001
3002 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3003 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3004 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3005 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3006 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3007
3008 /* expect the Handover Command to go out on RR */
3009 var RSL_Message rsl_ho_cmd
3010 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3011 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3012 var RSL_IE_Body rsl_ho_cmd_l3;
3013 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3014 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3015 setverdict(fail);
3016 } else {
3017 log("Found L3 Info: ", rsl_ho_cmd_l3);
3018 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3019 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3020 setverdict(fail);
3021 } else {
3022 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3023 setverdict(pass);
3024 }
3025 }
3026
3027 /* When the other BSS has reported a completed handover, this side is
3028 * torn down. */
3029
3030 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
3031 var BssmapCause cause := enum2int(cause_val);
3032 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3033
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003034 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003035 setverdict(pass);
3036 f_sleep(1.0);
3037}
3038testcase TC_ho_out_of_this_bsc() runs on test_CT {
3039 var MSC_ConnHdlr vc_conn;
3040
3041 f_init(1, true);
3042 f_sleep(1.0);
3043
3044 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
3045 vc_conn.done;
3046}
3047
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003048/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
3049 * simply never sends a BSSMAP Handover Command. */
3050private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003051 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003052
3053 var PDU_BSSAP ass_req := f_gen_ass_req();
3054 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3055 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3056 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3057 f_establish_fully(ass_req, exp_compl);
3058
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003059 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003060 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3061
3062 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3063
3064 /* osmo-bsc should time out 10 seconds after the handover started.
3065 * Let's give it a bit extra. */
3066 f_sleep(15.0);
3067
3068 /* The old lchan and conn should still be active. See that arbitrary L3
3069 * is still going through. */
3070 var octetstring l3 := '0123456789'O;
3071 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3072 var template PDU_BSSAP exp_data := {
3073 discriminator := '1'B,
3074 spare := '0000000'B,
3075 dlci := '00'O,
3076 lengthIndicator := 5,
3077 pdu := {
3078 dtap := l3
3079 }
3080 };
3081 BSSAP.receive(exp_data);
3082 setverdict(pass);
3083 f_sleep(1.0);
3084}
3085testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
3086 var MSC_ConnHdlr vc_conn;
3087
3088 f_init(1, true);
3089 f_sleep(1.0);
3090
3091 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
3092 vc_conn.done;
3093}
3094
3095/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
3096 * RR Handover Failure. */
3097private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003098 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003099
3100 var PDU_BSSAP ass_req := f_gen_ass_req();
3101 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3102 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3103 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3104 f_establish_fully(ass_req, exp_compl);
3105
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003106 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003107 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3108
3109 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3110
3111 f_sleep(0.5);
3112 /* The MSC negotiates Handover Request and Handover Request Ack with
3113 * the other BSS and comes back with a BSSMAP Handover Command
3114 * containing an RR Handover Command coming from the target BSS... */
3115
3116 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3117 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3118 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3119 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3120 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3121
3122 /* expect the Handover Command to go out on RR */
3123 var RSL_Message rsl_ho_cmd
3124 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3125 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3126 var RSL_IE_Body rsl_ho_cmd_l3;
3127 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3128 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3129 setverdict(fail);
3130 } else {
3131 log("Found L3 Info: ", rsl_ho_cmd_l3);
3132 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3133 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3134 setverdict(fail);
3135 } else {
3136 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3137 setverdict(pass);
3138 }
3139 }
3140
3141 f_sleep(0.2);
3142 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3143
3144 /* Should tell the MSC about the failure */
3145 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3146
3147 f_sleep(1.0);
3148
3149 /* The old lchan and conn should still be active. See that arbitrary L3
3150 * is still going through. */
3151 var octetstring l3 := '0123456789'O;
3152 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3153 var template PDU_BSSAP exp_data := {
3154 discriminator := '1'B,
3155 spare := '0000000'B,
3156 dlci := '00'O,
3157 lengthIndicator := 5,
3158 pdu := {
3159 dtap := l3
3160 }
3161 };
3162 BSSAP.receive(exp_data);
3163 setverdict(pass);
3164 f_sleep(1.0);
3165
3166 setverdict(pass);
3167 f_sleep(1.0);
3168}
3169testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
3170 var MSC_ConnHdlr vc_conn;
3171
3172 f_init(1, true);
3173 f_sleep(1.0);
3174
3175 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
3176 vc_conn.done;
3177}
3178
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003179/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
3180 * (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 +02003181 * and the lchan is released. */
3182private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003183 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003184
3185 var PDU_BSSAP ass_req := f_gen_ass_req();
3186 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3187 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3188 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3189 f_establish_fully(ass_req, exp_compl);
3190
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003191 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003192 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3193
3194 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3195
3196 f_sleep(0.5);
3197 /* The MSC negotiates Handover Request and Handover Request Ack with
3198 * the other BSS and comes back with a BSSMAP Handover Command
3199 * containing an RR Handover Command coming from the target BSS... */
3200
3201 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3202 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3203 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3204 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3205 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3206
3207 /* expect the Handover Command to go out on RR */
3208 var RSL_Message rsl_ho_cmd
3209 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3210 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3211 var RSL_IE_Body rsl_ho_cmd_l3;
3212 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3213 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3214 setverdict(fail);
3215 } else {
3216 log("Found L3 Info: ", rsl_ho_cmd_l3);
3217 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3218 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3219 setverdict(fail);
3220 } else {
3221 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3222 setverdict(pass);
3223 }
3224 }
3225
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003226 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
3227 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
3228 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003229
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003230 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02003231 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
3232 log("Got BSSMAP Clear Request");
3233 /* Instruct BSC to clear channel */
3234 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3235 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3236
3237 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003238 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01003239 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
3240 log("Got Deact SACCH");
3241 }
Harald Welte924b6ea2019-02-04 01:05:34 +01003242 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01003243 log("Got RR Release");
3244 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003245 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
3246 log("Got RF Chan Rel");
3247 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
3248 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003249 }
3250
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003251 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003252
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003253 setverdict(pass);
3254 f_sleep(1.0);
3255}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003256testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003257 var MSC_ConnHdlr vc_conn;
3258
3259 f_init(1, true);
3260 f_sleep(1.0);
3261
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003262 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003263 vc_conn.done;
3264}
3265
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003266private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
3267 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3268 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3269 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3270 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3271 * before we get started. */
3272 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3273 f_rslem_register(0, new_chan_nr);
3274 g_chan_nr := new_chan_nr;
3275 f_sleep(1.0);
3276
3277 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3278 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3279 activate(as_Media());
3280
3281 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3282 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003283 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003284
3285 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3286
3287 var PDU_BSSAP rx_bssap;
3288 var octetstring ho_command_str;
3289
3290 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02003291
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003292 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3293 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3294 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3295 log("L3 Info in HO Request Ack is ", ho_command);
3296
3297 var GsmArfcn arfcn;
3298 var RslChannelNr actual_new_chan_nr;
3299 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3300 actual_new_chan_nr, arfcn);
3301
3302 if (actual_new_chan_nr != new_chan_nr) {
3303 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3304 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3305 setverdict(fail);
3306 return;
3307 }
3308 log("Handover Command chan_nr is", actual_new_chan_nr);
3309
3310 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3311 * tells the MS to handover to the new lchan. Here comes the new MS on
3312 * the new lchan with a Handover RACH: */
3313
3314 /* send handover detect */
3315
3316 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3317
3318 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3319
3320 /* send handover complete over the new channel */
3321
3322 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
3323 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
3324 enc_PDU_ML3_MS_NW(l3_tx)));
3325
3326 BSSAP.receive(tr_BSSMAP_HandoverComplete);
3327 setverdict(pass);
3328}
3329testcase TC_ho_into_this_bsc() runs on test_CT {
3330 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003331 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003332
3333 f_init(1, true);
3334 f_sleep(1.0);
3335
3336 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3337 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3338
3339 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
3340 vc_conn.done;
3341}
3342
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003343private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
3344 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3345 f_rslem_register(0, new_chan_nr);
3346 g_chan_nr := new_chan_nr;
3347 f_sleep(1.0);
3348
3349 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3350 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3351 activate(as_Media());
3352
3353 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3354 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003355 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003356
3357 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3358
3359 var PDU_BSSAP rx_bssap;
3360 var octetstring ho_command_str;
3361
3362 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3363
3364 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3365 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3366 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3367 log("L3 Info in HO Request Ack is ", ho_command);
3368
3369 var GsmArfcn arfcn;
3370 var RslChannelNr actual_new_chan_nr;
3371 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3372 actual_new_chan_nr, arfcn);
3373
3374 if (actual_new_chan_nr != new_chan_nr) {
3375 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3376 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3377 setverdict(fail);
3378 return;
3379 }
3380 log("Handover Command chan_nr is", actual_new_chan_nr);
3381
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02003382 /* For deterministic test results, give some time for the MGW endpoint to be configured */
3383 f_sleep(1.0);
3384
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003385 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3386 * tells the MS to handover to the new lchan. In this case, the MS
3387 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
3388 * Handover Failure to the MSC. The procedure according to 3GPP TS
3389 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
3390 * BSSMAP Clear Command: */
3391
3392 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3393 var BssmapCause cause := enum2int(cause_val);
3394 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3395
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003396 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003397 setverdict(pass);
3398 f_sleep(1.0);
3399
3400 setverdict(pass);
3401}
3402testcase TC_ho_in_fail_msc_clears() runs on test_CT {
3403 var MSC_ConnHdlr vc_conn;
3404 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3405
3406 f_init(1, true);
3407 f_sleep(1.0);
3408
3409 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3410 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3411
3412 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
3413 vc_conn.done;
3414}
3415
3416private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
3417 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3418 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3419 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3420 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3421 * before we get started. */
3422 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3423 f_rslem_register(0, new_chan_nr);
3424 g_chan_nr := new_chan_nr;
3425 f_sleep(1.0);
3426
3427 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3428 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3429 activate(as_Media());
3430
3431 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3432 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003433 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003434
3435 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3436
3437 var PDU_BSSAP rx_bssap;
3438 var octetstring ho_command_str;
3439
3440 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3441
3442 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3443 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3444 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3445 log("L3 Info in HO Request Ack is ", ho_command);
3446
3447 var GsmArfcn arfcn;
3448 var RslChannelNr actual_new_chan_nr;
3449 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3450 actual_new_chan_nr, arfcn);
3451
3452 if (actual_new_chan_nr != new_chan_nr) {
3453 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3454 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3455 setverdict(fail);
3456 return;
3457 }
3458 log("Handover Command chan_nr is", actual_new_chan_nr);
3459
3460 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3461 * tells the MS to handover to the new lchan. Here comes the new MS on
3462 * the new lchan with a Handover RACH: */
3463
3464 /* send handover detect */
3465
3466 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3467
3468 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3469
3470 /* The MSC chooses to clear the connection now, maybe we got the
3471 * Handover RACH on the new cell but the MS still signaled Handover
3472 * Failure to the old BSS? */
3473
3474 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3475 var BssmapCause cause := enum2int(cause_val);
3476 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3477
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003478 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003479 setverdict(pass);
3480 f_sleep(1.0);
3481}
3482testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
3483 var MSC_ConnHdlr vc_conn;
3484 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3485
3486 f_init(1, true);
3487 f_sleep(1.0);
3488
3489 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3490 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3491
3492 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
3493 vc_conn.done;
3494}
3495
3496/* The new BSS's lchan times out before the MSC decides that handover failed. */
3497private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
3498 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3499 f_rslem_register(0, new_chan_nr);
3500 g_chan_nr := new_chan_nr;
3501 f_sleep(1.0);
3502
3503 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3504 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3505 activate(as_Media());
3506
3507 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3508 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003509 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003510
3511 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3512
3513 var PDU_BSSAP rx_bssap;
3514 var octetstring ho_command_str;
3515
3516 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3517
3518 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3519 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3520 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3521 log("L3 Info in HO Request Ack is ", ho_command);
3522
3523 var GsmArfcn arfcn;
3524 var RslChannelNr actual_new_chan_nr;
3525 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3526 actual_new_chan_nr, arfcn);
3527
3528 if (actual_new_chan_nr != new_chan_nr) {
3529 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3530 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3531 setverdict(fail);
3532 return;
3533 }
3534 log("Handover Command chan_nr is", actual_new_chan_nr);
3535
3536 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3537 * tells the MS to handover to the new lchan. But the MS never shows up
3538 * on the new lchan. */
3539
3540 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3541
3542 /* Did osmo-bsc also send a Clear Request? */
3543 timer T := 0.5;
3544 T.start;
3545 alt {
3546 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
3547 [] T.timeout { }
3548 }
3549
3550 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
3551 * asked for it, this is a Handover Failure after all). */
3552
3553 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3554 var BssmapCause cause := enum2int(cause_val);
3555 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3556
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003557 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003558 setverdict(pass);
3559 f_sleep(1.0);
3560
3561 setverdict(pass);
3562}
3563testcase TC_ho_in_fail_no_detect() runs on test_CT {
3564 var MSC_ConnHdlr vc_conn;
3565 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3566
3567 f_init(1, true);
3568 f_sleep(1.0);
3569
3570 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3571 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3572
3573 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
3574 vc_conn.done;
3575}
3576
3577/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
3578private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
3579 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3580 f_rslem_register(0, new_chan_nr);
3581 g_chan_nr := new_chan_nr;
3582 f_sleep(1.0);
3583
3584 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3585 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3586 activate(as_Media());
3587
3588 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3589 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003590 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003591
3592 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3593
3594 var PDU_BSSAP rx_bssap;
3595 var octetstring ho_command_str;
3596
3597 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3598
3599 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3600 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3601 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3602 log("L3 Info in HO Request Ack is ", ho_command);
3603
3604 var GsmArfcn arfcn;
3605 var RslChannelNr actual_new_chan_nr;
3606 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3607 actual_new_chan_nr, arfcn);
3608
3609 if (actual_new_chan_nr != new_chan_nr) {
3610 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3611 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3612 setverdict(fail);
3613 return;
3614 }
3615 log("Handover Command chan_nr is", actual_new_chan_nr);
3616
3617 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3618 * tells the MS to handover to the new lchan. But the MS never shows up
3619 * on the new lchan. */
3620
3621 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3622
3623 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003624 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003625
3626 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003627 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3628 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3629 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003630 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003631 setverdict(pass);
3632 f_sleep(1.0);
3633}
3634testcase TC_ho_in_fail_no_detect2() runs on test_CT {
3635 var MSC_ConnHdlr vc_conn;
3636 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3637
3638 f_init(1, true);
3639 f_sleep(1.0);
3640
3641 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3642 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3643
3644 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
3645 vc_conn.done;
3646}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003647
Neels Hofmeyr91401012019-07-11 00:42:35 +02003648type record of charstring Commands;
3649
3650private function f_bts_0_cfg(Commands cmds := {}) runs on MSC_ConnHdlr
3651{
3652 f_vty_enter_cfg_bts(BSCVTY, 0);
3653 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
3654 f_vty_transceive(BSCVTY, cmds[i]);
3655 }
3656 f_vty_transceive(BSCVTY, "end");
3657}
3658
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01003659private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
3660{
3661 f_vty_enter_cfg_cs7_inst(pt, 0);
3662 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
3663 f_vty_transceive(pt, cmds[i]);
3664 }
3665 f_vty_transceive(pt, "end");
3666}
3667
Neels Hofmeyr91401012019-07-11 00:42:35 +02003668private function f_probe_for_handover(charstring log_label,
3669 charstring log_descr,
3670 charstring handover_vty_cmd,
3671 boolean expect_handover,
3672 boolean is_inter_bsc_handover := false)
3673runs on MSC_ConnHdlr
3674{
3675 var RSL_Message rsl;
3676
3677 var charstring log_msg := " (expecting handover)"
3678 if (not expect_handover) {
3679 log_msg := " (expecting NO handover)";
3680 }
3681 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
3682 f_vty_transceive(BSCVTY, handover_vty_cmd);
3683
3684 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
3685 * lchans to be established on bts 1 or bts 2. */
3686 f_rslem_suspend(RSL1_PROC);
3687 f_rslem_suspend(RSL2_PROC);
3688
3689 timer T := 2.0;
3690 T.start;
3691
3692 alt {
3693 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
3694 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
3695 log("Rx L3 from net: ", l3);
3696 if (ischosen(l3.msgs.rrm.handoverCommand)) {
3697 var RslChannelNr new_chan_nr;
3698 var GsmArfcn arfcn;
3699 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
3700 new_chan_nr, arfcn);
3701 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
3702 log(l3.msgs.rrm.handoverCommand);
3703
3704 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
3705 * matter on which BTS it really is, we're not going to follow through an entire handover
3706 * anyway. */
3707 f_rslem_register(0, new_chan_nr, RSL1_PROC);
3708 f_rslem_resume(RSL1_PROC);
3709 f_rslem_register(0, new_chan_nr, RSL2_PROC);
3710 f_rslem_resume(RSL2_PROC);
3711
3712 if (expect_handover and not is_inter_bsc_handover) {
3713 setverdict(pass);
3714 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
3715 } else {
3716 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
3717 & log_label & ": " & log_descr);
3718 }
3719
3720 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
3721 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
3722 * Handover Failure. */
3723 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3724
3725 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
3726 f_sleep(0.5);
3727 RSL1.clear;
3728 RSL2.clear;
3729 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
3730 break;
3731 } else {
3732 repeat;
3733 }
3734 }
3735 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
3736 if (expect_handover and is_inter_bsc_handover) {
3737 setverdict(pass);
3738 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
3739 } else {
3740 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
3741 & log_label & ": " & log_descr);
3742 }
3743
3744 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
3745
3746 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
3747 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
3748 * setting a short timeout and waiting is the only way. */
3749 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
3750 f_sleep(1.5);
3751 log("f_probe_for_handover(" & log_label & "): ...done");
3752
3753 break;
3754 }
3755 [] T.timeout {
3756 if (expect_handover) {
3757 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
3758 & log_label & ": " & log_descr);
3759 } else {
3760 setverdict(pass);
3761 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
3762 }
3763 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
3764 break;
3765 }
3766 }
3767
3768 f_rslem_resume(RSL1_PROC);
3769 f_rslem_resume(RSL2_PROC);
3770 f_sleep(3.0);
3771 RSL.clear;
3772
3773 log("f_probe_for_handover(" & log_label & "): done clearing");
3774}
3775
3776/* Test the effect of various neighbor configuration scenarios:
3777 *
3778 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
3779 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
3780 */
3781private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
3782 g_pars := f_gen_test_hdlr_pars();
3783 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3784 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3785 const OCT8 kc := '0001020304050607'O;
3786
3787 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3788 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3789
3790 /* Establish lchan at bts 0 */
3791 f_establish_fully(ass_cmd, exp_compl);
3792
3793 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
3794 f_vty_enter_cfg_network(BSCVTY);
3795 f_vty_transceive(BSCVTY, "timer T7 1");
3796 f_vty_transceive(BSCVTY, "end");
3797}
3798
3799private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
3800 f_tc_ho_neighbor_config_start();
3801
3802 /*
3803 * bts 0 ARFCN 871 BSIC 10
3804 * bts 1 ARFCN 871 BSIC 11
3805 * bts 2 ARFCN 871 BSIC 12
3806 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3807 */
3808
3809 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
3810 f_bts_0_cfg({"no neighbors"});
3811 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
3812 "handover any to arfcn 871 bsic 11",
3813 true);
3814
3815 f_probe_for_handover("1.b", "HO to unknown cell does not start",
3816 "handover any to arfcn 13 bsic 39",
3817 false);
3818
3819 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
3820 "handover any to arfcn 871 bsic 12",
3821 false);
3822
3823 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
3824 "handover any to arfcn 871 bsic 11",
3825 true);
3826}
3827private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
3828 f_tc_ho_neighbor_config_start();
3829
3830 /*
3831 * bts 0 ARFCN 871 BSIC 10
3832 * bts 1 ARFCN 871 BSIC 11
3833 * bts 2 ARFCN 871 BSIC 12
3834 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3835 */
3836
3837 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
3838 f_bts_0_cfg({"neighbor bts 1"});
3839 f_sleep(0.5);
3840
3841 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
3842 "handover any to arfcn 871 bsic 11",
3843 true);
3844
3845 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
3846 "handover any to arfcn 871 bsic 12",
3847 false);
3848}
3849private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
3850 f_tc_ho_neighbor_config_start();
3851
3852 /*
3853 * bts 0 ARFCN 871 BSIC 10
3854 * bts 1 ARFCN 871 BSIC 11
3855 * bts 2 ARFCN 871 BSIC 12
3856 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3857 */
3858
3859 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
3860 f_bts_0_cfg({"no neighbors", "neighbor bts 2"});
3861 f_sleep(0.5);
3862
3863 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
3864 "handover any to arfcn 871 bsic 11",
3865 false);
3866 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",
3867 "handover any to arfcn 871 bsic 12",
3868 true);
3869}
3870private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
3871 f_tc_ho_neighbor_config_start();
3872
3873 /*
3874 * bts 0 ARFCN 871 BSIC 10
3875 * bts 1 ARFCN 871 BSIC 11
3876 * bts 2 ARFCN 871 BSIC 12
3877 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3878 */
3879
3880 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
3881 f_bts_0_cfg({"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
3882 f_sleep(0.5);
3883
3884 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
3885 "handover any to arfcn 871 bsic 11",
3886 false);
3887 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
3888 "handover any to arfcn 871 bsic 12",
3889 false);
3890 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
3891 "handover any to arfcn 123 bsic 45",
3892 true, true);
3893}
3894private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
3895 f_tc_ho_neighbor_config_start();
3896
3897 /*
3898 * bts 0 ARFCN 871 BSIC 10
3899 * bts 1 ARFCN 871 BSIC 11
3900 * bts 2 ARFCN 871 BSIC 12
3901 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3902 */
3903
3904 log("f_tc_ho_neighbor_config: 5. explicit remote neighbor re-using ARFCN+BSIC: 'neighbor lac 99 arfcn 871 bsic 12'");
3905 f_bts_0_cfg({"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
3906 f_sleep(0.5);
3907
3908 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
3909 "handover any to arfcn 871 bsic 12",
3910 true, true);
3911}
3912private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
3913 f_tc_ho_neighbor_config_start();
3914
3915 /*
3916 * bts 0 ARFCN 871 BSIC 10
3917 * bts 1 ARFCN 871 BSIC 11
3918 * bts 2 ARFCN 871 BSIC 12
3919 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3920 */
3921
3922 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
3923 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
3924 f_bts_0_cfg({"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
3925 f_sleep(0.5);
3926
3927 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
3928 "handover any to arfcn 871 bsic 12",
3929 false);
3930}
3931private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
3932 f_tc_ho_neighbor_config_start();
3933
3934 /*
3935 * bts 0 ARFCN 871 BSIC 10
3936 * bts 1 ARFCN 871 BSIC 11
3937 * bts 2 ARFCN 871 BSIC 12
3938 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3939 */
3940
3941 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
3942 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
3943 f_bts_0_cfg({"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
3944 f_sleep(0.5);
3945
3946 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
3947 "handover any to arfcn 871 bsic 12",
3948 true);
3949 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
3950 "handover any to arfcn 123 bsic 45",
3951 true, true);
3952}
3953
3954testcase TC_ho_neighbor_config_1() runs on test_CT {
3955 var MSC_ConnHdlr vc_conn;
3956 f_init(3, true);
3957 f_sleep(1.0);
3958 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
3959 vc_conn.done;
3960}
3961testcase TC_ho_neighbor_config_2() runs on test_CT {
3962 var MSC_ConnHdlr vc_conn;
3963 f_init(3, true);
3964 f_sleep(1.0);
3965 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
3966 vc_conn.done;
3967}
3968testcase TC_ho_neighbor_config_3() runs on test_CT {
3969 var MSC_ConnHdlr vc_conn;
3970 f_init(3, true);
3971 f_sleep(1.0);
3972 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
3973 vc_conn.done;
3974}
3975testcase TC_ho_neighbor_config_4() runs on test_CT {
3976 var MSC_ConnHdlr vc_conn;
3977 f_init(3, true);
3978 f_sleep(1.0);
3979 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
3980 vc_conn.done;
3981}
3982testcase TC_ho_neighbor_config_5() runs on test_CT {
3983 var MSC_ConnHdlr vc_conn;
3984 f_init(3, true);
3985 f_sleep(1.0);
3986 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
3987 vc_conn.done;
3988}
3989testcase TC_ho_neighbor_config_6() runs on test_CT {
3990 var MSC_ConnHdlr vc_conn;
3991 f_init(3, true);
3992 f_sleep(1.0);
3993 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
3994 vc_conn.done;
3995}
3996testcase TC_ho_neighbor_config_7() runs on test_CT {
3997 var MSC_ConnHdlr vc_conn;
3998 f_init(3, true);
3999 f_sleep(1.0);
4000 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
4001 vc_conn.done;
4002}
4003
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004004/* OS#3041: Open and close N connections in a normal fashion, and expect no
4005 * BSSMAP Reset just because of that. */
4006testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
4007 var default d;
4008 var integer i;
4009 var DchanTuple dt;
4010
4011 f_init();
4012
4013 /* Wait for initial BSSMAP Reset to pass */
4014 f_sleep(4.0);
4015
4016 d := activate(no_bssmap_reset());
4017
4018 /* Setup up a number of connections and RLSD them again from the MSC
4019 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4020 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02004021 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004022 /* Since we're doing a lot of runs, give each one a fresh
4023 * T_guard from the top. */
4024 T_guard.start;
4025
4026 /* Setup a BSSAP connection and clear it right away. This is
4027 * the MSC telling the BSC about a planned release, it's not an
4028 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004029 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004030
4031 /* MSC disconnects (RLSD). */
4032 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
4033 }
4034
4035 /* In the buggy behavior, a timeout of 2 seconds happens between above
4036 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4037 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4038 f_sleep(4.0);
4039
4040 deactivate(d);
4041 f_shutdown_helper();
4042}
Harald Welte552620d2017-12-16 23:21:36 +01004043
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004044/* OS#3041: Open and close N connections in a normal fashion, and expect no
4045 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
4046 * the MSC. */
4047testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
4048 var default d;
4049 var integer i;
4050 var DchanTuple dt;
4051 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004052 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
4053 var BssmapCause cause := enum2int(cause_val);
4054
4055 f_init();
4056
4057 /* Wait for initial BSSMAP Reset to pass */
4058 f_sleep(4.0);
4059
4060 d := activate(no_bssmap_reset());
4061
4062 /* Setup up a number of connections and RLSD them again from the MSC
4063 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4064 * Let's do it some more times for good measure. */
4065 for (i := 0; i < 8; i := i+1) {
4066 /* Since we're doing a lot of runs, give each one a fresh
4067 * T_guard from the top. */
4068 T_guard.start;
4069
4070 /* Setup a BSSAP connection and clear it right away. This is
4071 * the MSC telling the BSC about a planned release, it's not an
4072 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004073 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004074
4075 /* Instruct BSC to clear channel */
4076 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4077
4078 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004079 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004080 }
4081
4082 /* In the buggy behavior, a timeout of 2 seconds happens between above
4083 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4084 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4085 f_sleep(4.0);
4086
4087 deactivate(d);
4088 f_shutdown_helper();
4089}
4090
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004091/* OS#3041: Open and close N connections in a normal fashion, and expect no
4092 * BSSMAP Reset just because of that. Close connections from the MS side with a
4093 * Release Ind on RSL. */
4094testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
4095 var default d;
4096 var integer i;
4097 var DchanTuple dt;
4098 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004099 var integer j;
4100
4101 f_init();
4102
4103 /* Wait for initial BSSMAP Reset to pass */
4104 f_sleep(4.0);
4105
4106 d := activate(no_bssmap_reset());
4107
4108 /* Setup up a number of connections and RLSD them again from the MSC
4109 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4110 * Let's do it some more times for good measure. */
4111 for (i := 0; i < 8; i := i+1) {
4112 /* Since we're doing a lot of runs, give each one a fresh
4113 * T_guard from the top. */
4114 T_guard.start;
4115
4116 /* Setup a BSSAP connection and clear it right away. This is
4117 * the MSC telling the BSC about a planned release, it's not an
4118 * erratic loss of a connection. */
4119 dt := f_est_dchan('23'O, 23, '00010203040506'O);
4120
4121 /* simulate RLL REL IND */
4122 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
4123
4124 /* expect Clear Request on MSC side */
4125 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
4126
4127 /* Instruct BSC to clear channel */
4128 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
4129 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4130
4131 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004132 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004133 }
4134
4135 /* In the buggy behavior, a timeout of 2 seconds happens between above
4136 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4137 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4138 f_sleep(4.0);
4139
4140 deactivate(d);
4141 f_shutdown_helper();
4142}
4143
Harald Welte94e0c342018-04-07 11:33:23 +02004144/***********************************************************************
4145 * IPA style dynamic PDCH
4146 ***********************************************************************/
4147
4148private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4149 template (omit) RSL_Cause nack := omit)
4150runs on test_CT {
4151 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4152 var RSL_Message rsl_unused;
4153 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4154 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
4155 /* expect the BSC to issue the related RSL command */
4156 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4157 if (istemplatekind(nack, "omit")) {
4158 /* respond with a related acknowledgement */
4159 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4160 } else {
4161 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
4162 }
4163}
4164
4165private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4166 template (omit) RSL_Cause nack := omit)
4167runs on test_CT {
4168 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4169 var RSL_Message rsl_unused;
4170 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4171 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
4172 /* expect the BSC to issue the related RSL command */
4173 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
4174 if (istemplatekind(nack, "omit")) {
4175 /* respond with a related acknowledgement */
4176 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
4177 } else {
4178 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
4179 }
4180}
4181
4182private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
4183runs on test_CT return charstring {
4184 var charstring cmd, resp;
4185 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01004186 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02004187}
4188
4189private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
4190 template charstring exp)
4191runs on test_CT {
4192 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
4193 if (not match(mode, exp)) {
4194 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02004195 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02004196 }
4197}
4198
4199private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
4200runs on test_CT {
4201 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
4202 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
4203 f_vty_transceive(BSCVTY, "end");
4204}
4205
4206private const charstring TCHF_MODE := "TCH/F mode";
4207private const charstring TCHH_MODE := "TCH/H mode";
4208private const charstring PDCH_MODE := "PDCH mode";
4209private const charstring NONE_MODE := "NONE mode";
4210
4211/* Test IPA PDCH activation / deactivation triggered by VTY */
4212testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
4213 var RSL_Message rsl_unused;
4214
4215 /* change Timeslot 6 before f_init() starts RSL */
4216 f_init_vty();
4217 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4218 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4219
4220 f_init(1, false);
4221 f_sleep(1.0);
4222
4223 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4224
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004225 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004226 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4227 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4228 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4229 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4230 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004231 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004232 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4233
4234 /* De-activate it via VTY */
4235 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4236 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004237 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004238 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4239
4240 /* re-activate it via VTY */
4241 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
4242 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004243 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004244 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4245
4246 /* and finally de-activate it again */
4247 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4248 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004249 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004250 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4251
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004252 /* clean up config */
4253 f_ts_set_chcomb(0, 0, 6, "PDCH");
4254
Harald Welte94e0c342018-04-07 11:33:23 +02004255 setverdict(pass);
4256}
4257
4258/* Test IPA PDCH activation NACK */
4259testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
4260 var RSL_Message rsl_unused;
4261
4262 /* change Timeslot 6 before f_init() starts RSL */
4263 f_init_vty();
4264 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4265 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4266
4267 f_init(1, false);
4268 f_sleep(1.0);
4269
4270 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4271
4272 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4273 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4274 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4275 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4276 f_sleep(1.0);
4277 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4278
4279 /* De-activate it via VTY */
4280 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4281 f_sleep(1.0);
4282 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4283
4284 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
4285 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
4286 f_sleep(1.0);
4287 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4288
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004289 /* clean up config */
4290 f_ts_set_chcomb(0, 0, 6, "PDCH");
4291
Harald Welte94e0c342018-04-07 11:33:23 +02004292 setverdict(pass);
4293}
4294
4295
4296/***********************************************************************
4297 * Osmocom style dynamic PDCH
4298 ***********************************************************************/
4299
4300private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4301 template (omit) RSL_Cause nack := omit)
4302runs on test_CT {
4303 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4304 var RSL_Message rsl_unused;
4305 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4306 /* FIXME: no VTY command to activate Osmocom PDCH !! */
4307 /* expect the BSC to issue the related RSL command */
4308 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
4309 if (istemplatekind(nack, "omit")) {
4310 /* respond with a related acknowledgement */
4311 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
4312 } else {
4313 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
4314 }
4315}
4316
4317private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4318 template (omit) RSL_Cause nack := omit)
4319runs on test_CT {
4320 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4321 var RSL_Message rsl_unused;
4322 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4323 /* FIXME: no VTY command to activate Osmocom PDCH !! */
4324 /* expect the BSC to issue the related RSL command */
4325 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
4326 if (istemplatekind(nack, "omit")) {
4327 /* respond with a related acknowledgement */
4328 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
4329 } else {
4330 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
4331 }
4332}
4333
4334/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
4335testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
4336 var RSL_Message rsl_unused;
4337
4338 /* change Timeslot 6 before f_init() starts RSL */
4339 f_init_vty();
4340 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
4341 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4342
4343 f_init(1, false);
4344 f_sleep(1.0);
4345
4346 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
4347
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004348 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004349 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4350 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4351 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
4352
4353 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
4354 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004355 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 +02004356 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4357
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004358 /* clean up config */
4359 f_ts_set_chcomb(0, 0, 6, "PDCH");
4360
Harald Welte94e0c342018-04-07 11:33:23 +02004361 setverdict(pass);
4362}
4363
4364/* Test Osmocom dyn PDCH activation NACK behavior */
4365testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
4366 var RSL_Message rsl_unused;
4367
4368 /* change Timeslot 6 before f_init() starts RSL */
4369 f_init_vty();
4370 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
4371 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4372
4373 f_init(1, false);
4374 f_sleep(1.0);
4375
4376 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
4377
4378 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4379 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4380 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
4381
4382 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
4383 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
4384 f_sleep(1.0);
4385 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4386
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004387 /* clean up config */
4388 f_ts_set_chcomb(0, 0, 6, "PDCH");
4389
Harald Welte94e0c342018-04-07 11:33:23 +02004390 setverdict(pass);
4391}
4392
Stefan Sperling0796a822018-10-05 13:01:39 +02004393testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02004394 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02004395 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
4396 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
4397 }
4398}
4399
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004400testcase TC_chopped_ipa_payload() runs on test_CT {
4401 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
4402 /* TODO: mp_bsc_ctrl_port does not work yet */};
4403 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
4404 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
4405 }
4406}
4407
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01004408/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
4409 the BTS does autonomous MS power control loop */
4410testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
4411 var MSC_ConnHdlr vc_conn;
4412 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4413 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
4414 pars.exp_ms_power_params := true;
4415
4416 f_init(1, true);
4417 f_sleep(1.0);
4418 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
4419 vc_conn.done;
4420}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004421
Harald Welte0ea2d5e2018-04-07 21:40:29 +02004422/* Dyn PDCH todo:
4423 * activate OSMO as TCH/F
4424 * activate OSMO as TCH/H
4425 * does the BSC-located PCU socket get the updated INFO?
4426 * what if no PCU is connected at the time?
4427 * is the info correct on delayed PCU (re)connect?
4428 */
Harald Welte94e0c342018-04-07 11:33:23 +02004429
Harald Welte28d943e2017-11-25 15:00:50 +01004430control {
Harald Welte898113b2018-01-31 18:32:21 +01004431 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01004432 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01004433 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01004434 execute( TC_ctrl() );
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02004435 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
4436 execute( TC_ctrl_location() );
4437 }
Harald Welte898113b2018-01-31 18:32:21 +01004438
4439 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01004440 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01004441 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01004442 execute( TC_chan_act_ack_noest() );
4443 execute( TC_chan_act_ack_est_ind_noreply() );
4444 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01004445 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01004446 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07004447 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01004448 execute( TC_chan_rel_rll_rel_ind() );
4449 execute( TC_chan_rel_conn_fail() );
4450 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01004451 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01004452 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02004453 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01004454 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01004455 execute( TC_chan_rel_sccp_tiar_timeout() );
Harald Welte6f521d82017-12-11 19:52:02 +01004456
Harald Weltecfe2c962017-12-15 12:09:32 +01004457 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01004458
4459 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01004460 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01004461 execute( TC_assignment_csd() );
4462 execute( TC_assignment_ctm() );
4463 execute( TC_assignment_sign() );
4464 execute( TC_assignment_fr_a5_0() );
4465 execute( TC_assignment_fr_a5_1() );
Harald Welte8f67d1d2018-05-25 20:38:42 +02004466 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
4467 execute( TC_assignment_fr_a5_1_codec_missing() );
4468 }
Harald Welte235ebf12017-12-15 14:18:16 +01004469 execute( TC_assignment_fr_a5_3() );
4470 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02004471 execute( TC_ciph_mode_a5_0() );
4472 execute( TC_ciph_mode_a5_1() );
4473 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01004474
Harald Welte60aa5762018-03-21 19:33:13 +01004475 execute( TC_assignment_codec_fr() );
4476 execute( TC_assignment_codec_hr() );
4477 execute( TC_assignment_codec_efr() );
4478 execute( TC_assignment_codec_amr_f() );
4479 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01004480
4481 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
4482 execute( TC_assignment_codec_amr_f_S1() );
4483 execute( TC_assignment_codec_amr_h_S1() );
4484 execute( TC_assignment_codec_amr_f_S124() );
4485 execute( TC_assignment_codec_amr_h_S124() );
4486 execute( TC_assignment_codec_amr_f_S0() );
4487 execute( TC_assignment_codec_amr_f_S02() );
4488 execute( TC_assignment_codec_amr_f_S024() );
4489 execute( TC_assignment_codec_amr_f_S0247() );
4490 execute( TC_assignment_codec_amr_h_S0() );
4491 execute( TC_assignment_codec_amr_h_S02() );
4492 execute( TC_assignment_codec_amr_h_S024() );
4493 execute( TC_assignment_codec_amr_h_S0247() );
4494 execute( TC_assignment_codec_amr_f_S01234567() );
4495 execute( TC_assignment_codec_amr_f_S0234567() );
4496 execute( TC_assignment_codec_amr_f_zero() );
4497 execute( TC_assignment_codec_amr_f_unsupp() );
4498 execute( TC_assignment_codec_amr_h_S7() );
4499 }
Harald Welte60aa5762018-03-21 19:33:13 +01004500
Philipp Maierac09bfc2019-01-08 13:41:39 +01004501 execute( TC_assignment_codec_fr_exhausted_req_hr() );
4502 execute( TC_assignment_codec_fr_exhausted_req_fr() );
4503 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
4504 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
4505 execute( TC_assignment_codec_hr_exhausted_req_fr() );
4506 execute( TC_assignment_codec_hr_exhausted_req_hr() );
4507 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
4508 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
4509 execute( TC_assignment_codec_req_hr_fr() );
4510 execute( TC_assignment_codec_req_fr_hr() );
4511
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02004512 if (mp_enable_osmux_test) {
4513 execute( TC_assignment_osmux() );
4514 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004515
Harald Welte898113b2018-01-31 18:32:21 +01004516 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01004517 execute( TC_rll_est_ind_inact_lchan() );
4518 execute( TC_rll_est_ind_inval_sapi1() );
4519 execute( TC_rll_est_ind_inval_sapi3() );
4520 execute( TC_rll_est_ind_inval_sacch() );
4521
Harald Welte898113b2018-01-31 18:32:21 +01004522 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01004523 execute( TC_paging_imsi_nochan() );
4524 execute( TC_paging_tmsi_nochan() );
4525 execute( TC_paging_tmsi_any() );
4526 execute( TC_paging_tmsi_sdcch() );
4527 execute( TC_paging_tmsi_tch_f() );
4528 execute( TC_paging_tmsi_tch_hf() );
4529 execute( TC_paging_imsi_nochan_cgi() );
4530 execute( TC_paging_imsi_nochan_lac_ci() );
4531 execute( TC_paging_imsi_nochan_ci() );
4532 execute( TC_paging_imsi_nochan_lai() );
4533 execute( TC_paging_imsi_nochan_lac() );
4534 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01004535 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
4536 execute( TC_paging_imsi_nochan_rnc() );
4537 execute( TC_paging_imsi_nochan_lac_rnc() );
4538 execute( TC_paging_imsi_nochan_lacs() );
4539 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01004540 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01004541 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01004542 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01004543 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01004544 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01004545
4546 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01004547 execute( TC_rsl_unknown_unit_id() );
4548
4549 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01004550
4551 execute( TC_classmark() );
4552 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01004553 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004554 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01004555 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01004556 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004557
Harald Welte261af4b2018-02-12 21:20:39 +01004558 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004559
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004560 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004561 execute( TC_ho_out_fail_no_msc_response() );
4562 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004563 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004564
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004565 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004566 execute( TC_ho_in_fail_msc_clears() );
4567 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
4568 execute( TC_ho_in_fail_no_detect() );
4569 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004570
Neels Hofmeyr91401012019-07-11 00:42:35 +02004571 execute( TC_ho_neighbor_config_1() );
4572 execute( TC_ho_neighbor_config_2() );
4573 execute( TC_ho_neighbor_config_3() );
4574 execute( TC_ho_neighbor_config_4() );
4575 execute( TC_ho_neighbor_config_5() );
4576 execute( TC_ho_neighbor_config_6() );
4577 execute( TC_ho_neighbor_config_7() );
4578
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004579 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004580 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004581 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02004582
4583 execute( TC_dyn_pdch_ipa_act_deact() );
4584 execute( TC_dyn_pdch_ipa_act_nack() );
4585 execute( TC_dyn_pdch_osmo_act_deact() );
4586 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004587
Stefan Sperling0796a822018-10-05 13:01:39 +02004588 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004589 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02004590
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01004591 /* Power control related */
4592 execute( TC_assignment_verify_ms_power_params_ie() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004593 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
4594 execute( TC_early_conn_fail() );
4595 execute( TC_late_conn_fail() );
4596
Harald Welte28d943e2017-11-25 15:00:50 +01004597}
4598
4599}