blob: 364254c504efa03f19b38d56025d37e9d866d99d [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;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020062const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010063const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010064
Harald Welte799c97b2017-12-14 17:50:30 +010065/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020066const integer NUM_TCHH_PER_BTS := 2;
67const integer NUM_TCHF_PER_BTS := 4;
Harald Weltedd8cbf32018-01-28 12:07:52 +010068const integer NUM_SDCCH_PER_BTS := 4;
Harald Welte799c97b2017-12-14 17:50:30 +010069
Harald Welte4003d112017-12-09 22:35:39 +010070
Harald Welte21b46bd2017-12-17 19:46:32 +010071/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010072type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010073 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010074 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010075}
76
Harald Weltea4ca4462018-02-09 00:17:14 +010077type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +010078 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +010079 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +010080 /* RSL common Channel Port (for RSL_Emulation) */
81 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +010082 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +010083 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +010084 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +020085 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
86 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +010087
Daniel Willmann191e0d92018-01-17 12:44:35 +010088 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +010089 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +010090
Neels Hofmeyrf246a922020-05-13 02:27:10 +020091 var RAN_Adapter g_bssap[NUM_MSC];
Harald Weltea4ca4462018-02-09 00:17:14 +010092 /* for old legacy-tests only */
93 port BSSAP_CODEC_PT BSSAP;
94
Harald Welte21b46bd2017-12-17 19:46:32 +010095 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +010096 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +010097
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +020098 /* Osmux is enabled through VTY */
99 var boolean g_osmux_enabled := false;
100
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100101 /*Configure T(tias) over VTY, seconds */
102 var integer g_bsc_sccp_timer_ias := 7 * 60;
103 /*Configure T(tiar) over VTY, seconds */
104 var integer g_bsc_sccp_timer_iar := 15 * 60;
105
Harald Welte21b46bd2017-12-17 19:46:32 +0100106 /* global test case guard timer */
Harald Welteae026692017-12-09 01:03:01 +0100107 timer T_guard := 30.0;
108
Harald Welte28d943e2017-11-25 15:00:50 +0100109}
110
111modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100112 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100113 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100114 /* port number to which to establish the IPA OML connections */
115 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100116 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100117 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100118 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100119 integer mp_bsc_ctrl_port := 4249;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100120 /* IP address at which the test binds */
121 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100122
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200123 RAN_Configurations mp_bssap_cfg := {
124 {
125 transport := BSSAP_TRANSPORT_AoIP,
126 sccp_service_type := "mtp3_itu",
127 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
128 own_pc := 185, /* 0.23.1 first MSC emulation */
129 own_ssn := 254,
130 peer_pc := 187, /* 0.23.3 osmo-bsc */
131 peer_ssn := 254,
132 sio := '83'O,
133 rctx := 0
134 },
135 {
136 transport := BSSAP_TRANSPORT_AoIP,
137 sccp_service_type := "mtp3_itu",
138 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
139 own_pc := 2, /* 0.0.2 second MSC emulation */
140 own_ssn := 254,
141 peer_pc := 187, /* 0.23.3 osmo-bsc */
142 peer_ssn := 254,
143 sio := '83'O,
144 rctx := 2
145 },
146 {
147 transport := BSSAP_TRANSPORT_AoIP,
148 sccp_service_type := "mtp3_itu",
149 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
150 own_pc := 3, /* 0.0.3 third MSC emulation */
151 own_ssn := 254,
152 peer_pc := 187, /* 0.23.3 osmo-bsc */
153 peer_ssn := 254,
154 sio := '83'O,
155 rctx := 3
156 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100157 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200158
159 /* Whether to enable osmux tests. Can be dropped completely and enable
160 unconditionally once new version of osmo-bsc is released (current
161 version: 1.4.1) */
162 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100163 /* Value set in osmo-bsc.cfg "ms max power" */
164 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100165}
166
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200167private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200168
169 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200170 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200171 pars.aoip := true;
172 } else {
173 pars.aoip := false;
174 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100175 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200176 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maier48604732018-10-09 15:00:37 +0200177
178 return pars;
179}
180
Philipp Maier282ca4b2018-02-27 17:17:00 +0100181private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200182 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100183 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200184 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100185}
186
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200187private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100188 var BSSAP_N_UNITDATA_ind ud_ind;
189 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200190 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
191 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100192 T.start;
193 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200194 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
195 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100196 log("Received RESET-ACK in response to RESET, we're ready to go!");
197 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200198 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100199 log("Respoding to inbound RESET with RESET-ACK");
200 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200201 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100202 repeat;
203 }
204 [] BSSAP.receive { repeat; }
205 [] T.timeout { setverdict(fail, "Waiting for RESET-ACK after sending RESET"); }
206 }
Harald Welte28d943e2017-11-25 15:00:50 +0100207}
208
Harald Welteae026692017-12-09 01:03:01 +0100209type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100210 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100211 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100212 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100213 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100214 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100215 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100216 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100217 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100218}
219
Harald Welte21b46bd2017-12-17 19:46:32 +0100220/*! Start the IPA/RSL related bits for one IPA_Client.
221 * \param clnt IPA_Client for which to establish
222 * \param bsc_host IP address / hostname of the BSC
223 * \param bsc_port TCP port number of the BSC
224 * \param i number identifying this BTS
225 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100226function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
227 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100228runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100229 timer T := 10.0;
230
Harald Welte96c94412017-12-09 03:12:45 +0100231 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100232 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
233 clnt.ccm_pars := c_IPA_default_ccm_pars;
234 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
235 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100236 if (handler_mode) {
237 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100238 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100239 }
Harald Welteae026692017-12-09 01:03:01 +0100240
241 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100242 if (handler_mode) {
243 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
244 } else {
245 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
246 }
Harald Welteae026692017-12-09 01:03:01 +0100247
Harald Welte5d1a2202017-12-13 19:51:29 +0100248 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100249 if (handler_mode) {
250 clnt.vc_RSL.start(RSL_Emulation.main());
251 return;
252 }
Harald Welteae026692017-12-09 01:03:01 +0100253
254 /* wait for IPA RSL link to connect and send ID ACK */
255 T.start;
256 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700257 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100258 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700259 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100260 }
Harald Welte60e823a2017-12-10 14:10:59 +0100261 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100262 [] IPA_RSL[i].receive { repeat }
263 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100264 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200265 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100266 }
267 }
268}
269
Harald Welte12055472018-03-17 20:10:08 +0100270function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
271 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
272 return;
273 }
274 clnt.vc_IPA.stop;
275 if (isbound(clnt.vc_RSL)) {
276 clnt.vc_RSL.stop;
277 }
278}
279
Harald Welte21b46bd2017-12-17 19:46:32 +0100280/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100281function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
282 timer T := secs_max;
283 T.start;
284 while (true) {
285 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
286 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100287 /* the 'degraded' state exists from OML connection time, and we have to wait
288 * until all MO's are initialized */
289 T.start(1.0);
290 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100291 return;
292 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100293 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100294 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100295 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200296 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100297 }
298 }
299}
300
Harald Welte21b46bd2017-12-17 19:46:32 +0100301/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100302altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100303 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100304 [] T_guard.timeout {
305 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200306 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100307 }
Harald Welte60e823a2017-12-10 14:10:59 +0100308 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200309 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100310 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200311 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100312 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100313 }
Harald Welte28d943e2017-11-25 15:00:50 +0100314}
315
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100316altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200317 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100318 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200319 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100320 }
321}
322
Daniel Willmann191e0d92018-01-17 12:44:35 +0100323function f_init_mgcp(charstring id) runs on test_CT {
324 id := id & "-MGCP";
325
326 var MGCPOps ops := {
327 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
328 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
329 };
330 var MGCP_conn_parameters mgcp_pars := {
331 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100332 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100333 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200334 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200335 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
336 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200337 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100338 };
339
340 vc_MGCP := MGCP_Emulation_CT.create(id);
341 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
342}
343
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200344/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
345 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
346 * OsmuxCID IE.
347 */
348private function f_vty_allow_osmux(boolean allow) runs on test_CT {
349 f_vty_enter_cfg_msc(BSCVTY, 0);
350 if (allow) {
351 f_vty_transceive(BSCVTY, "osmux on");
352 } else {
353 f_vty_transceive(BSCVTY, "osmux off");
354 }
355 f_vty_transceive(BSCVTY, "exit");
356 f_vty_transceive(BSCVTY, "exit");
357 g_osmux_enabled := allow;
358}
359
Max2253c0b2018-11-06 19:28:05 +0100360function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200361 if (BSCVTY.checkstate("Mapped")) {
362 /* skip initialization if already executed once */
363 return;
364 }
Harald Weltebc03c762018-02-12 18:09:38 +0100365 map(self:BSCVTY, system:BSCVTY);
366 f_vty_set_prompts(BSCVTY);
367 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100368 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
369 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100370}
371
Harald Welte21b46bd2017-12-17 19:46:32 +0100372/* global initialization function
373 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200374 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
375 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
376 */
377function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
378 integer nr_msc := 1) runs on test_CT {
379 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +0100380 var integer i;
Harald Welte28d943e2017-11-25 15:00:50 +0100381
Harald Welteae026692017-12-09 01:03:01 +0100382 if (g_initialized) {
383 return;
Harald Welte28d943e2017-11-25 15:00:50 +0100384 }
Harald Welteae026692017-12-09 01:03:01 +0100385 g_initialized := true;
386
Daniel Willmanne68f9272018-11-27 15:15:28 +0100387 T_guard.start;
388 activate(as_Tguard());
389
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200390 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200391 if (mp_enable_osmux_test) {
392 f_vty_allow_osmux(allow_osmux);
393 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200394
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200395 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
396 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
397 * MSC-side BSSAP emulation */
398 if (handler_mode) {
399 var RanOps ranops := MSC_RanOps;
400 ranops.use_osmux := g_osmux_enabled;
401 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
402 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
403 f_ran_adapter_start(g_bssap[bssap_idx]);
404 } else {
405 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
406 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
407 f_ran_adapter_start(g_bssap[bssap_idx]);
408 f_legacy_bssap_reset();
409 }
Harald Welte67089ee2018-01-17 22:19:03 +0100410 }
Harald Welted5833a82018-05-27 16:52:56 +0200411
Harald Welteffe55fc2018-01-17 22:39:54 +0100412 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +0100413
Daniel Willmann191e0d92018-01-17 12:44:35 +0100414 f_init_mgcp("VirtMSC");
415
Harald Welte89d42e82017-12-17 16:42:41 +0100416 for (i := 0; i < nr_bts; i := i+1) {
Harald Weltea5d2ab22017-12-09 14:21:42 +0100417 /* wait until osmo-bts-omldummy has respawned */
418 f_wait_oml(i, "degraded", 5.0);
419 /* start RSL connection */
Harald Welte624f9632017-12-16 19:26:04 +0100420 f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i, handler_mode);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100421 /* wait until BSC tells us "connected" */
422 f_wait_oml(i, "connected", 5.0);
Harald Welte696ddb62017-12-08 14:01:43 +0100423 }
424
Harald Welte28d943e2017-11-25 15:00:50 +0100425}
426
Maxd4e56962018-10-31 19:08:25 +0100427/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welteae026692017-12-09 01:03:01 +0100428function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
429runs on test_CT return RSL_Message {
430 var ASP_RSL_Unitdata rx_rsl_ud;
431 timer T := t_secs;
432
433 T.start;
434 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700435 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +0100436 T.stop;
437 }
438 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +0100439 [] T.timeout {
440 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +0200441 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +0100442 }
Harald Welteae026692017-12-09 01:03:01 +0100443 }
444 return rx_rsl_ud.rsl;
445}
446
Harald Welte21b46bd2017-12-17 19:46:32 +0100447/* helper function to transmit RSL on a given BTS/stream */
Harald Welteae026692017-12-09 01:03:01 +0100448function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
449runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700450 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +0100451}
452
453
Harald Welte4003d112017-12-09 22:35:39 +0100454/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +0100455testcase TC_chan_act_noreply() runs on test_CT {
456 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +0100457 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +0100458
Harald Welte89d42e82017-12-17 16:42:41 +0100459 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +0100460
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700461 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +0100462 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welteae026692017-12-09 01:03:01 +0100463 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +0100464}
465
Harald Welte4003d112017-12-09 22:35:39 +0100466/* verify if the "chreq:total" counter increments as expected */
467testcase TC_chan_act_counter() runs on test_CT {
468 var BSSAP_N_UNITDATA_ind ud_ind;
469 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +0100470 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +0100471
Harald Welte89d42e82017-12-17 16:42:41 +0100472 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100473
474 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700475 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +0100476 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +0100477 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
478
479 setverdict(pass);
480}
481
Harald Welteae026692017-12-09 01:03:01 +0100482/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
483testcase TC_chan_act_ack_noest() runs on test_CT {
484 var RSL_Message rx_rsl;
485
Harald Welte89d42e82017-12-17 16:42:41 +0100486 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100487
488 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100489 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100490
491 /* expect BSC to disable the channel again if there's no RLL EST IND */
492 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
493
494 setverdict(pass);
495}
496
497/* Test behavior if MSC never answers to CR */
498testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +0100499 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
500 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +0100501 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +0100502 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +0100503
Harald Welte89d42e82017-12-17 16:42:41 +0100504 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100505
506 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100507 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100508
509 var octetstring l3 := '00010203040506'O
510 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
511
512 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
513
514 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +0100515 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100516 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +0100517 setverdict(pass);
518}
519
520/* Test behavior if MSC answers with CREF to CR */
521testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
522 var BSSAP_N_CONNECT_ind rx_c_ind;
523 var RSL_Message rx_rsl;
524
Harald Welte89d42e82017-12-17 16:42:41 +0100525 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100526
527 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100528 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100529
530 var octetstring l3 := '00010203040506'O
531 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
532
533 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
534 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
535
536 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100537 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +0100538 setverdict(pass);
539}
540
Harald Welte618ef642017-12-14 14:58:20 +0100541/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
542testcase TC_chan_act_nack() runs on test_CT {
543 var RSL_Message rx_rsl;
544 var integer chact_nack;
545
Harald Welte89d42e82017-12-17 16:42:41 +0100546 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +0100547
548 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
549
550 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
551 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
552 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
553
554 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
555
556 /* wait for some time to hope the NACK arrives before the CTRL GET below */
557 f_sleep(0.5);
558
559 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
560
561 setverdict(pass);
562}
563
Harald Welte799c97b2017-12-14 17:50:30 +0100564/* Test for channel exhaustion due to RACH overload */
565testcase TC_chan_exhaustion() runs on test_CT {
566 var ASP_RSL_Unitdata rsl_ud;
567 var integer i;
568 var integer chreq_total, chreq_nochan;
569
Harald Welte89d42e82017-12-17 16:42:41 +0100570 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +0100571
572 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
573 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
574
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +0100575 /* GSM 04.08 Table 9.9a:
576 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
577 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +0200578 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 +0100579 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +0100580 }
581
582 IPA_RSL[0].clear;
583
Harald Weltedd8cbf32018-01-28 12:07:52 +0100584 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200585 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +0100586
587 /* now expect additional channel activations to fail */
588 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
589
590 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700591 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +0100592 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
593 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700594 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +0100595 var GsmRrMessage rr;
596 /* match on IMM ASS REJ */
597 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
598 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
599 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200600 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +0100601 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
602 chreq_nochan+1);
603 setverdict(pass);
604 } else {
605 repeat;
606 }
607 }
608 [] IPA_RSL[0].receive { repeat; }
609 }
610}
611
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +0700612/* Test channel deactivation due to silence from MS */
613testcase TC_chan_deact_silence() runs on test_CT {
614 var RslChannelNr chan_nr;
615
616 f_init(1);
617
618 /* Request for a dedicated channel */
619 chan_nr := f_chreq_act_ack('23'O);
620
621 /* Wait some time until the channel is released */
622 f_sleep(2.0);
623
624 /* Expect CHANnel RELease */
625 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700626 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +0700627 log("Received CHANnel RELease");
628 setverdict(pass);
629 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700630 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +0700631 /* See OS#3709, OsmoBSC should not send Immediate
632 * Assignment Reject since a dedicated channel was
633 * already allocated, and Immediate Assignment was
634 * already sent. */
635 setverdict(fail, "Unexpected Immediate Assignment!");
636 }
637 [] IPA_RSL[0].receive {
638 setverdict(fail, "Unexpected RSL message!");
639 }
640 }
641}
642
Harald Weltecfe2c962017-12-15 12:09:32 +0100643/***********************************************************************
644 * Assignment Testing
645 ***********************************************************************/
646
Neels Hofmeyrda4a6952018-06-14 04:02:49 +0200647/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
648 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200649testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +0100650 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +0100651
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200652 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
653 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +0100654 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
655 setverdict(pass);
656}
657
Harald Welte16a4adf2017-12-14 18:54:01 +0100658/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200659testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +0100660 var BSSAP_N_CONNECT_ind rx_c_ind;
661 var RSL_Message rx_rsl;
662 var DchanTuple dt;
663
Harald Welte89d42e82017-12-17 16:42:41 +0100664 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +0100665
666 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200667 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +0200668 /* send assignment without AoIP IEs */
669 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
670 } else {
671 /* Send assignmetn without CIC in IPA case */
672 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
673 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
674 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
675 }
Harald Welte16a4adf2017-12-14 18:54:01 +0100676 alt {
677 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
678 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
679 }
Harald Welte235ebf12017-12-15 14:18:16 +0100680 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +0100681 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
682 setverdict(pass);
683 }
684 [] BSSAP.receive { repeat; }
685 }
686}
687
Harald Welteed848512018-05-24 22:27:58 +0200688/* generate an assignment request for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200689function f_gen_ass_req(boolean osmux_enabled := false, integer bssap_idx := 0) return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200690 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200691 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200692 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +0200693 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
694 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200695 if (osmux_enabled) {
696 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
697 } else {
698 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
699 }
Harald Welteed848512018-05-24 22:27:58 +0200700 } else {
701 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +0200702 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +0200703 }
704 return ass_cmd;
705}
706
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200707function f_gen_handover_req(integer bssap_idx := 0) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100708 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200709 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100710 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
711 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
712 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
713 } else {
714 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
715 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
716 }
717 return ho_req;
718}
719
Harald Welteed848512018-05-24 22:27:58 +0200720/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200721function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200722 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200723 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200724 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200725 if (expect_osmux) {
726 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
727 } else {
728 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
729 }
Harald Welteed848512018-05-24 22:27:58 +0200730 } else {
731 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +0200732 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +0200733 }
734 return exp_compl;
735}
736
Harald Welte235ebf12017-12-15 14:18:16 +0100737/* Run everything required up to sending a caller-specified assignment command and expect response */
738function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
739runs on test_CT {
740 var BSSAP_N_CONNECT_ind rx_c_ind;
741 var RSL_Message rx_rsl;
742 var DchanTuple dt;
743
Harald Welte89d42e82017-12-17 16:42:41 +0100744 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +0100745
746 dt := f_est_dchan('23'O, 23, '00000000'O);
747 /* send assignment without AoIP IEs */
748 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
749 alt {
750 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
751 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
752 setverdict(pass);
753 } else {
754 setverdict(fail, fail_text);
755 }
756 }
757 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
758 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
759 setverdict(pass);
760 } else {
761 setverdict(fail, fail_text);
762 }
763 }
764 [] BSSAP.receive { repeat; }
765 }
766}
767testcase TC_assignment_csd() runs on test_CT {
768 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200769 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100770 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
771 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
772 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
773}
774
775testcase TC_assignment_ctm() runs on test_CT {
776 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200777 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100778 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
779 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
780 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
781}
782
Harald Welte4003d112017-12-09 22:35:39 +0100783type record DchanTuple {
784 integer sccp_conn_id,
785 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +0100786}
787
Harald Welted6939652017-12-13 21:02:46 +0100788/* Send CHAN RQD and wait for allocation; acknowledge it */
789private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
790runs on test_CT return RslChannelNr {
791 var RSL_Message rx_rsl;
792 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
793 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
794 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
795 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +0200796 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +0100797 return chan_nr;
798}
799
Harald Welte4003d112017-12-09 22:35:39 +0100800/* helper function to establish a dedicated channel via BTS and MSC */
801function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
802runs on test_CT return DchanTuple {
803 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +0100804 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100805
Harald Welte4003d112017-12-09 22:35:39 +0100806 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100807 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +0100808
809 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
810
811 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
812 dt.sccp_conn_id := rx_c_ind.connectionId;
813 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
814
815 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100816}
817
Harald Welte641fcbe2018-06-14 10:58:35 +0200818/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
819private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
820 var RSL_Message rx_rsl;
821 /* expect BSC to disable the channel */
822 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
823 /* respond with CHAN REL ACK */
824 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
825
826 /* expect Clear Complete from BSC */
827 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
828
829 /* MSC disconnects as instructed. */
830 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
831}
832
Harald Welte4003d112017-12-09 22:35:39 +0100833/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
834testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100835 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100836 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +0100837
Harald Welte89d42e82017-12-17 16:42:41 +0100838 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +0100839
Harald Welte4003d112017-12-09 22:35:39 +0100840 dt := f_est_dchan('23'O, 23, '00010203040506'O);
841
842 /* simulate RLL REL IND */
843 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
844
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100845 /* expect Clear Request on MSC side */
846 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
847
848 /* Instruct BSC to clear channel */
849 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
850 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
851
Harald Welte4003d112017-12-09 22:35:39 +0100852 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +0200853 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100854
855 /* wait for SCCP emulation to do its job */
856 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +0100857
858 setverdict(pass);
859}
860
861/* Test behavior of channel release after CONN FAIL IND from BTS */
862testcase TC_chan_rel_conn_fail() runs on test_CT {
863 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100864 var DchanTuple dt;
865
Harald Welte89d42e82017-12-17 16:42:41 +0100866 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100867
868 dt := f_est_dchan('23'O, 23, '00010203040506'O);
869
870 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +0100871 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 +0100872 /* TODO: different cause values? */
873
Harald Welte4003d112017-12-09 22:35:39 +0100874 /* expect Clear Request from BSC */
875 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
876
877 /* Instruct BSC to clear channel */
878 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
879 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
880
Harald Welte6ff76ea2018-01-28 13:08:01 +0100881 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +0200882 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +0100883
884 /* wait for SCCP emulation to do its job */
885 f_sleep(1.0);
886
887 setverdict(pass);
888}
889
Harald Welte99f3ca02018-06-14 13:40:29 +0200890/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
891/* See also https://www.osmocom.org/issues/3182 */
892testcase TC_early_conn_fail() runs on test_CT {
893 var RSL_Message rx_rsl;
894 var DchanTuple dt;
895
896 f_init(1);
897
898 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
899 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_octstring(1), 23);
900
901 /* BTS->BSC: simulate CONN FAIL IND */
902 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
903
904 /* BTS->BSC: Expect RF channel release from BSC on Abis */
905 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
906
907 /* BTS<-BSC: respond with CHAN REL ACK */
908 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
909
910 setverdict(pass);
911}
912
913/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
914/* See also https://www.osmocom.org/issues/3182 */
915testcase TC_late_conn_fail() runs on test_CT {
916 var RSL_Message rx_rsl;
917 var DchanTuple dt;
918
919 f_init(1);
920
921 dt := f_est_dchan('23'O, 23, '00010203040506'O);
922
923 /* BSC<-MSC: Instruct BSC to clear connection */
924 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
925
926 /* BTS->BSC: expect BSC to deactivate SACCH */
927 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
928
929 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
930 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
931
932 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
933 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
934 /* BTS->BSC: respond with CHAN REL ACK */
935 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
936
937 /* BSC->MSC: expect Clear Complete from BSC */
938 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
939
940 /* BSC<-MSC: MSC disconnects as requested. */
941 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
942
943 setverdict(pass);
944}
945
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +0100946function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100947 boolean expect_deact_sacch := true,
948 boolean expect_rr_chan_rel := true,
949 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +0100950 boolean handle_rll_rel := true,
951 boolean is_csfb := false
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100952 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +0100953
954 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100955 var boolean got_deact_sacch := false;
956 var boolean got_rr_chan_rel := false;
957 var boolean got_rll_rel_req := false;
958 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
959 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +0100960 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700961 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100962 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100963 repeat;
964 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700965 [is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CSFB))) {
Harald Welte99787102019-02-04 10:41:36 +0100966 got_rr_chan_rel := true;
967 repeat;
968 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700969 [not is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100970 got_rr_chan_rel := true;
Neels Hofmeyr211169d2018-11-07 00:37:29 +0100971 repeat;
972 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700973 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100974 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100975 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100976 if (handle_rll_rel) {
977 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
978 }
Harald Welte91d54a52018-01-28 15:35:07 +0100979 repeat;
980 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700981 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +0100982 /* respond with CHAN REL ACK */
983 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
984 }
985 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700986 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +0100987 repeat;
988 }
989 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100990
991 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
992 " got_rll_rel_req=", got_rll_rel_req);
993
994 if (expect_deact_sacch != got_deact_sacch) {
995 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
996 }
997 if (expect_rr_chan_rel != got_rr_chan_rel) {
998 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
999 }
1000 if (expect_rll_rel_req != got_rll_rel_req) {
1001 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1002 }
Harald Welte91d54a52018-01-28 15:35:07 +01001003}
1004
Harald Welte4003d112017-12-09 22:35:39 +01001005/* Test behavior of channel release after hard Clear Command from MSC */
1006testcase TC_chan_rel_hard_clear() runs on test_CT {
1007 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001008 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001009
Harald Welte89d42e82017-12-17 16:42:41 +01001010 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001011
1012 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1013
1014 /* Instruct BSC to clear channel */
1015 var BssmapCause cause := 0;
1016 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1017
1018 /* expect Clear Complete from BSC on A */
1019 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1020 /* release the SCCP connection */
1021 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1022 }
1023
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001024 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte4003d112017-12-09 22:35:39 +01001025 setverdict(pass);
1026}
1027
Harald Welte99787102019-02-04 10:41:36 +01001028/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1029testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1030 var BSSAP_N_DATA_ind rx_di;
1031 var DchanTuple dt;
1032
1033 f_init(1);
1034
1035 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1036
1037 /* Instruct BSC to clear channel */
1038 var BssmapCause cause := 0;
1039 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1040
1041 /* expect Clear Complete from BSC on A */
1042 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1043 /* release the SCCP connection */
1044 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1045 }
1046
1047 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
1048 setverdict(pass);
1049}
1050
Harald Welted8c36cd2017-12-09 23:05:31 +01001051/* Test behavior of channel release after hard RLSD from MSC */
1052testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001053 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001054
Harald Welte89d42e82017-12-17 16:42:41 +01001055 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001056
1057 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1058
1059 /* release the SCCP connection */
1060 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1061
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001062 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welted8c36cd2017-12-09 23:05:31 +01001063 setverdict(pass);
1064}
1065
Harald Welte550daf92018-06-11 19:22:13 +02001066/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1067testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1068 var DchanTuple dt;
1069
1070 f_init(1);
1071
1072 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1073
1074 /* release the SCCP connection */
1075 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1076
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001077 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte550daf92018-06-11 19:22:13 +02001078 setverdict(pass);
1079}
1080
Harald Welte85804d42017-12-10 14:11:58 +01001081/* Test behavior of channel release after BSSMAP RESET from MSC */
1082testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001083 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001084
Harald Welte89d42e82017-12-17 16:42:41 +01001085 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001086
1087 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1088
1089 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1090 IPA_RSL[0].clear;
1091
1092 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001093 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte85804d42017-12-10 14:11:58 +01001094 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001095 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[0].sccp_addr_own, g_bssap[0].sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte85804d42017-12-10 14:11:58 +01001096 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1097 }
1098
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001099 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte85804d42017-12-10 14:11:58 +01001100 setverdict(pass);
1101}
1102
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001103/* Verify T(iar) triggers and releases the channel */
1104testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1105 var DchanTuple dt;
1106
1107 /* Set T(iar) in BSC low enough that it will trigger before other side
1108 has time to keep alive with a T(ias). Keep recommended ratio of
1109 T(iar) >= T(ias)*2 */
1110 g_bsc_sccp_timer_ias := 2;
1111 g_bsc_sccp_timer_iar := 5;
1112
1113 f_init(1);
1114
1115 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1116 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
1117 setverdict(pass);
1118}
1119
Harald Welte5cd20ed2017-12-13 21:03:20 +01001120/* Test behavior if RSL EST IND for non-active channel */
1121testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1122 timer T := 2.0;
1123
Harald Welte89d42e82017-12-17 16:42:41 +01001124 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001125
1126 var octetstring l3 := '00010203040506'O;
1127 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1128 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1129
1130 T.start;
1131 alt {
1132 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1133 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1134 }
1135 [] BSSAP.receive {}
1136 [] IPA_RSL[0].receive {}
1137 [] T.timeout {}
1138 }
1139
1140 setverdict(pass);
1141}
1142
1143/* Test behavior if RSL EST IND for invalid SAPI */
1144testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1145 var RslChannelNr chan_nr;
1146
Harald Welte89d42e82017-12-17 16:42:41 +01001147 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001148
1149 chan_nr := f_chreq_act_ack()
1150
1151 var octetstring l3 := '00010203040506'O;
1152 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1153
1154 timer T := 2.0;
1155 T.start;
1156 alt {
1157 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1158 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1159 }
1160 [] BSSAP.receive { repeat; }
1161 [] IPA_RSL[0].receive { repeat; }
1162 [] T.timeout {}
1163 }
1164
1165 setverdict(pass);
1166}
1167
1168/* Test behavior if RSL EST IND for invalid SAPI */
1169testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
1170 timer T := 2.0;
1171
Harald Welte89d42e82017-12-17 16:42:41 +01001172 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001173
1174 var RslChannelNr chan_nr := f_chreq_act_ack();
1175
1176 var octetstring l3 := '00010203040506'O;
1177 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
1178
1179 T.start;
1180 alt {
1181 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1182 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
1183 }
1184 [] BSSAP.receive { repeat; }
1185 [] IPA_RSL[0].receive { repeat; }
1186 [] T.timeout {}
1187 }
1188
1189 setverdict(pass);
1190}
1191
1192/* Test behavior if RSL EST IND for invalid SACCH */
1193testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
1194 timer T := 2.0;
1195
Harald Welte89d42e82017-12-17 16:42:41 +01001196 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001197
1198 var RslChannelNr chan_nr := f_chreq_act_ack();
1199
1200 var octetstring l3 := '00010203040506'O;
1201 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
1202
1203 T.start;
1204 alt {
1205 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1206 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
1207 }
1208 [] BSSAP.receive { repeat; }
1209 [] IPA_RSL[0].receive { repeat; }
1210 [] T.timeout {}
1211 }
1212
1213 setverdict(pass);
1214}
1215
1216
1217
Harald Welte4003d112017-12-09 22:35:39 +01001218
1219testcase TC_ctrl_msc_connection_status() runs on test_CT {
1220 var charstring ctrl_resp;
1221
Harald Welte89d42e82017-12-17 16:42:41 +01001222 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001223
1224 /* See https://osmocom.org/issues/2729 */
1225 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
1226 setverdict(pass);
1227}
1228
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001229testcase TC_ctrl_msc0_connection_status() runs on test_CT {
1230 var charstring ctrl_resp;
1231
1232 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001233
1234 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
1235 setverdict(pass);
1236}
1237
Harald Welte4003d112017-12-09 22:35:39 +01001238testcase TC_ctrl() runs on test_CT {
1239 var charstring ctrl_resp;
1240
Harald Welte89d42e82017-12-17 16:42:41 +01001241 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001242
1243 /* all below values must match the osmo-bsc.cfg config file used */
1244
Harald Welte6a129692018-03-17 17:30:14 +01001245 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
1246 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02001247 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01001248
1249 var integer bts_nr := 0;
1250 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
1251 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
1252 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
1253 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
1254 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
1255 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
1256 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
1257
1258 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
1259 f_sleep(2.0);
1260 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
1261 setverdict(fail, "oml-uptime not incrementing as expected");
1262 }
1263 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
1264
1265 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
1266
1267 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +01001268}
1269
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02001270/* Verify that Upon receival of SET "location", BSC forwards a TRAP
1271 "location-state" over the SCCPlite IPA conn */
1272testcase TC_ctrl_location() runs on test_CT {
1273 var MSC_ConnHdlr vc_conn;
1274 var integer bts_nr := 0;
1275
1276 f_init(1, true);
1277 f_sleep(1.0);
1278
1279 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
1280 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
1281 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
1282
1283 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
1284 f_sleep(2.0);
1285
1286 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
1287 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
1288 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
1289
1290 /* should match the one from config */
1291 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
1292
1293 setverdict(pass);
1294}
1295
Harald Welte6f521d82017-12-11 19:52:02 +01001296
1297/***********************************************************************
1298 * Paging Testing
1299 ***********************************************************************/
1300
1301type record Cell_Identity {
1302 GsmMcc mcc,
1303 GsmMnc mnc,
1304 GsmLac lac,
1305 GsmCellId ci
1306};
Harald Welte24135bd2018-03-17 19:27:53 +01001307private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001308private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001309
Harald Welte5d1a2202017-12-13 19:51:29 +01001310type set of integer BtsIdList;
1311
1312private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1313 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1314 if (bts_id == bts_ids[j]) {
1315 return true;
1316 }
1317 }
1318 return false;
1319}
Harald Welte6f521d82017-12-11 19:52:02 +01001320
1321/* core paging test helper function; used by most paging test cases */
1322private function f_pageing_helper(hexstring imsi,
1323 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001324 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001325 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001326 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01001327{
1328 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001329 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01001330 var RSL_Message rx_rsl;
1331 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001332 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001333
1334 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001335
1336 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001337 for (i := 0; i < NUM_BTS; i := i + 1) {
1338 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001339 }
Harald Welte6f521d82017-12-11 19:52:02 +01001340
1341 if (isvalue(rsl_chneed)) {
1342 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1343 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1344 } else {
1345 bssmap_chneed := omit;
1346 }
1347
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001348 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
1349 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01001350
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001351 if (not istemplatekind(tmsi, "omit")) {
1352 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01001353 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001354 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01001355 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001356
Harald Welte5d1a2202017-12-13 19:51:29 +01001357 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001358 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01001359 /* check channel type, paging group */
1360 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1361 setverdict(fail, "Paging for wrong paging group");
1362 }
1363 if (ispresent(rsl_chneed) and
1364 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1365 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1366 }
Harald Welte6f521d82017-12-11 19:52:02 +01001367 }
Harald Welte2fccd982018-01-31 15:48:19 +01001368 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001369 /* do a quick check on all not-included BTSs if they received paging */
1370 for (i := 0; i < NUM_BTS; i := i + 1) {
1371 timer T := 0.1;
1372 if (f_bts_in_list(i, bts_ids)) {
1373 continue;
1374 }
1375 T.start;
1376 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001377 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01001378 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1379 }
1380 [] IPA_RSL[i].receive { repeat; }
1381 [] T.timeout { }
1382 }
Harald Welte6f521d82017-12-11 19:52:02 +01001383 }
1384
1385 setverdict(pass);
1386}
1387
Harald Welte5d1a2202017-12-13 19:51:29 +01001388const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001389const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001390const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1391const BtsIdList c_BtsId_LAC2 := { 2 };
1392
Harald Welte6f521d82017-12-11 19:52:02 +01001393/* PAGING by IMSI + TMSI */
1394testcase TC_paging_imsi_nochan() runs on test_CT {
1395 var BSSMAP_FIELD_CellIdentificationList cid_list;
1396 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001397 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001398 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001399}
1400
1401/* PAGING by IMSI + TMSI */
1402testcase TC_paging_tmsi_nochan() 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('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001406 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001407}
1408
1409/* Paging with different "channel needed' values */
1410testcase TC_paging_tmsi_any() runs on test_CT {
1411 var BSSMAP_FIELD_CellIdentificationList cid_list;
1412 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001413 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001414 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001415}
1416testcase TC_paging_tmsi_sdcch() runs on test_CT {
1417 var BSSMAP_FIELD_CellIdentificationList cid_list;
1418 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001419 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001420 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001421}
1422testcase TC_paging_tmsi_tch_f() runs on test_CT {
1423 var BSSMAP_FIELD_CellIdentificationList cid_list;
1424 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001425 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001426 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001427}
1428testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1429 var BSSMAP_FIELD_CellIdentificationList cid_list;
1430 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001431 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001432 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001433}
1434
1435/* Paging by CGI */
1436testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1437 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1438 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001439 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001440 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001441}
1442
1443/* Paging by LAC+CI */
1444testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1445 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1446 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001447 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001448 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001449}
1450
1451/* Paging by CI */
1452testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1453 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1454 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001455 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001456 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001457}
1458
1459/* Paging by LAI */
1460testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1461 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1462 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001463 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001464 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001465}
1466
1467/* Paging by LAC */
1468testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1469 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1470 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001471 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001472 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001473}
1474
1475/* Paging by "all in BSS" */
1476testcase TC_paging_imsi_nochan_all() runs on test_CT {
1477 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1478 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001479 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001480 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001481}
1482
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001483/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001484testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1485 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1486 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 +01001487 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001488 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001489}
Harald Welte6f521d82017-12-11 19:52:02 +01001490
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001491/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001492testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1493 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1494 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001495 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001496 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001497}
1498
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001499/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001500testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1501 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1502 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001503 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001504 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001505}
1506
Harald Welte6f521d82017-12-11 19:52:02 +01001507/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001508testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1509 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1510 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1511 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001512 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001513}
1514
1515/* Paging on empty list: Verify none of them page */
1516testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1517 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1518 cid_list := { cIl_LAC := { } };
1519 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001520 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001521}
1522
Stefan Sperling049a86e2018-03-20 15:51:00 +01001523/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1524testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1525 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1526 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1527 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1528 f_shutdown_helper();
1529}
1530
Harald Welte6f521d82017-12-11 19:52:02 +01001531/* Verify paging retransmission interval + count */
1532/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001533/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001534
Harald Weltee65d40e2017-12-13 00:09:06 +01001535/* Verify PCH load */
1536testcase TC_paging_imsi_load() runs on test_CT {
1537 var BSSMAP_FIELD_CellIdentificationList cid_list;
1538 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001539 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001540 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001541 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001542
1543 /* tell BSC there is no paging space anymore */
1544 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001545 f_sleep(0.2);
1546 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001547
1548 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1549 * there would be 8 retransmissions during 4 seconds */
1550 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001551 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001552 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001553 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01001554 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02001555 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01001556 }
Harald Welte2caa1062018-03-17 18:19:05 +01001557 [] T_retrans.timeout {
1558 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1559 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1560 T_retrans.start;
1561 repeat;
1562 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001563 [] T.timeout {
1564 setverdict(pass);
1565 }
1566 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001567
1568 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001569}
1570
Harald Welte235ebf12017-12-15 14:18:16 +01001571/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001572testcase TC_paging_counter() runs on test_CT {
1573 var BSSMAP_FIELD_CellIdentificationList cid_list;
1574 timer T := 4.0;
1575 var integer i;
1576 var integer paging_attempted_bsc;
1577 var integer paging_attempted_bts[NUM_BTS];
1578 var integer paging_expired_bts[NUM_BTS];
1579 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1580
1581 f_init();
1582
1583 /* read counters before paging */
1584 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1585 for (i := 0; i < NUM_BTS; i := i+1) {
1586 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1587 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1588 }
1589
1590 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1591
1592 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1593 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1594 for (i := 0; i < NUM_BTS; i := i+1) {
1595 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1596 paging_attempted_bts[i]+1);
1597 }
1598
1599 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1600 f_sleep(12.0);
1601 for (i := 0; i < NUM_BTS; i := i+1) {
1602 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1603 paging_expired_bts[i]+1);
1604 }
Harald Welte1ff69992017-12-14 12:31:17 +01001605
Philipp Maier282ca4b2018-02-27 17:17:00 +01001606 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001607}
1608
1609
Harald Welte10985002017-12-12 09:29:15 +01001610/* Verify paging stops after A-RESET */
1611testcase TC_paging_imsi_a_reset() runs on test_CT {
1612 var BSSMAP_FIELD_CellIdentificationList cid_list;
1613 timer T := 3.0;
1614 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001615 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001616
1617 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001618 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte10985002017-12-12 09:29:15 +01001619 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001620 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[0].sccp_addr_own, g_bssap[0].sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte10985002017-12-12 09:29:15 +01001621 [] BSSAP.receive { repeat; }
1622 }
1623
Daniel Willmanncbef3982018-07-30 09:22:40 +02001624 /* Wait to avoid a possible race condition if a paging message is
1625 * received right before the reset ACK. */
1626 f_sleep(0.2);
1627
Harald Welte10985002017-12-12 09:29:15 +01001628 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001629 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1630 IPA_RSL[i].clear;
1631 }
Harald Welte10985002017-12-12 09:29:15 +01001632
1633 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1634 T.start;
1635 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001636 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01001637 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001638 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01001639 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001640 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01001641 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001642 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001643 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001644 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01001645 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001646 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001647 }
Harald Welte10985002017-12-12 09:29:15 +01001648 [] T.timeout {
1649 setverdict(pass);
1650 }
1651 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001652
1653 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001654}
Harald Welteae026692017-12-09 01:03:01 +01001655
Philipp Maierf45824a2019-08-14 14:44:10 +02001656/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
1657 * paging response we can not know which MSC is in charge, so we will blindly
1658 * pick the first configured MSC. This behavior is required in order to make
1659 * MT-CSFB calls working because in those cases the BSC can not know that the
1660 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
1661 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001662 */
1663testcase TC_paging_resp_unsol() runs on test_CT {
1664
1665 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02001666 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001667
1668 var BSSAP_N_CONNECT_ind rx_c_ind;
1669 var DchanTuple dt;
1670 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02001671 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001672
1673 /* Send CHAN RQD and wait for allocation; acknowledge it */
1674 dt.rsl_chan_nr := f_chreq_act_ack();
1675
1676 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
1677 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
1678
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001679
Philipp Maierf45824a2019-08-14 14:44:10 +02001680 /* Expevct a CR with a matching Paging response on the A-Interface */
1681 T.start;
1682 alt {
1683 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
1684 setverdict(pass);
1685 }
1686 [] BSSAP.receive {
1687 setverdict(fail, "Received unexpected message on A-Interface!");
1688 }
1689 [] T.timeout {
1690 setverdict(fail, "Received nothing on A-Interface!");
1691 }
1692 }
1693
1694 setverdict(pass);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001695}
1696
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001697/* Test RSL link drop causes counter increment */
1698testcase TC_rsl_drop_counter() runs on test_CT {
1699 var integer rsl_fail;
1700
Harald Welte89d42e82017-12-17 16:42:41 +01001701 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001702
1703 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1704
1705 bts[0].rsl.vc_IPA.stop;
1706
1707 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1708
1709 setverdict(pass);
1710}
1711
1712/* TODO: Test OML link drop causes counter increment */
1713
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001714/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1715function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1716 timer T := 10.0;
1717
1718 bts[0].rsl.id := "IPA-0-RSL";
1719 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1720 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1721 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02001722 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001723
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001724 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1725
1726 f_init_mgcp("VirtMSC");
1727
1728 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1729 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1730 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1731 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1732
1733 /* wait for IPA OML link to connect and then disconnect */
1734 T.start;
1735 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07001736 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001737 T.stop;
1738 return true;
1739 }
1740 [] IPA_RSL[0].receive { repeat }
1741 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02001742 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001743 }
1744 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001745 return false;
1746}
1747
1748/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1749testcase TC_rsl_unknown_unit_id() runs on test_CT {
1750 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1751 setverdict(pass);
1752 } else {
1753 setverdict(fail, "Timeout RSL waiting for connection to close");
1754 }
1755}
1756
1757
1758/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1759testcase TC_oml_unknown_unit_id() runs on test_CT {
1760 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1761 setverdict(pass);
1762 } else {
1763 setverdict(fail, "Timeout OML waiting for connection to close");
1764 }
1765}
1766
1767
Harald Weltec1a2fff2017-12-17 11:06:19 +01001768/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02001769 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01001770 ***********************************************************************/
1771
Harald Welte6811d102019-04-14 22:23:14 +02001772import from RAN_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01001773import from RSL_Emulation all;
1774import from MSC_ConnectionHandler all;
1775
1776type function void_fn(charstring id) runs on MSC_ConnHdlr;
1777
Harald Welte336820c2018-05-31 20:34:52 +02001778/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001779private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
1780 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001781 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001782 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001783 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001784 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001785 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1786 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1787 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02001788 if (isvalue(bts[2])) {
1789 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
1790 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
1791 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001792 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001793 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02001794 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Harald Welte336820c2018-05-31 20:34:52 +02001795}
1796
1797function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
1798runs on test_CT return MSC_ConnHdlr {
1799 var charstring id := testcasename();
1800 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001801 var integer bssap_idx := 0;
1802 if (isvalue(pars)) {
1803 bssap_idx := valueof(pars).mscpool.bssap_idx;
1804 }
Harald Welte336820c2018-05-31 20:34:52 +02001805 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001806 f_connect_handler(vc_conn, bssap_idx);
Harald Weltea0630032018-03-20 21:09:55 +01001807 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001808 return vc_conn;
1809}
1810
Harald Weltea0630032018-03-20 21:09:55 +01001811/* first function inside ConnHdlr component; sets g_pars + starts function */
1812private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1813runs on MSC_ConnHdlr {
1814 if (isvalue(pars)) {
1815 g_pars := valueof(pars);
1816 }
1817 fn.apply(id);
1818}
1819
Harald Welte3c86ea02018-05-10 22:28:05 +02001820/* Establish signalling channel (non-assignment case) followed by cipher mode */
1821private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001822 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1823 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001824 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02001825 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
1826 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
1827 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
1828 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02001829
Philipp Maier23000732018-05-18 11:25:37 +02001830 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02001831}
1832testcase TC_ciph_mode_a5_0() runs on test_CT {
1833 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001834 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001835 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1836
1837 f_init(1, true);
1838 f_sleep(1.0);
1839 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1840 vc_conn.done;
1841}
1842testcase TC_ciph_mode_a5_1() runs on test_CT {
1843 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001844 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001845 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1846
1847 f_init(1, true);
1848 f_sleep(1.0);
1849 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1850 vc_conn.done;
1851}
1852testcase TC_ciph_mode_a5_3() runs on test_CT {
1853 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001854 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001855 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1856
1857 f_init(1, true);
1858 f_sleep(1.0);
1859 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1860 vc_conn.done;
1861}
1862
1863
1864/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001865private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001866 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1867 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001868
Harald Welte552620d2017-12-16 23:21:36 +01001869 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1870 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001871
Harald Weltea0630032018-03-20 21:09:55 +01001872 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001873}
Harald Welte552620d2017-12-16 23:21:36 +01001874testcase TC_assignment_fr_a5_0() runs on test_CT {
1875 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001876 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001877 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001878
Harald Welte89d42e82017-12-17 16:42:41 +01001879 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001880 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001881 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001882 vc_conn.done;
1883}
Harald Welte552620d2017-12-16 23:21:36 +01001884testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001885 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001886 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001887 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001888
Harald Welte89d42e82017-12-17 16:42:41 +01001889 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001890 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001891 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1892 vc_conn.done;
1893}
1894testcase TC_assignment_fr_a5_3() runs on test_CT {
1895 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001896 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001897 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001898
Harald Welte651fcdc2018-05-10 20:23:16 +02001899 f_init(1, true);
1900 f_sleep(1.0);
1901 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001902 vc_conn.done;
1903}
1904
Harald Welte552620d2017-12-16 23:21:36 +01001905/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1906private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001907 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01001908 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001909 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001910 const OCT8 kc := '0001020304050607'O;
1911
1912 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001913 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
1914
Harald Weltea0630032018-03-20 21:09:55 +01001915 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001916}
Harald Welte552620d2017-12-16 23:21:36 +01001917testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1918 var MSC_ConnHdlr vc_conn;
1919
Harald Welte89d42e82017-12-17 16:42:41 +01001920 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001921 f_sleep(1.0);
1922
Harald Welte8863fa12018-05-10 20:15:27 +02001923 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001924 vc_conn.done;
1925}
1926
Harald Welte552620d2017-12-16 23:21:36 +01001927private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001928 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02001929 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1930 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001931 const OCT8 kc := '0001020304050607'O;
1932 const OCT16 kc128 := kc & kc;
1933
1934 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1935 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001936 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001937 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001938 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001939}
Harald Welte552620d2017-12-16 23:21:36 +01001940testcase TC_assignment_fr_a5_4() runs on test_CT {
1941 var MSC_ConnHdlr vc_conn;
1942
Harald Welte89d42e82017-12-17 16:42:41 +01001943 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001944 f_sleep(1.0);
1945
Harald Welte8863fa12018-05-10 20:15:27 +02001946 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001947 vc_conn.done;
1948}
1949
1950
Harald Welte4532e0a2017-12-23 02:05:44 +01001951private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001952 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01001953 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02001954 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01001955 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001956 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001957}
1958
1959testcase TC_assignment_sign() runs on test_CT {
1960 var MSC_ConnHdlr vc_conn;
1961
1962 f_init(1, true);
1963 f_sleep(1.0);
1964
Harald Welte8863fa12018-05-10 20:15:27 +02001965 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001966 vc_conn.done;
1967}
1968
Harald Welte60aa5762018-03-21 19:33:13 +01001969/***********************************************************************
1970 * Codec (list) testing
1971 ***********************************************************************/
1972
1973/* check if the given rsl_mode is compatible with the a_elem */
1974private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1975return boolean {
1976 select (a_elem.codecType) {
1977 case (GSM_FR) {
1978 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1979 return true;
1980 }
1981 }
1982 case (GSM_HR) {
1983 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1984 return true;
1985 }
1986 }
1987 case (GSM_EFR) {
1988 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1989 return true;
1990 }
1991 }
1992 case (FR_AMR) {
1993 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1994 return true;
1995 }
1996 }
1997 case (HR_AMR) {
1998 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1999 return true;
2000 }
2001 }
2002 case else { }
2003 }
2004 return false;
2005}
2006
2007/* check if the given rsl_mode is compatible with the a_list */
2008private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
2009return boolean {
2010 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
2011 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
2012 return true;
2013 }
2014 }
2015 return false;
2016}
2017
2018/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02002019function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01002020return BSSMAP_IE_ChannelType {
2021 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
2022 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
2023 select (a_elem.codecType) {
2024 case (GSM_FR) {
2025 ret.channelRateAndType := ChRate_TCHF;
2026 ret.speechId_DataIndicator := Spdi_TCHF_FR;
2027 }
2028 case (GSM_HR) {
2029 ret.channelRateAndType := ChRate_TCHH;
2030 ret.speechId_DataIndicator := Spdi_TCHH_HR;
2031 }
2032 case (GSM_EFR) {
2033 ret.channelRateAndType := ChRate_TCHF;
2034 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
2035 }
2036 case (FR_AMR) {
2037 ret.channelRateAndType := ChRate_TCHF;
2038 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
2039 }
2040 case (HR_AMR) {
2041 ret.channelRateAndType := ChRate_TCHH;
2042 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
2043 }
2044 case else {
2045 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02002046 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01002047 }
2048 }
2049 return ret;
2050}
2051
Harald Weltea63b9102018-03-22 20:36:16 +01002052private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
2053return template RSL_IE_Body {
2054 var template RSL_IE_Body mode_ie := {
2055 chan_mode := {
2056 len := ?,
2057 reserved := ?,
2058 dtx_d := ?,
2059 dtx_u := ?,
2060 spd_ind := RSL_SPDI_SPEECH,
2061 ch_rate_type := -,
2062 coding_alg_rate := -
2063 }
2064 }
2065
2066 select (a_elem.codecType) {
2067 case (GSM_FR) {
2068 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2069 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2070 }
2071 case (GSM_HR) {
2072 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2073 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2074 }
2075 case (GSM_EFR) {
2076 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2077 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
2078 }
2079 case (FR_AMR) {
2080 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2081 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2082 }
2083 case (HR_AMR) {
2084 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2085 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2086 }
2087 }
2088 return mode_ie;
2089}
2090
Harald Welte60aa5762018-03-21 19:33:13 +01002091type record CodecListTest {
2092 BSSMAP_IE_SpeechCodecList codec_list,
2093 charstring id
2094}
2095type record of CodecListTest CodecListTests
2096
2097private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002098 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
2099 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01002100
2101 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002102 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02002103 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2104 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
2105 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01002106 if (isvalue(g_pars.expect_mr_s0_s7)) {
2107 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
2108 g_pars.expect_mr_s0_s7;
2109 }
Harald Welte79f3f542018-05-25 20:02:37 +02002110 }
Harald Welte60aa5762018-03-21 19:33:13 +01002111 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2112 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01002113 log("expecting ASS COMPL like this: ", exp_compl);
2114
2115 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01002116
2117 /* Verify that the RSL-side activation actually matches our expectations */
2118 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
2119
2120 var RSL_IE_Body mode_ie;
2121 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
2122 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02002123 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01002124 }
2125 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
2126 if (not match(mode_ie, t_mode_ie)) {
2127 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
2128 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002129
2130 var RSL_IE_Body mr_conf;
2131 if (g_pars.expect_mr_conf_ie != omit) {
2132 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
2133 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02002134 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002135 }
2136 log("found RSL MR CONFIG IE: ", mr_conf);
2137
2138 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
2139 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
2140 g_pars.expect_mr_conf_ie);
2141 }
2142 } else {
2143 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
2144 log("found RSL MR CONFIG IE: ", mr_conf);
2145 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02002146 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002147 }
2148 }
Harald Welte60aa5762018-03-21 19:33:13 +01002149}
2150
Philipp Maierd0e64b02019-03-13 14:15:23 +01002151private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
2152
2153 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2154 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2155
2156 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002157 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01002158 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2159 }
2160 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2161 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
2162 log("expecting ASS FAIL like this: ", exp_fail);
2163
2164 f_establish_fully(ass_cmd, exp_fail);
2165}
2166
Harald Welte60aa5762018-03-21 19:33:13 +01002167testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002168 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002169 var MSC_ConnHdlr vc_conn;
2170
2171 f_init(1, true);
2172 f_sleep(1.0);
2173
2174 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002175 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002176 vc_conn.done;
2177}
2178
2179testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002180 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002181 var MSC_ConnHdlr vc_conn;
2182
2183 f_init(1, true);
2184 f_sleep(1.0);
2185
2186 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002187 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002188 vc_conn.done;
2189}
2190
2191testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002192 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002193 var MSC_ConnHdlr vc_conn;
2194
2195 f_init(1, true);
2196 f_sleep(1.0);
2197
2198 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002199 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002200 vc_conn.done;
2201}
2202
Philipp Maierd0e64b02019-03-13 14:15:23 +01002203/* Allow 5,90k only (current default config) */
2204private function f_allow_amr_rate_5_90k() runs on test_CT {
2205 f_vty_enter_cfg_msc(BSCVTY, 0);
2206 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
2207 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2208 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2209 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
2210 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2211 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2212 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2213 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
2214 f_vty_transceive(BSCVTY, "exit");
2215 f_vty_transceive(BSCVTY, "exit");
2216}
2217
2218/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
2219 * ("Config-NB-Code = 1") */
2220private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
2221 f_vty_enter_cfg_msc(BSCVTY, 0);
2222 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
2223 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2224 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2225 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
2226 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2227 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2228 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2229 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
2230 f_vty_transceive(BSCVTY, "exit");
2231 f_vty_transceive(BSCVTY, "exit");
2232}
2233
Harald Welte60aa5762018-03-21 19:33:13 +01002234testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002235 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002236 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002237
2238 /* Note: This setups the codec configuration. The parameter payload in
2239 * mr_conf must be consistant with the parameter codecElements in pars
2240 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002241 var RSL_IE_Body mr_conf := {
2242 other := {
2243 len := 2,
2244 payload := '2804'O
2245 }
2246 };
Harald Welte60aa5762018-03-21 19:33:13 +01002247
Philipp Maier7695a0d2018-09-27 17:52:14 +02002248 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002249 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002250 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
2251 pars.expect_mr_conf_ie := mr_conf;
2252
Harald Welte60aa5762018-03-21 19:33:13 +01002253 f_init(1, true);
2254 f_sleep(1.0);
2255
Harald Welte8863fa12018-05-10 20:15:27 +02002256 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002257 vc_conn.done;
2258}
2259
2260testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002261 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002262 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002263
2264 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002265 var RSL_IE_Body mr_conf := {
2266 other := {
2267 len := 2,
2268 payload := '2804'O
2269 }
2270 };
Harald Welte60aa5762018-03-21 19:33:13 +01002271
Philipp Maier7695a0d2018-09-27 17:52:14 +02002272 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002273 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002274 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2275 pars.expect_mr_conf_ie := mr_conf;
2276
Harald Welte60aa5762018-03-21 19:33:13 +01002277 f_init(1, true);
2278 f_sleep(1.0);
2279
Harald Welte8863fa12018-05-10 20:15:27 +02002280 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002281 vc_conn.done;
2282}
2283
Philipp Maierd0e64b02019-03-13 14:15:23 +01002284function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
2285runs on test_CT {
2286
2287 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2288 var MSC_ConnHdlr vc_conn;
2289
2290 /* See note above */
2291 var RSL_IE_Body mr_conf := {
2292 other := {
2293 len := lengthof(mrconf),
2294 payload := mrconf
2295 }
2296 };
2297
2298 if (fr) {
2299 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2300 } else {
2301 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2302 }
2303 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2304 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2305 pars.expect_mr_conf_ie := mr_conf;
2306 pars.expect_mr_s0_s7 := exp_s8_s0;
2307
2308 f_init(1, true);
2309 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2310 f_sleep(1.0);
2311
2312 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2313 vc_conn.done;
2314 f_allow_amr_rate_5_90k();
2315}
2316
2317function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
2318runs on test_CT {
2319
2320 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2321 var MSC_ConnHdlr vc_conn;
2322
2323 if (fr) {
2324 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2325 } else {
2326 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2327 }
2328 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2329 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2330
2331 f_init(1, true);
2332 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2333 f_sleep(1.0);
2334
2335 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
2336 vc_conn.done;
2337 f_allow_amr_rate_5_90k();
2338}
2339
2340
2341/* Set S1, we expect an AMR multirate configuration IE with all four rates
2342 * set. */
2343testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
2344 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
2345}
2346
2347/* Set S1, we expect an AMR multirate configuration IE with the lower three
2348 * rates set. */
2349testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
2350 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
2351}
2352
2353/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2354 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2355testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
2356 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
2357}
2358
2359/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2360 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2361testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
2362 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
2363}
2364
2365/* The following block of tests selects more and more rates until all four
2366 * possible rates are in the active set (full rate) */
2367testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
2368 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
2369}
2370
2371testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
2372 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
2373}
2374
2375testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
2376 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
2377}
2378
2379testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
2380 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
2381}
2382
2383/* The following block of tests selects more and more rates until all three
2384 * possible rates are in the active set (half rate) */
2385testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
2386 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
2387}
2388
2389testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
2390 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
2391}
2392
2393testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
2394 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
2395}
2396
2397/* The following block tests what happens when the MSC does offer rate
2398 * configurations that are not supported by the BSC. Normally such situations
2399 * should not happen because the MSC gets informed by the BSC in advance via
2400 * the L3 COMPLETE message which rates are applicable. The MSC should not try
2401 * to offer rates that are not applicable anyway. */
2402
2403testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
2404 /* Try to include 12,2k in into the active set even though the channel
2405 * is half rate only. The BSC is expected to remove the 12,0k */
2406 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
2407}
2408
2409testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
2410 /* See what happens when all rates are selected at once. Since then
2411 * Also S1 is selected, this setting will be prefered and we should
2412 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
2413 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
2414}
2415
2416testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
2417 /* Same as above, but with S1 missing, the MSC is then expected to
2418 * select the currently supported rates, which are also 12.2k, 7,40k,
2419 * 5,90k, and 4,75k, into the active set. */
2420 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
2421}
2422
2423testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
2424 /* Try to select no rates at all */
2425 f_TC_assignment_codec_amr_fail(true, '00000000'B);
2426}
2427
2428testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
2429 /* Try to select only unsupported rates */
2430 f_TC_assignment_codec_amr_fail(true, '01101000'B);
2431}
2432
2433testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
2434 /* Try to select 12,2k for half rate */
2435 f_TC_assignment_codec_amr_fail(false, '10000000'B);
2436}
2437
Philipp Maierac09bfc2019-01-08 13:41:39 +01002438private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002439 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
2440 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
2441 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
2442 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002443}
2444
2445private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002446 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
2447 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002448}
2449
2450private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002451 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
2452 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
2453 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
2454 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
2455 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
2456 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002457}
2458
2459/* Allow HR only */
2460private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
2461 g_pars := f_gen_test_hdlr_pars();
2462 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2463 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2464 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2465 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2466 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2467 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2468 f_establish_fully(ass_cmd, exp_compl);
2469}
2470
2471/* Allow FR only */
2472private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
2473 g_pars := f_gen_test_hdlr_pars();
2474 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2475 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2476 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2477 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2478 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2479 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2480 f_establish_fully(ass_cmd, exp_compl);
2481}
2482
2483/* Allow HR only (expect assignment failure) */
2484private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
2485 g_pars := f_gen_test_hdlr_pars();
2486 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2487 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2488 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2489 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2490 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2491 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2492 f_establish_fully(ass_cmd, exp_fail);
2493}
2494
2495/* Allow FR only (expect assignment failure) */
2496private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
2497 g_pars := f_gen_test_hdlr_pars();
2498 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2499 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2500 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2501 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2502 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2503 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2504 f_establish_fully(ass_cmd, exp_fail);
2505}
2506
2507/* Allow FR and HR, but prefer FR */
2508private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2509 g_pars := f_gen_test_hdlr_pars();
2510 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2511 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2512 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2513 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2514 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2515 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2516 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2517 f_establish_fully(ass_cmd, exp_compl);
2518}
2519
2520/* Allow FR and HR, but prefer HR */
2521private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2522 g_pars := f_gen_test_hdlr_pars();
2523 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2524 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2525 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2526 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2527 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2528 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2529 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2530 f_establish_fully(ass_cmd, exp_compl);
2531}
2532
2533/* Allow FR and HR, but prefer FR */
2534private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2535 g_pars := f_gen_test_hdlr_pars();
2536 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2537 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2538 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2539 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2540 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2541 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2542 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2543 f_establish_fully(ass_cmd, exp_compl);
2544}
2545
2546/* Allow FR and HR, but prefer HR */
2547private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2548 g_pars := f_gen_test_hdlr_pars();
2549 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2550 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2551 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2552 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2553 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2554 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2555 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2556 f_establish_fully(ass_cmd, exp_compl);
2557}
2558
2559/* Request a HR channel while all FR channels are exhausted, this is expected
2560 * to work without conflicts */
2561testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
2562 var MSC_ConnHdlr vc_conn;
2563 f_init(1, true);
2564 f_sleep(1.0);
2565 f_enable_all_tch();
2566 f_disable_all_tch_f();
2567 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
2568 vc_conn.done;
2569 f_enable_all_tch();
2570 setverdict(pass);
2571}
2572
2573/* Request a FR channel while all FR channels are exhausted, this is expected
2574 * to fail. */
2575testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
2576 var MSC_ConnHdlr vc_conn;
2577 f_init(1, true);
2578 f_sleep(1.0);
2579 f_enable_all_tch();
2580 f_disable_all_tch_f();
2581 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
2582 vc_conn.done;
2583 f_enable_all_tch();
2584 setverdict(pass);
2585}
2586
2587/* Request a FR (prefered) or alternatively a HR channel while all FR channels
2588 * are exhausted, this is expected to be resolved by selecting a HR channel. */
2589testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
2590 var MSC_ConnHdlr vc_conn;
2591 f_init(1, true);
2592 f_sleep(1.0);
2593 f_enable_all_tch();
2594 f_disable_all_tch_f();
2595 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
2596 vc_conn.done;
2597 f_enable_all_tch();
2598 setverdict(pass);
2599}
2600
2601/* Request a HR (prefered) or alternatively a FR channel while all FR channels
2602 * are exhausted, this is expected to work without conflicts. */
2603testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
2604 var MSC_ConnHdlr vc_conn;
2605 f_init(1, true);
2606 f_sleep(1.0);
2607 f_enable_all_tch();
2608 f_disable_all_tch_f();
2609 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
2610 vc_conn.done;
2611 f_enable_all_tch();
2612 setverdict(pass);
2613}
2614
2615/* Request a FR channel while all HR channels are exhausted, this is expected
2616 * to work without conflicts */
2617testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
2618 var MSC_ConnHdlr vc_conn;
2619 f_init(1, true);
2620 f_sleep(1.0);
2621 f_enable_all_tch();
2622 f_disable_all_tch_h();
2623 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
2624 vc_conn.done;
2625 f_enable_all_tch();
2626 setverdict(pass);
2627}
2628
2629/* Request a HR channel while all HR channels are exhausted, this is expected
2630 * to fail. */
2631testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
2632 var MSC_ConnHdlr vc_conn;
2633 f_init(1, true);
2634 f_sleep(1.0);
2635 f_enable_all_tch();
2636 f_disable_all_tch_h();
2637 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
2638 vc_conn.done;
2639 f_enable_all_tch();
2640 setverdict(pass);
2641}
2642
2643/* Request a HR (prefered) or alternatively a FR channel while all HR channels
2644 * are exhausted, this is expected to be resolved by selecting a FR channel. */
2645testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
2646 var MSC_ConnHdlr vc_conn;
2647 f_init(1, true);
2648 f_sleep(1.0);
2649 f_enable_all_tch();
2650 f_disable_all_tch_h();
2651 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
2652 vc_conn.done;
2653 f_enable_all_tch();
2654 setverdict(pass);
2655}
2656
2657/* Request a FR (prefered) or alternatively a HR channel while all HR channels
2658 * are exhausted, this is expected to work without conflicts. */
2659testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
2660 var MSC_ConnHdlr vc_conn;
2661 f_init(1, true);
2662 f_sleep(1.0);
2663 f_enable_all_tch();
2664 f_disable_all_tch_h();
2665 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
2666 vc_conn.done;
2667 f_enable_all_tch();
2668 setverdict(pass);
2669}
2670
2671/* Allow FR and HR, but prefer HR */
2672private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2673 g_pars := f_gen_test_hdlr_pars();
2674 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2675 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2676 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2677 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2678 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2679 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2680 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2681 f_establish_fully(ass_cmd, exp_compl);
2682}
2683
2684/* Allow FR and HR, but prefer FR */
2685private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2686 g_pars := f_gen_test_hdlr_pars();
2687 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2688 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2689 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2690 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2691 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2692 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2693 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2694 f_establish_fully(ass_cmd, exp_compl);
2695}
2696
2697/* Request a HR (prefered) or alternatively a FR channel, it is expected that
2698 * HR, which is the prefered type, is selected. */
2699testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
2700 var MSC_ConnHdlr vc_conn;
2701 f_init(1, true);
2702 f_sleep(1.0);
2703 f_enable_all_tch();
2704 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
2705 vc_conn.done;
2706 setverdict(pass);
2707}
2708
2709/* Request a FR (prefered) or alternatively a HR channel, it is expected that
2710 * FR, which is the prefered type, is selected. */
2711testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
2712 var MSC_ConnHdlr vc_conn;
2713 f_init(1, true);
2714 f_sleep(1.0);
2715 f_enable_all_tch();
2716 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
2717 vc_conn.done;
2718 setverdict(pass);
2719}
2720
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002721testcase TC_assignment_osmux() runs on test_CT {
2722 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2723 var MSC_ConnHdlr vc_conn;
2724
2725 /* See note above */
2726 var RSL_IE_Body mr_conf := {
2727 other := {
2728 len := 2,
2729 payload := '2804'O
2730 }
2731 };
2732
2733 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2734 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
2735 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2736 pars.expect_mr_conf_ie := mr_conf;
2737 pars.use_osmux := true;
2738
2739 f_init(1, true, true);
2740 f_sleep(1.0);
2741
2742 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2743 vc_conn.done;
2744}
2745
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002746/* test the procedure of the MSC requesting a Classmark Update:
2747 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
2748 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01002749private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002750 g_pars := f_gen_test_hdlr_pars();
2751
Harald Weltea0630032018-03-20 21:09:55 +01002752 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002753 /* we should now have a COMPL_L3 at the MSC */
2754 BSSAP.receive(tr_BSSMAP_ComplL3);
2755
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002756 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
2757 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
2758
Harald Welte898113b2018-01-31 18:32:21 +01002759 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
2760 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
2761 setverdict(pass);
2762}
2763testcase TC_classmark() runs on test_CT {
2764 var MSC_ConnHdlr vc_conn;
2765 f_init(1, true);
2766 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002767 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01002768 vc_conn.done;
2769}
2770
Harald Weltee3bd6582018-01-31 22:51:25 +01002771private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002772 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002773 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002774 /* we should now have a COMPL_L3 at the MSC */
2775 BSSAP.receive(tr_BSSMAP_ComplL3);
2776
Harald Weltee3bd6582018-01-31 22:51:25 +01002777 /* send the single message we want to send */
2778 f_rsl_send_l3(l3);
2779}
2780
2781private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
2782 timer T := sec;
2783 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01002784 T.start;
2785 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01002786 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
2787 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02002788 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01002789 }
2790 [] T.timeout {
2791 setverdict(pass);
2792 }
2793 }
2794}
2795
Harald Weltee3bd6582018-01-31 22:51:25 +01002796/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2797private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
2798 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
2799 f_bssap_expect_nothing();
2800}
Harald Welte898113b2018-01-31 18:32:21 +01002801testcase TC_unsol_ass_fail() runs on test_CT {
2802 var MSC_ConnHdlr vc_conn;
2803 f_init(1, true);
2804 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002805 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01002806 vc_conn.done;
2807}
Harald Welte552620d2017-12-16 23:21:36 +01002808
Harald Welteea99a002018-01-31 20:46:43 +01002809
2810/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
2811private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002812 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
2813 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01002814}
2815testcase TC_unsol_ass_compl() runs on test_CT {
2816 var MSC_ConnHdlr vc_conn;
2817 f_init(1, true);
2818 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002819 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01002820 vc_conn.done;
2821}
2822
2823
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002824/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2825private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002826 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
2827 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002828}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002829testcase TC_unsol_ho_fail() runs on test_CT {
2830 var MSC_ConnHdlr vc_conn;
2831 f_init(1, true);
2832 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002833 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002834 vc_conn.done;
2835}
2836
2837
Harald Weltee3bd6582018-01-31 22:51:25 +01002838/* short message from MS should be ignored */
2839private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002840 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002841 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01002842 /* we should now have a COMPL_L3 at the MSC */
2843 BSSAP.receive(tr_BSSMAP_ComplL3);
2844
2845 /* send short message */
2846 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
2847 f_bssap_expect_nothing();
2848}
2849testcase TC_err_82_short_msg() runs on test_CT {
2850 var MSC_ConnHdlr vc_conn;
2851 f_init(1, true);
2852 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002853 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01002854 vc_conn.done;
2855}
2856
2857
Harald Weltee9e02e42018-01-31 23:36:25 +01002858/* 24.008 8.4 Unknown message must trigger RR STATUS */
2859private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
2860 f_est_single_l3(ts_RRM_UL_REL('00'O));
2861 timer T := 3.0
2862 alt {
2863 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
2864 setverdict(pass);
2865 }
2866 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01002867 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01002868 }
2869}
2870testcase TC_err_84_unknown_msg() runs on test_CT {
2871 var MSC_ConnHdlr vc_conn;
2872 f_init(1, true);
2873 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002874 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01002875 vc_conn.done;
2876}
2877
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002878/***********************************************************************
2879 * Handover
2880 ***********************************************************************/
2881
Harald Welte94e0c342018-04-07 11:33:23 +02002882/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
2883private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
2884runs on test_CT {
2885 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2886 " timeslot "&int2str(ts_nr)&" ";
2887 f_vty_transceive(BSCVTY, cmd & suffix);
2888}
2889
Harald Welte261af4b2018-02-12 21:20:39 +01002890/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
2891private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
2892runs on MSC_ConnHdlr {
2893 /* FIXME: resolve those from component-global state */
2894 var integer ts_nr := chan_nr.tn;
2895 var integer ss_nr;
2896 if (ischosen(chan_nr.u.ch0)) {
2897 ss_nr := 0;
2898 } else if (ischosen(chan_nr.u.lm)) {
2899 ss_nr := chan_nr.u.lm.sub_chan;
2900 } else if (ischosen(chan_nr.u.sdcch4)) {
2901 ss_nr := chan_nr.u.sdcch4.sub_chan;
2902 } else if (ischosen(chan_nr.u.sdcch8)) {
2903 ss_nr := chan_nr.u.sdcch8.sub_chan;
2904 } else {
2905 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02002906 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01002907 }
2908
2909 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2910 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
2911 f_vty_transceive(BSCVTY, cmd & suffix);
2912}
2913
Neels Hofmeyr91401012019-07-11 00:42:35 +02002914/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
2915 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
2916 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
2917 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
2918 * pair, not really to a specific BTS number. */
Harald Welte261af4b2018-02-12 21:20:39 +01002919private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
2920 integer new_bts_nr)
2921runs on MSC_ConnHdlr {
2922 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
2923}
2924
2925/* intra-BSC hand-over between BTS0 and BTS1 */
2926private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002927 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02002928 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2929 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01002930 const OCT8 kc := '0001020304050607'O;
2931
2932 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2933 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2934
Harald Weltea0630032018-03-20 21:09:55 +01002935 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02002936 f_bts_0_cfg({"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01002937
2938 var HandoverState hs := {
2939 rr_ho_cmpl_seen := false,
2940 handover_done := false,
2941 old_chan_nr := -
2942 };
2943 /* issue hand-over command on VTY */
2944 f_vty_handover(0, 0, g_chan_nr, 1);
2945 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2946 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002947
2948 /* From the MGW perspective, a handover is is characterized by
2949 * performing one MDCX operation with the MGW. So we expect to see
2950 * one more MDCX during handover. */
2951 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
2952
Harald Welte261af4b2018-02-12 21:20:39 +01002953 alt {
2954 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01002955 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002956
Philipp Maier4dae0652018-11-12 12:03:26 +01002957 /* Since this is an internal handover we expect the BSC to inform the
2958 * MSC about the event */
2959 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
2960
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002961 /* Check the amount of MGCP transactions is still consistant with the
2962 * test expectation */
2963 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01002964 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01002965}
2966
2967testcase TC_ho_int() runs on test_CT {
2968 var MSC_ConnHdlr vc_conn;
2969 f_init(2, true);
2970 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002971 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002972 vc_conn.done;
2973}
Harald Weltee9e02e42018-01-31 23:36:25 +01002974
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002975/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02002976private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002977 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002978 var template MgcpResponse mgcp_resp;
2979 var MGCP_RecvFrom mrf;
2980 var template MgcpMessage msg_resp;
2981 var template MgcpMessage msg_dlcx := {
2982 command := tr_DLCX()
2983 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002984
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002985 if (g_pars.aoip) {
2986 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002987 log("Got first DLCX: ", mgcp);
2988 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002989 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002990
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002991 MGCP.receive(tr_DLCX()) -> value mgcp {
2992 log("Got second DLCX: ", mgcp);
2993 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
2994 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002995 } else {
2996 /* For SCCPLite, BSC doesn't handle the MSC-side */
2997 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
2998 log("Got first DLCX: ", mrf.msg.command);
2999 msg_resp := {
3000 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
3001 }
3002 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
3003 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003004 }
3005
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003006 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003007}
3008
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003009private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003010 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003011
3012 var PDU_BSSAP ass_req := f_gen_ass_req();
3013 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3014 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3015 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3016 f_establish_fully(ass_req, exp_compl);
3017
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003018 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003019 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3020
3021 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3022
3023 f_sleep(0.5);
3024 /* The MSC negotiates Handover Request and Handover Request Ack with
3025 * the other BSS and comes back with a BSSMAP Handover Command
3026 * containing an RR Handover Command coming from the target BSS... */
3027
3028 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3029 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3030 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3031 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3032 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3033
3034 /* expect the Handover Command to go out on RR */
3035 var RSL_Message rsl_ho_cmd
3036 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3037 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3038 var RSL_IE_Body rsl_ho_cmd_l3;
3039 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3040 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3041 setverdict(fail);
3042 } else {
3043 log("Found L3 Info: ", rsl_ho_cmd_l3);
3044 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3045 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3046 setverdict(fail);
3047 } else {
3048 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3049 setverdict(pass);
3050 }
3051 }
3052
3053 /* When the other BSS has reported a completed handover, this side is
3054 * torn down. */
3055
3056 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
3057 var BssmapCause cause := enum2int(cause_val);
3058 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3059
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003060 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003061 setverdict(pass);
3062 f_sleep(1.0);
3063}
3064testcase TC_ho_out_of_this_bsc() runs on test_CT {
3065 var MSC_ConnHdlr vc_conn;
3066
3067 f_init(1, true);
3068 f_sleep(1.0);
3069
3070 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
3071 vc_conn.done;
3072}
3073
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003074/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
3075 * simply never sends a BSSMAP Handover Command. */
3076private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003077 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003078
3079 var PDU_BSSAP ass_req := f_gen_ass_req();
3080 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3081 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3082 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3083 f_establish_fully(ass_req, exp_compl);
3084
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003085 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003086 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3087
3088 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3089
3090 /* osmo-bsc should time out 10 seconds after the handover started.
3091 * Let's give it a bit extra. */
3092 f_sleep(15.0);
3093
3094 /* The old lchan and conn should still be active. See that arbitrary L3
3095 * is still going through. */
3096 var octetstring l3 := '0123456789'O;
3097 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3098 var template PDU_BSSAP exp_data := {
3099 discriminator := '1'B,
3100 spare := '0000000'B,
3101 dlci := '00'O,
3102 lengthIndicator := 5,
3103 pdu := {
3104 dtap := l3
3105 }
3106 };
3107 BSSAP.receive(exp_data);
3108 setverdict(pass);
3109 f_sleep(1.0);
3110}
3111testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
3112 var MSC_ConnHdlr vc_conn;
3113
3114 f_init(1, true);
3115 f_sleep(1.0);
3116
3117 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
3118 vc_conn.done;
3119}
3120
3121/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
3122 * RR Handover Failure. */
3123private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003124 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003125
3126 var PDU_BSSAP ass_req := f_gen_ass_req();
3127 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3128 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3129 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3130 f_establish_fully(ass_req, exp_compl);
3131
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003132 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003133 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3134
3135 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3136
3137 f_sleep(0.5);
3138 /* The MSC negotiates Handover Request and Handover Request Ack with
3139 * the other BSS and comes back with a BSSMAP Handover Command
3140 * containing an RR Handover Command coming from the target BSS... */
3141
3142 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3143 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3144 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3145 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3146 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3147
3148 /* expect the Handover Command to go out on RR */
3149 var RSL_Message rsl_ho_cmd
3150 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3151 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3152 var RSL_IE_Body rsl_ho_cmd_l3;
3153 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3154 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3155 setverdict(fail);
3156 } else {
3157 log("Found L3 Info: ", rsl_ho_cmd_l3);
3158 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3159 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3160 setverdict(fail);
3161 } else {
3162 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3163 setverdict(pass);
3164 }
3165 }
3166
3167 f_sleep(0.2);
3168 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3169
3170 /* Should tell the MSC about the failure */
3171 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3172
3173 f_sleep(1.0);
3174
3175 /* The old lchan and conn should still be active. See that arbitrary L3
3176 * is still going through. */
3177 var octetstring l3 := '0123456789'O;
3178 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3179 var template PDU_BSSAP exp_data := {
3180 discriminator := '1'B,
3181 spare := '0000000'B,
3182 dlci := '00'O,
3183 lengthIndicator := 5,
3184 pdu := {
3185 dtap := l3
3186 }
3187 };
3188 BSSAP.receive(exp_data);
3189 setverdict(pass);
3190 f_sleep(1.0);
3191
3192 setverdict(pass);
3193 f_sleep(1.0);
3194}
3195testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
3196 var MSC_ConnHdlr vc_conn;
3197
3198 f_init(1, true);
3199 f_sleep(1.0);
3200
3201 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
3202 vc_conn.done;
3203}
3204
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003205/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
3206 * (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 +02003207 * and the lchan is released. */
3208private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003209 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003210
3211 var PDU_BSSAP ass_req := f_gen_ass_req();
3212 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3213 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3214 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3215 f_establish_fully(ass_req, exp_compl);
3216
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003217 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003218 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3219
3220 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3221
3222 f_sleep(0.5);
3223 /* The MSC negotiates Handover Request and Handover Request Ack with
3224 * the other BSS and comes back with a BSSMAP Handover Command
3225 * containing an RR Handover Command coming from the target BSS... */
3226
3227 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3228 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3229 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3230 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3231 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3232
3233 /* expect the Handover Command to go out on RR */
3234 var RSL_Message rsl_ho_cmd
3235 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3236 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3237 var RSL_IE_Body rsl_ho_cmd_l3;
3238 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3239 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3240 setverdict(fail);
3241 } else {
3242 log("Found L3 Info: ", rsl_ho_cmd_l3);
3243 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3244 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3245 setverdict(fail);
3246 } else {
3247 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3248 setverdict(pass);
3249 }
3250 }
3251
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003252 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
3253 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
3254 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003255
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003256 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02003257 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
3258 log("Got BSSMAP Clear Request");
3259 /* Instruct BSC to clear channel */
3260 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3261 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3262
3263 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003264 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01003265 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
3266 log("Got Deact SACCH");
3267 }
Harald Welte924b6ea2019-02-04 01:05:34 +01003268 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01003269 log("Got RR Release");
3270 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003271 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
3272 log("Got RF Chan Rel");
3273 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
3274 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003275 }
3276
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003277 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003278
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003279 setverdict(pass);
3280 f_sleep(1.0);
3281}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003282testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003283 var MSC_ConnHdlr vc_conn;
3284
3285 f_init(1, true);
3286 f_sleep(1.0);
3287
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003288 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003289 vc_conn.done;
3290}
3291
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003292private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
3293 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3294 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3295 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3296 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3297 * before we get started. */
3298 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3299 f_rslem_register(0, new_chan_nr);
3300 g_chan_nr := new_chan_nr;
3301 f_sleep(1.0);
3302
3303 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3304 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3305 activate(as_Media());
3306
3307 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3308 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003309 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003310
3311 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3312
3313 var PDU_BSSAP rx_bssap;
3314 var octetstring ho_command_str;
3315
3316 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02003317
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003318 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3319 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3320 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3321 log("L3 Info in HO Request Ack is ", ho_command);
3322
3323 var GsmArfcn arfcn;
3324 var RslChannelNr actual_new_chan_nr;
3325 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3326 actual_new_chan_nr, arfcn);
3327
3328 if (actual_new_chan_nr != new_chan_nr) {
3329 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3330 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3331 setverdict(fail);
3332 return;
3333 }
3334 log("Handover Command chan_nr is", actual_new_chan_nr);
3335
3336 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3337 * tells the MS to handover to the new lchan. Here comes the new MS on
3338 * the new lchan with a Handover RACH: */
3339
3340 /* send handover detect */
3341
3342 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3343
3344 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3345
3346 /* send handover complete over the new channel */
3347
3348 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
3349 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
3350 enc_PDU_ML3_MS_NW(l3_tx)));
3351
3352 BSSAP.receive(tr_BSSMAP_HandoverComplete);
3353 setverdict(pass);
3354}
3355testcase TC_ho_into_this_bsc() runs on test_CT {
3356 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003357 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003358
3359 f_init(1, true);
3360 f_sleep(1.0);
3361
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003362 pars.handover.sccp_addr_msc := g_bssap[0].sccp_addr_own;
3363 pars.handover.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003364
3365 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
3366 vc_conn.done;
3367}
3368
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003369private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
3370 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3371 f_rslem_register(0, new_chan_nr);
3372 g_chan_nr := new_chan_nr;
3373 f_sleep(1.0);
3374
3375 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3376 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3377 activate(as_Media());
3378
3379 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3380 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003381 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003382
3383 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3384
3385 var PDU_BSSAP rx_bssap;
3386 var octetstring ho_command_str;
3387
3388 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3389
3390 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3391 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3392 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3393 log("L3 Info in HO Request Ack is ", ho_command);
3394
3395 var GsmArfcn arfcn;
3396 var RslChannelNr actual_new_chan_nr;
3397 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3398 actual_new_chan_nr, arfcn);
3399
3400 if (actual_new_chan_nr != new_chan_nr) {
3401 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3402 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3403 setverdict(fail);
3404 return;
3405 }
3406 log("Handover Command chan_nr is", actual_new_chan_nr);
3407
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02003408 /* For deterministic test results, give some time for the MGW endpoint to be configured */
3409 f_sleep(1.0);
3410
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003411 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3412 * tells the MS to handover to the new lchan. In this case, the MS
3413 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
3414 * Handover Failure to the MSC. The procedure according to 3GPP TS
3415 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
3416 * BSSMAP Clear Command: */
3417
3418 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3419 var BssmapCause cause := enum2int(cause_val);
3420 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3421
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003422 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003423 setverdict(pass);
3424 f_sleep(1.0);
3425
3426 setverdict(pass);
3427}
3428testcase TC_ho_in_fail_msc_clears() runs on test_CT {
3429 var MSC_ConnHdlr vc_conn;
3430 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3431
3432 f_init(1, true);
3433 f_sleep(1.0);
3434
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003435 pars.handover.sccp_addr_msc := g_bssap[0].sccp_addr_own;
3436 pars.handover.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003437
3438 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
3439 vc_conn.done;
3440}
3441
3442private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
3443 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3444 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3445 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3446 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3447 * before we get started. */
3448 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3449 f_rslem_register(0, new_chan_nr);
3450 g_chan_nr := new_chan_nr;
3451 f_sleep(1.0);
3452
3453 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3454 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3455 activate(as_Media());
3456
3457 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3458 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003459 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003460
3461 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3462
3463 var PDU_BSSAP rx_bssap;
3464 var octetstring ho_command_str;
3465
3466 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3467
3468 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3469 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3470 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3471 log("L3 Info in HO Request Ack is ", ho_command);
3472
3473 var GsmArfcn arfcn;
3474 var RslChannelNr actual_new_chan_nr;
3475 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3476 actual_new_chan_nr, arfcn);
3477
3478 if (actual_new_chan_nr != new_chan_nr) {
3479 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3480 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3481 setverdict(fail);
3482 return;
3483 }
3484 log("Handover Command chan_nr is", actual_new_chan_nr);
3485
3486 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3487 * tells the MS to handover to the new lchan. Here comes the new MS on
3488 * the new lchan with a Handover RACH: */
3489
3490 /* send handover detect */
3491
3492 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3493
3494 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3495
3496 /* The MSC chooses to clear the connection now, maybe we got the
3497 * Handover RACH on the new cell but the MS still signaled Handover
3498 * Failure to the old BSS? */
3499
3500 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3501 var BssmapCause cause := enum2int(cause_val);
3502 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3503
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003504 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003505 setverdict(pass);
3506 f_sleep(1.0);
3507}
3508testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
3509 var MSC_ConnHdlr vc_conn;
3510 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3511
3512 f_init(1, true);
3513 f_sleep(1.0);
3514
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003515 pars.handover.sccp_addr_msc := g_bssap[0].sccp_addr_own;
3516 pars.handover.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003517
3518 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
3519 vc_conn.done;
3520}
3521
3522/* The new BSS's lchan times out before the MSC decides that handover failed. */
3523private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
3524 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3525 f_rslem_register(0, new_chan_nr);
3526 g_chan_nr := new_chan_nr;
3527 f_sleep(1.0);
3528
3529 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3530 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3531 activate(as_Media());
3532
3533 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3534 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003535 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003536
3537 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3538
3539 var PDU_BSSAP rx_bssap;
3540 var octetstring ho_command_str;
3541
3542 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3543
3544 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3545 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3546 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3547 log("L3 Info in HO Request Ack is ", ho_command);
3548
3549 var GsmArfcn arfcn;
3550 var RslChannelNr actual_new_chan_nr;
3551 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3552 actual_new_chan_nr, arfcn);
3553
3554 if (actual_new_chan_nr != new_chan_nr) {
3555 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3556 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3557 setverdict(fail);
3558 return;
3559 }
3560 log("Handover Command chan_nr is", actual_new_chan_nr);
3561
3562 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3563 * tells the MS to handover to the new lchan. But the MS never shows up
3564 * on the new lchan. */
3565
3566 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3567
3568 /* Did osmo-bsc also send a Clear Request? */
3569 timer T := 0.5;
3570 T.start;
3571 alt {
3572 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
3573 [] T.timeout { }
3574 }
3575
3576 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
3577 * asked for it, this is a Handover Failure after all). */
3578
3579 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3580 var BssmapCause cause := enum2int(cause_val);
3581 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3582
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003583 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003584 setverdict(pass);
3585 f_sleep(1.0);
3586
3587 setverdict(pass);
3588}
3589testcase TC_ho_in_fail_no_detect() runs on test_CT {
3590 var MSC_ConnHdlr vc_conn;
3591 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3592
3593 f_init(1, true);
3594 f_sleep(1.0);
3595
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003596 pars.handover.sccp_addr_msc := g_bssap[0].sccp_addr_own;
3597 pars.handover.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003598
3599 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
3600 vc_conn.done;
3601}
3602
3603/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
3604private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
3605 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3606 f_rslem_register(0, new_chan_nr);
3607 g_chan_nr := new_chan_nr;
3608 f_sleep(1.0);
3609
3610 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3611 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3612 activate(as_Media());
3613
3614 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3615 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003616 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003617
3618 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3619
3620 var PDU_BSSAP rx_bssap;
3621 var octetstring ho_command_str;
3622
3623 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3624
3625 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3626 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3627 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3628 log("L3 Info in HO Request Ack is ", ho_command);
3629
3630 var GsmArfcn arfcn;
3631 var RslChannelNr actual_new_chan_nr;
3632 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3633 actual_new_chan_nr, arfcn);
3634
3635 if (actual_new_chan_nr != new_chan_nr) {
3636 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3637 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3638 setverdict(fail);
3639 return;
3640 }
3641 log("Handover Command chan_nr is", actual_new_chan_nr);
3642
3643 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3644 * tells the MS to handover to the new lchan. But the MS never shows up
3645 * on the new lchan. */
3646
3647 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3648
3649 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003650 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003651
3652 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003653 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3654 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3655 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003656 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003657 setverdict(pass);
3658 f_sleep(1.0);
3659}
3660testcase TC_ho_in_fail_no_detect2() runs on test_CT {
3661 var MSC_ConnHdlr vc_conn;
3662 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3663
3664 f_init(1, true);
3665 f_sleep(1.0);
3666
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003667 pars.handover.sccp_addr_msc := g_bssap[0].sccp_addr_own;
3668 pars.handover.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003669
3670 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
3671 vc_conn.done;
3672}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003673
Neels Hofmeyr91401012019-07-11 00:42:35 +02003674type record of charstring Commands;
3675
3676private function f_bts_0_cfg(Commands cmds := {}) runs on MSC_ConnHdlr
3677{
3678 f_vty_enter_cfg_bts(BSCVTY, 0);
3679 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
3680 f_vty_transceive(BSCVTY, cmds[i]);
3681 }
3682 f_vty_transceive(BSCVTY, "end");
3683}
3684
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01003685private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
3686{
3687 f_vty_enter_cfg_cs7_inst(pt, 0);
3688 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
3689 f_vty_transceive(pt, cmds[i]);
3690 }
3691 f_vty_transceive(pt, "end");
3692}
3693
Neels Hofmeyr91401012019-07-11 00:42:35 +02003694private function f_probe_for_handover(charstring log_label,
3695 charstring log_descr,
3696 charstring handover_vty_cmd,
3697 boolean expect_handover,
3698 boolean is_inter_bsc_handover := false)
3699runs on MSC_ConnHdlr
3700{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02003701 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
3702 * lchans to be established on bts 1 or bts 2. */
3703 f_rslem_suspend(RSL1_PROC);
3704 f_rslem_suspend(RSL2_PROC);
3705
Neels Hofmeyr91401012019-07-11 00:42:35 +02003706 var RSL_Message rsl;
3707
3708 var charstring log_msg := " (expecting handover)"
3709 if (not expect_handover) {
3710 log_msg := " (expecting NO handover)";
3711 }
3712 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
3713 f_vty_transceive(BSCVTY, handover_vty_cmd);
3714
Neels Hofmeyr91401012019-07-11 00:42:35 +02003715 timer T := 2.0;
3716 T.start;
3717
3718 alt {
3719 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
3720 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
3721 log("Rx L3 from net: ", l3);
3722 if (ischosen(l3.msgs.rrm.handoverCommand)) {
3723 var RslChannelNr new_chan_nr;
3724 var GsmArfcn arfcn;
3725 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
3726 new_chan_nr, arfcn);
3727 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
3728 log(l3.msgs.rrm.handoverCommand);
3729
3730 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
3731 * matter on which BTS it really is, we're not going to follow through an entire handover
3732 * anyway. */
3733 f_rslem_register(0, new_chan_nr, RSL1_PROC);
3734 f_rslem_resume(RSL1_PROC);
3735 f_rslem_register(0, new_chan_nr, RSL2_PROC);
3736 f_rslem_resume(RSL2_PROC);
3737
3738 if (expect_handover and not is_inter_bsc_handover) {
3739 setverdict(pass);
3740 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
3741 } else {
3742 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
3743 & log_label & ": " & log_descr);
3744 }
3745
3746 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
3747 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
3748 * Handover Failure. */
3749 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3750
3751 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
3752 f_sleep(0.5);
3753 RSL1.clear;
3754 RSL2.clear;
3755 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
3756 break;
3757 } else {
3758 repeat;
3759 }
3760 }
3761 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
3762 if (expect_handover and is_inter_bsc_handover) {
3763 setverdict(pass);
3764 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
3765 } else {
3766 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
3767 & log_label & ": " & log_descr);
3768 }
3769
3770 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
3771
3772 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
3773 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
3774 * setting a short timeout and waiting is the only way. */
3775 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
3776 f_sleep(1.5);
3777 log("f_probe_for_handover(" & log_label & "): ...done");
3778
3779 break;
3780 }
3781 [] T.timeout {
3782 if (expect_handover) {
3783 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
3784 & log_label & ": " & log_descr);
3785 } else {
3786 setverdict(pass);
3787 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
3788 }
3789 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
3790 break;
3791 }
3792 }
3793
3794 f_rslem_resume(RSL1_PROC);
3795 f_rslem_resume(RSL2_PROC);
3796 f_sleep(3.0);
3797 RSL.clear;
3798
3799 log("f_probe_for_handover(" & log_label & "): done clearing");
3800}
3801
3802/* Test the effect of various neighbor configuration scenarios:
3803 *
3804 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
3805 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
3806 */
3807private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
3808 g_pars := f_gen_test_hdlr_pars();
3809 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3810 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3811 const OCT8 kc := '0001020304050607'O;
3812
3813 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3814 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3815
3816 /* Establish lchan at bts 0 */
3817 f_establish_fully(ass_cmd, exp_compl);
3818
3819 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
3820 f_vty_enter_cfg_network(BSCVTY);
3821 f_vty_transceive(BSCVTY, "timer T7 1");
3822 f_vty_transceive(BSCVTY, "end");
3823}
3824
3825private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
3826 f_tc_ho_neighbor_config_start();
3827
3828 /*
3829 * bts 0 ARFCN 871 BSIC 10
3830 * bts 1 ARFCN 871 BSIC 11
3831 * bts 2 ARFCN 871 BSIC 12
3832 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3833 */
3834
3835 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
3836 f_bts_0_cfg({"no neighbors"});
3837 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
3838 "handover any to arfcn 871 bsic 11",
3839 true);
3840
3841 f_probe_for_handover("1.b", "HO to unknown cell does not start",
3842 "handover any to arfcn 13 bsic 39",
3843 false);
3844
3845 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
3846 "handover any to arfcn 871 bsic 12",
3847 false);
3848
3849 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
3850 "handover any to arfcn 871 bsic 11",
3851 true);
3852}
3853private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
3854 f_tc_ho_neighbor_config_start();
3855
3856 /*
3857 * bts 0 ARFCN 871 BSIC 10
3858 * bts 1 ARFCN 871 BSIC 11
3859 * bts 2 ARFCN 871 BSIC 12
3860 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3861 */
3862
3863 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
3864 f_bts_0_cfg({"neighbor bts 1"});
3865 f_sleep(0.5);
3866
3867 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
3868 "handover any to arfcn 871 bsic 11",
3869 true);
3870
3871 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
3872 "handover any to arfcn 871 bsic 12",
3873 false);
3874}
3875private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
3876 f_tc_ho_neighbor_config_start();
3877
3878 /*
3879 * bts 0 ARFCN 871 BSIC 10
3880 * bts 1 ARFCN 871 BSIC 11
3881 * bts 2 ARFCN 871 BSIC 12
3882 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3883 */
3884
3885 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
3886 f_bts_0_cfg({"no neighbors", "neighbor bts 2"});
3887 f_sleep(0.5);
3888
3889 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
3890 "handover any to arfcn 871 bsic 11",
3891 false);
3892 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",
3893 "handover any to arfcn 871 bsic 12",
3894 true);
3895}
3896private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
3897 f_tc_ho_neighbor_config_start();
3898
3899 /*
3900 * bts 0 ARFCN 871 BSIC 10
3901 * bts 1 ARFCN 871 BSIC 11
3902 * bts 2 ARFCN 871 BSIC 12
3903 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3904 */
3905
3906 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
3907 f_bts_0_cfg({"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
3908 f_sleep(0.5);
3909
3910 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
3911 "handover any to arfcn 871 bsic 11",
3912 false);
3913 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
3914 "handover any to arfcn 871 bsic 12",
3915 false);
3916 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
3917 "handover any to arfcn 123 bsic 45",
3918 true, true);
3919}
3920private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
3921 f_tc_ho_neighbor_config_start();
3922
3923 /*
3924 * bts 0 ARFCN 871 BSIC 10
3925 * bts 1 ARFCN 871 BSIC 11
3926 * bts 2 ARFCN 871 BSIC 12
3927 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3928 */
3929
3930 log("f_tc_ho_neighbor_config: 5. explicit remote neighbor re-using ARFCN+BSIC: 'neighbor lac 99 arfcn 871 bsic 12'");
3931 f_bts_0_cfg({"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
3932 f_sleep(0.5);
3933
3934 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
3935 "handover any to arfcn 871 bsic 12",
3936 true, true);
3937}
3938private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
3939 f_tc_ho_neighbor_config_start();
3940
3941 /*
3942 * bts 0 ARFCN 871 BSIC 10
3943 * bts 1 ARFCN 871 BSIC 11
3944 * bts 2 ARFCN 871 BSIC 12
3945 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3946 */
3947
3948 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
3949 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
3950 f_bts_0_cfg({"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
3951 f_sleep(0.5);
3952
3953 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
3954 "handover any to arfcn 871 bsic 12",
3955 false);
3956}
3957private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
3958 f_tc_ho_neighbor_config_start();
3959
3960 /*
3961 * bts 0 ARFCN 871 BSIC 10
3962 * bts 1 ARFCN 871 BSIC 11
3963 * bts 2 ARFCN 871 BSIC 12
3964 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3965 */
3966
3967 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
3968 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
3969 f_bts_0_cfg({"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
3970 f_sleep(0.5);
3971
3972 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
3973 "handover any to arfcn 871 bsic 12",
3974 true);
3975 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
3976 "handover any to arfcn 123 bsic 45",
3977 true, true);
3978}
3979
3980testcase TC_ho_neighbor_config_1() runs on test_CT {
3981 var MSC_ConnHdlr vc_conn;
3982 f_init(3, true);
3983 f_sleep(1.0);
3984 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
3985 vc_conn.done;
3986}
3987testcase TC_ho_neighbor_config_2() runs on test_CT {
3988 var MSC_ConnHdlr vc_conn;
3989 f_init(3, true);
3990 f_sleep(1.0);
3991 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
3992 vc_conn.done;
3993}
3994testcase TC_ho_neighbor_config_3() runs on test_CT {
3995 var MSC_ConnHdlr vc_conn;
3996 f_init(3, true);
3997 f_sleep(1.0);
3998 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
3999 vc_conn.done;
4000}
4001testcase TC_ho_neighbor_config_4() runs on test_CT {
4002 var MSC_ConnHdlr vc_conn;
4003 f_init(3, true);
4004 f_sleep(1.0);
4005 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
4006 vc_conn.done;
4007}
4008testcase TC_ho_neighbor_config_5() runs on test_CT {
4009 var MSC_ConnHdlr vc_conn;
4010 f_init(3, true);
4011 f_sleep(1.0);
4012 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
4013 vc_conn.done;
4014}
4015testcase TC_ho_neighbor_config_6() runs on test_CT {
4016 var MSC_ConnHdlr vc_conn;
4017 f_init(3, true);
4018 f_sleep(1.0);
4019 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
4020 vc_conn.done;
4021}
4022testcase TC_ho_neighbor_config_7() runs on test_CT {
4023 var MSC_ConnHdlr vc_conn;
4024 f_init(3, true);
4025 f_sleep(1.0);
4026 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
4027 vc_conn.done;
4028}
4029
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004030/* OS#3041: Open and close N connections in a normal fashion, and expect no
4031 * BSSMAP Reset just because of that. */
4032testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
4033 var default d;
4034 var integer i;
4035 var DchanTuple dt;
4036
4037 f_init();
4038
4039 /* Wait for initial BSSMAP Reset to pass */
4040 f_sleep(4.0);
4041
4042 d := activate(no_bssmap_reset());
4043
4044 /* Setup up a number of connections and RLSD them again from the MSC
4045 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4046 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02004047 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004048 /* Since we're doing a lot of runs, give each one a fresh
4049 * T_guard from the top. */
4050 T_guard.start;
4051
4052 /* Setup a BSSAP connection and clear it right away. This is
4053 * the MSC telling the BSC about a planned release, it's not an
4054 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004055 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004056
4057 /* MSC disconnects (RLSD). */
4058 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
4059 }
4060
4061 /* In the buggy behavior, a timeout of 2 seconds happens between above
4062 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4063 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4064 f_sleep(4.0);
4065
4066 deactivate(d);
4067 f_shutdown_helper();
4068}
Harald Welte552620d2017-12-16 23:21:36 +01004069
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004070/* OS#3041: Open and close N connections in a normal fashion, and expect no
4071 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
4072 * the MSC. */
4073testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
4074 var default d;
4075 var integer i;
4076 var DchanTuple dt;
4077 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004078 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
4079 var BssmapCause cause := enum2int(cause_val);
4080
4081 f_init();
4082
4083 /* Wait for initial BSSMAP Reset to pass */
4084 f_sleep(4.0);
4085
4086 d := activate(no_bssmap_reset());
4087
4088 /* Setup up a number of connections and RLSD them again from the MSC
4089 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4090 * Let's do it some more times for good measure. */
4091 for (i := 0; i < 8; i := i+1) {
4092 /* Since we're doing a lot of runs, give each one a fresh
4093 * T_guard from the top. */
4094 T_guard.start;
4095
4096 /* Setup a BSSAP connection and clear it right away. This is
4097 * the MSC telling the BSC about a planned release, it's not an
4098 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004099 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004100
4101 /* Instruct BSC to clear channel */
4102 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4103
4104 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004105 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004106 }
4107
4108 /* In the buggy behavior, a timeout of 2 seconds happens between above
4109 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4110 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4111 f_sleep(4.0);
4112
4113 deactivate(d);
4114 f_shutdown_helper();
4115}
4116
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004117/* OS#3041: Open and close N connections in a normal fashion, and expect no
4118 * BSSMAP Reset just because of that. Close connections from the MS side with a
4119 * Release Ind on RSL. */
4120testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
4121 var default d;
4122 var integer i;
4123 var DchanTuple dt;
4124 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004125 var integer j;
4126
4127 f_init();
4128
4129 /* Wait for initial BSSMAP Reset to pass */
4130 f_sleep(4.0);
4131
4132 d := activate(no_bssmap_reset());
4133
4134 /* Setup up a number of connections and RLSD them again from the MSC
4135 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4136 * Let's do it some more times for good measure. */
4137 for (i := 0; i < 8; i := i+1) {
4138 /* Since we're doing a lot of runs, give each one a fresh
4139 * T_guard from the top. */
4140 T_guard.start;
4141
4142 /* Setup a BSSAP connection and clear it right away. This is
4143 * the MSC telling the BSC about a planned release, it's not an
4144 * erratic loss of a connection. */
4145 dt := f_est_dchan('23'O, 23, '00010203040506'O);
4146
4147 /* simulate RLL REL IND */
4148 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
4149
4150 /* expect Clear Request on MSC side */
4151 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
4152
4153 /* Instruct BSC to clear channel */
4154 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
4155 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4156
4157 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004158 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004159 }
4160
4161 /* In the buggy behavior, a timeout of 2 seconds happens between above
4162 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4163 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4164 f_sleep(4.0);
4165
4166 deactivate(d);
4167 f_shutdown_helper();
4168}
4169
Harald Welte94e0c342018-04-07 11:33:23 +02004170/***********************************************************************
4171 * IPA style dynamic PDCH
4172 ***********************************************************************/
4173
4174private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4175 template (omit) RSL_Cause nack := omit)
4176runs on test_CT {
4177 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4178 var RSL_Message rsl_unused;
4179 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4180 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
4181 /* expect the BSC to issue the related RSL command */
4182 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4183 if (istemplatekind(nack, "omit")) {
4184 /* respond with a related acknowledgement */
4185 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4186 } else {
4187 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
4188 }
4189}
4190
4191private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4192 template (omit) RSL_Cause nack := omit)
4193runs on test_CT {
4194 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4195 var RSL_Message rsl_unused;
4196 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4197 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
4198 /* expect the BSC to issue the related RSL command */
4199 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
4200 if (istemplatekind(nack, "omit")) {
4201 /* respond with a related acknowledgement */
4202 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
4203 } else {
4204 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
4205 }
4206}
4207
4208private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
4209runs on test_CT return charstring {
4210 var charstring cmd, resp;
4211 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01004212 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02004213}
4214
4215private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
4216 template charstring exp)
4217runs on test_CT {
4218 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
4219 if (not match(mode, exp)) {
4220 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02004221 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02004222 }
4223}
4224
4225private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
4226runs on test_CT {
4227 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
4228 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
4229 f_vty_transceive(BSCVTY, "end");
4230}
4231
4232private const charstring TCHF_MODE := "TCH/F mode";
4233private const charstring TCHH_MODE := "TCH/H mode";
4234private const charstring PDCH_MODE := "PDCH mode";
4235private const charstring NONE_MODE := "NONE mode";
4236
4237/* Test IPA PDCH activation / deactivation triggered by VTY */
4238testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
4239 var RSL_Message rsl_unused;
4240
4241 /* change Timeslot 6 before f_init() starts RSL */
4242 f_init_vty();
4243 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4244 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4245
4246 f_init(1, false);
4247 f_sleep(1.0);
4248
4249 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4250
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004251 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004252 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4253 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4254 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4255 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4256 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004257 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004258 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4259
4260 /* De-activate it via VTY */
4261 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4262 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004263 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004264 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4265
4266 /* re-activate it via VTY */
4267 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
4268 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004269 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004270 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4271
4272 /* and finally de-activate it again */
4273 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4274 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004275 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004276 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4277
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004278 /* clean up config */
4279 f_ts_set_chcomb(0, 0, 6, "PDCH");
4280
Harald Welte94e0c342018-04-07 11:33:23 +02004281 setverdict(pass);
4282}
4283
4284/* Test IPA PDCH activation NACK */
4285testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
4286 var RSL_Message rsl_unused;
4287
4288 /* change Timeslot 6 before f_init() starts RSL */
4289 f_init_vty();
4290 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4291 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4292
4293 f_init(1, false);
4294 f_sleep(1.0);
4295
4296 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4297
4298 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4299 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4300 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4301 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4302 f_sleep(1.0);
4303 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4304
4305 /* De-activate it via VTY */
4306 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4307 f_sleep(1.0);
4308 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4309
4310 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
4311 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
4312 f_sleep(1.0);
4313 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4314
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004315 /* clean up config */
4316 f_ts_set_chcomb(0, 0, 6, "PDCH");
4317
Harald Welte94e0c342018-04-07 11:33:23 +02004318 setverdict(pass);
4319}
4320
4321
4322/***********************************************************************
4323 * Osmocom style dynamic PDCH
4324 ***********************************************************************/
4325
4326private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4327 template (omit) RSL_Cause nack := omit)
4328runs on test_CT {
4329 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4330 var RSL_Message rsl_unused;
4331 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4332 /* FIXME: no VTY command to activate Osmocom PDCH !! */
4333 /* expect the BSC to issue the related RSL command */
4334 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
4335 if (istemplatekind(nack, "omit")) {
4336 /* respond with a related acknowledgement */
4337 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
4338 } else {
4339 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
4340 }
4341}
4342
4343private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4344 template (omit) RSL_Cause nack := omit)
4345runs on test_CT {
4346 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4347 var RSL_Message rsl_unused;
4348 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4349 /* FIXME: no VTY command to activate Osmocom PDCH !! */
4350 /* expect the BSC to issue the related RSL command */
4351 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
4352 if (istemplatekind(nack, "omit")) {
4353 /* respond with a related acknowledgement */
4354 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
4355 } else {
4356 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
4357 }
4358}
4359
4360/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
4361testcase TC_dyn_pdch_osmo_act_deact() 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
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004374 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004375 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4376 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4377 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
4378
4379 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
4380 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004381 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 +02004382 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4383
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004384 /* clean up config */
4385 f_ts_set_chcomb(0, 0, 6, "PDCH");
4386
Harald Welte94e0c342018-04-07 11:33:23 +02004387 setverdict(pass);
4388}
4389
4390/* Test Osmocom dyn PDCH activation NACK behavior */
4391testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
4392 var RSL_Message rsl_unused;
4393
4394 /* change Timeslot 6 before f_init() starts RSL */
4395 f_init_vty();
4396 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
4397 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4398
4399 f_init(1, false);
4400 f_sleep(1.0);
4401
4402 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
4403
4404 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4405 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4406 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
4407
4408 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
4409 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
4410 f_sleep(1.0);
4411 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4412
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004413 /* clean up config */
4414 f_ts_set_chcomb(0, 0, 6, "PDCH");
4415
Harald Welte94e0c342018-04-07 11:33:23 +02004416 setverdict(pass);
4417}
4418
Stefan Sperling0796a822018-10-05 13:01:39 +02004419testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02004420 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02004421 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
4422 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
4423 }
4424}
4425
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004426testcase TC_chopped_ipa_payload() runs on test_CT {
4427 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
4428 /* TODO: mp_bsc_ctrl_port does not work yet */};
4429 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
4430 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
4431 }
4432}
4433
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01004434/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
4435 the BTS does autonomous MS power control loop */
4436testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
4437 var MSC_ConnHdlr vc_conn;
4438 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4439 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
4440 pars.exp_ms_power_params := true;
4441
4442 f_init(1, true);
4443 f_sleep(1.0);
4444 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
4445 vc_conn.done;
4446}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004447
Harald Welte0ea2d5e2018-04-07 21:40:29 +02004448/* Dyn PDCH todo:
4449 * activate OSMO as TCH/F
4450 * activate OSMO as TCH/H
4451 * does the BSC-located PCU socket get the updated INFO?
4452 * what if no PCU is connected at the time?
4453 * is the info correct on delayed PCU (re)connect?
4454 */
Harald Welte94e0c342018-04-07 11:33:23 +02004455
Harald Welte28d943e2017-11-25 15:00:50 +01004456control {
Harald Welte898113b2018-01-31 18:32:21 +01004457 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01004458 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01004459 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01004460 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004461 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02004462 execute( TC_ctrl_location() );
4463 }
Harald Welte898113b2018-01-31 18:32:21 +01004464
4465 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01004466 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01004467 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01004468 execute( TC_chan_act_ack_noest() );
4469 execute( TC_chan_act_ack_est_ind_noreply() );
4470 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01004471 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01004472 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07004473 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01004474 execute( TC_chan_rel_rll_rel_ind() );
4475 execute( TC_chan_rel_conn_fail() );
4476 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01004477 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01004478 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02004479 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01004480 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01004481 execute( TC_chan_rel_sccp_tiar_timeout() );
Harald Welte6f521d82017-12-11 19:52:02 +01004482
Harald Weltecfe2c962017-12-15 12:09:32 +01004483 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01004484
4485 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01004486 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01004487 execute( TC_assignment_csd() );
4488 execute( TC_assignment_ctm() );
4489 execute( TC_assignment_sign() );
4490 execute( TC_assignment_fr_a5_0() );
4491 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004492 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02004493 execute( TC_assignment_fr_a5_1_codec_missing() );
4494 }
Harald Welte235ebf12017-12-15 14:18:16 +01004495 execute( TC_assignment_fr_a5_3() );
4496 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02004497 execute( TC_ciph_mode_a5_0() );
4498 execute( TC_ciph_mode_a5_1() );
4499 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01004500
Harald Welte60aa5762018-03-21 19:33:13 +01004501 execute( TC_assignment_codec_fr() );
4502 execute( TC_assignment_codec_hr() );
4503 execute( TC_assignment_codec_efr() );
4504 execute( TC_assignment_codec_amr_f() );
4505 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01004506
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004507 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01004508 execute( TC_assignment_codec_amr_f_S1() );
4509 execute( TC_assignment_codec_amr_h_S1() );
4510 execute( TC_assignment_codec_amr_f_S124() );
4511 execute( TC_assignment_codec_amr_h_S124() );
4512 execute( TC_assignment_codec_amr_f_S0() );
4513 execute( TC_assignment_codec_amr_f_S02() );
4514 execute( TC_assignment_codec_amr_f_S024() );
4515 execute( TC_assignment_codec_amr_f_S0247() );
4516 execute( TC_assignment_codec_amr_h_S0() );
4517 execute( TC_assignment_codec_amr_h_S02() );
4518 execute( TC_assignment_codec_amr_h_S024() );
4519 execute( TC_assignment_codec_amr_h_S0247() );
4520 execute( TC_assignment_codec_amr_f_S01234567() );
4521 execute( TC_assignment_codec_amr_f_S0234567() );
4522 execute( TC_assignment_codec_amr_f_zero() );
4523 execute( TC_assignment_codec_amr_f_unsupp() );
4524 execute( TC_assignment_codec_amr_h_S7() );
4525 }
Harald Welte60aa5762018-03-21 19:33:13 +01004526
Philipp Maierac09bfc2019-01-08 13:41:39 +01004527 execute( TC_assignment_codec_fr_exhausted_req_hr() );
4528 execute( TC_assignment_codec_fr_exhausted_req_fr() );
4529 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
4530 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
4531 execute( TC_assignment_codec_hr_exhausted_req_fr() );
4532 execute( TC_assignment_codec_hr_exhausted_req_hr() );
4533 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
4534 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
4535 execute( TC_assignment_codec_req_hr_fr() );
4536 execute( TC_assignment_codec_req_fr_hr() );
4537
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02004538 if (mp_enable_osmux_test) {
4539 execute( TC_assignment_osmux() );
4540 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004541
Harald Welte898113b2018-01-31 18:32:21 +01004542 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01004543 execute( TC_rll_est_ind_inact_lchan() );
4544 execute( TC_rll_est_ind_inval_sapi1() );
4545 execute( TC_rll_est_ind_inval_sapi3() );
4546 execute( TC_rll_est_ind_inval_sacch() );
4547
Harald Welte898113b2018-01-31 18:32:21 +01004548 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01004549 execute( TC_paging_imsi_nochan() );
4550 execute( TC_paging_tmsi_nochan() );
4551 execute( TC_paging_tmsi_any() );
4552 execute( TC_paging_tmsi_sdcch() );
4553 execute( TC_paging_tmsi_tch_f() );
4554 execute( TC_paging_tmsi_tch_hf() );
4555 execute( TC_paging_imsi_nochan_cgi() );
4556 execute( TC_paging_imsi_nochan_lac_ci() );
4557 execute( TC_paging_imsi_nochan_ci() );
4558 execute( TC_paging_imsi_nochan_lai() );
4559 execute( TC_paging_imsi_nochan_lac() );
4560 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01004561 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
4562 execute( TC_paging_imsi_nochan_rnc() );
4563 execute( TC_paging_imsi_nochan_lac_rnc() );
4564 execute( TC_paging_imsi_nochan_lacs() );
4565 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01004566 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01004567 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01004568 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01004569 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01004570 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01004571
4572 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01004573 execute( TC_rsl_unknown_unit_id() );
4574
4575 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01004576
4577 execute( TC_classmark() );
4578 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01004579 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004580 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01004581 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01004582 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004583
Harald Welte261af4b2018-02-12 21:20:39 +01004584 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004585
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004586 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004587 execute( TC_ho_out_fail_no_msc_response() );
4588 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004589 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004590
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004591 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004592 execute( TC_ho_in_fail_msc_clears() );
4593 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
4594 execute( TC_ho_in_fail_no_detect() );
4595 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004596
Neels Hofmeyr91401012019-07-11 00:42:35 +02004597 execute( TC_ho_neighbor_config_1() );
4598 execute( TC_ho_neighbor_config_2() );
4599 execute( TC_ho_neighbor_config_3() );
4600 execute( TC_ho_neighbor_config_4() );
4601 execute( TC_ho_neighbor_config_5() );
4602 execute( TC_ho_neighbor_config_6() );
4603 execute( TC_ho_neighbor_config_7() );
4604
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004605 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004606 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004607 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02004608
4609 execute( TC_dyn_pdch_ipa_act_deact() );
4610 execute( TC_dyn_pdch_ipa_act_nack() );
4611 execute( TC_dyn_pdch_osmo_act_deact() );
4612 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004613
Stefan Sperling0796a822018-10-05 13:01:39 +02004614 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004615 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02004616
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01004617 /* Power control related */
4618 execute( TC_assignment_verify_ms_power_params_ie() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004619 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
4620 execute( TC_early_conn_fail() );
4621 execute( TC_late_conn_fail() );
4622
Harald Welte28d943e2017-11-25 15:00:50 +01004623}
4624
4625}