blob: 353ab16ef8219e6fc45db363836aa753bc7a78a3 [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,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001301 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01001302{
1303 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001304 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01001305 var RSL_Message rx_rsl;
1306 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001307 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001308
1309 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001310
1311 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001312 for (i := 0; i < NUM_BTS; i := i + 1) {
1313 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001314 }
Harald Welte6f521d82017-12-11 19:52:02 +01001315
1316 if (isvalue(rsl_chneed)) {
1317 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1318 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1319 } else {
1320 bssmap_chneed := omit;
1321 }
1322
1323 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
1324
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001325 if (not istemplatekind(tmsi, "omit")) {
1326 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01001327 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001328 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01001329 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001330
Harald Welte5d1a2202017-12-13 19:51:29 +01001331 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001332 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01001333 /* check channel type, paging group */
1334 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1335 setverdict(fail, "Paging for wrong paging group");
1336 }
1337 if (ispresent(rsl_chneed) and
1338 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1339 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1340 }
Harald Welte6f521d82017-12-11 19:52:02 +01001341 }
Harald Welte2fccd982018-01-31 15:48:19 +01001342 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001343 /* do a quick check on all not-included BTSs if they received paging */
1344 for (i := 0; i < NUM_BTS; i := i + 1) {
1345 timer T := 0.1;
1346 if (f_bts_in_list(i, bts_ids)) {
1347 continue;
1348 }
1349 T.start;
1350 alt {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001351 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01001352 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1353 }
1354 [] IPA_RSL[i].receive { repeat; }
1355 [] T.timeout { }
1356 }
Harald Welte6f521d82017-12-11 19:52:02 +01001357 }
1358
1359 setverdict(pass);
1360}
1361
Harald Welte5d1a2202017-12-13 19:51:29 +01001362const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001363const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001364const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1365const BtsIdList c_BtsId_LAC2 := { 2 };
1366
Harald Welte6f521d82017-12-11 19:52:02 +01001367/* PAGING by IMSI + TMSI */
1368testcase TC_paging_imsi_nochan() runs on test_CT {
1369 var BSSMAP_FIELD_CellIdentificationList cid_list;
1370 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001371 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001372 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001373}
1374
1375/* PAGING by IMSI + TMSI */
1376testcase TC_paging_tmsi_nochan() runs on test_CT {
1377 var BSSMAP_FIELD_CellIdentificationList cid_list;
1378 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001379 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001380 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001381}
1382
1383/* Paging with different "channel needed' values */
1384testcase TC_paging_tmsi_any() runs on test_CT {
1385 var BSSMAP_FIELD_CellIdentificationList cid_list;
1386 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001387 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001388 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001389}
1390testcase TC_paging_tmsi_sdcch() runs on test_CT {
1391 var BSSMAP_FIELD_CellIdentificationList cid_list;
1392 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001393 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001394 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001395}
1396testcase TC_paging_tmsi_tch_f() runs on test_CT {
1397 var BSSMAP_FIELD_CellIdentificationList cid_list;
1398 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001399 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001400 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001401}
1402testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1403 var BSSMAP_FIELD_CellIdentificationList cid_list;
1404 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001405 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001406 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001407}
1408
1409/* Paging by CGI */
1410testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1411 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1412 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001413 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001414 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001415}
1416
1417/* Paging by LAC+CI */
1418testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1419 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1420 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001421 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001422 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001423}
1424
1425/* Paging by CI */
1426testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1427 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1428 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001429 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001430 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001431}
1432
1433/* Paging by LAI */
1434testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1435 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1436 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001437 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001438 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001439}
1440
1441/* Paging by LAC */
1442testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1443 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1444 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001445 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001446 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001447}
1448
1449/* Paging by "all in BSS" */
1450testcase TC_paging_imsi_nochan_all() runs on test_CT {
1451 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1452 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001453 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001454 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001455}
1456
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001457/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001458testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1459 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1460 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 +01001461 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001462 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001463}
Harald Welte6f521d82017-12-11 19:52:02 +01001464
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001465/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001466testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1467 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1468 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001469 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001470 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001471}
1472
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001473/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001474testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1475 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1476 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001477 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001478 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001479}
1480
Harald Welte6f521d82017-12-11 19:52:02 +01001481/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001482testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1483 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1484 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1485 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001486 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001487}
1488
1489/* Paging on empty list: Verify none of them page */
1490testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1491 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1492 cid_list := { cIl_LAC := { } };
1493 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001494 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001495}
1496
Stefan Sperling049a86e2018-03-20 15:51:00 +01001497/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1498testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1499 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1500 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1501 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1502 f_shutdown_helper();
1503}
1504
Harald Welte6f521d82017-12-11 19:52:02 +01001505/* Verify paging retransmission interval + count */
1506/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001507/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001508
Harald Weltee65d40e2017-12-13 00:09:06 +01001509/* Verify PCH load */
1510testcase TC_paging_imsi_load() runs on test_CT {
1511 var BSSMAP_FIELD_CellIdentificationList cid_list;
1512 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001513 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001514 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001515 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001516
1517 /* tell BSC there is no paging space anymore */
1518 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001519 f_sleep(0.2);
1520 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001521
1522 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1523 * there would be 8 retransmissions during 4 seconds */
1524 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001525 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001526 alt {
1527 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1528 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02001529 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01001530 }
Harald Welte2caa1062018-03-17 18:19:05 +01001531 [] T_retrans.timeout {
1532 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1533 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1534 T_retrans.start;
1535 repeat;
1536 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001537 [] T.timeout {
1538 setverdict(pass);
1539 }
1540 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001541
1542 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001543}
1544
Harald Welte235ebf12017-12-15 14:18:16 +01001545/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001546testcase TC_paging_counter() runs on test_CT {
1547 var BSSMAP_FIELD_CellIdentificationList cid_list;
1548 timer T := 4.0;
1549 var integer i;
1550 var integer paging_attempted_bsc;
1551 var integer paging_attempted_bts[NUM_BTS];
1552 var integer paging_expired_bts[NUM_BTS];
1553 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1554
1555 f_init();
1556
1557 /* read counters before paging */
1558 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1559 for (i := 0; i < NUM_BTS; i := i+1) {
1560 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1561 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1562 }
1563
1564 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1565
1566 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1567 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1568 for (i := 0; i < NUM_BTS; i := i+1) {
1569 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1570 paging_attempted_bts[i]+1);
1571 }
1572
1573 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1574 f_sleep(12.0);
1575 for (i := 0; i < NUM_BTS; i := i+1) {
1576 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1577 paging_expired_bts[i]+1);
1578 }
Harald Welte1ff69992017-12-14 12:31:17 +01001579
Philipp Maier282ca4b2018-02-27 17:17:00 +01001580 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001581}
1582
1583
Harald Welte10985002017-12-12 09:29:15 +01001584/* Verify paging stops after A-RESET */
1585testcase TC_paging_imsi_a_reset() runs on test_CT {
1586 var BSSMAP_FIELD_CellIdentificationList cid_list;
1587 timer T := 3.0;
1588 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001589 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001590
1591 /* Perform a BSSMAP Reset and wait for ACK */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001592 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 +01001593 alt {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001594 [] 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 +01001595 [] BSSAP.receive { repeat; }
1596 }
1597
Daniel Willmanncbef3982018-07-30 09:22:40 +02001598 /* Wait to avoid a possible race condition if a paging message is
1599 * received right before the reset ACK. */
1600 f_sleep(0.2);
1601
Harald Welte10985002017-12-12 09:29:15 +01001602 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001603 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1604 IPA_RSL[i].clear;
1605 }
Harald Welte10985002017-12-12 09:29:15 +01001606
1607 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1608 T.start;
1609 alt {
1610 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1611 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001612 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01001613 }
Harald Welte5d1a2202017-12-13 19:51:29 +01001614 [] IPA_RSL[1].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 Welte5d1a2202017-12-13 19:51:29 +01001617 }
1618 [] IPA_RSL[2].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 }
Harald Welte10985002017-12-12 09:29:15 +01001622 [] T.timeout {
1623 setverdict(pass);
1624 }
1625 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001626
1627 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001628}
Harald Welteae026692017-12-09 01:03:01 +01001629
Philipp Maierf45824a2019-08-14 14:44:10 +02001630/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
1631 * paging response we can not know which MSC is in charge, so we will blindly
1632 * pick the first configured MSC. This behavior is required in order to make
1633 * MT-CSFB calls working because in those cases the BSC can not know that the
1634 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
1635 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001636 */
1637testcase TC_paging_resp_unsol() runs on test_CT {
1638
1639 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02001640 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001641
1642 var BSSAP_N_CONNECT_ind rx_c_ind;
1643 var DchanTuple dt;
1644 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02001645 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001646
1647 /* Send CHAN RQD and wait for allocation; acknowledge it */
1648 dt.rsl_chan_nr := f_chreq_act_ack();
1649
1650 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
1651 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
1652
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001653
Philipp Maierf45824a2019-08-14 14:44:10 +02001654 /* Expevct a CR with a matching Paging response on the A-Interface */
1655 T.start;
1656 alt {
1657 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
1658 setverdict(pass);
1659 }
1660 [] BSSAP.receive {
1661 setverdict(fail, "Received unexpected message on A-Interface!");
1662 }
1663 [] T.timeout {
1664 setverdict(fail, "Received nothing on A-Interface!");
1665 }
1666 }
1667
1668 setverdict(pass);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001669}
1670
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001671/* Test RSL link drop causes counter increment */
1672testcase TC_rsl_drop_counter() runs on test_CT {
1673 var integer rsl_fail;
1674
Harald Welte89d42e82017-12-17 16:42:41 +01001675 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001676
1677 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1678
1679 bts[0].rsl.vc_IPA.stop;
1680
1681 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1682
1683 setverdict(pass);
1684}
1685
1686/* TODO: Test OML link drop causes counter increment */
1687
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001688/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1689function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1690 timer T := 10.0;
1691
1692 bts[0].rsl.id := "IPA-0-RSL";
1693 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1694 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1695 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02001696 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001697
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001698 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1699
1700 f_init_mgcp("VirtMSC");
1701
1702 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1703 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1704 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1705 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1706
1707 /* wait for IPA OML link to connect and then disconnect */
1708 T.start;
1709 alt {
1710 [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) {
1711 T.stop;
1712 return true;
1713 }
1714 [] IPA_RSL[0].receive { repeat }
1715 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02001716 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001717 }
1718 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001719 return false;
1720}
1721
1722/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1723testcase TC_rsl_unknown_unit_id() runs on test_CT {
1724 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1725 setverdict(pass);
1726 } else {
1727 setverdict(fail, "Timeout RSL waiting for connection to close");
1728 }
1729}
1730
1731
1732/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1733testcase TC_oml_unknown_unit_id() runs on test_CT {
1734 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1735 setverdict(pass);
1736 } else {
1737 setverdict(fail, "Timeout OML waiting for connection to close");
1738 }
1739}
1740
1741
Harald Weltec1a2fff2017-12-17 11:06:19 +01001742/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02001743 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01001744 ***********************************************************************/
1745
Harald Welte6811d102019-04-14 22:23:14 +02001746import from RAN_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01001747import from RSL_Emulation all;
1748import from MSC_ConnectionHandler all;
1749
1750type function void_fn(charstring id) runs on MSC_ConnHdlr;
1751
Harald Welte336820c2018-05-31 20:34:52 +02001752/* helper function to create and connect a MSC_ConnHdlr component */
Harald Welteff579f92018-05-31 22:19:39 +02001753private function f_connect_handler(inout MSC_ConnHdlr vc_conn) runs on test_CT {
Harald Welte6811d102019-04-14 22:23:14 +02001754 connect(vc_conn:RAN, g_bssap.vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001755 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001756 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001757 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001758 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001759 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1760 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1761 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02001762 if (isvalue(bts[2])) {
1763 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
1764 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
1765 }
Harald Welte6811d102019-04-14 22:23:14 +02001766 connect(vc_conn:BSSAP, g_bssap.vc_RAN:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001767 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02001768 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Harald Welte336820c2018-05-31 20:34:52 +02001769}
1770
1771function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
1772runs on test_CT return MSC_ConnHdlr {
1773 var charstring id := testcasename();
1774 var MSC_ConnHdlr vc_conn;
1775 vc_conn := MSC_ConnHdlr.create(id);
1776 f_connect_handler(vc_conn);
Harald Weltea0630032018-03-20 21:09:55 +01001777 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001778 return vc_conn;
1779}
1780
Harald Weltea0630032018-03-20 21:09:55 +01001781/* first function inside ConnHdlr component; sets g_pars + starts function */
1782private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1783runs on MSC_ConnHdlr {
1784 if (isvalue(pars)) {
1785 g_pars := valueof(pars);
1786 }
1787 fn.apply(id);
1788}
1789
Harald Welte3c86ea02018-05-10 22:28:05 +02001790/* Establish signalling channel (non-assignment case) followed by cipher mode */
1791private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001792 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1793 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001794 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02001795 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
1796 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
1797 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
1798 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02001799
Philipp Maier23000732018-05-18 11:25:37 +02001800 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02001801}
1802testcase TC_ciph_mode_a5_0() runs on test_CT {
1803 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001804 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001805 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1806
1807 f_init(1, true);
1808 f_sleep(1.0);
1809 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1810 vc_conn.done;
1811}
1812testcase TC_ciph_mode_a5_1() runs on test_CT {
1813 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001814 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001815 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1816
1817 f_init(1, true);
1818 f_sleep(1.0);
1819 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1820 vc_conn.done;
1821}
1822testcase TC_ciph_mode_a5_3() runs on test_CT {
1823 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001824 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001825 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1826
1827 f_init(1, true);
1828 f_sleep(1.0);
1829 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1830 vc_conn.done;
1831}
1832
1833
1834/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001835private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001836 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1837 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001838
Harald Welte552620d2017-12-16 23:21:36 +01001839 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1840 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001841
Harald Weltea0630032018-03-20 21:09:55 +01001842 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001843}
Harald Welte552620d2017-12-16 23:21:36 +01001844testcase TC_assignment_fr_a5_0() runs on test_CT {
1845 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001846 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001847 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001848
Harald Welte89d42e82017-12-17 16:42:41 +01001849 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001850 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001851 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001852 vc_conn.done;
1853}
Harald Welte552620d2017-12-16 23:21:36 +01001854testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001855 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001856 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001857 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001858
Harald Welte89d42e82017-12-17 16:42:41 +01001859 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001860 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001861 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1862 vc_conn.done;
1863}
1864testcase TC_assignment_fr_a5_3() runs on test_CT {
1865 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001866 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001867 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001868
Harald Welte651fcdc2018-05-10 20:23:16 +02001869 f_init(1, true);
1870 f_sleep(1.0);
1871 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001872 vc_conn.done;
1873}
1874
Harald Welte552620d2017-12-16 23:21:36 +01001875/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1876private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001877 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01001878 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001879 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001880 const OCT8 kc := '0001020304050607'O;
1881
1882 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001883 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
1884
Harald Weltea0630032018-03-20 21:09:55 +01001885 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001886}
Harald Welte552620d2017-12-16 23:21:36 +01001887testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1888 var MSC_ConnHdlr vc_conn;
1889
Harald Welte89d42e82017-12-17 16:42:41 +01001890 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001891 f_sleep(1.0);
1892
Harald Welte8863fa12018-05-10 20:15:27 +02001893 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001894 vc_conn.done;
1895}
1896
Harald Welte552620d2017-12-16 23:21:36 +01001897private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001898 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02001899 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1900 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001901 const OCT8 kc := '0001020304050607'O;
1902 const OCT16 kc128 := kc & kc;
1903
1904 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1905 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001906 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001907 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001908 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001909}
Harald Welte552620d2017-12-16 23:21:36 +01001910testcase TC_assignment_fr_a5_4() runs on test_CT {
1911 var MSC_ConnHdlr vc_conn;
1912
Harald Welte89d42e82017-12-17 16:42:41 +01001913 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001914 f_sleep(1.0);
1915
Harald Welte8863fa12018-05-10 20:15:27 +02001916 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001917 vc_conn.done;
1918}
1919
1920
Harald Welte4532e0a2017-12-23 02:05:44 +01001921private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001922 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01001923 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02001924 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01001925 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001926 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001927}
1928
1929testcase TC_assignment_sign() runs on test_CT {
1930 var MSC_ConnHdlr vc_conn;
1931
1932 f_init(1, true);
1933 f_sleep(1.0);
1934
Harald Welte8863fa12018-05-10 20:15:27 +02001935 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001936 vc_conn.done;
1937}
1938
Harald Welte60aa5762018-03-21 19:33:13 +01001939/***********************************************************************
1940 * Codec (list) testing
1941 ***********************************************************************/
1942
1943/* check if the given rsl_mode is compatible with the a_elem */
1944private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1945return boolean {
1946 select (a_elem.codecType) {
1947 case (GSM_FR) {
1948 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1949 return true;
1950 }
1951 }
1952 case (GSM_HR) {
1953 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1954 return true;
1955 }
1956 }
1957 case (GSM_EFR) {
1958 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1959 return true;
1960 }
1961 }
1962 case (FR_AMR) {
1963 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1964 return true;
1965 }
1966 }
1967 case (HR_AMR) {
1968 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1969 return true;
1970 }
1971 }
1972 case else { }
1973 }
1974 return false;
1975}
1976
1977/* check if the given rsl_mode is compatible with the a_list */
1978private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
1979return boolean {
1980 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
1981 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
1982 return true;
1983 }
1984 }
1985 return false;
1986}
1987
1988/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02001989function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01001990return BSSMAP_IE_ChannelType {
1991 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
1992 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
1993 select (a_elem.codecType) {
1994 case (GSM_FR) {
1995 ret.channelRateAndType := ChRate_TCHF;
1996 ret.speechId_DataIndicator := Spdi_TCHF_FR;
1997 }
1998 case (GSM_HR) {
1999 ret.channelRateAndType := ChRate_TCHH;
2000 ret.speechId_DataIndicator := Spdi_TCHH_HR;
2001 }
2002 case (GSM_EFR) {
2003 ret.channelRateAndType := ChRate_TCHF;
2004 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
2005 }
2006 case (FR_AMR) {
2007 ret.channelRateAndType := ChRate_TCHF;
2008 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
2009 }
2010 case (HR_AMR) {
2011 ret.channelRateAndType := ChRate_TCHH;
2012 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
2013 }
2014 case else {
2015 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02002016 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01002017 }
2018 }
2019 return ret;
2020}
2021
Harald Weltea63b9102018-03-22 20:36:16 +01002022private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
2023return template RSL_IE_Body {
2024 var template RSL_IE_Body mode_ie := {
2025 chan_mode := {
2026 len := ?,
2027 reserved := ?,
2028 dtx_d := ?,
2029 dtx_u := ?,
2030 spd_ind := RSL_SPDI_SPEECH,
2031 ch_rate_type := -,
2032 coding_alg_rate := -
2033 }
2034 }
2035
2036 select (a_elem.codecType) {
2037 case (GSM_FR) {
2038 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2039 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2040 }
2041 case (GSM_HR) {
2042 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2043 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2044 }
2045 case (GSM_EFR) {
2046 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2047 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
2048 }
2049 case (FR_AMR) {
2050 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2051 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2052 }
2053 case (HR_AMR) {
2054 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2055 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2056 }
2057 }
2058 return mode_ie;
2059}
2060
Harald Welte60aa5762018-03-21 19:33:13 +01002061type record CodecListTest {
2062 BSSMAP_IE_SpeechCodecList codec_list,
2063 charstring id
2064}
2065type record of CodecListTest CodecListTests
2066
2067private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002068 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
2069 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01002070
2071 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Harald Welte79f3f542018-05-25 20:02:37 +02002072 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2073 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2074 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
2075 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01002076 if (isvalue(g_pars.expect_mr_s0_s7)) {
2077 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
2078 g_pars.expect_mr_s0_s7;
2079 }
Harald Welte79f3f542018-05-25 20:02:37 +02002080 }
Harald Welte60aa5762018-03-21 19:33:13 +01002081 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2082 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01002083 log("expecting ASS COMPL like this: ", exp_compl);
2084
2085 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01002086
2087 /* Verify that the RSL-side activation actually matches our expectations */
2088 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
2089
2090 var RSL_IE_Body mode_ie;
2091 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
2092 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02002093 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01002094 }
2095 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
2096 if (not match(mode_ie, t_mode_ie)) {
2097 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
2098 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002099
2100 var RSL_IE_Body mr_conf;
2101 if (g_pars.expect_mr_conf_ie != omit) {
2102 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
2103 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02002104 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002105 }
2106 log("found RSL MR CONFIG IE: ", mr_conf);
2107
2108 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
2109 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
2110 g_pars.expect_mr_conf_ie);
2111 }
2112 } else {
2113 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
2114 log("found RSL MR CONFIG IE: ", mr_conf);
2115 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02002116 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002117 }
2118 }
Harald Welte60aa5762018-03-21 19:33:13 +01002119}
2120
Philipp Maierd0e64b02019-03-13 14:15:23 +01002121private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
2122
2123 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2124 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2125
2126 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
2127 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2128 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2129 }
2130 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2131 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
2132 log("expecting ASS FAIL like this: ", exp_fail);
2133
2134 f_establish_fully(ass_cmd, exp_fail);
2135}
2136
Harald Welte60aa5762018-03-21 19:33:13 +01002137testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002138 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002139 var MSC_ConnHdlr vc_conn;
2140
2141 f_init(1, true);
2142 f_sleep(1.0);
2143
2144 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002145 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002146 vc_conn.done;
2147}
2148
2149testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002150 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002151 var MSC_ConnHdlr vc_conn;
2152
2153 f_init(1, true);
2154 f_sleep(1.0);
2155
2156 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002157 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002158 vc_conn.done;
2159}
2160
2161testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002162 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002163 var MSC_ConnHdlr vc_conn;
2164
2165 f_init(1, true);
2166 f_sleep(1.0);
2167
2168 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002169 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002170 vc_conn.done;
2171}
2172
Philipp Maierd0e64b02019-03-13 14:15:23 +01002173/* Allow 5,90k only (current default config) */
2174private function f_allow_amr_rate_5_90k() runs on test_CT {
2175 f_vty_enter_cfg_msc(BSCVTY, 0);
2176 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
2177 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2178 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2179 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
2180 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2181 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2182 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2183 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
2184 f_vty_transceive(BSCVTY, "exit");
2185 f_vty_transceive(BSCVTY, "exit");
2186}
2187
2188/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
2189 * ("Config-NB-Code = 1") */
2190private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
2191 f_vty_enter_cfg_msc(BSCVTY, 0);
2192 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
2193 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2194 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2195 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
2196 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2197 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2198 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2199 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
2200 f_vty_transceive(BSCVTY, "exit");
2201 f_vty_transceive(BSCVTY, "exit");
2202}
2203
Harald Welte60aa5762018-03-21 19:33:13 +01002204testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002205 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002206 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002207
2208 /* Note: This setups the codec configuration. The parameter payload in
2209 * mr_conf must be consistant with the parameter codecElements in pars
2210 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002211 var RSL_IE_Body mr_conf := {
2212 other := {
2213 len := 2,
2214 payload := '2804'O
2215 }
2216 };
Harald Welte60aa5762018-03-21 19:33:13 +01002217
Philipp Maier7695a0d2018-09-27 17:52:14 +02002218 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002219 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002220 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
2221 pars.expect_mr_conf_ie := mr_conf;
2222
Harald Welte60aa5762018-03-21 19:33:13 +01002223 f_init(1, true);
2224 f_sleep(1.0);
2225
Harald Welte8863fa12018-05-10 20:15:27 +02002226 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002227 vc_conn.done;
2228}
2229
2230testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002231 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002232 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002233
2234 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002235 var RSL_IE_Body mr_conf := {
2236 other := {
2237 len := 2,
2238 payload := '2804'O
2239 }
2240 };
Harald Welte60aa5762018-03-21 19:33:13 +01002241
Philipp Maier7695a0d2018-09-27 17:52:14 +02002242 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002243 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002244 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2245 pars.expect_mr_conf_ie := mr_conf;
2246
Harald Welte60aa5762018-03-21 19:33:13 +01002247 f_init(1, true);
2248 f_sleep(1.0);
2249
Harald Welte8863fa12018-05-10 20:15:27 +02002250 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002251 vc_conn.done;
2252}
2253
Philipp Maierd0e64b02019-03-13 14:15:23 +01002254function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
2255runs on test_CT {
2256
2257 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2258 var MSC_ConnHdlr vc_conn;
2259
2260 /* See note above */
2261 var RSL_IE_Body mr_conf := {
2262 other := {
2263 len := lengthof(mrconf),
2264 payload := mrconf
2265 }
2266 };
2267
2268 if (fr) {
2269 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2270 } else {
2271 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2272 }
2273 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2274 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2275 pars.expect_mr_conf_ie := mr_conf;
2276 pars.expect_mr_s0_s7 := exp_s8_s0;
2277
2278 f_init(1, true);
2279 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2280 f_sleep(1.0);
2281
2282 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2283 vc_conn.done;
2284 f_allow_amr_rate_5_90k();
2285}
2286
2287function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
2288runs on test_CT {
2289
2290 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2291 var MSC_ConnHdlr vc_conn;
2292
2293 if (fr) {
2294 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2295 } else {
2296 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2297 }
2298 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2299 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2300
2301 f_init(1, true);
2302 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2303 f_sleep(1.0);
2304
2305 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
2306 vc_conn.done;
2307 f_allow_amr_rate_5_90k();
2308}
2309
2310
2311/* Set S1, we expect an AMR multirate configuration IE with all four rates
2312 * set. */
2313testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
2314 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
2315}
2316
2317/* Set S1, we expect an AMR multirate configuration IE with the lower three
2318 * rates set. */
2319testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
2320 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
2321}
2322
2323/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2324 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2325testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
2326 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
2327}
2328
2329/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2330 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2331testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
2332 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
2333}
2334
2335/* The following block of tests selects more and more rates until all four
2336 * possible rates are in the active set (full rate) */
2337testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
2338 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
2339}
2340
2341testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
2342 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
2343}
2344
2345testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
2346 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
2347}
2348
2349testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
2350 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
2351}
2352
2353/* The following block of tests selects more and more rates until all three
2354 * possible rates are in the active set (half rate) */
2355testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
2356 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
2357}
2358
2359testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
2360 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
2361}
2362
2363testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
2364 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
2365}
2366
2367/* The following block tests what happens when the MSC does offer rate
2368 * configurations that are not supported by the BSC. Normally such situations
2369 * should not happen because the MSC gets informed by the BSC in advance via
2370 * the L3 COMPLETE message which rates are applicable. The MSC should not try
2371 * to offer rates that are not applicable anyway. */
2372
2373testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
2374 /* Try to include 12,2k in into the active set even though the channel
2375 * is half rate only. The BSC is expected to remove the 12,0k */
2376 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
2377}
2378
2379testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
2380 /* See what happens when all rates are selected at once. Since then
2381 * Also S1 is selected, this setting will be prefered and we should
2382 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
2383 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
2384}
2385
2386testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
2387 /* Same as above, but with S1 missing, the MSC is then expected to
2388 * select the currently supported rates, which are also 12.2k, 7,40k,
2389 * 5,90k, and 4,75k, into the active set. */
2390 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
2391}
2392
2393testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
2394 /* Try to select no rates at all */
2395 f_TC_assignment_codec_amr_fail(true, '00000000'B);
2396}
2397
2398testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
2399 /* Try to select only unsupported rates */
2400 f_TC_assignment_codec_amr_fail(true, '01101000'B);
2401}
2402
2403testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
2404 /* Try to select 12,2k for half rate */
2405 f_TC_assignment_codec_amr_fail(false, '10000000'B);
2406}
2407
Philipp Maierac09bfc2019-01-08 13:41:39 +01002408private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002409 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
2410 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
2411 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
2412 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002413}
2414
2415private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002416 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
2417 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002418}
2419
2420private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002421 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
2422 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
2423 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
2424 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
2425 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
2426 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002427}
2428
2429/* Allow HR only */
2430private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
2431 g_pars := f_gen_test_hdlr_pars();
2432 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2433 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2434 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2435 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2436 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2437 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2438 f_establish_fully(ass_cmd, exp_compl);
2439}
2440
2441/* Allow FR only */
2442private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
2443 g_pars := f_gen_test_hdlr_pars();
2444 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2445 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2446 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2447 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2448 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2449 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2450 f_establish_fully(ass_cmd, exp_compl);
2451}
2452
2453/* Allow HR only (expect assignment failure) */
2454private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
2455 g_pars := f_gen_test_hdlr_pars();
2456 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2457 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2458 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2459 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2460 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2461 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2462 f_establish_fully(ass_cmd, exp_fail);
2463}
2464
2465/* Allow FR only (expect assignment failure) */
2466private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
2467 g_pars := f_gen_test_hdlr_pars();
2468 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2469 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2470 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2471 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2472 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2473 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2474 f_establish_fully(ass_cmd, exp_fail);
2475}
2476
2477/* Allow FR and HR, but prefer FR */
2478private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2479 g_pars := f_gen_test_hdlr_pars();
2480 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2481 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2482 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2483 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2484 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2485 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2486 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2487 f_establish_fully(ass_cmd, exp_compl);
2488}
2489
2490/* Allow FR and HR, but prefer HR */
2491private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2492 g_pars := f_gen_test_hdlr_pars();
2493 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2494 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2495 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2496 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2497 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2498 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2499 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2500 f_establish_fully(ass_cmd, exp_compl);
2501}
2502
2503/* Allow FR and HR, but prefer FR */
2504private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2505 g_pars := f_gen_test_hdlr_pars();
2506 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2507 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2508 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2509 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2510 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2511 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2512 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2513 f_establish_fully(ass_cmd, exp_compl);
2514}
2515
2516/* Allow FR and HR, but prefer HR */
2517private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2518 g_pars := f_gen_test_hdlr_pars();
2519 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2520 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2521 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2522 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2523 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2524 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2525 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2526 f_establish_fully(ass_cmd, exp_compl);
2527}
2528
2529/* Request a HR channel while all FR channels are exhausted, this is expected
2530 * to work without conflicts */
2531testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
2532 var MSC_ConnHdlr vc_conn;
2533 f_init(1, true);
2534 f_sleep(1.0);
2535 f_enable_all_tch();
2536 f_disable_all_tch_f();
2537 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
2538 vc_conn.done;
2539 f_enable_all_tch();
2540 setverdict(pass);
2541}
2542
2543/* Request a FR channel while all FR channels are exhausted, this is expected
2544 * to fail. */
2545testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
2546 var MSC_ConnHdlr vc_conn;
2547 f_init(1, true);
2548 f_sleep(1.0);
2549 f_enable_all_tch();
2550 f_disable_all_tch_f();
2551 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
2552 vc_conn.done;
2553 f_enable_all_tch();
2554 setverdict(pass);
2555}
2556
2557/* Request a FR (prefered) or alternatively a HR channel while all FR channels
2558 * are exhausted, this is expected to be resolved by selecting a HR channel. */
2559testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
2560 var MSC_ConnHdlr vc_conn;
2561 f_init(1, true);
2562 f_sleep(1.0);
2563 f_enable_all_tch();
2564 f_disable_all_tch_f();
2565 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
2566 vc_conn.done;
2567 f_enable_all_tch();
2568 setverdict(pass);
2569}
2570
2571/* Request a HR (prefered) or alternatively a FR channel while all FR channels
2572 * are exhausted, this is expected to work without conflicts. */
2573testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
2574 var MSC_ConnHdlr vc_conn;
2575 f_init(1, true);
2576 f_sleep(1.0);
2577 f_enable_all_tch();
2578 f_disable_all_tch_f();
2579 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
2580 vc_conn.done;
2581 f_enable_all_tch();
2582 setverdict(pass);
2583}
2584
2585/* Request a FR channel while all HR channels are exhausted, this is expected
2586 * to work without conflicts */
2587testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
2588 var MSC_ConnHdlr vc_conn;
2589 f_init(1, true);
2590 f_sleep(1.0);
2591 f_enable_all_tch();
2592 f_disable_all_tch_h();
2593 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
2594 vc_conn.done;
2595 f_enable_all_tch();
2596 setverdict(pass);
2597}
2598
2599/* Request a HR channel while all HR channels are exhausted, this is expected
2600 * to fail. */
2601testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
2602 var MSC_ConnHdlr vc_conn;
2603 f_init(1, true);
2604 f_sleep(1.0);
2605 f_enable_all_tch();
2606 f_disable_all_tch_h();
2607 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
2608 vc_conn.done;
2609 f_enable_all_tch();
2610 setverdict(pass);
2611}
2612
2613/* Request a HR (prefered) or alternatively a FR channel while all HR channels
2614 * are exhausted, this is expected to be resolved by selecting a FR channel. */
2615testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
2616 var MSC_ConnHdlr vc_conn;
2617 f_init(1, true);
2618 f_sleep(1.0);
2619 f_enable_all_tch();
2620 f_disable_all_tch_h();
2621 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
2622 vc_conn.done;
2623 f_enable_all_tch();
2624 setverdict(pass);
2625}
2626
2627/* Request a FR (prefered) or alternatively a HR channel while all HR channels
2628 * are exhausted, this is expected to work without conflicts. */
2629testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
2630 var MSC_ConnHdlr vc_conn;
2631 f_init(1, true);
2632 f_sleep(1.0);
2633 f_enable_all_tch();
2634 f_disable_all_tch_h();
2635 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
2636 vc_conn.done;
2637 f_enable_all_tch();
2638 setverdict(pass);
2639}
2640
2641/* Allow FR and HR, but prefer HR */
2642private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2643 g_pars := f_gen_test_hdlr_pars();
2644 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2645 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2646 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2647 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2648 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2649 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2650 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2651 f_establish_fully(ass_cmd, exp_compl);
2652}
2653
2654/* Allow FR and HR, but prefer FR */
2655private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2656 g_pars := f_gen_test_hdlr_pars();
2657 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2658 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2659 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2660 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2661 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2662 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2663 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2664 f_establish_fully(ass_cmd, exp_compl);
2665}
2666
2667/* Request a HR (prefered) or alternatively a FR channel, it is expected that
2668 * HR, which is the prefered type, is selected. */
2669testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
2670 var MSC_ConnHdlr vc_conn;
2671 f_init(1, true);
2672 f_sleep(1.0);
2673 f_enable_all_tch();
2674 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
2675 vc_conn.done;
2676 setverdict(pass);
2677}
2678
2679/* Request a FR (prefered) or alternatively a HR channel, it is expected that
2680 * FR, which is the prefered type, is selected. */
2681testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
2682 var MSC_ConnHdlr vc_conn;
2683 f_init(1, true);
2684 f_sleep(1.0);
2685 f_enable_all_tch();
2686 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
2687 vc_conn.done;
2688 setverdict(pass);
2689}
2690
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002691testcase TC_assignment_osmux() runs on test_CT {
2692 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2693 var MSC_ConnHdlr vc_conn;
2694
2695 /* See note above */
2696 var RSL_IE_Body mr_conf := {
2697 other := {
2698 len := 2,
2699 payload := '2804'O
2700 }
2701 };
2702
2703 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2704 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
2705 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2706 pars.expect_mr_conf_ie := mr_conf;
2707 pars.use_osmux := true;
2708
2709 f_init(1, true, true);
2710 f_sleep(1.0);
2711
2712 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2713 vc_conn.done;
2714}
2715
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002716/* test the procedure of the MSC requesting a Classmark Update:
2717 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
2718 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01002719private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002720 g_pars := f_gen_test_hdlr_pars();
2721
Harald Weltea0630032018-03-20 21:09:55 +01002722 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002723 /* we should now have a COMPL_L3 at the MSC */
2724 BSSAP.receive(tr_BSSMAP_ComplL3);
2725
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002726 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
2727 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
2728
Harald Welte898113b2018-01-31 18:32:21 +01002729 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
2730 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
2731 setverdict(pass);
2732}
2733testcase TC_classmark() runs on test_CT {
2734 var MSC_ConnHdlr vc_conn;
2735 f_init(1, true);
2736 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002737 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01002738 vc_conn.done;
2739}
2740
Harald Weltee3bd6582018-01-31 22:51:25 +01002741private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002742 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002743 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002744 /* we should now have a COMPL_L3 at the MSC */
2745 BSSAP.receive(tr_BSSMAP_ComplL3);
2746
Harald Weltee3bd6582018-01-31 22:51:25 +01002747 /* send the single message we want to send */
2748 f_rsl_send_l3(l3);
2749}
2750
2751private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
2752 timer T := sec;
2753 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01002754 T.start;
2755 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01002756 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
2757 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02002758 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01002759 }
2760 [] T.timeout {
2761 setverdict(pass);
2762 }
2763 }
2764}
2765
Harald Weltee3bd6582018-01-31 22:51:25 +01002766/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2767private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
2768 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
2769 f_bssap_expect_nothing();
2770}
Harald Welte898113b2018-01-31 18:32:21 +01002771testcase TC_unsol_ass_fail() runs on test_CT {
2772 var MSC_ConnHdlr vc_conn;
2773 f_init(1, true);
2774 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002775 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01002776 vc_conn.done;
2777}
Harald Welte552620d2017-12-16 23:21:36 +01002778
Harald Welteea99a002018-01-31 20:46:43 +01002779
2780/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
2781private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002782 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
2783 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01002784}
2785testcase TC_unsol_ass_compl() runs on test_CT {
2786 var MSC_ConnHdlr vc_conn;
2787 f_init(1, true);
2788 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002789 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01002790 vc_conn.done;
2791}
2792
2793
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002794/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2795private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002796 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
2797 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002798}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002799testcase TC_unsol_ho_fail() runs on test_CT {
2800 var MSC_ConnHdlr vc_conn;
2801 f_init(1, true);
2802 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002803 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002804 vc_conn.done;
2805}
2806
2807
Harald Weltee3bd6582018-01-31 22:51:25 +01002808/* short message from MS should be ignored */
2809private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002810 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002811 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01002812 /* we should now have a COMPL_L3 at the MSC */
2813 BSSAP.receive(tr_BSSMAP_ComplL3);
2814
2815 /* send short message */
2816 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
2817 f_bssap_expect_nothing();
2818}
2819testcase TC_err_82_short_msg() runs on test_CT {
2820 var MSC_ConnHdlr vc_conn;
2821 f_init(1, true);
2822 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002823 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01002824 vc_conn.done;
2825}
2826
2827
Harald Weltee9e02e42018-01-31 23:36:25 +01002828/* 24.008 8.4 Unknown message must trigger RR STATUS */
2829private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
2830 f_est_single_l3(ts_RRM_UL_REL('00'O));
2831 timer T := 3.0
2832 alt {
2833 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
2834 setverdict(pass);
2835 }
2836 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01002837 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01002838 }
2839}
2840testcase TC_err_84_unknown_msg() runs on test_CT {
2841 var MSC_ConnHdlr vc_conn;
2842 f_init(1, true);
2843 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002844 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01002845 vc_conn.done;
2846}
2847
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002848/***********************************************************************
2849 * Handover
2850 ***********************************************************************/
2851
Harald Welte94e0c342018-04-07 11:33:23 +02002852/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
2853private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
2854runs on test_CT {
2855 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2856 " timeslot "&int2str(ts_nr)&" ";
2857 f_vty_transceive(BSCVTY, cmd & suffix);
2858}
2859
Harald Welte261af4b2018-02-12 21:20:39 +01002860/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
2861private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
2862runs on MSC_ConnHdlr {
2863 /* FIXME: resolve those from component-global state */
2864 var integer ts_nr := chan_nr.tn;
2865 var integer ss_nr;
2866 if (ischosen(chan_nr.u.ch0)) {
2867 ss_nr := 0;
2868 } else if (ischosen(chan_nr.u.lm)) {
2869 ss_nr := chan_nr.u.lm.sub_chan;
2870 } else if (ischosen(chan_nr.u.sdcch4)) {
2871 ss_nr := chan_nr.u.sdcch4.sub_chan;
2872 } else if (ischosen(chan_nr.u.sdcch8)) {
2873 ss_nr := chan_nr.u.sdcch8.sub_chan;
2874 } else {
2875 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02002876 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01002877 }
2878
2879 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2880 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
2881 f_vty_transceive(BSCVTY, cmd & suffix);
2882}
2883
Neels Hofmeyr91401012019-07-11 00:42:35 +02002884/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
2885 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
2886 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
2887 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
2888 * pair, not really to a specific BTS number. */
Harald Welte261af4b2018-02-12 21:20:39 +01002889private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
2890 integer new_bts_nr)
2891runs on MSC_ConnHdlr {
2892 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
2893}
2894
2895/* intra-BSC hand-over between BTS0 and BTS1 */
2896private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002897 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02002898 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2899 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01002900 const OCT8 kc := '0001020304050607'O;
2901
2902 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2903 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2904
Harald Weltea0630032018-03-20 21:09:55 +01002905 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02002906 f_bts_0_cfg({"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01002907
2908 var HandoverState hs := {
2909 rr_ho_cmpl_seen := false,
2910 handover_done := false,
2911 old_chan_nr := -
2912 };
2913 /* issue hand-over command on VTY */
2914 f_vty_handover(0, 0, g_chan_nr, 1);
2915 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2916 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002917
2918 /* From the MGW perspective, a handover is is characterized by
2919 * performing one MDCX operation with the MGW. So we expect to see
2920 * one more MDCX during handover. */
2921 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
2922
Harald Welte261af4b2018-02-12 21:20:39 +01002923 alt {
2924 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01002925 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002926
Philipp Maier4dae0652018-11-12 12:03:26 +01002927 /* Since this is an internal handover we expect the BSC to inform the
2928 * MSC about the event */
2929 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
2930
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002931 /* Check the amount of MGCP transactions is still consistant with the
2932 * test expectation */
2933 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01002934 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01002935}
2936
2937testcase TC_ho_int() runs on test_CT {
2938 var MSC_ConnHdlr vc_conn;
2939 f_init(2, true);
2940 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002941 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002942 vc_conn.done;
2943}
Harald Weltee9e02e42018-01-31 23:36:25 +01002944
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002945/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02002946private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002947 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002948 var template MgcpResponse mgcp_resp;
2949 var MGCP_RecvFrom mrf;
2950 var template MgcpMessage msg_resp;
2951 var template MgcpMessage msg_dlcx := {
2952 command := tr_DLCX()
2953 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002954
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002955 if (g_pars.aoip) {
2956 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002957 log("Got first DLCX: ", mgcp);
2958 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002959 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002960
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002961 MGCP.receive(tr_DLCX()) -> value mgcp {
2962 log("Got second DLCX: ", mgcp);
2963 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
2964 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002965 } else {
2966 /* For SCCPLite, BSC doesn't handle the MSC-side */
2967 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
2968 log("Got first DLCX: ", mrf.msg.command);
2969 msg_resp := {
2970 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
2971 }
2972 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
2973 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002974 }
2975
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02002976 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002977}
2978
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002979private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002980 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002981
2982 var PDU_BSSAP ass_req := f_gen_ass_req();
2983 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2984 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2985 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2986 f_establish_fully(ass_req, exp_compl);
2987
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02002988 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002989 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2990
2991 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2992
2993 f_sleep(0.5);
2994 /* The MSC negotiates Handover Request and Handover Request Ack with
2995 * the other BSS and comes back with a BSSMAP Handover Command
2996 * containing an RR Handover Command coming from the target BSS... */
2997
2998 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
2999 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3000 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3001 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3002 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3003
3004 /* expect the Handover Command to go out on RR */
3005 var RSL_Message rsl_ho_cmd
3006 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3007 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3008 var RSL_IE_Body rsl_ho_cmd_l3;
3009 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3010 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3011 setverdict(fail);
3012 } else {
3013 log("Found L3 Info: ", rsl_ho_cmd_l3);
3014 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3015 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3016 setverdict(fail);
3017 } else {
3018 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3019 setverdict(pass);
3020 }
3021 }
3022
3023 /* When the other BSS has reported a completed handover, this side is
3024 * torn down. */
3025
3026 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
3027 var BssmapCause cause := enum2int(cause_val);
3028 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3029
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003030 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003031 setverdict(pass);
3032 f_sleep(1.0);
3033}
3034testcase TC_ho_out_of_this_bsc() runs on test_CT {
3035 var MSC_ConnHdlr vc_conn;
3036
3037 f_init(1, true);
3038 f_sleep(1.0);
3039
3040 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
3041 vc_conn.done;
3042}
3043
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003044/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
3045 * simply never sends a BSSMAP Handover Command. */
3046private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003047 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003048
3049 var PDU_BSSAP ass_req := f_gen_ass_req();
3050 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3051 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3052 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3053 f_establish_fully(ass_req, exp_compl);
3054
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003055 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003056 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3057
3058 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3059
3060 /* osmo-bsc should time out 10 seconds after the handover started.
3061 * Let's give it a bit extra. */
3062 f_sleep(15.0);
3063
3064 /* The old lchan and conn should still be active. See that arbitrary L3
3065 * is still going through. */
3066 var octetstring l3 := '0123456789'O;
3067 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3068 var template PDU_BSSAP exp_data := {
3069 discriminator := '1'B,
3070 spare := '0000000'B,
3071 dlci := '00'O,
3072 lengthIndicator := 5,
3073 pdu := {
3074 dtap := l3
3075 }
3076 };
3077 BSSAP.receive(exp_data);
3078 setverdict(pass);
3079 f_sleep(1.0);
3080}
3081testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
3082 var MSC_ConnHdlr vc_conn;
3083
3084 f_init(1, true);
3085 f_sleep(1.0);
3086
3087 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
3088 vc_conn.done;
3089}
3090
3091/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
3092 * RR Handover Failure. */
3093private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003094 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003095
3096 var PDU_BSSAP ass_req := f_gen_ass_req();
3097 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3098 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3099 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3100 f_establish_fully(ass_req, exp_compl);
3101
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003102 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003103 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3104
3105 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3106
3107 f_sleep(0.5);
3108 /* The MSC negotiates Handover Request and Handover Request Ack with
3109 * the other BSS and comes back with a BSSMAP Handover Command
3110 * containing an RR Handover Command coming from the target BSS... */
3111
3112 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3113 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3114 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3115 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3116 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3117
3118 /* expect the Handover Command to go out on RR */
3119 var RSL_Message rsl_ho_cmd
3120 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3121 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3122 var RSL_IE_Body rsl_ho_cmd_l3;
3123 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3124 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3125 setverdict(fail);
3126 } else {
3127 log("Found L3 Info: ", rsl_ho_cmd_l3);
3128 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3129 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3130 setverdict(fail);
3131 } else {
3132 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3133 setverdict(pass);
3134 }
3135 }
3136
3137 f_sleep(0.2);
3138 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3139
3140 /* Should tell the MSC about the failure */
3141 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3142
3143 f_sleep(1.0);
3144
3145 /* The old lchan and conn should still be active. See that arbitrary L3
3146 * is still going through. */
3147 var octetstring l3 := '0123456789'O;
3148 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3149 var template PDU_BSSAP exp_data := {
3150 discriminator := '1'B,
3151 spare := '0000000'B,
3152 dlci := '00'O,
3153 lengthIndicator := 5,
3154 pdu := {
3155 dtap := l3
3156 }
3157 };
3158 BSSAP.receive(exp_data);
3159 setverdict(pass);
3160 f_sleep(1.0);
3161
3162 setverdict(pass);
3163 f_sleep(1.0);
3164}
3165testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
3166 var MSC_ConnHdlr vc_conn;
3167
3168 f_init(1, true);
3169 f_sleep(1.0);
3170
3171 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
3172 vc_conn.done;
3173}
3174
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003175/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
3176 * (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 +02003177 * and the lchan is released. */
3178private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003179 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003180
3181 var PDU_BSSAP ass_req := f_gen_ass_req();
3182 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3183 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3184 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3185 f_establish_fully(ass_req, exp_compl);
3186
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003187 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003188 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3189
3190 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3191
3192 f_sleep(0.5);
3193 /* The MSC negotiates Handover Request and Handover Request Ack with
3194 * the other BSS and comes back with a BSSMAP Handover Command
3195 * containing an RR Handover Command coming from the target BSS... */
3196
3197 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3198 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3199 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3200 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3201 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3202
3203 /* expect the Handover Command to go out on RR */
3204 var RSL_Message rsl_ho_cmd
3205 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3206 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3207 var RSL_IE_Body rsl_ho_cmd_l3;
3208 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3209 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3210 setverdict(fail);
3211 } else {
3212 log("Found L3 Info: ", rsl_ho_cmd_l3);
3213 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3214 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3215 setverdict(fail);
3216 } else {
3217 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3218 setverdict(pass);
3219 }
3220 }
3221
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003222 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
3223 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
3224 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003225
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003226 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02003227 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
3228 log("Got BSSMAP Clear Request");
3229 /* Instruct BSC to clear channel */
3230 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3231 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3232
3233 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003234 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01003235 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
3236 log("Got Deact SACCH");
3237 }
Harald Welte924b6ea2019-02-04 01:05:34 +01003238 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01003239 log("Got RR Release");
3240 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003241 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
3242 log("Got RF Chan Rel");
3243 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
3244 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003245 }
3246
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003247 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003248
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003249 setverdict(pass);
3250 f_sleep(1.0);
3251}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003252testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003253 var MSC_ConnHdlr vc_conn;
3254
3255 f_init(1, true);
3256 f_sleep(1.0);
3257
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003258 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003259 vc_conn.done;
3260}
3261
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003262private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
3263 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3264 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3265 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3266 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3267 * before we get started. */
3268 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3269 f_rslem_register(0, new_chan_nr);
3270 g_chan_nr := new_chan_nr;
3271 f_sleep(1.0);
3272
3273 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3274 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3275 activate(as_Media());
3276
3277 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3278 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003279 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003280
3281 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3282
3283 var PDU_BSSAP rx_bssap;
3284 var octetstring ho_command_str;
3285
3286 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02003287
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003288 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3289 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3290 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3291 log("L3 Info in HO Request Ack is ", ho_command);
3292
3293 var GsmArfcn arfcn;
3294 var RslChannelNr actual_new_chan_nr;
3295 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3296 actual_new_chan_nr, arfcn);
3297
3298 if (actual_new_chan_nr != new_chan_nr) {
3299 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3300 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3301 setverdict(fail);
3302 return;
3303 }
3304 log("Handover Command chan_nr is", actual_new_chan_nr);
3305
3306 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3307 * tells the MS to handover to the new lchan. Here comes the new MS on
3308 * the new lchan with a Handover RACH: */
3309
3310 /* send handover detect */
3311
3312 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3313
3314 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3315
3316 /* send handover complete over the new channel */
3317
3318 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
3319 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
3320 enc_PDU_ML3_MS_NW(l3_tx)));
3321
3322 BSSAP.receive(tr_BSSMAP_HandoverComplete);
3323 setverdict(pass);
3324}
3325testcase TC_ho_into_this_bsc() runs on test_CT {
3326 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003327 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003328
3329 f_init(1, true);
3330 f_sleep(1.0);
3331
3332 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3333 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3334
3335 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
3336 vc_conn.done;
3337}
3338
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003339private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
3340 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3341 f_rslem_register(0, new_chan_nr);
3342 g_chan_nr := new_chan_nr;
3343 f_sleep(1.0);
3344
3345 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3346 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3347 activate(as_Media());
3348
3349 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3350 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003351 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003352
3353 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3354
3355 var PDU_BSSAP rx_bssap;
3356 var octetstring ho_command_str;
3357
3358 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3359
3360 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3361 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3362 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3363 log("L3 Info in HO Request Ack is ", ho_command);
3364
3365 var GsmArfcn arfcn;
3366 var RslChannelNr actual_new_chan_nr;
3367 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3368 actual_new_chan_nr, arfcn);
3369
3370 if (actual_new_chan_nr != new_chan_nr) {
3371 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3372 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3373 setverdict(fail);
3374 return;
3375 }
3376 log("Handover Command chan_nr is", actual_new_chan_nr);
3377
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02003378 /* For deterministic test results, give some time for the MGW endpoint to be configured */
3379 f_sleep(1.0);
3380
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003381 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3382 * tells the MS to handover to the new lchan. In this case, the MS
3383 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
3384 * Handover Failure to the MSC. The procedure according to 3GPP TS
3385 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
3386 * BSSMAP Clear Command: */
3387
3388 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3389 var BssmapCause cause := enum2int(cause_val);
3390 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3391
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003392 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003393 setverdict(pass);
3394 f_sleep(1.0);
3395
3396 setverdict(pass);
3397}
3398testcase TC_ho_in_fail_msc_clears() runs on test_CT {
3399 var MSC_ConnHdlr vc_conn;
3400 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3401
3402 f_init(1, true);
3403 f_sleep(1.0);
3404
3405 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3406 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3407
3408 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
3409 vc_conn.done;
3410}
3411
3412private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
3413 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3414 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3415 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3416 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3417 * before we get started. */
3418 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3419 f_rslem_register(0, new_chan_nr);
3420 g_chan_nr := new_chan_nr;
3421 f_sleep(1.0);
3422
3423 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3424 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3425 activate(as_Media());
3426
3427 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3428 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003429 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003430
3431 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3432
3433 var PDU_BSSAP rx_bssap;
3434 var octetstring ho_command_str;
3435
3436 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3437
3438 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3439 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3440 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3441 log("L3 Info in HO Request Ack is ", ho_command);
3442
3443 var GsmArfcn arfcn;
3444 var RslChannelNr actual_new_chan_nr;
3445 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3446 actual_new_chan_nr, arfcn);
3447
3448 if (actual_new_chan_nr != new_chan_nr) {
3449 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3450 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3451 setverdict(fail);
3452 return;
3453 }
3454 log("Handover Command chan_nr is", actual_new_chan_nr);
3455
3456 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3457 * tells the MS to handover to the new lchan. Here comes the new MS on
3458 * the new lchan with a Handover RACH: */
3459
3460 /* send handover detect */
3461
3462 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3463
3464 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3465
3466 /* The MSC chooses to clear the connection now, maybe we got the
3467 * Handover RACH on the new cell but the MS still signaled Handover
3468 * Failure to the old BSS? */
3469
3470 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3471 var BssmapCause cause := enum2int(cause_val);
3472 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3473
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003474 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003475 setverdict(pass);
3476 f_sleep(1.0);
3477}
3478testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
3479 var MSC_ConnHdlr vc_conn;
3480 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3481
3482 f_init(1, true);
3483 f_sleep(1.0);
3484
3485 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3486 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3487
3488 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
3489 vc_conn.done;
3490}
3491
3492/* The new BSS's lchan times out before the MSC decides that handover failed. */
3493private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
3494 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3495 f_rslem_register(0, new_chan_nr);
3496 g_chan_nr := new_chan_nr;
3497 f_sleep(1.0);
3498
3499 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3500 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3501 activate(as_Media());
3502
3503 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3504 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003505 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003506
3507 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3508
3509 var PDU_BSSAP rx_bssap;
3510 var octetstring ho_command_str;
3511
3512 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3513
3514 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3515 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3516 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3517 log("L3 Info in HO Request Ack is ", ho_command);
3518
3519 var GsmArfcn arfcn;
3520 var RslChannelNr actual_new_chan_nr;
3521 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3522 actual_new_chan_nr, arfcn);
3523
3524 if (actual_new_chan_nr != new_chan_nr) {
3525 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3526 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3527 setverdict(fail);
3528 return;
3529 }
3530 log("Handover Command chan_nr is", actual_new_chan_nr);
3531
3532 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3533 * tells the MS to handover to the new lchan. But the MS never shows up
3534 * on the new lchan. */
3535
3536 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3537
3538 /* Did osmo-bsc also send a Clear Request? */
3539 timer T := 0.5;
3540 T.start;
3541 alt {
3542 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
3543 [] T.timeout { }
3544 }
3545
3546 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
3547 * asked for it, this is a Handover Failure after all). */
3548
3549 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3550 var BssmapCause cause := enum2int(cause_val);
3551 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3552
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003553 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003554 setverdict(pass);
3555 f_sleep(1.0);
3556
3557 setverdict(pass);
3558}
3559testcase TC_ho_in_fail_no_detect() runs on test_CT {
3560 var MSC_ConnHdlr vc_conn;
3561 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3562
3563 f_init(1, true);
3564 f_sleep(1.0);
3565
3566 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3567 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3568
3569 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
3570 vc_conn.done;
3571}
3572
3573/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
3574private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
3575 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3576 f_rslem_register(0, new_chan_nr);
3577 g_chan_nr := new_chan_nr;
3578 f_sleep(1.0);
3579
3580 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3581 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3582 activate(as_Media());
3583
3584 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3585 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003586 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003587
3588 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3589
3590 var PDU_BSSAP rx_bssap;
3591 var octetstring ho_command_str;
3592
3593 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3594
3595 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3596 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3597 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3598 log("L3 Info in HO Request Ack is ", ho_command);
3599
3600 var GsmArfcn arfcn;
3601 var RslChannelNr actual_new_chan_nr;
3602 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3603 actual_new_chan_nr, arfcn);
3604
3605 if (actual_new_chan_nr != new_chan_nr) {
3606 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3607 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3608 setverdict(fail);
3609 return;
3610 }
3611 log("Handover Command chan_nr is", actual_new_chan_nr);
3612
3613 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3614 * tells the MS to handover to the new lchan. But the MS never shows up
3615 * on the new lchan. */
3616
3617 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3618
3619 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003620 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003621
3622 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003623 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3624 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3625 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003626 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003627 setverdict(pass);
3628 f_sleep(1.0);
3629}
3630testcase TC_ho_in_fail_no_detect2() runs on test_CT {
3631 var MSC_ConnHdlr vc_conn;
3632 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3633
3634 f_init(1, true);
3635 f_sleep(1.0);
3636
3637 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3638 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3639
3640 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
3641 vc_conn.done;
3642}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003643
Neels Hofmeyr91401012019-07-11 00:42:35 +02003644type record of charstring Commands;
3645
3646private function f_bts_0_cfg(Commands cmds := {}) runs on MSC_ConnHdlr
3647{
3648 f_vty_enter_cfg_bts(BSCVTY, 0);
3649 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
3650 f_vty_transceive(BSCVTY, cmds[i]);
3651 }
3652 f_vty_transceive(BSCVTY, "end");
3653}
3654
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01003655private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
3656{
3657 f_vty_enter_cfg_cs7_inst(pt, 0);
3658 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
3659 f_vty_transceive(pt, cmds[i]);
3660 }
3661 f_vty_transceive(pt, "end");
3662}
3663
Neels Hofmeyr91401012019-07-11 00:42:35 +02003664private function f_probe_for_handover(charstring log_label,
3665 charstring log_descr,
3666 charstring handover_vty_cmd,
3667 boolean expect_handover,
3668 boolean is_inter_bsc_handover := false)
3669runs on MSC_ConnHdlr
3670{
3671 var RSL_Message rsl;
3672
3673 var charstring log_msg := " (expecting handover)"
3674 if (not expect_handover) {
3675 log_msg := " (expecting NO handover)";
3676 }
3677 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
3678 f_vty_transceive(BSCVTY, handover_vty_cmd);
3679
3680 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
3681 * lchans to be established on bts 1 or bts 2. */
3682 f_rslem_suspend(RSL1_PROC);
3683 f_rslem_suspend(RSL2_PROC);
3684
3685 timer T := 2.0;
3686 T.start;
3687
3688 alt {
3689 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
3690 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
3691 log("Rx L3 from net: ", l3);
3692 if (ischosen(l3.msgs.rrm.handoverCommand)) {
3693 var RslChannelNr new_chan_nr;
3694 var GsmArfcn arfcn;
3695 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
3696 new_chan_nr, arfcn);
3697 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
3698 log(l3.msgs.rrm.handoverCommand);
3699
3700 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
3701 * matter on which BTS it really is, we're not going to follow through an entire handover
3702 * anyway. */
3703 f_rslem_register(0, new_chan_nr, RSL1_PROC);
3704 f_rslem_resume(RSL1_PROC);
3705 f_rslem_register(0, new_chan_nr, RSL2_PROC);
3706 f_rslem_resume(RSL2_PROC);
3707
3708 if (expect_handover and not is_inter_bsc_handover) {
3709 setverdict(pass);
3710 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
3711 } else {
3712 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
3713 & log_label & ": " & log_descr);
3714 }
3715
3716 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
3717 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
3718 * Handover Failure. */
3719 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3720
3721 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
3722 f_sleep(0.5);
3723 RSL1.clear;
3724 RSL2.clear;
3725 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
3726 break;
3727 } else {
3728 repeat;
3729 }
3730 }
3731 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
3732 if (expect_handover and is_inter_bsc_handover) {
3733 setverdict(pass);
3734 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
3735 } else {
3736 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
3737 & log_label & ": " & log_descr);
3738 }
3739
3740 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
3741
3742 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
3743 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
3744 * setting a short timeout and waiting is the only way. */
3745 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
3746 f_sleep(1.5);
3747 log("f_probe_for_handover(" & log_label & "): ...done");
3748
3749 break;
3750 }
3751 [] T.timeout {
3752 if (expect_handover) {
3753 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
3754 & log_label & ": " & log_descr);
3755 } else {
3756 setverdict(pass);
3757 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
3758 }
3759 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
3760 break;
3761 }
3762 }
3763
3764 f_rslem_resume(RSL1_PROC);
3765 f_rslem_resume(RSL2_PROC);
3766 f_sleep(3.0);
3767 RSL.clear;
3768
3769 log("f_probe_for_handover(" & log_label & "): done clearing");
3770}
3771
3772/* Test the effect of various neighbor configuration scenarios:
3773 *
3774 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
3775 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
3776 */
3777private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
3778 g_pars := f_gen_test_hdlr_pars();
3779 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3780 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3781 const OCT8 kc := '0001020304050607'O;
3782
3783 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3784 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3785
3786 /* Establish lchan at bts 0 */
3787 f_establish_fully(ass_cmd, exp_compl);
3788
3789 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
3790 f_vty_enter_cfg_network(BSCVTY);
3791 f_vty_transceive(BSCVTY, "timer T7 1");
3792 f_vty_transceive(BSCVTY, "end");
3793}
3794
3795private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
3796 f_tc_ho_neighbor_config_start();
3797
3798 /*
3799 * bts 0 ARFCN 871 BSIC 10
3800 * bts 1 ARFCN 871 BSIC 11
3801 * bts 2 ARFCN 871 BSIC 12
3802 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3803 */
3804
3805 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
3806 f_bts_0_cfg({"no neighbors"});
3807 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
3808 "handover any to arfcn 871 bsic 11",
3809 true);
3810
3811 f_probe_for_handover("1.b", "HO to unknown cell does not start",
3812 "handover any to arfcn 13 bsic 39",
3813 false);
3814
3815 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
3816 "handover any to arfcn 871 bsic 12",
3817 false);
3818
3819 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
3820 "handover any to arfcn 871 bsic 11",
3821 true);
3822}
3823private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
3824 f_tc_ho_neighbor_config_start();
3825
3826 /*
3827 * bts 0 ARFCN 871 BSIC 10
3828 * bts 1 ARFCN 871 BSIC 11
3829 * bts 2 ARFCN 871 BSIC 12
3830 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3831 */
3832
3833 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
3834 f_bts_0_cfg({"neighbor bts 1"});
3835 f_sleep(0.5);
3836
3837 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
3838 "handover any to arfcn 871 bsic 11",
3839 true);
3840
3841 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
3842 "handover any to arfcn 871 bsic 12",
3843 false);
3844}
3845private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
3846 f_tc_ho_neighbor_config_start();
3847
3848 /*
3849 * bts 0 ARFCN 871 BSIC 10
3850 * bts 1 ARFCN 871 BSIC 11
3851 * bts 2 ARFCN 871 BSIC 12
3852 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3853 */
3854
3855 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
3856 f_bts_0_cfg({"no neighbors", "neighbor bts 2"});
3857 f_sleep(0.5);
3858
3859 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
3860 "handover any to arfcn 871 bsic 11",
3861 false);
3862 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",
3863 "handover any to arfcn 871 bsic 12",
3864 true);
3865}
3866private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
3867 f_tc_ho_neighbor_config_start();
3868
3869 /*
3870 * bts 0 ARFCN 871 BSIC 10
3871 * bts 1 ARFCN 871 BSIC 11
3872 * bts 2 ARFCN 871 BSIC 12
3873 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3874 */
3875
3876 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
3877 f_bts_0_cfg({"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
3878 f_sleep(0.5);
3879
3880 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
3881 "handover any to arfcn 871 bsic 11",
3882 false);
3883 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
3884 "handover any to arfcn 871 bsic 12",
3885 false);
3886 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
3887 "handover any to arfcn 123 bsic 45",
3888 true, true);
3889}
3890private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
3891 f_tc_ho_neighbor_config_start();
3892
3893 /*
3894 * bts 0 ARFCN 871 BSIC 10
3895 * bts 1 ARFCN 871 BSIC 11
3896 * bts 2 ARFCN 871 BSIC 12
3897 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3898 */
3899
3900 log("f_tc_ho_neighbor_config: 5. explicit remote neighbor re-using ARFCN+BSIC: 'neighbor lac 99 arfcn 871 bsic 12'");
3901 f_bts_0_cfg({"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
3902 f_sleep(0.5);
3903
3904 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
3905 "handover any to arfcn 871 bsic 12",
3906 true, true);
3907}
3908private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
3909 f_tc_ho_neighbor_config_start();
3910
3911 /*
3912 * bts 0 ARFCN 871 BSIC 10
3913 * bts 1 ARFCN 871 BSIC 11
3914 * bts 2 ARFCN 871 BSIC 12
3915 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3916 */
3917
3918 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
3919 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
3920 f_bts_0_cfg({"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
3921 f_sleep(0.5);
3922
3923 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
3924 "handover any to arfcn 871 bsic 12",
3925 false);
3926}
3927private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
3928 f_tc_ho_neighbor_config_start();
3929
3930 /*
3931 * bts 0 ARFCN 871 BSIC 10
3932 * bts 1 ARFCN 871 BSIC 11
3933 * bts 2 ARFCN 871 BSIC 12
3934 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3935 */
3936
3937 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
3938 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
3939 f_bts_0_cfg({"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
3940 f_sleep(0.5);
3941
3942 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
3943 "handover any to arfcn 871 bsic 12",
3944 true);
3945 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
3946 "handover any to arfcn 123 bsic 45",
3947 true, true);
3948}
3949
3950testcase TC_ho_neighbor_config_1() runs on test_CT {
3951 var MSC_ConnHdlr vc_conn;
3952 f_init(3, true);
3953 f_sleep(1.0);
3954 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
3955 vc_conn.done;
3956}
3957testcase TC_ho_neighbor_config_2() runs on test_CT {
3958 var MSC_ConnHdlr vc_conn;
3959 f_init(3, true);
3960 f_sleep(1.0);
3961 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
3962 vc_conn.done;
3963}
3964testcase TC_ho_neighbor_config_3() runs on test_CT {
3965 var MSC_ConnHdlr vc_conn;
3966 f_init(3, true);
3967 f_sleep(1.0);
3968 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
3969 vc_conn.done;
3970}
3971testcase TC_ho_neighbor_config_4() runs on test_CT {
3972 var MSC_ConnHdlr vc_conn;
3973 f_init(3, true);
3974 f_sleep(1.0);
3975 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
3976 vc_conn.done;
3977}
3978testcase TC_ho_neighbor_config_5() runs on test_CT {
3979 var MSC_ConnHdlr vc_conn;
3980 f_init(3, true);
3981 f_sleep(1.0);
3982 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
3983 vc_conn.done;
3984}
3985testcase TC_ho_neighbor_config_6() runs on test_CT {
3986 var MSC_ConnHdlr vc_conn;
3987 f_init(3, true);
3988 f_sleep(1.0);
3989 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
3990 vc_conn.done;
3991}
3992testcase TC_ho_neighbor_config_7() runs on test_CT {
3993 var MSC_ConnHdlr vc_conn;
3994 f_init(3, true);
3995 f_sleep(1.0);
3996 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
3997 vc_conn.done;
3998}
3999
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004000/* OS#3041: Open and close N connections in a normal fashion, and expect no
4001 * BSSMAP Reset just because of that. */
4002testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
4003 var default d;
4004 var integer i;
4005 var DchanTuple dt;
4006
4007 f_init();
4008
4009 /* Wait for initial BSSMAP Reset to pass */
4010 f_sleep(4.0);
4011
4012 d := activate(no_bssmap_reset());
4013
4014 /* Setup up a number of connections and RLSD them again from the MSC
4015 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4016 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02004017 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004018 /* Since we're doing a lot of runs, give each one a fresh
4019 * T_guard from the top. */
4020 T_guard.start;
4021
4022 /* Setup a BSSAP connection and clear it right away. This is
4023 * the MSC telling the BSC about a planned release, it's not an
4024 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004025 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004026
4027 /* MSC disconnects (RLSD). */
4028 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
4029 }
4030
4031 /* In the buggy behavior, a timeout of 2 seconds happens between above
4032 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4033 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4034 f_sleep(4.0);
4035
4036 deactivate(d);
4037 f_shutdown_helper();
4038}
Harald Welte552620d2017-12-16 23:21:36 +01004039
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004040/* OS#3041: Open and close N connections in a normal fashion, and expect no
4041 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
4042 * the MSC. */
4043testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
4044 var default d;
4045 var integer i;
4046 var DchanTuple dt;
4047 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004048 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
4049 var BssmapCause cause := enum2int(cause_val);
4050
4051 f_init();
4052
4053 /* Wait for initial BSSMAP Reset to pass */
4054 f_sleep(4.0);
4055
4056 d := activate(no_bssmap_reset());
4057
4058 /* Setup up a number of connections and RLSD them again from the MSC
4059 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4060 * Let's do it some more times for good measure. */
4061 for (i := 0; i < 8; i := i+1) {
4062 /* Since we're doing a lot of runs, give each one a fresh
4063 * T_guard from the top. */
4064 T_guard.start;
4065
4066 /* Setup a BSSAP connection and clear it right away. This is
4067 * the MSC telling the BSC about a planned release, it's not an
4068 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004069 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004070
4071 /* Instruct BSC to clear channel */
4072 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4073
4074 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004075 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004076 }
4077
4078 /* In the buggy behavior, a timeout of 2 seconds happens between above
4079 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4080 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4081 f_sleep(4.0);
4082
4083 deactivate(d);
4084 f_shutdown_helper();
4085}
4086
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004087/* OS#3041: Open and close N connections in a normal fashion, and expect no
4088 * BSSMAP Reset just because of that. Close connections from the MS side with a
4089 * Release Ind on RSL. */
4090testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
4091 var default d;
4092 var integer i;
4093 var DchanTuple dt;
4094 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004095 var integer j;
4096
4097 f_init();
4098
4099 /* Wait for initial BSSMAP Reset to pass */
4100 f_sleep(4.0);
4101
4102 d := activate(no_bssmap_reset());
4103
4104 /* Setup up a number of connections and RLSD them again from the MSC
4105 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4106 * Let's do it some more times for good measure. */
4107 for (i := 0; i < 8; i := i+1) {
4108 /* Since we're doing a lot of runs, give each one a fresh
4109 * T_guard from the top. */
4110 T_guard.start;
4111
4112 /* Setup a BSSAP connection and clear it right away. This is
4113 * the MSC telling the BSC about a planned release, it's not an
4114 * erratic loss of a connection. */
4115 dt := f_est_dchan('23'O, 23, '00010203040506'O);
4116
4117 /* simulate RLL REL IND */
4118 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
4119
4120 /* expect Clear Request on MSC side */
4121 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
4122
4123 /* Instruct BSC to clear channel */
4124 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
4125 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4126
4127 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004128 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004129 }
4130
4131 /* In the buggy behavior, a timeout of 2 seconds happens between above
4132 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4133 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4134 f_sleep(4.0);
4135
4136 deactivate(d);
4137 f_shutdown_helper();
4138}
4139
Harald Welte94e0c342018-04-07 11:33:23 +02004140/***********************************************************************
4141 * IPA style dynamic PDCH
4142 ***********************************************************************/
4143
4144private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4145 template (omit) RSL_Cause nack := omit)
4146runs on test_CT {
4147 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4148 var RSL_Message rsl_unused;
4149 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4150 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
4151 /* expect the BSC to issue the related RSL command */
4152 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4153 if (istemplatekind(nack, "omit")) {
4154 /* respond with a related acknowledgement */
4155 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4156 } else {
4157 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
4158 }
4159}
4160
4161private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4162 template (omit) RSL_Cause nack := omit)
4163runs on test_CT {
4164 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4165 var RSL_Message rsl_unused;
4166 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4167 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
4168 /* expect the BSC to issue the related RSL command */
4169 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
4170 if (istemplatekind(nack, "omit")) {
4171 /* respond with a related acknowledgement */
4172 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
4173 } else {
4174 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
4175 }
4176}
4177
4178private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
4179runs on test_CT return charstring {
4180 var charstring cmd, resp;
4181 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01004182 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02004183}
4184
4185private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
4186 template charstring exp)
4187runs on test_CT {
4188 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
4189 if (not match(mode, exp)) {
4190 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02004191 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02004192 }
4193}
4194
4195private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
4196runs on test_CT {
4197 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
4198 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
4199 f_vty_transceive(BSCVTY, "end");
4200}
4201
4202private const charstring TCHF_MODE := "TCH/F mode";
4203private const charstring TCHH_MODE := "TCH/H mode";
4204private const charstring PDCH_MODE := "PDCH mode";
4205private const charstring NONE_MODE := "NONE mode";
4206
4207/* Test IPA PDCH activation / deactivation triggered by VTY */
4208testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
4209 var RSL_Message rsl_unused;
4210
4211 /* change Timeslot 6 before f_init() starts RSL */
4212 f_init_vty();
4213 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4214 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4215
4216 f_init(1, false);
4217 f_sleep(1.0);
4218
4219 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4220
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004221 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004222 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4223 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4224 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4225 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4226 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004227 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004228 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4229
4230 /* De-activate it via VTY */
4231 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4232 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004233 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004234 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4235
4236 /* re-activate it via VTY */
4237 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
4238 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004239 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004240 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4241
4242 /* and finally de-activate it again */
4243 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4244 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004245 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004246 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4247
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004248 /* clean up config */
4249 f_ts_set_chcomb(0, 0, 6, "PDCH");
4250
Harald Welte94e0c342018-04-07 11:33:23 +02004251 setverdict(pass);
4252}
4253
4254/* Test IPA PDCH activation NACK */
4255testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
4256 var RSL_Message rsl_unused;
4257
4258 /* change Timeslot 6 before f_init() starts RSL */
4259 f_init_vty();
4260 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4261 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4262
4263 f_init(1, false);
4264 f_sleep(1.0);
4265
4266 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4267
4268 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4269 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4270 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4271 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4272 f_sleep(1.0);
4273 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4274
4275 /* De-activate it via VTY */
4276 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4277 f_sleep(1.0);
4278 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4279
4280 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
4281 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
4282 f_sleep(1.0);
4283 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4284
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004285 /* clean up config */
4286 f_ts_set_chcomb(0, 0, 6, "PDCH");
4287
Harald Welte94e0c342018-04-07 11:33:23 +02004288 setverdict(pass);
4289}
4290
4291
4292/***********************************************************************
4293 * Osmocom style dynamic PDCH
4294 ***********************************************************************/
4295
4296private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4297 template (omit) RSL_Cause nack := omit)
4298runs on test_CT {
4299 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4300 var RSL_Message rsl_unused;
4301 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4302 /* FIXME: no VTY command to activate Osmocom PDCH !! */
4303 /* expect the BSC to issue the related RSL command */
4304 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
4305 if (istemplatekind(nack, "omit")) {
4306 /* respond with a related acknowledgement */
4307 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
4308 } else {
4309 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
4310 }
4311}
4312
4313private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4314 template (omit) RSL_Cause nack := omit)
4315runs on test_CT {
4316 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4317 var RSL_Message rsl_unused;
4318 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4319 /* FIXME: no VTY command to activate Osmocom PDCH !! */
4320 /* expect the BSC to issue the related RSL command */
4321 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
4322 if (istemplatekind(nack, "omit")) {
4323 /* respond with a related acknowledgement */
4324 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
4325 } else {
4326 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
4327 }
4328}
4329
4330/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
4331testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
4332 var RSL_Message rsl_unused;
4333
4334 /* change Timeslot 6 before f_init() starts RSL */
4335 f_init_vty();
4336 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
4337 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4338
4339 f_init(1, false);
4340 f_sleep(1.0);
4341
4342 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
4343
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004344 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004345 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4346 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4347 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
4348
4349 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
4350 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004351 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 +02004352 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4353
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004354 /* clean up config */
4355 f_ts_set_chcomb(0, 0, 6, "PDCH");
4356
Harald Welte94e0c342018-04-07 11:33:23 +02004357 setverdict(pass);
4358}
4359
4360/* Test Osmocom dyn PDCH activation NACK behavior */
4361testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
4362 var RSL_Message rsl_unused;
4363
4364 /* change Timeslot 6 before f_init() starts RSL */
4365 f_init_vty();
4366 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
4367 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4368
4369 f_init(1, false);
4370 f_sleep(1.0);
4371
4372 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
4373
4374 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4375 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4376 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
4377
4378 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
4379 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
4380 f_sleep(1.0);
4381 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4382
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004383 /* clean up config */
4384 f_ts_set_chcomb(0, 0, 6, "PDCH");
4385
Harald Welte94e0c342018-04-07 11:33:23 +02004386 setverdict(pass);
4387}
4388
Stefan Sperling0796a822018-10-05 13:01:39 +02004389testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02004390 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02004391 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
4392 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
4393 }
4394}
4395
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004396testcase TC_chopped_ipa_payload() runs on test_CT {
4397 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
4398 /* TODO: mp_bsc_ctrl_port does not work yet */};
4399 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
4400 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
4401 }
4402}
4403
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01004404/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
4405 the BTS does autonomous MS power control loop */
4406testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
4407 var MSC_ConnHdlr vc_conn;
4408 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4409 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
4410 pars.exp_ms_power_params := true;
4411
4412 f_init(1, true);
4413 f_sleep(1.0);
4414 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
4415 vc_conn.done;
4416}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004417
Harald Welte0ea2d5e2018-04-07 21:40:29 +02004418/* Dyn PDCH todo:
4419 * activate OSMO as TCH/F
4420 * activate OSMO as TCH/H
4421 * does the BSC-located PCU socket get the updated INFO?
4422 * what if no PCU is connected at the time?
4423 * is the info correct on delayed PCU (re)connect?
4424 */
Harald Welte94e0c342018-04-07 11:33:23 +02004425
Harald Welte28d943e2017-11-25 15:00:50 +01004426control {
Harald Welte898113b2018-01-31 18:32:21 +01004427 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01004428 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01004429 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01004430 execute( TC_ctrl() );
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02004431 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
4432 execute( TC_ctrl_location() );
4433 }
Harald Welte898113b2018-01-31 18:32:21 +01004434
4435 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01004436 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01004437 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01004438 execute( TC_chan_act_ack_noest() );
4439 execute( TC_chan_act_ack_est_ind_noreply() );
4440 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01004441 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01004442 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07004443 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01004444 execute( TC_chan_rel_rll_rel_ind() );
4445 execute( TC_chan_rel_conn_fail() );
4446 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01004447 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01004448 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02004449 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01004450 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01004451 execute( TC_chan_rel_sccp_tiar_timeout() );
Harald Welte6f521d82017-12-11 19:52:02 +01004452
Harald Weltecfe2c962017-12-15 12:09:32 +01004453 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01004454
4455 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01004456 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01004457 execute( TC_assignment_csd() );
4458 execute( TC_assignment_ctm() );
4459 execute( TC_assignment_sign() );
4460 execute( TC_assignment_fr_a5_0() );
4461 execute( TC_assignment_fr_a5_1() );
Harald Welte8f67d1d2018-05-25 20:38:42 +02004462 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
4463 execute( TC_assignment_fr_a5_1_codec_missing() );
4464 }
Harald Welte235ebf12017-12-15 14:18:16 +01004465 execute( TC_assignment_fr_a5_3() );
4466 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02004467 execute( TC_ciph_mode_a5_0() );
4468 execute( TC_ciph_mode_a5_1() );
4469 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01004470
Harald Welte60aa5762018-03-21 19:33:13 +01004471 execute( TC_assignment_codec_fr() );
4472 execute( TC_assignment_codec_hr() );
4473 execute( TC_assignment_codec_efr() );
4474 execute( TC_assignment_codec_amr_f() );
4475 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01004476
4477 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
4478 execute( TC_assignment_codec_amr_f_S1() );
4479 execute( TC_assignment_codec_amr_h_S1() );
4480 execute( TC_assignment_codec_amr_f_S124() );
4481 execute( TC_assignment_codec_amr_h_S124() );
4482 execute( TC_assignment_codec_amr_f_S0() );
4483 execute( TC_assignment_codec_amr_f_S02() );
4484 execute( TC_assignment_codec_amr_f_S024() );
4485 execute( TC_assignment_codec_amr_f_S0247() );
4486 execute( TC_assignment_codec_amr_h_S0() );
4487 execute( TC_assignment_codec_amr_h_S02() );
4488 execute( TC_assignment_codec_amr_h_S024() );
4489 execute( TC_assignment_codec_amr_h_S0247() );
4490 execute( TC_assignment_codec_amr_f_S01234567() );
4491 execute( TC_assignment_codec_amr_f_S0234567() );
4492 execute( TC_assignment_codec_amr_f_zero() );
4493 execute( TC_assignment_codec_amr_f_unsupp() );
4494 execute( TC_assignment_codec_amr_h_S7() );
4495 }
Harald Welte60aa5762018-03-21 19:33:13 +01004496
Philipp Maierac09bfc2019-01-08 13:41:39 +01004497 execute( TC_assignment_codec_fr_exhausted_req_hr() );
4498 execute( TC_assignment_codec_fr_exhausted_req_fr() );
4499 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
4500 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
4501 execute( TC_assignment_codec_hr_exhausted_req_fr() );
4502 execute( TC_assignment_codec_hr_exhausted_req_hr() );
4503 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
4504 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
4505 execute( TC_assignment_codec_req_hr_fr() );
4506 execute( TC_assignment_codec_req_fr_hr() );
4507
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02004508 if (mp_enable_osmux_test) {
4509 execute( TC_assignment_osmux() );
4510 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004511
Harald Welte898113b2018-01-31 18:32:21 +01004512 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01004513 execute( TC_rll_est_ind_inact_lchan() );
4514 execute( TC_rll_est_ind_inval_sapi1() );
4515 execute( TC_rll_est_ind_inval_sapi3() );
4516 execute( TC_rll_est_ind_inval_sacch() );
4517
Harald Welte898113b2018-01-31 18:32:21 +01004518 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01004519 execute( TC_paging_imsi_nochan() );
4520 execute( TC_paging_tmsi_nochan() );
4521 execute( TC_paging_tmsi_any() );
4522 execute( TC_paging_tmsi_sdcch() );
4523 execute( TC_paging_tmsi_tch_f() );
4524 execute( TC_paging_tmsi_tch_hf() );
4525 execute( TC_paging_imsi_nochan_cgi() );
4526 execute( TC_paging_imsi_nochan_lac_ci() );
4527 execute( TC_paging_imsi_nochan_ci() );
4528 execute( TC_paging_imsi_nochan_lai() );
4529 execute( TC_paging_imsi_nochan_lac() );
4530 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01004531 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
4532 execute( TC_paging_imsi_nochan_rnc() );
4533 execute( TC_paging_imsi_nochan_lac_rnc() );
4534 execute( TC_paging_imsi_nochan_lacs() );
4535 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01004536 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01004537 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01004538 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01004539 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01004540 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01004541
4542 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01004543 execute( TC_rsl_unknown_unit_id() );
4544
4545 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01004546
4547 execute( TC_classmark() );
4548 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01004549 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004550 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01004551 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01004552 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004553
Harald Welte261af4b2018-02-12 21:20:39 +01004554 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004555
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004556 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004557 execute( TC_ho_out_fail_no_msc_response() );
4558 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004559 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004560
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004561 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004562 execute( TC_ho_in_fail_msc_clears() );
4563 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
4564 execute( TC_ho_in_fail_no_detect() );
4565 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004566
Neels Hofmeyr91401012019-07-11 00:42:35 +02004567 execute( TC_ho_neighbor_config_1() );
4568 execute( TC_ho_neighbor_config_2() );
4569 execute( TC_ho_neighbor_config_3() );
4570 execute( TC_ho_neighbor_config_4() );
4571 execute( TC_ho_neighbor_config_5() );
4572 execute( TC_ho_neighbor_config_6() );
4573 execute( TC_ho_neighbor_config_7() );
4574
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004575 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004576 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004577 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02004578
4579 execute( TC_dyn_pdch_ipa_act_deact() );
4580 execute( TC_dyn_pdch_ipa_act_nack() );
4581 execute( TC_dyn_pdch_osmo_act_deact() );
4582 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004583
Stefan Sperling0796a822018-10-05 13:01:39 +02004584 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004585 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02004586
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01004587 /* Power control related */
4588 execute( TC_assignment_verify_ms_power_params_ie() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004589 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
4590 execute( TC_early_conn_fail() );
4591 execute( TC_late_conn_fail() );
4592
Harald Welte28d943e2017-11-25 15:00:50 +01004593}
4594
4595}