blob: 48766f15ede091d2e0e1af0edce04e5388698fae [file] [log] [blame]
Harald Welte28d943e2017-11-25 15:00:50 +01001module BSC_Tests {
2
Harald Welte21b46bd2017-12-17 19:46:32 +01003/* Integration Tests for OsmoBSC
Harald Weltea0630032018-03-20 21:09:55 +01004 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte21b46bd2017-12-17 19:46:32 +01005 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
Harald Welte34b5a952019-05-27 11:54:11 +020010 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
Harald Welte21b46bd2017-12-17 19:46:32 +010012 * This test suite tests OsmoBSC while emulating both multiple BTS + MS as
13 * well as the MSC. See README for more details.
14 *
15 * There are test cases that run in so-called 'handler mode' and test cases
16 * that run directly on top of the BSSAP and RSL CodecPorts. The "handler mode"
17 * tests abstract the multiplexing/demultiplexing of multiple SCCP connections
18 * and/or RSL channels and are hence suitable for higher-level test cases, while
19 * the "raw" tests directly on top of the CodecPorts are more suitable for lower-
20 * level testing.
21 */
22
Harald Welte4003d112017-12-09 22:35:39 +010023import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010024import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010025import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010026import from IPL4asp_Types all;
27
Harald Welte6f521d82017-12-11 19:52:02 +010028import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020029import from RAN_Adapter all;
Harald Welteae026692017-12-09 01:03:01 +010030import from BSSAP_CodecPort all;
31import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010032import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010033import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010034import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020035import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010036import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010037import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010038import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010039import from MGCP_Templates all;
40import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020041import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010042
Harald Welte96c94412017-12-09 03:12:45 +010043import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010044import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010045import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010046
Harald Weltebc03c762018-02-12 18:09:38 +010047import from Osmocom_VTY_Functions all;
48import from TELNETasp_PortType all;
49
Harald Welte6f521d82017-12-11 19:52:02 +010050import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010051import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010052import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010053import from L3_Templates all;
54import from GSM_RR_Types all;
55
Stefan Sperlingc307e682018-06-14 15:15:46 +020056import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010057import from BSSMAP_Templates all;
58
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010059import from SCCPasp_Types all;
60
Harald Welte5d1a2202017-12-13 19:51:29 +010061const integer NUM_BTS := 3;
Harald Welteae026692017-12-09 01:03:01 +010062const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010063
Harald Welte799c97b2017-12-14 17:50:30 +010064/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020065const integer NUM_TCHH_PER_BTS := 2;
66const integer NUM_TCHF_PER_BTS := 4;
Harald Weltedd8cbf32018-01-28 12:07:52 +010067const integer NUM_SDCCH_PER_BTS := 4;
Harald Welte799c97b2017-12-14 17:50:30 +010068
Harald Welte4003d112017-12-09 22:35:39 +010069
Harald Welte21b46bd2017-12-17 19:46:32 +010070/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010071type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010072 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010073 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010074}
75
Harald Weltea4ca4462018-02-09 00:17:14 +010076type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +010077 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +010078 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +010079 /* RSL common Channel Port (for RSL_Emulation) */
80 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +010081 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +010082 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +010083 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +020084 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
85 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +010086
Daniel Willmann191e0d92018-01-17 12:44:35 +010087 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +010088 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +010089
Harald Welte6811d102019-04-14 22:23:14 +020090 var RAN_Adapter g_bssap;
Harald Weltea4ca4462018-02-09 00:17:14 +010091 /* for old legacy-tests only */
92 port BSSAP_CODEC_PT BSSAP;
93
Harald Welte21b46bd2017-12-17 19:46:32 +010094 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +010095 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +010096
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +020097 /* Osmux is enabled through VTY */
98 var boolean g_osmux_enabled := false;
99
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100100 /*Configure T(tias) over VTY, seconds */
101 var integer g_bsc_sccp_timer_ias := 7 * 60;
102 /*Configure T(tiar) over VTY, seconds */
103 var integer g_bsc_sccp_timer_iar := 15 * 60;
104
Harald Welte21b46bd2017-12-17 19:46:32 +0100105 /* global test case guard timer */
Harald Welteae026692017-12-09 01:03:01 +0100106 timer T_guard := 30.0;
107
Harald Welte28d943e2017-11-25 15:00:50 +0100108}
109
110modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100111 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100112 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100113 /* port number to which to establish the IPA OML connections */
114 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100115 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100116 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100117 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100118 integer mp_bsc_ctrl_port := 4249;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100119 /* IP address at which the test binds */
120 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100121
Harald Welte6811d102019-04-14 22:23:14 +0200122 RAN_Configuration mp_bssap_cfg := {
Harald Welte7ef51aa2018-04-16 19:16:01 +0200123 transport := BSSAP_TRANSPORT_AoIP,
Harald Weltea4ca4462018-02-09 00:17:14 +0100124 sccp_service_type := "mtp3_itu",
125 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
126 own_pc := 185,
127 own_ssn := 254,
128 peer_pc := 187,
129 peer_ssn := 254,
Philipp Maier38d68942018-03-29 15:38:09 +0200130 sio := '83'O,
131 rctx := 0
Harald Weltea4ca4462018-02-09 00:17:14 +0100132 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200133
134 /* Whether to enable osmux tests. Can be dropped completely and enable
135 unconditionally once new version of osmo-bsc is released (current
136 version: 1.4.1) */
137 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100138 /* Value set in osmo-bsc.cfg "ms max power" */
139 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100140}
141
Philipp Maier48604732018-10-09 15:00:37 +0200142private function f_gen_test_hdlr_pars() return TestHdlrParams {
143
144 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
145 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
146 pars.aoip := true;
147 } else {
148 pars.aoip := false;
149 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100150 pars.exp_ms_power_level := mp_exp_ms_power_level;
Philipp Maier48604732018-10-09 15:00:37 +0200151
152 return pars;
153}
154
Philipp Maier282ca4b2018-02-27 17:17:00 +0100155private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200156 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100157 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200158 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100159}
160
Harald Weltea4ca4462018-02-09 00:17:14 +0100161private function f_legacy_bssap_reset() runs on test_CT {
162 var BSSAP_N_UNITDATA_ind ud_ind;
163 timer T := 5.0;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200164 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100165 T.start;
166 alt {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200167 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100168 log("Received RESET-ACK in response to RESET, we're ready to go!");
169 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200170 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100171 log("Respoding to inbound RESET with RESET-ACK");
172 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200173 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100174 repeat;
175 }
176 [] BSSAP.receive { repeat; }
177 [] T.timeout { setverdict(fail, "Waiting for RESET-ACK after sending RESET"); }
178 }
Harald Welte28d943e2017-11-25 15:00:50 +0100179}
180
Harald Welteae026692017-12-09 01:03:01 +0100181type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100182 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100183 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100184 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100185 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100186 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100187 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100188 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100189 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100190}
191
Harald Welte21b46bd2017-12-17 19:46:32 +0100192/*! Start the IPA/RSL related bits for one IPA_Client.
193 * \param clnt IPA_Client for which to establish
194 * \param bsc_host IP address / hostname of the BSC
195 * \param bsc_port TCP port number of the BSC
196 * \param i number identifying this BTS
197 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100198function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
199 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100200runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100201 timer T := 10.0;
202
Harald Welte96c94412017-12-09 03:12:45 +0100203 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100204 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
205 clnt.ccm_pars := c_IPA_default_ccm_pars;
206 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
207 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100208 if (handler_mode) {
209 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100210 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100211 }
Harald Welteae026692017-12-09 01:03:01 +0100212
213 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100214 if (handler_mode) {
215 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
216 } else {
217 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
218 }
Harald Welteae026692017-12-09 01:03:01 +0100219
Harald Welte5d1a2202017-12-13 19:51:29 +0100220 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100221 if (handler_mode) {
222 clnt.vc_RSL.start(RSL_Emulation.main());
223 return;
224 }
Harald Welteae026692017-12-09 01:03:01 +0100225
226 /* wait for IPA RSL link to connect and send ID ACK */
227 T.start;
228 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700229 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100230 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700231 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100232 }
Harald Welte60e823a2017-12-10 14:10:59 +0100233 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100234 [] IPA_RSL[i].receive { repeat }
235 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100236 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200237 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100238 }
239 }
240}
241
Harald Welte12055472018-03-17 20:10:08 +0100242function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
243 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
244 return;
245 }
246 clnt.vc_IPA.stop;
247 if (isbound(clnt.vc_RSL)) {
248 clnt.vc_RSL.stop;
249 }
250}
251
Harald Welte21b46bd2017-12-17 19:46:32 +0100252/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100253function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
254 timer T := secs_max;
255 T.start;
256 while (true) {
257 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
258 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100259 /* the 'degraded' state exists from OML connection time, and we have to wait
260 * until all MO's are initialized */
261 T.start(1.0);
262 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100263 return;
264 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100265 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100266 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100267 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200268 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100269 }
270 }
271}
272
Harald Welte21b46bd2017-12-17 19:46:32 +0100273/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100274altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100275 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100276 [] T_guard.timeout {
277 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200278 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100279 }
Harald Welte60e823a2017-12-10 14:10:59 +0100280 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200281 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100282 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200283 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100284 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100285 }
Harald Welte28d943e2017-11-25 15:00:50 +0100286}
287
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100288altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200289 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100290 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200291 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100292 }
293}
294
Daniel Willmann191e0d92018-01-17 12:44:35 +0100295function f_init_mgcp(charstring id) runs on test_CT {
296 id := id & "-MGCP";
297
298 var MGCPOps ops := {
299 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
300 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
301 };
302 var MGCP_conn_parameters mgcp_pars := {
303 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100304 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100305 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200306 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200307 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
308 the on with MGCP over IPA forwarded from MSC one) */
309 multi_conn_mode := (mp_bssap_cfg.transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100310 };
311
312 vc_MGCP := MGCP_Emulation_CT.create(id);
313 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
314}
315
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200316/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
317 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
318 * OsmuxCID IE.
319 */
320private function f_vty_allow_osmux(boolean allow) runs on test_CT {
321 f_vty_enter_cfg_msc(BSCVTY, 0);
322 if (allow) {
323 f_vty_transceive(BSCVTY, "osmux on");
324 } else {
325 f_vty_transceive(BSCVTY, "osmux off");
326 }
327 f_vty_transceive(BSCVTY, "exit");
328 f_vty_transceive(BSCVTY, "exit");
329 g_osmux_enabled := allow;
330}
331
Max2253c0b2018-11-06 19:28:05 +0100332function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200333 if (BSCVTY.checkstate("Mapped")) {
334 /* skip initialization if already executed once */
335 return;
336 }
Harald Weltebc03c762018-02-12 18:09:38 +0100337 map(self:BSCVTY, system:BSCVTY);
338 f_vty_set_prompts(BSCVTY);
339 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100340 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
341 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100342}
343
Harald Welte21b46bd2017-12-17 19:46:32 +0100344/* global initialization function
345 * \param nr_bts Number of BTSs we should start/bring up
346 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200347function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false) runs on test_CT {
Harald Welte28d943e2017-11-25 15:00:50 +0100348 var integer i;
Harald Welte28d943e2017-11-25 15:00:50 +0100349
Harald Welteae026692017-12-09 01:03:01 +0100350 if (g_initialized) {
351 return;
Harald Welte28d943e2017-11-25 15:00:50 +0100352 }
Harald Welteae026692017-12-09 01:03:01 +0100353 g_initialized := true;
354
Daniel Willmanne68f9272018-11-27 15:15:28 +0100355 T_guard.start;
356 activate(as_Tguard());
357
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200358 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200359 if (mp_enable_osmux_test) {
360 f_vty_allow_osmux(allow_osmux);
361 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200362
Harald Welte6811d102019-04-14 22:23:14 +0200363 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
Harald Welteae026692017-12-09 01:03:01 +0100364 * MSC-side BSSAP emulation */
Harald Welte67089ee2018-01-17 22:19:03 +0100365 if (handler_mode) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200366 var RanOps ranops := MSC_RanOps;
367 ranops.use_osmux := g_osmux_enabled;
368 f_ran_adapter_init(g_bssap, mp_bssap_cfg, "VirtMSC", ranops);
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200369 connect(self:SCCPLITE_IPA_CTRL, g_bssap.vc_RAN:CTRL_CLIENT);
Harald Welte3ca0ce12019-04-23 17:18:48 +0200370 f_ran_adapter_start(g_bssap);
Harald Welte67089ee2018-01-17 22:19:03 +0100371 } else {
Harald Welte3ca0ce12019-04-23 17:18:48 +0200372 f_ran_adapter_init(g_bssap, mp_bssap_cfg, "VirtMSC", omit);
Harald Weltea4ca4462018-02-09 00:17:14 +0100373 connect(self:BSSAP, g_bssap.vc_SCCP:SCCP_SP_PORT);
Harald Welte3ca0ce12019-04-23 17:18:48 +0200374 f_ran_adapter_start(g_bssap);
Harald Weltea4ca4462018-02-09 00:17:14 +0100375 f_legacy_bssap_reset();
Harald Welte67089ee2018-01-17 22:19:03 +0100376 }
Harald Welted5833a82018-05-27 16:52:56 +0200377
Harald Welteffe55fc2018-01-17 22:39:54 +0100378 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +0100379
Daniel Willmann191e0d92018-01-17 12:44:35 +0100380 f_init_mgcp("VirtMSC");
381
Harald Welte89d42e82017-12-17 16:42:41 +0100382 for (i := 0; i < nr_bts; i := i+1) {
Harald Weltea5d2ab22017-12-09 14:21:42 +0100383 /* wait until osmo-bts-omldummy has respawned */
384 f_wait_oml(i, "degraded", 5.0);
385 /* start RSL connection */
Harald Welte624f9632017-12-16 19:26:04 +0100386 f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i, handler_mode);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100387 /* wait until BSC tells us "connected" */
388 f_wait_oml(i, "connected", 5.0);
Harald Welte696ddb62017-12-08 14:01:43 +0100389 }
390
Harald Welte28d943e2017-11-25 15:00:50 +0100391}
392
Maxd4e56962018-10-31 19:08:25 +0100393/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welteae026692017-12-09 01:03:01 +0100394function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
395runs on test_CT return RSL_Message {
396 var ASP_RSL_Unitdata rx_rsl_ud;
397 timer T := t_secs;
398
399 T.start;
400 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700401 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +0100402 T.stop;
403 }
404 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +0100405 [] T.timeout {
406 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +0200407 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +0100408 }
Harald Welteae026692017-12-09 01:03:01 +0100409 }
410 return rx_rsl_ud.rsl;
411}
412
Harald Welte21b46bd2017-12-17 19:46:32 +0100413/* helper function to transmit RSL on a given BTS/stream */
Harald Welteae026692017-12-09 01:03:01 +0100414function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
415runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700416 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +0100417}
418
419
Harald Welte4003d112017-12-09 22:35:39 +0100420/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +0100421testcase TC_chan_act_noreply() runs on test_CT {
422 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +0100423 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +0100424
Harald Welte89d42e82017-12-17 16:42:41 +0100425 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +0100426
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700427 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +0100428 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welteae026692017-12-09 01:03:01 +0100429 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +0100430}
431
Harald Welte4003d112017-12-09 22:35:39 +0100432/* verify if the "chreq:total" counter increments as expected */
433testcase TC_chan_act_counter() runs on test_CT {
434 var BSSAP_N_UNITDATA_ind ud_ind;
435 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +0100436 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +0100437
Harald Welte89d42e82017-12-17 16:42:41 +0100438 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100439
440 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700441 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +0100442 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +0100443 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
444
445 setverdict(pass);
446}
447
Harald Welteae026692017-12-09 01:03:01 +0100448/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
449testcase TC_chan_act_ack_noest() runs on test_CT {
450 var RSL_Message rx_rsl;
451
Harald Welte89d42e82017-12-17 16:42:41 +0100452 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100453
454 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100455 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100456
457 /* expect BSC to disable the channel again if there's no RLL EST IND */
458 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
459
460 setverdict(pass);
461}
462
463/* Test behavior if MSC never answers to CR */
464testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +0100465 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
466 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +0100467 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +0100468 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +0100469
Harald Welte89d42e82017-12-17 16:42:41 +0100470 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100471
472 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100473 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100474
475 var octetstring l3 := '00010203040506'O
476 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
477
478 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
479
480 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +0100481 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100482 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +0100483 setverdict(pass);
484}
485
486/* Test behavior if MSC answers with CREF to CR */
487testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
488 var BSSAP_N_CONNECT_ind rx_c_ind;
489 var RSL_Message rx_rsl;
490
Harald Welte89d42e82017-12-17 16:42:41 +0100491 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100492
493 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100494 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100495
496 var octetstring l3 := '00010203040506'O
497 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
498
499 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
500 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
501
502 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100503 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +0100504 setverdict(pass);
505}
506
Harald Welte618ef642017-12-14 14:58:20 +0100507/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
508testcase TC_chan_act_nack() runs on test_CT {
509 var RSL_Message rx_rsl;
510 var integer chact_nack;
511
Harald Welte89d42e82017-12-17 16:42:41 +0100512 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +0100513
514 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
515
516 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
517 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
518 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
519
520 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
521
522 /* wait for some time to hope the NACK arrives before the CTRL GET below */
523 f_sleep(0.5);
524
525 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
526
527 setverdict(pass);
528}
529
Harald Welte799c97b2017-12-14 17:50:30 +0100530/* Test for channel exhaustion due to RACH overload */
531testcase TC_chan_exhaustion() runs on test_CT {
532 var ASP_RSL_Unitdata rsl_ud;
533 var integer i;
534 var integer chreq_total, chreq_nochan;
535
Harald Welte89d42e82017-12-17 16:42:41 +0100536 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +0100537
538 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
539 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
540
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +0100541 /* GSM 04.08 Table 9.9a:
542 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
543 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +0200544 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +0100545 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +0100546 }
547
548 IPA_RSL[0].clear;
549
Harald Weltedd8cbf32018-01-28 12:07:52 +0100550 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200551 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +0100552
553 /* now expect additional channel activations to fail */
554 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
555
556 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700557 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +0100558 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
559 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700560 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +0100561 var GsmRrMessage rr;
562 /* match on IMM ASS REJ */
563 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
564 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
565 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200566 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +0100567 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
568 chreq_nochan+1);
569 setverdict(pass);
570 } else {
571 repeat;
572 }
573 }
574 [] IPA_RSL[0].receive { repeat; }
575 }
576}
577
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +0700578/* Test channel deactivation due to silence from MS */
579testcase TC_chan_deact_silence() runs on test_CT {
580 var RslChannelNr chan_nr;
581
582 f_init(1);
583
584 /* Request for a dedicated channel */
585 chan_nr := f_chreq_act_ack('23'O);
586
587 /* Wait some time until the channel is released */
588 f_sleep(2.0);
589
590 /* Expect CHANnel RELease */
591 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700592 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +0700593 log("Received CHANnel RELease");
594 setverdict(pass);
595 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700596 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +0700597 /* See OS#3709, OsmoBSC should not send Immediate
598 * Assignment Reject since a dedicated channel was
599 * already allocated, and Immediate Assignment was
600 * already sent. */
601 setverdict(fail, "Unexpected Immediate Assignment!");
602 }
603 [] IPA_RSL[0].receive {
604 setverdict(fail, "Unexpected RSL message!");
605 }
606 }
607}
608
Harald Weltecfe2c962017-12-15 12:09:32 +0100609/***********************************************************************
610 * Assignment Testing
611 ***********************************************************************/
612
Neels Hofmeyrda4a6952018-06-14 04:02:49 +0200613/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
614 * except for the inter-BSC handover, MT side) */
Harald Weltecfe2c962017-12-15 12:09:32 +0100615testcase TC_outbound_connect() runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +0100616 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +0100617
Harald Weltea4ca4462018-02-09 00:17:14 +0100618 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +0100619 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
620 setverdict(pass);
621}
622
Harald Welte16a4adf2017-12-14 18:54:01 +0100623/* Test behavior if MSC answers with CREF to CR */
624testcase TC_assignment_cic_only() runs on test_CT {
625 var BSSAP_N_CONNECT_ind rx_c_ind;
626 var RSL_Message rx_rsl;
627 var DchanTuple dt;
628
Harald Welte89d42e82017-12-17 16:42:41 +0100629 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +0100630
631 dt := f_est_dchan('23'O, 23, '00000000'O);
Harald Welte17b27da2018-05-25 20:33:53 +0200632 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
633 /* send assignment without AoIP IEs */
634 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
635 } else {
636 /* Send assignmetn without CIC in IPA case */
637 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
638 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
639 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
640 }
Harald Welte16a4adf2017-12-14 18:54:01 +0100641 alt {
642 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
643 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
644 }
Harald Welte235ebf12017-12-15 14:18:16 +0100645 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +0100646 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
647 setverdict(pass);
648 }
649 [] BSSAP.receive { repeat; }
650 }
651}
652
Harald Welteed848512018-05-24 22:27:58 +0200653/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200654function f_gen_ass_req(boolean osmux_enabled := false) return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200655 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200656 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Harald Welteed848512018-05-24 22:27:58 +0200657 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
658 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
659 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200660 if (osmux_enabled) {
661 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
662 } else {
663 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
664 }
Harald Welteed848512018-05-24 22:27:58 +0200665 } else {
666 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +0200667 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +0200668 }
669 return ass_cmd;
670}
671
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100672function f_gen_handover_req() return PDU_BSSAP {
673 var PDU_BSSAP ho_req;
674 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
675 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
676 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
677 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
678 } else {
679 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
680 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
681 }
682 return ho_req;
683}
684
Harald Welteed848512018-05-24 22:27:58 +0200685/* generate an assignment complete template for either AoIP or SCCPlite */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200686function f_gen_exp_compl(boolean expect_osmux := false) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200687 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200688 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Harald Welteed848512018-05-24 22:27:58 +0200689 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200690 if (expect_osmux) {
691 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
692 } else {
693 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
694 }
Harald Welteed848512018-05-24 22:27:58 +0200695 } else {
696 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +0200697 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +0200698 }
699 return exp_compl;
700}
701
Harald Welte235ebf12017-12-15 14:18:16 +0100702/* Run everything required up to sending a caller-specified assignment command and expect response */
703function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
704runs on test_CT {
705 var BSSAP_N_CONNECT_ind rx_c_ind;
706 var RSL_Message rx_rsl;
707 var DchanTuple dt;
708
Harald Welte89d42e82017-12-17 16:42:41 +0100709 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +0100710
711 dt := f_est_dchan('23'O, 23, '00000000'O);
712 /* send assignment without AoIP IEs */
713 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
714 alt {
715 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
716 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
717 setverdict(pass);
718 } else {
719 setverdict(fail, fail_text);
720 }
721 }
722 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
723 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
724 setverdict(pass);
725 } else {
726 setverdict(fail, fail_text);
727 }
728 }
729 [] BSSAP.receive { repeat; }
730 }
731}
732testcase TC_assignment_csd() runs on test_CT {
733 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200734 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100735 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
736 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
737 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
738}
739
740testcase TC_assignment_ctm() runs on test_CT {
741 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200742 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100743 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
744 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
745 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
746}
747
Harald Welte4003d112017-12-09 22:35:39 +0100748type record DchanTuple {
749 integer sccp_conn_id,
750 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +0100751}
752
Harald Welted6939652017-12-13 21:02:46 +0100753/* Send CHAN RQD and wait for allocation; acknowledge it */
754private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
755runs on test_CT return RslChannelNr {
756 var RSL_Message rx_rsl;
757 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
758 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
759 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
760 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +0200761 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +0100762 return chan_nr;
763}
764
Harald Welte4003d112017-12-09 22:35:39 +0100765/* helper function to establish a dedicated channel via BTS and MSC */
766function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
767runs on test_CT return DchanTuple {
768 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +0100769 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100770
Harald Welte4003d112017-12-09 22:35:39 +0100771 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100772 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +0100773
774 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
775
776 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
777 dt.sccp_conn_id := rx_c_ind.connectionId;
778 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
779
780 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100781}
782
Harald Welte641fcbe2018-06-14 10:58:35 +0200783/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
784private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
785 var RSL_Message rx_rsl;
786 /* expect BSC to disable the channel */
787 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
788 /* respond with CHAN REL ACK */
789 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
790
791 /* expect Clear Complete from BSC */
792 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
793
794 /* MSC disconnects as instructed. */
795 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
796}
797
Harald Welte4003d112017-12-09 22:35:39 +0100798/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
799testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100800 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100801 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +0100802
Harald Welte89d42e82017-12-17 16:42:41 +0100803 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +0100804
Harald Welte4003d112017-12-09 22:35:39 +0100805 dt := f_est_dchan('23'O, 23, '00010203040506'O);
806
807 /* simulate RLL REL IND */
808 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
809
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100810 /* expect Clear Request on MSC side */
811 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
812
813 /* Instruct BSC to clear channel */
814 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
815 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
816
Harald Welte4003d112017-12-09 22:35:39 +0100817 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +0200818 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100819
820 /* wait for SCCP emulation to do its job */
821 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +0100822
823 setverdict(pass);
824}
825
826/* Test behavior of channel release after CONN FAIL IND from BTS */
827testcase TC_chan_rel_conn_fail() runs on test_CT {
828 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100829 var DchanTuple dt;
830
Harald Welte89d42e82017-12-17 16:42:41 +0100831 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100832
833 dt := f_est_dchan('23'O, 23, '00010203040506'O);
834
835 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +0100836 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 +0100837 /* TODO: different cause values? */
838
Harald Welte4003d112017-12-09 22:35:39 +0100839 /* expect Clear Request from BSC */
840 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
841
842 /* Instruct BSC to clear channel */
843 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
844 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
845
Harald Welte6ff76ea2018-01-28 13:08:01 +0100846 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +0200847 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +0100848
849 /* wait for SCCP emulation to do its job */
850 f_sleep(1.0);
851
852 setverdict(pass);
853}
854
Harald Welte99f3ca02018-06-14 13:40:29 +0200855/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
856/* See also https://www.osmocom.org/issues/3182 */
857testcase TC_early_conn_fail() runs on test_CT {
858 var RSL_Message rx_rsl;
859 var DchanTuple dt;
860
861 f_init(1);
862
863 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
864 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_octstring(1), 23);
865
866 /* BTS->BSC: simulate CONN FAIL IND */
867 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
868
869 /* BTS->BSC: Expect RF channel release from BSC on Abis */
870 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
871
872 /* BTS<-BSC: respond with CHAN REL ACK */
873 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
874
875 setverdict(pass);
876}
877
878/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
879/* See also https://www.osmocom.org/issues/3182 */
880testcase TC_late_conn_fail() runs on test_CT {
881 var RSL_Message rx_rsl;
882 var DchanTuple dt;
883
884 f_init(1);
885
886 dt := f_est_dchan('23'O, 23, '00010203040506'O);
887
888 /* BSC<-MSC: Instruct BSC to clear connection */
889 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
890
891 /* BTS->BSC: expect BSC to deactivate SACCH */
892 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
893
894 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
895 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
896
897 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
898 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
899 /* BTS->BSC: respond with CHAN REL ACK */
900 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
901
902 /* BSC->MSC: expect Clear Complete from BSC */
903 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
904
905 /* BSC<-MSC: MSC disconnects as requested. */
906 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
907
908 setverdict(pass);
909}
910
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +0100911function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100912 boolean expect_deact_sacch := true,
913 boolean expect_rr_chan_rel := true,
914 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +0100915 boolean handle_rll_rel := true,
916 boolean is_csfb := false
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100917 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +0100918
919 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100920 var boolean got_deact_sacch := false;
921 var boolean got_rr_chan_rel := false;
922 var boolean got_rll_rel_req := false;
923 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
924 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +0100925 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700926 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100927 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100928 repeat;
929 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700930 [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 +0100931 got_rr_chan_rel := true;
932 repeat;
933 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700934 [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 +0100935 got_rr_chan_rel := true;
Neels Hofmeyr211169d2018-11-07 00:37:29 +0100936 repeat;
937 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700938 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100939 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100940 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100941 if (handle_rll_rel) {
942 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
943 }
Harald Welte91d54a52018-01-28 15:35:07 +0100944 repeat;
945 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700946 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +0100947 /* respond with CHAN REL ACK */
948 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
949 }
950 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700951 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +0100952 repeat;
953 }
954 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100955
956 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
957 " got_rll_rel_req=", got_rll_rel_req);
958
959 if (expect_deact_sacch != got_deact_sacch) {
960 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
961 }
962 if (expect_rr_chan_rel != got_rr_chan_rel) {
963 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
964 }
965 if (expect_rll_rel_req != got_rll_rel_req) {
966 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
967 }
Harald Welte91d54a52018-01-28 15:35:07 +0100968}
969
Harald Welte4003d112017-12-09 22:35:39 +0100970/* Test behavior of channel release after hard Clear Command from MSC */
971testcase TC_chan_rel_hard_clear() runs on test_CT {
972 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100973 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +0100974
Harald Welte89d42e82017-12-17 16:42:41 +0100975 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100976
977 dt := f_est_dchan('23'O, 23, '00010203040506'O);
978
979 /* Instruct BSC to clear channel */
980 var BssmapCause cause := 0;
981 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
982
983 /* expect Clear Complete from BSC on A */
984 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
985 /* release the SCCP connection */
986 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
987 }
988
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100989 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte4003d112017-12-09 22:35:39 +0100990 setverdict(pass);
991}
992
Harald Welte99787102019-02-04 10:41:36 +0100993/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
994testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
995 var BSSAP_N_DATA_ind rx_di;
996 var DchanTuple dt;
997
998 f_init(1);
999
1000 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1001
1002 /* Instruct BSC to clear channel */
1003 var BssmapCause cause := 0;
1004 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1005
1006 /* expect Clear Complete from BSC on A */
1007 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1008 /* release the SCCP connection */
1009 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1010 }
1011
1012 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
1013 setverdict(pass);
1014}
1015
Harald Welted8c36cd2017-12-09 23:05:31 +01001016/* Test behavior of channel release after hard RLSD from MSC */
1017testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001018 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001019
Harald Welte89d42e82017-12-17 16:42:41 +01001020 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001021
1022 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1023
1024 /* release the SCCP connection */
1025 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1026
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001027 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welted8c36cd2017-12-09 23:05:31 +01001028 setverdict(pass);
1029}
1030
Harald Welte550daf92018-06-11 19:22:13 +02001031/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1032testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1033 var DchanTuple dt;
1034
1035 f_init(1);
1036
1037 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1038
1039 /* release the SCCP connection */
1040 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1041
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001042 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte550daf92018-06-11 19:22:13 +02001043 setverdict(pass);
1044}
1045
Harald Welte85804d42017-12-10 14:11:58 +01001046/* Test behavior of channel release after BSSMAP RESET from MSC */
1047testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001048 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001049
Harald Welte89d42e82017-12-17 16:42:41 +01001050 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001051
1052 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1053
1054 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1055 IPA_RSL[0].clear;
1056
1057 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001058 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte85804d42017-12-10 14:11:58 +01001059 interleave {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001060 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte85804d42017-12-10 14:11:58 +01001061 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1062 }
1063
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001064 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte85804d42017-12-10 14:11:58 +01001065 setverdict(pass);
1066}
1067
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001068/* Verify T(iar) triggers and releases the channel */
1069testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1070 var DchanTuple dt;
1071
1072 /* Set T(iar) in BSC low enough that it will trigger before other side
1073 has time to keep alive with a T(ias). Keep recommended ratio of
1074 T(iar) >= T(ias)*2 */
1075 g_bsc_sccp_timer_ias := 2;
1076 g_bsc_sccp_timer_iar := 5;
1077
1078 f_init(1);
1079
1080 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1081 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
1082 setverdict(pass);
1083}
1084
Harald Welte5cd20ed2017-12-13 21:03:20 +01001085/* Test behavior if RSL EST IND for non-active channel */
1086testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1087 timer T := 2.0;
1088
Harald Welte89d42e82017-12-17 16:42:41 +01001089 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001090
1091 var octetstring l3 := '00010203040506'O;
1092 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1093 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1094
1095 T.start;
1096 alt {
1097 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1098 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1099 }
1100 [] BSSAP.receive {}
1101 [] IPA_RSL[0].receive {}
1102 [] T.timeout {}
1103 }
1104
1105 setverdict(pass);
1106}
1107
1108/* Test behavior if RSL EST IND for invalid SAPI */
1109testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1110 var RslChannelNr chan_nr;
1111
Harald Welte89d42e82017-12-17 16:42:41 +01001112 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001113
1114 chan_nr := f_chreq_act_ack()
1115
1116 var octetstring l3 := '00010203040506'O;
1117 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1118
1119 timer T := 2.0;
1120 T.start;
1121 alt {
1122 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1123 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1124 }
1125 [] BSSAP.receive { repeat; }
1126 [] IPA_RSL[0].receive { repeat; }
1127 [] T.timeout {}
1128 }
1129
1130 setverdict(pass);
1131}
1132
1133/* Test behavior if RSL EST IND for invalid SAPI */
1134testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
1135 timer T := 2.0;
1136
Harald Welte89d42e82017-12-17 16:42:41 +01001137 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001138
1139 var RslChannelNr chan_nr := f_chreq_act_ack();
1140
1141 var octetstring l3 := '00010203040506'O;
1142 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
1143
1144 T.start;
1145 alt {
1146 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1147 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
1148 }
1149 [] BSSAP.receive { repeat; }
1150 [] IPA_RSL[0].receive { repeat; }
1151 [] T.timeout {}
1152 }
1153
1154 setverdict(pass);
1155}
1156
1157/* Test behavior if RSL EST IND for invalid SACCH */
1158testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
1159 timer T := 2.0;
1160
Harald Welte89d42e82017-12-17 16:42:41 +01001161 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001162
1163 var RslChannelNr chan_nr := f_chreq_act_ack();
1164
1165 var octetstring l3 := '00010203040506'O;
1166 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
1167
1168 T.start;
1169 alt {
1170 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1171 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
1172 }
1173 [] BSSAP.receive { repeat; }
1174 [] IPA_RSL[0].receive { repeat; }
1175 [] T.timeout {}
1176 }
1177
1178 setverdict(pass);
1179}
1180
1181
1182
Harald Welte4003d112017-12-09 22:35:39 +01001183
1184testcase TC_ctrl_msc_connection_status() runs on test_CT {
1185 var charstring ctrl_resp;
1186
Harald Welte89d42e82017-12-17 16:42:41 +01001187 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001188
1189 /* See https://osmocom.org/issues/2729 */
1190 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
1191 setverdict(pass);
1192}
1193
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001194testcase TC_ctrl_msc0_connection_status() runs on test_CT {
1195 var charstring ctrl_resp;
1196
1197 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001198
1199 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
1200 setverdict(pass);
1201}
1202
Harald Welte4003d112017-12-09 22:35:39 +01001203testcase TC_ctrl() runs on test_CT {
1204 var charstring ctrl_resp;
1205
Harald Welte89d42e82017-12-17 16:42:41 +01001206 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001207
1208 /* all below values must match the osmo-bsc.cfg config file used */
1209
Harald Welte6a129692018-03-17 17:30:14 +01001210 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
1211 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02001212 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01001213
1214 var integer bts_nr := 0;
1215 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
1216 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
1217 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
1218 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
1219 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
1220 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
1221 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
1222
1223 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
1224 f_sleep(2.0);
1225 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
1226 setverdict(fail, "oml-uptime not incrementing as expected");
1227 }
1228 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
1229
1230 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
1231
1232 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +01001233}
1234
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02001235/* Verify that Upon receival of SET "location", BSC forwards a TRAP
1236 "location-state" over the SCCPlite IPA conn */
1237testcase TC_ctrl_location() runs on test_CT {
1238 var MSC_ConnHdlr vc_conn;
1239 var integer bts_nr := 0;
1240
1241 f_init(1, true);
1242 f_sleep(1.0);
1243
1244 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
1245 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
1246 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
1247
1248 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
1249 f_sleep(2.0);
1250
1251 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
1252 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
1253 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
1254
1255 /* should match the one from config */
1256 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
1257
1258 setverdict(pass);
1259}
1260
Harald Welte6f521d82017-12-11 19:52:02 +01001261function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +01001262 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, bssap));
Harald Welte6f521d82017-12-11 19:52:02 +01001263}
1264
1265
1266/***********************************************************************
1267 * Paging Testing
1268 ***********************************************************************/
1269
1270type record Cell_Identity {
1271 GsmMcc mcc,
1272 GsmMnc mnc,
1273 GsmLac lac,
1274 GsmCellId ci
1275};
Harald Welte24135bd2018-03-17 19:27:53 +01001276private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001277private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001278
Harald Welte5d1a2202017-12-13 19:51:29 +01001279type set of integer BtsIdList;
1280
1281private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1282 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1283 if (bts_id == bts_ids[j]) {
1284 return true;
1285 }
1286 }
1287 return false;
1288}
Harald Welte6f521d82017-12-11 19:52:02 +01001289
1290/* core paging test helper function; used by most paging test cases */
1291private function f_pageing_helper(hexstring imsi,
1292 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001293 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001294 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001295 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01001296{
1297 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001298 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01001299 var RSL_Message rx_rsl;
1300 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001301 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001302
1303 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001304
1305 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001306 for (i := 0; i < NUM_BTS; i := i + 1) {
1307 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001308 }
Harald Welte6f521d82017-12-11 19:52:02 +01001309
1310 if (isvalue(rsl_chneed)) {
1311 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1312 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1313 } else {
1314 bssmap_chneed := omit;
1315 }
1316
1317 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
1318
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001319 if (not istemplatekind(tmsi, "omit")) {
1320 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01001321 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001322 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01001323 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001324
Harald Welte5d1a2202017-12-13 19:51:29 +01001325 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001326 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01001327 /* check channel type, paging group */
1328 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1329 setverdict(fail, "Paging for wrong paging group");
1330 }
1331 if (ispresent(rsl_chneed) and
1332 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1333 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1334 }
Harald Welte6f521d82017-12-11 19:52:02 +01001335 }
Harald Welte2fccd982018-01-31 15:48:19 +01001336 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001337 /* do a quick check on all not-included BTSs if they received paging */
1338 for (i := 0; i < NUM_BTS; i := i + 1) {
1339 timer T := 0.1;
1340 if (f_bts_in_list(i, bts_ids)) {
1341 continue;
1342 }
1343 T.start;
1344 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001345 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01001346 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1347 }
1348 [] IPA_RSL[i].receive { repeat; }
1349 [] T.timeout { }
1350 }
Harald Welte6f521d82017-12-11 19:52:02 +01001351 }
1352
1353 setverdict(pass);
1354}
1355
Harald Welte5d1a2202017-12-13 19:51:29 +01001356const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001357const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001358const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1359const BtsIdList c_BtsId_LAC2 := { 2 };
1360
Harald Welte6f521d82017-12-11 19:52:02 +01001361/* PAGING by IMSI + TMSI */
1362testcase TC_paging_imsi_nochan() runs on test_CT {
1363 var BSSMAP_FIELD_CellIdentificationList cid_list;
1364 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001365 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001366 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001367}
1368
1369/* PAGING by IMSI + TMSI */
1370testcase TC_paging_tmsi_nochan() runs on test_CT {
1371 var BSSMAP_FIELD_CellIdentificationList cid_list;
1372 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001373 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001374 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001375}
1376
1377/* Paging with different "channel needed' values */
1378testcase TC_paging_tmsi_any() runs on test_CT {
1379 var BSSMAP_FIELD_CellIdentificationList cid_list;
1380 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001381 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001382 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001383}
1384testcase TC_paging_tmsi_sdcch() runs on test_CT {
1385 var BSSMAP_FIELD_CellIdentificationList cid_list;
1386 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001387 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001388 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001389}
1390testcase TC_paging_tmsi_tch_f() runs on test_CT {
1391 var BSSMAP_FIELD_CellIdentificationList cid_list;
1392 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001393 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001394 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001395}
1396testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1397 var BSSMAP_FIELD_CellIdentificationList cid_list;
1398 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001399 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001400 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001401}
1402
1403/* Paging by CGI */
1404testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1405 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1406 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001407 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001408 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001409}
1410
1411/* Paging by LAC+CI */
1412testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1413 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1414 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001415 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001416 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001417}
1418
1419/* Paging by CI */
1420testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1421 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1422 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001423 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001424 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001425}
1426
1427/* Paging by LAI */
1428testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1429 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1430 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001431 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001432 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001433}
1434
1435/* Paging by LAC */
1436testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1437 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1438 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001439 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001440 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001441}
1442
1443/* Paging by "all in BSS" */
1444testcase TC_paging_imsi_nochan_all() runs on test_CT {
1445 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1446 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001447 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001448 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001449}
1450
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001451/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001452testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1453 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1454 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 +01001455 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001456 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001457}
Harald Welte6f521d82017-12-11 19:52:02 +01001458
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001459/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001460testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1461 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1462 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001463 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001464 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001465}
1466
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001467/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001468testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1469 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1470 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001471 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001472 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001473}
1474
Harald Welte6f521d82017-12-11 19:52:02 +01001475/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001476testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1477 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1478 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1479 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001480 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001481}
1482
1483/* Paging on empty list: Verify none of them page */
1484testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1485 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1486 cid_list := { cIl_LAC := { } };
1487 f_pageing_helper('001010000000016'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}
1490
Stefan Sperling049a86e2018-03-20 15:51:00 +01001491/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1492testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1493 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1494 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1495 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1496 f_shutdown_helper();
1497}
1498
Harald Welte6f521d82017-12-11 19:52:02 +01001499/* Verify paging retransmission interval + count */
1500/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001501/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001502
Harald Weltee65d40e2017-12-13 00:09:06 +01001503/* Verify PCH load */
1504testcase TC_paging_imsi_load() runs on test_CT {
1505 var BSSMAP_FIELD_CellIdentificationList cid_list;
1506 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001507 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001508 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001509 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001510
1511 /* tell BSC there is no paging space anymore */
1512 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001513 f_sleep(0.2);
1514 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001515
1516 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1517 * there would be 8 retransmissions during 4 seconds */
1518 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001519 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001520 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001521 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01001522 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02001523 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01001524 }
Harald Welte2caa1062018-03-17 18:19:05 +01001525 [] T_retrans.timeout {
1526 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1527 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1528 T_retrans.start;
1529 repeat;
1530 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001531 [] T.timeout {
1532 setverdict(pass);
1533 }
1534 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001535
1536 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001537}
1538
Harald Welte235ebf12017-12-15 14:18:16 +01001539/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001540testcase TC_paging_counter() runs on test_CT {
1541 var BSSMAP_FIELD_CellIdentificationList cid_list;
1542 timer T := 4.0;
1543 var integer i;
1544 var integer paging_attempted_bsc;
1545 var integer paging_attempted_bts[NUM_BTS];
1546 var integer paging_expired_bts[NUM_BTS];
1547 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1548
1549 f_init();
1550
1551 /* read counters before paging */
1552 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1553 for (i := 0; i < NUM_BTS; i := i+1) {
1554 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1555 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1556 }
1557
1558 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1559
1560 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1561 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1562 for (i := 0; i < NUM_BTS; i := i+1) {
1563 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1564 paging_attempted_bts[i]+1);
1565 }
1566
1567 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1568 f_sleep(12.0);
1569 for (i := 0; i < NUM_BTS; i := i+1) {
1570 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1571 paging_expired_bts[i]+1);
1572 }
Harald Welte1ff69992017-12-14 12:31:17 +01001573
Philipp Maier282ca4b2018-02-27 17:17:00 +01001574 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001575}
1576
1577
Harald Welte10985002017-12-12 09:29:15 +01001578/* Verify paging stops after A-RESET */
1579testcase TC_paging_imsi_a_reset() runs on test_CT {
1580 var BSSMAP_FIELD_CellIdentificationList cid_list;
1581 timer T := 3.0;
1582 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001583 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001584
1585 /* Perform a BSSMAP Reset and wait for ACK */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001586 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte10985002017-12-12 09:29:15 +01001587 alt {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001588 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte10985002017-12-12 09:29:15 +01001589 [] BSSAP.receive { repeat; }
1590 }
1591
Daniel Willmanncbef3982018-07-30 09:22:40 +02001592 /* Wait to avoid a possible race condition if a paging message is
1593 * received right before the reset ACK. */
1594 f_sleep(0.2);
1595
Harald Welte10985002017-12-12 09:29:15 +01001596 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001597 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1598 IPA_RSL[i].clear;
1599 }
Harald Welte10985002017-12-12 09:29:15 +01001600
1601 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1602 T.start;
1603 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001604 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01001605 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001606 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01001607 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001608 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01001609 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001610 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001611 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001612 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01001613 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001614 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001615 }
Harald Welte10985002017-12-12 09:29:15 +01001616 [] T.timeout {
1617 setverdict(pass);
1618 }
1619 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001620
1621 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001622}
Harald Welteae026692017-12-09 01:03:01 +01001623
Philipp Maierf45824a2019-08-14 14:44:10 +02001624/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
1625 * paging response we can not know which MSC is in charge, so we will blindly
1626 * pick the first configured MSC. This behavior is required in order to make
1627 * MT-CSFB calls working because in those cases the BSC can not know that the
1628 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
1629 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001630 */
1631testcase TC_paging_resp_unsol() runs on test_CT {
1632
1633 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02001634 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001635
1636 var BSSAP_N_CONNECT_ind rx_c_ind;
1637 var DchanTuple dt;
1638 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02001639 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001640
1641 /* Send CHAN RQD and wait for allocation; acknowledge it */
1642 dt.rsl_chan_nr := f_chreq_act_ack();
1643
1644 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
1645 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
1646
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001647
Philipp Maierf45824a2019-08-14 14:44:10 +02001648 /* Expevct a CR with a matching Paging response on the A-Interface */
1649 T.start;
1650 alt {
1651 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
1652 setverdict(pass);
1653 }
1654 [] BSSAP.receive {
1655 setverdict(fail, "Received unexpected message on A-Interface!");
1656 }
1657 [] T.timeout {
1658 setverdict(fail, "Received nothing on A-Interface!");
1659 }
1660 }
1661
1662 setverdict(pass);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001663}
1664
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001665/* Test RSL link drop causes counter increment */
1666testcase TC_rsl_drop_counter() runs on test_CT {
1667 var integer rsl_fail;
1668
Harald Welte89d42e82017-12-17 16:42:41 +01001669 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001670
1671 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1672
1673 bts[0].rsl.vc_IPA.stop;
1674
1675 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1676
1677 setverdict(pass);
1678}
1679
1680/* TODO: Test OML link drop causes counter increment */
1681
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001682/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1683function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1684 timer T := 10.0;
1685
1686 bts[0].rsl.id := "IPA-0-RSL";
1687 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1688 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1689 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02001690 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001691
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001692 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1693
1694 f_init_mgcp("VirtMSC");
1695
1696 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1697 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1698 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1699 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1700
1701 /* wait for IPA OML link to connect and then disconnect */
1702 T.start;
1703 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07001704 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001705 T.stop;
1706 return true;
1707 }
1708 [] IPA_RSL[0].receive { repeat }
1709 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02001710 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001711 }
1712 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001713 return false;
1714}
1715
1716/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1717testcase TC_rsl_unknown_unit_id() runs on test_CT {
1718 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1719 setverdict(pass);
1720 } else {
1721 setverdict(fail, "Timeout RSL waiting for connection to close");
1722 }
1723}
1724
1725
1726/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1727testcase TC_oml_unknown_unit_id() runs on test_CT {
1728 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1729 setverdict(pass);
1730 } else {
1731 setverdict(fail, "Timeout OML waiting for connection to close");
1732 }
1733}
1734
1735
Harald Weltec1a2fff2017-12-17 11:06:19 +01001736/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02001737 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01001738 ***********************************************************************/
1739
Harald Welte6811d102019-04-14 22:23:14 +02001740import from RAN_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01001741import from RSL_Emulation all;
1742import from MSC_ConnectionHandler all;
1743
1744type function void_fn(charstring id) runs on MSC_ConnHdlr;
1745
Harald Welte336820c2018-05-31 20:34:52 +02001746/* helper function to create and connect a MSC_ConnHdlr component */
Harald Welteff579f92018-05-31 22:19:39 +02001747private function f_connect_handler(inout MSC_ConnHdlr vc_conn) runs on test_CT {
Harald Welte6811d102019-04-14 22:23:14 +02001748 connect(vc_conn:RAN, g_bssap.vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001749 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001750 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001751 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001752 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001753 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1754 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1755 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02001756 if (isvalue(bts[2])) {
1757 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
1758 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
1759 }
Harald Welte6811d102019-04-14 22:23:14 +02001760 connect(vc_conn:BSSAP, g_bssap.vc_RAN:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001761 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02001762 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Harald Welte336820c2018-05-31 20:34:52 +02001763}
1764
1765function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
1766runs on test_CT return MSC_ConnHdlr {
1767 var charstring id := testcasename();
1768 var MSC_ConnHdlr vc_conn;
1769 vc_conn := MSC_ConnHdlr.create(id);
1770 f_connect_handler(vc_conn);
Harald Weltea0630032018-03-20 21:09:55 +01001771 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001772 return vc_conn;
1773}
1774
Harald Weltea0630032018-03-20 21:09:55 +01001775/* first function inside ConnHdlr component; sets g_pars + starts function */
1776private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1777runs on MSC_ConnHdlr {
1778 if (isvalue(pars)) {
1779 g_pars := valueof(pars);
1780 }
1781 fn.apply(id);
1782}
1783
Harald Welte3c86ea02018-05-10 22:28:05 +02001784/* Establish signalling channel (non-assignment case) followed by cipher mode */
1785private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001786 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1787 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001788 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02001789 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
1790 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
1791 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
1792 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02001793
Philipp Maier23000732018-05-18 11:25:37 +02001794 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02001795}
1796testcase TC_ciph_mode_a5_0() runs on test_CT {
1797 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001798 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001799 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1800
1801 f_init(1, true);
1802 f_sleep(1.0);
1803 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1804 vc_conn.done;
1805}
1806testcase TC_ciph_mode_a5_1() runs on test_CT {
1807 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001808 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001809 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1810
1811 f_init(1, true);
1812 f_sleep(1.0);
1813 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1814 vc_conn.done;
1815}
1816testcase TC_ciph_mode_a5_3() runs on test_CT {
1817 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001818 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001819 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1820
1821 f_init(1, true);
1822 f_sleep(1.0);
1823 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1824 vc_conn.done;
1825}
1826
1827
1828/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001829private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001830 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1831 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001832
Harald Welte552620d2017-12-16 23:21:36 +01001833 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1834 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001835
Harald Weltea0630032018-03-20 21:09:55 +01001836 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001837}
Harald Welte552620d2017-12-16 23:21:36 +01001838testcase TC_assignment_fr_a5_0() runs on test_CT {
1839 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001840 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001841 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001842
Harald Welte89d42e82017-12-17 16:42:41 +01001843 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001844 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001845 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001846 vc_conn.done;
1847}
Harald Welte552620d2017-12-16 23:21:36 +01001848testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001849 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001850 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001851 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001852
Harald Welte89d42e82017-12-17 16:42:41 +01001853 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001854 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001855 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1856 vc_conn.done;
1857}
1858testcase TC_assignment_fr_a5_3() runs on test_CT {
1859 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001860 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001861 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001862
Harald Welte651fcdc2018-05-10 20:23:16 +02001863 f_init(1, true);
1864 f_sleep(1.0);
1865 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001866 vc_conn.done;
1867}
1868
Harald Welte552620d2017-12-16 23:21:36 +01001869/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1870private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001871 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01001872 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001873 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001874 const OCT8 kc := '0001020304050607'O;
1875
1876 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001877 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
1878
Harald Weltea0630032018-03-20 21:09:55 +01001879 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001880}
Harald Welte552620d2017-12-16 23:21:36 +01001881testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1882 var MSC_ConnHdlr vc_conn;
1883
Harald Welte89d42e82017-12-17 16:42:41 +01001884 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001885 f_sleep(1.0);
1886
Harald Welte8863fa12018-05-10 20:15:27 +02001887 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001888 vc_conn.done;
1889}
1890
Harald Welte552620d2017-12-16 23:21:36 +01001891private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001892 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02001893 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1894 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001895 const OCT8 kc := '0001020304050607'O;
1896 const OCT16 kc128 := kc & kc;
1897
1898 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1899 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001900 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001901 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001902 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001903}
Harald Welte552620d2017-12-16 23:21:36 +01001904testcase TC_assignment_fr_a5_4() runs on test_CT {
1905 var MSC_ConnHdlr vc_conn;
1906
Harald Welte89d42e82017-12-17 16:42:41 +01001907 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001908 f_sleep(1.0);
1909
Harald Welte8863fa12018-05-10 20:15:27 +02001910 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001911 vc_conn.done;
1912}
1913
1914
Harald Welte4532e0a2017-12-23 02:05:44 +01001915private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001916 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01001917 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02001918 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01001919 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001920 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001921}
1922
1923testcase TC_assignment_sign() runs on test_CT {
1924 var MSC_ConnHdlr vc_conn;
1925
1926 f_init(1, true);
1927 f_sleep(1.0);
1928
Harald Welte8863fa12018-05-10 20:15:27 +02001929 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001930 vc_conn.done;
1931}
1932
Harald Welte60aa5762018-03-21 19:33:13 +01001933/***********************************************************************
1934 * Codec (list) testing
1935 ***********************************************************************/
1936
1937/* check if the given rsl_mode is compatible with the a_elem */
1938private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1939return boolean {
1940 select (a_elem.codecType) {
1941 case (GSM_FR) {
1942 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1943 return true;
1944 }
1945 }
1946 case (GSM_HR) {
1947 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1948 return true;
1949 }
1950 }
1951 case (GSM_EFR) {
1952 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1953 return true;
1954 }
1955 }
1956 case (FR_AMR) {
1957 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1958 return true;
1959 }
1960 }
1961 case (HR_AMR) {
1962 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1963 return true;
1964 }
1965 }
1966 case else { }
1967 }
1968 return false;
1969}
1970
1971/* check if the given rsl_mode is compatible with the a_list */
1972private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
1973return boolean {
1974 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
1975 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
1976 return true;
1977 }
1978 }
1979 return false;
1980}
1981
1982/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02001983function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01001984return BSSMAP_IE_ChannelType {
1985 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
1986 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
1987 select (a_elem.codecType) {
1988 case (GSM_FR) {
1989 ret.channelRateAndType := ChRate_TCHF;
1990 ret.speechId_DataIndicator := Spdi_TCHF_FR;
1991 }
1992 case (GSM_HR) {
1993 ret.channelRateAndType := ChRate_TCHH;
1994 ret.speechId_DataIndicator := Spdi_TCHH_HR;
1995 }
1996 case (GSM_EFR) {
1997 ret.channelRateAndType := ChRate_TCHF;
1998 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
1999 }
2000 case (FR_AMR) {
2001 ret.channelRateAndType := ChRate_TCHF;
2002 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
2003 }
2004 case (HR_AMR) {
2005 ret.channelRateAndType := ChRate_TCHH;
2006 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
2007 }
2008 case else {
2009 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02002010 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01002011 }
2012 }
2013 return ret;
2014}
2015
Harald Weltea63b9102018-03-22 20:36:16 +01002016private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
2017return template RSL_IE_Body {
2018 var template RSL_IE_Body mode_ie := {
2019 chan_mode := {
2020 len := ?,
2021 reserved := ?,
2022 dtx_d := ?,
2023 dtx_u := ?,
2024 spd_ind := RSL_SPDI_SPEECH,
2025 ch_rate_type := -,
2026 coding_alg_rate := -
2027 }
2028 }
2029
2030 select (a_elem.codecType) {
2031 case (GSM_FR) {
2032 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2033 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2034 }
2035 case (GSM_HR) {
2036 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2037 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2038 }
2039 case (GSM_EFR) {
2040 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2041 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
2042 }
2043 case (FR_AMR) {
2044 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2045 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2046 }
2047 case (HR_AMR) {
2048 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2049 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2050 }
2051 }
2052 return mode_ie;
2053}
2054
Harald Welte60aa5762018-03-21 19:33:13 +01002055type record CodecListTest {
2056 BSSMAP_IE_SpeechCodecList codec_list,
2057 charstring id
2058}
2059type record of CodecListTest CodecListTests
2060
2061private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002062 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
2063 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01002064
2065 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Harald Welte79f3f542018-05-25 20:02:37 +02002066 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2067 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2068 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
2069 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01002070 if (isvalue(g_pars.expect_mr_s0_s7)) {
2071 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
2072 g_pars.expect_mr_s0_s7;
2073 }
Harald Welte79f3f542018-05-25 20:02:37 +02002074 }
Harald Welte60aa5762018-03-21 19:33:13 +01002075 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2076 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01002077 log("expecting ASS COMPL like this: ", exp_compl);
2078
2079 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01002080
2081 /* Verify that the RSL-side activation actually matches our expectations */
2082 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
2083
2084 var RSL_IE_Body mode_ie;
2085 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
2086 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02002087 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01002088 }
2089 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
2090 if (not match(mode_ie, t_mode_ie)) {
2091 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
2092 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002093
2094 var RSL_IE_Body mr_conf;
2095 if (g_pars.expect_mr_conf_ie != omit) {
2096 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
2097 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02002098 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002099 }
2100 log("found RSL MR CONFIG IE: ", mr_conf);
2101
2102 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
2103 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
2104 g_pars.expect_mr_conf_ie);
2105 }
2106 } else {
2107 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
2108 log("found RSL MR CONFIG IE: ", mr_conf);
2109 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02002110 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002111 }
2112 }
Harald Welte60aa5762018-03-21 19:33:13 +01002113}
2114
Philipp Maierd0e64b02019-03-13 14:15:23 +01002115private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
2116
2117 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2118 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2119
2120 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
2121 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2122 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2123 }
2124 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2125 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
2126 log("expecting ASS FAIL like this: ", exp_fail);
2127
2128 f_establish_fully(ass_cmd, exp_fail);
2129}
2130
Harald Welte60aa5762018-03-21 19:33:13 +01002131testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002132 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002133 var MSC_ConnHdlr vc_conn;
2134
2135 f_init(1, true);
2136 f_sleep(1.0);
2137
2138 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002139 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002140 vc_conn.done;
2141}
2142
2143testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002144 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002145 var MSC_ConnHdlr vc_conn;
2146
2147 f_init(1, true);
2148 f_sleep(1.0);
2149
2150 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002151 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002152 vc_conn.done;
2153}
2154
2155testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002156 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002157 var MSC_ConnHdlr vc_conn;
2158
2159 f_init(1, true);
2160 f_sleep(1.0);
2161
2162 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002163 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002164 vc_conn.done;
2165}
2166
Philipp Maierd0e64b02019-03-13 14:15:23 +01002167/* Allow 5,90k only (current default config) */
2168private function f_allow_amr_rate_5_90k() runs on test_CT {
2169 f_vty_enter_cfg_msc(BSCVTY, 0);
2170 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
2171 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2172 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2173 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
2174 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2175 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2176 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2177 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
2178 f_vty_transceive(BSCVTY, "exit");
2179 f_vty_transceive(BSCVTY, "exit");
2180}
2181
2182/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
2183 * ("Config-NB-Code = 1") */
2184private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
2185 f_vty_enter_cfg_msc(BSCVTY, 0);
2186 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
2187 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2188 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2189 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
2190 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2191 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2192 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2193 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
2194 f_vty_transceive(BSCVTY, "exit");
2195 f_vty_transceive(BSCVTY, "exit");
2196}
2197
Harald Welte60aa5762018-03-21 19:33:13 +01002198testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002199 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002200 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002201
2202 /* Note: This setups the codec configuration. The parameter payload in
2203 * mr_conf must be consistant with the parameter codecElements in pars
2204 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002205 var RSL_IE_Body mr_conf := {
2206 other := {
2207 len := 2,
2208 payload := '2804'O
2209 }
2210 };
Harald Welte60aa5762018-03-21 19:33:13 +01002211
Philipp Maier7695a0d2018-09-27 17:52:14 +02002212 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002213 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002214 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
2215 pars.expect_mr_conf_ie := mr_conf;
2216
Harald Welte60aa5762018-03-21 19:33:13 +01002217 f_init(1, true);
2218 f_sleep(1.0);
2219
Harald Welte8863fa12018-05-10 20:15:27 +02002220 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002221 vc_conn.done;
2222}
2223
2224testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002225 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002226 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002227
2228 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002229 var RSL_IE_Body mr_conf := {
2230 other := {
2231 len := 2,
2232 payload := '2804'O
2233 }
2234 };
Harald Welte60aa5762018-03-21 19:33:13 +01002235
Philipp Maier7695a0d2018-09-27 17:52:14 +02002236 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002237 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002238 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2239 pars.expect_mr_conf_ie := mr_conf;
2240
Harald Welte60aa5762018-03-21 19:33:13 +01002241 f_init(1, true);
2242 f_sleep(1.0);
2243
Harald Welte8863fa12018-05-10 20:15:27 +02002244 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002245 vc_conn.done;
2246}
2247
Philipp Maierd0e64b02019-03-13 14:15:23 +01002248function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
2249runs on test_CT {
2250
2251 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2252 var MSC_ConnHdlr vc_conn;
2253
2254 /* See note above */
2255 var RSL_IE_Body mr_conf := {
2256 other := {
2257 len := lengthof(mrconf),
2258 payload := mrconf
2259 }
2260 };
2261
2262 if (fr) {
2263 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2264 } else {
2265 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2266 }
2267 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2268 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2269 pars.expect_mr_conf_ie := mr_conf;
2270 pars.expect_mr_s0_s7 := exp_s8_s0;
2271
2272 f_init(1, true);
2273 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2274 f_sleep(1.0);
2275
2276 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2277 vc_conn.done;
2278 f_allow_amr_rate_5_90k();
2279}
2280
2281function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
2282runs on test_CT {
2283
2284 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2285 var MSC_ConnHdlr vc_conn;
2286
2287 if (fr) {
2288 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2289 } else {
2290 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2291 }
2292 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2293 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2294
2295 f_init(1, true);
2296 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2297 f_sleep(1.0);
2298
2299 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
2300 vc_conn.done;
2301 f_allow_amr_rate_5_90k();
2302}
2303
2304
2305/* Set S1, we expect an AMR multirate configuration IE with all four rates
2306 * set. */
2307testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
2308 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
2309}
2310
2311/* Set S1, we expect an AMR multirate configuration IE with the lower three
2312 * rates set. */
2313testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
2314 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
2315}
2316
2317/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2318 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2319testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
2320 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
2321}
2322
2323/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2324 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2325testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
2326 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
2327}
2328
2329/* The following block of tests selects more and more rates until all four
2330 * possible rates are in the active set (full rate) */
2331testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
2332 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
2333}
2334
2335testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
2336 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
2337}
2338
2339testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
2340 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
2341}
2342
2343testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
2344 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
2345}
2346
2347/* The following block of tests selects more and more rates until all three
2348 * possible rates are in the active set (half rate) */
2349testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
2350 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
2351}
2352
2353testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
2354 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
2355}
2356
2357testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
2358 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
2359}
2360
2361/* The following block tests what happens when the MSC does offer rate
2362 * configurations that are not supported by the BSC. Normally such situations
2363 * should not happen because the MSC gets informed by the BSC in advance via
2364 * the L3 COMPLETE message which rates are applicable. The MSC should not try
2365 * to offer rates that are not applicable anyway. */
2366
2367testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
2368 /* Try to include 12,2k in into the active set even though the channel
2369 * is half rate only. The BSC is expected to remove the 12,0k */
2370 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
2371}
2372
2373testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
2374 /* See what happens when all rates are selected at once. Since then
2375 * Also S1 is selected, this setting will be prefered and we should
2376 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
2377 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
2378}
2379
2380testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
2381 /* Same as above, but with S1 missing, the MSC is then expected to
2382 * select the currently supported rates, which are also 12.2k, 7,40k,
2383 * 5,90k, and 4,75k, into the active set. */
2384 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
2385}
2386
2387testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
2388 /* Try to select no rates at all */
2389 f_TC_assignment_codec_amr_fail(true, '00000000'B);
2390}
2391
2392testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
2393 /* Try to select only unsupported rates */
2394 f_TC_assignment_codec_amr_fail(true, '01101000'B);
2395}
2396
2397testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
2398 /* Try to select 12,2k for half rate */
2399 f_TC_assignment_codec_amr_fail(false, '10000000'B);
2400}
2401
Philipp Maierac09bfc2019-01-08 13:41:39 +01002402private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002403 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
2404 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
2405 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
2406 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002407}
2408
2409private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002410 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
2411 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002412}
2413
2414private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002415 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
2416 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
2417 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
2418 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
2419 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
2420 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002421}
2422
2423/* Allow HR only */
2424private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
2425 g_pars := f_gen_test_hdlr_pars();
2426 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2427 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2428 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2429 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2430 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2431 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2432 f_establish_fully(ass_cmd, exp_compl);
2433}
2434
2435/* Allow FR only */
2436private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
2437 g_pars := f_gen_test_hdlr_pars();
2438 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2439 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2440 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2441 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2442 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2443 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2444 f_establish_fully(ass_cmd, exp_compl);
2445}
2446
2447/* Allow HR only (expect assignment failure) */
2448private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
2449 g_pars := f_gen_test_hdlr_pars();
2450 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2451 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2452 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2453 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2454 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2455 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2456 f_establish_fully(ass_cmd, exp_fail);
2457}
2458
2459/* Allow FR only (expect assignment failure) */
2460private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(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_fail := tr_BSSMAP_AssignmentFail;
2464 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2465 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2466 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2467 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2468 f_establish_fully(ass_cmd, exp_fail);
2469}
2470
2471/* Allow FR and HR, but prefer FR */
2472private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(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 := '0A'O; /* Prefer FR */
2478 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2479 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2480 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2481 f_establish_fully(ass_cmd, exp_compl);
2482}
2483
2484/* Allow FR and HR, but prefer HR */
2485private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2486 g_pars := f_gen_test_hdlr_pars();
2487 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2488 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2489 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2490 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2491 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2492 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2493 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2494 f_establish_fully(ass_cmd, exp_compl);
2495}
2496
2497/* Allow FR and HR, but prefer FR */
2498private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2499 g_pars := f_gen_test_hdlr_pars();
2500 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2501 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2502 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2503 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2504 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2505 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2506 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2507 f_establish_fully(ass_cmd, exp_compl);
2508}
2509
2510/* Allow FR and HR, but prefer HR */
2511private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2512 g_pars := f_gen_test_hdlr_pars();
2513 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2514 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2515 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2516 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2517 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2518 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2519 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2520 f_establish_fully(ass_cmd, exp_compl);
2521}
2522
2523/* Request a HR channel while all FR channels are exhausted, this is expected
2524 * to work without conflicts */
2525testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
2526 var MSC_ConnHdlr vc_conn;
2527 f_init(1, true);
2528 f_sleep(1.0);
2529 f_enable_all_tch();
2530 f_disable_all_tch_f();
2531 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
2532 vc_conn.done;
2533 f_enable_all_tch();
2534 setverdict(pass);
2535}
2536
2537/* Request a FR channel while all FR channels are exhausted, this is expected
2538 * to fail. */
2539testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
2540 var MSC_ConnHdlr vc_conn;
2541 f_init(1, true);
2542 f_sleep(1.0);
2543 f_enable_all_tch();
2544 f_disable_all_tch_f();
2545 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
2546 vc_conn.done;
2547 f_enable_all_tch();
2548 setverdict(pass);
2549}
2550
2551/* Request a FR (prefered) or alternatively a HR channel while all FR channels
2552 * are exhausted, this is expected to be resolved by selecting a HR channel. */
2553testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
2554 var MSC_ConnHdlr vc_conn;
2555 f_init(1, true);
2556 f_sleep(1.0);
2557 f_enable_all_tch();
2558 f_disable_all_tch_f();
2559 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
2560 vc_conn.done;
2561 f_enable_all_tch();
2562 setverdict(pass);
2563}
2564
2565/* Request a HR (prefered) or alternatively a FR channel while all FR channels
2566 * are exhausted, this is expected to work without conflicts. */
2567testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
2568 var MSC_ConnHdlr vc_conn;
2569 f_init(1, true);
2570 f_sleep(1.0);
2571 f_enable_all_tch();
2572 f_disable_all_tch_f();
2573 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
2574 vc_conn.done;
2575 f_enable_all_tch();
2576 setverdict(pass);
2577}
2578
2579/* Request a FR channel while all HR channels are exhausted, this is expected
2580 * to work without conflicts */
2581testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
2582 var MSC_ConnHdlr vc_conn;
2583 f_init(1, true);
2584 f_sleep(1.0);
2585 f_enable_all_tch();
2586 f_disable_all_tch_h();
2587 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
2588 vc_conn.done;
2589 f_enable_all_tch();
2590 setverdict(pass);
2591}
2592
2593/* Request a HR channel while all HR channels are exhausted, this is expected
2594 * to fail. */
2595testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
2596 var MSC_ConnHdlr vc_conn;
2597 f_init(1, true);
2598 f_sleep(1.0);
2599 f_enable_all_tch();
2600 f_disable_all_tch_h();
2601 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
2602 vc_conn.done;
2603 f_enable_all_tch();
2604 setverdict(pass);
2605}
2606
2607/* Request a HR (prefered) or alternatively a FR channel while all HR channels
2608 * are exhausted, this is expected to be resolved by selecting a FR channel. */
2609testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
2610 var MSC_ConnHdlr vc_conn;
2611 f_init(1, true);
2612 f_sleep(1.0);
2613 f_enable_all_tch();
2614 f_disable_all_tch_h();
2615 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
2616 vc_conn.done;
2617 f_enable_all_tch();
2618 setverdict(pass);
2619}
2620
2621/* Request a FR (prefered) or alternatively a HR channel while all HR channels
2622 * are exhausted, this is expected to work without conflicts. */
2623testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
2624 var MSC_ConnHdlr vc_conn;
2625 f_init(1, true);
2626 f_sleep(1.0);
2627 f_enable_all_tch();
2628 f_disable_all_tch_h();
2629 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
2630 vc_conn.done;
2631 f_enable_all_tch();
2632 setverdict(pass);
2633}
2634
2635/* Allow FR and HR, but prefer HR */
2636private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2637 g_pars := f_gen_test_hdlr_pars();
2638 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2639 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2640 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2641 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2642 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2643 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2644 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2645 f_establish_fully(ass_cmd, exp_compl);
2646}
2647
2648/* Allow FR and HR, but prefer FR */
2649private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2650 g_pars := f_gen_test_hdlr_pars();
2651 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2652 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2653 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2654 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2655 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2656 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2657 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2658 f_establish_fully(ass_cmd, exp_compl);
2659}
2660
2661/* Request a HR (prefered) or alternatively a FR channel, it is expected that
2662 * HR, which is the prefered type, is selected. */
2663testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
2664 var MSC_ConnHdlr vc_conn;
2665 f_init(1, true);
2666 f_sleep(1.0);
2667 f_enable_all_tch();
2668 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
2669 vc_conn.done;
2670 setverdict(pass);
2671}
2672
2673/* Request a FR (prefered) or alternatively a HR channel, it is expected that
2674 * FR, which is the prefered type, is selected. */
2675testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
2676 var MSC_ConnHdlr vc_conn;
2677 f_init(1, true);
2678 f_sleep(1.0);
2679 f_enable_all_tch();
2680 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
2681 vc_conn.done;
2682 setverdict(pass);
2683}
2684
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002685testcase TC_assignment_osmux() runs on test_CT {
2686 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2687 var MSC_ConnHdlr vc_conn;
2688
2689 /* See note above */
2690 var RSL_IE_Body mr_conf := {
2691 other := {
2692 len := 2,
2693 payload := '2804'O
2694 }
2695 };
2696
2697 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2698 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
2699 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2700 pars.expect_mr_conf_ie := mr_conf;
2701 pars.use_osmux := true;
2702
2703 f_init(1, true, true);
2704 f_sleep(1.0);
2705
2706 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2707 vc_conn.done;
2708}
2709
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002710/* test the procedure of the MSC requesting a Classmark Update:
2711 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
2712 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01002713private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002714 g_pars := f_gen_test_hdlr_pars();
2715
Harald Weltea0630032018-03-20 21:09:55 +01002716 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002717 /* we should now have a COMPL_L3 at the MSC */
2718 BSSAP.receive(tr_BSSMAP_ComplL3);
2719
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002720 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
2721 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
2722
Harald Welte898113b2018-01-31 18:32:21 +01002723 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
2724 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
2725 setverdict(pass);
2726}
2727testcase TC_classmark() runs on test_CT {
2728 var MSC_ConnHdlr vc_conn;
2729 f_init(1, true);
2730 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002731 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01002732 vc_conn.done;
2733}
2734
Harald Weltee3bd6582018-01-31 22:51:25 +01002735private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002736 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002737 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002738 /* we should now have a COMPL_L3 at the MSC */
2739 BSSAP.receive(tr_BSSMAP_ComplL3);
2740
Harald Weltee3bd6582018-01-31 22:51:25 +01002741 /* send the single message we want to send */
2742 f_rsl_send_l3(l3);
2743}
2744
2745private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
2746 timer T := sec;
2747 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01002748 T.start;
2749 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01002750 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
2751 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02002752 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01002753 }
2754 [] T.timeout {
2755 setverdict(pass);
2756 }
2757 }
2758}
2759
Harald Weltee3bd6582018-01-31 22:51:25 +01002760/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2761private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
2762 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
2763 f_bssap_expect_nothing();
2764}
Harald Welte898113b2018-01-31 18:32:21 +01002765testcase TC_unsol_ass_fail() runs on test_CT {
2766 var MSC_ConnHdlr vc_conn;
2767 f_init(1, true);
2768 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002769 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01002770 vc_conn.done;
2771}
Harald Welte552620d2017-12-16 23:21:36 +01002772
Harald Welteea99a002018-01-31 20:46:43 +01002773
2774/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
2775private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002776 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
2777 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01002778}
2779testcase TC_unsol_ass_compl() runs on test_CT {
2780 var MSC_ConnHdlr vc_conn;
2781 f_init(1, true);
2782 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002783 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01002784 vc_conn.done;
2785}
2786
2787
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002788/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2789private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002790 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
2791 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002792}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002793testcase TC_unsol_ho_fail() runs on test_CT {
2794 var MSC_ConnHdlr vc_conn;
2795 f_init(1, true);
2796 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002797 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002798 vc_conn.done;
2799}
2800
2801
Harald Weltee3bd6582018-01-31 22:51:25 +01002802/* short message from MS should be ignored */
2803private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002804 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002805 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01002806 /* we should now have a COMPL_L3 at the MSC */
2807 BSSAP.receive(tr_BSSMAP_ComplL3);
2808
2809 /* send short message */
2810 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
2811 f_bssap_expect_nothing();
2812}
2813testcase TC_err_82_short_msg() runs on test_CT {
2814 var MSC_ConnHdlr vc_conn;
2815 f_init(1, true);
2816 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002817 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01002818 vc_conn.done;
2819}
2820
2821
Harald Weltee9e02e42018-01-31 23:36:25 +01002822/* 24.008 8.4 Unknown message must trigger RR STATUS */
2823private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
2824 f_est_single_l3(ts_RRM_UL_REL('00'O));
2825 timer T := 3.0
2826 alt {
2827 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
2828 setverdict(pass);
2829 }
2830 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01002831 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01002832 }
2833}
2834testcase TC_err_84_unknown_msg() runs on test_CT {
2835 var MSC_ConnHdlr vc_conn;
2836 f_init(1, true);
2837 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002838 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01002839 vc_conn.done;
2840}
2841
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002842/***********************************************************************
2843 * Handover
2844 ***********************************************************************/
2845
Harald Welte94e0c342018-04-07 11:33:23 +02002846/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
2847private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
2848runs on test_CT {
2849 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2850 " timeslot "&int2str(ts_nr)&" ";
2851 f_vty_transceive(BSCVTY, cmd & suffix);
2852}
2853
Harald Welte261af4b2018-02-12 21:20:39 +01002854/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
2855private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
2856runs on MSC_ConnHdlr {
2857 /* FIXME: resolve those from component-global state */
2858 var integer ts_nr := chan_nr.tn;
2859 var integer ss_nr;
2860 if (ischosen(chan_nr.u.ch0)) {
2861 ss_nr := 0;
2862 } else if (ischosen(chan_nr.u.lm)) {
2863 ss_nr := chan_nr.u.lm.sub_chan;
2864 } else if (ischosen(chan_nr.u.sdcch4)) {
2865 ss_nr := chan_nr.u.sdcch4.sub_chan;
2866 } else if (ischosen(chan_nr.u.sdcch8)) {
2867 ss_nr := chan_nr.u.sdcch8.sub_chan;
2868 } else {
2869 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02002870 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01002871 }
2872
2873 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2874 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
2875 f_vty_transceive(BSCVTY, cmd & suffix);
2876}
2877
Neels Hofmeyr91401012019-07-11 00:42:35 +02002878/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
2879 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
2880 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
2881 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
2882 * pair, not really to a specific BTS number. */
Harald Welte261af4b2018-02-12 21:20:39 +01002883private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
2884 integer new_bts_nr)
2885runs on MSC_ConnHdlr {
2886 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
2887}
2888
2889/* intra-BSC hand-over between BTS0 and BTS1 */
2890private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002891 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02002892 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2893 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01002894 const OCT8 kc := '0001020304050607'O;
2895
2896 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2897 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2898
Harald Weltea0630032018-03-20 21:09:55 +01002899 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02002900 f_bts_0_cfg({"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01002901
2902 var HandoverState hs := {
2903 rr_ho_cmpl_seen := false,
2904 handover_done := false,
2905 old_chan_nr := -
2906 };
2907 /* issue hand-over command on VTY */
2908 f_vty_handover(0, 0, g_chan_nr, 1);
2909 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2910 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002911
2912 /* From the MGW perspective, a handover is is characterized by
2913 * performing one MDCX operation with the MGW. So we expect to see
2914 * one more MDCX during handover. */
2915 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
2916
Harald Welte261af4b2018-02-12 21:20:39 +01002917 alt {
2918 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01002919 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002920
Philipp Maier4dae0652018-11-12 12:03:26 +01002921 /* Since this is an internal handover we expect the BSC to inform the
2922 * MSC about the event */
2923 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
2924
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002925 /* Check the amount of MGCP transactions is still consistant with the
2926 * test expectation */
2927 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01002928 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01002929}
2930
2931testcase TC_ho_int() runs on test_CT {
2932 var MSC_ConnHdlr vc_conn;
2933 f_init(2, true);
2934 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002935 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002936 vc_conn.done;
2937}
Harald Weltee9e02e42018-01-31 23:36:25 +01002938
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002939/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02002940private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002941 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002942 var template MgcpResponse mgcp_resp;
2943 var MGCP_RecvFrom mrf;
2944 var template MgcpMessage msg_resp;
2945 var template MgcpMessage msg_dlcx := {
2946 command := tr_DLCX()
2947 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002948
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002949 if (g_pars.aoip) {
2950 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002951 log("Got first DLCX: ", mgcp);
2952 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002953 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002954
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002955 MGCP.receive(tr_DLCX()) -> value mgcp {
2956 log("Got second DLCX: ", mgcp);
2957 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
2958 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002959 } else {
2960 /* For SCCPLite, BSC doesn't handle the MSC-side */
2961 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
2962 log("Got first DLCX: ", mrf.msg.command);
2963 msg_resp := {
2964 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
2965 }
2966 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
2967 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002968 }
2969
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02002970 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02002971}
2972
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002973private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002974 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002975
2976 var PDU_BSSAP ass_req := f_gen_ass_req();
2977 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2978 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2979 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2980 f_establish_fully(ass_req, exp_compl);
2981
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02002982 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002983 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2984
2985 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2986
2987 f_sleep(0.5);
2988 /* The MSC negotiates Handover Request and Handover Request Ack with
2989 * the other BSS and comes back with a BSSMAP Handover Command
2990 * containing an RR Handover Command coming from the target BSS... */
2991
2992 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
2993 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
2994 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
2995 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
2996 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
2997
2998 /* expect the Handover Command to go out on RR */
2999 var RSL_Message rsl_ho_cmd
3000 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3001 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3002 var RSL_IE_Body rsl_ho_cmd_l3;
3003 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3004 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3005 setverdict(fail);
3006 } else {
3007 log("Found L3 Info: ", rsl_ho_cmd_l3);
3008 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3009 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3010 setverdict(fail);
3011 } else {
3012 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3013 setverdict(pass);
3014 }
3015 }
3016
3017 /* When the other BSS has reported a completed handover, this side is
3018 * torn down. */
3019
3020 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
3021 var BssmapCause cause := enum2int(cause_val);
3022 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3023
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003024 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003025 setverdict(pass);
3026 f_sleep(1.0);
3027}
3028testcase TC_ho_out_of_this_bsc() runs on test_CT {
3029 var MSC_ConnHdlr vc_conn;
3030
3031 f_init(1, true);
3032 f_sleep(1.0);
3033
3034 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
3035 vc_conn.done;
3036}
3037
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003038/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
3039 * simply never sends a BSSMAP Handover Command. */
3040private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003041 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003042
3043 var PDU_BSSAP ass_req := f_gen_ass_req();
3044 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3045 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3046 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3047 f_establish_fully(ass_req, exp_compl);
3048
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003049 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003050 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3051
3052 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3053
3054 /* osmo-bsc should time out 10 seconds after the handover started.
3055 * Let's give it a bit extra. */
3056 f_sleep(15.0);
3057
3058 /* The old lchan and conn should still be active. See that arbitrary L3
3059 * is still going through. */
3060 var octetstring l3 := '0123456789'O;
3061 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3062 var template PDU_BSSAP exp_data := {
3063 discriminator := '1'B,
3064 spare := '0000000'B,
3065 dlci := '00'O,
3066 lengthIndicator := 5,
3067 pdu := {
3068 dtap := l3
3069 }
3070 };
3071 BSSAP.receive(exp_data);
3072 setverdict(pass);
3073 f_sleep(1.0);
3074}
3075testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
3076 var MSC_ConnHdlr vc_conn;
3077
3078 f_init(1, true);
3079 f_sleep(1.0);
3080
3081 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
3082 vc_conn.done;
3083}
3084
3085/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
3086 * RR Handover Failure. */
3087private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003088 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003089
3090 var PDU_BSSAP ass_req := f_gen_ass_req();
3091 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3092 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3093 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3094 f_establish_fully(ass_req, exp_compl);
3095
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003096 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003097 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3098
3099 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3100
3101 f_sleep(0.5);
3102 /* The MSC negotiates Handover Request and Handover Request Ack with
3103 * the other BSS and comes back with a BSSMAP Handover Command
3104 * containing an RR Handover Command coming from the target BSS... */
3105
3106 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3107 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3108 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3109 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3110 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3111
3112 /* expect the Handover Command to go out on RR */
3113 var RSL_Message rsl_ho_cmd
3114 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3115 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3116 var RSL_IE_Body rsl_ho_cmd_l3;
3117 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3118 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3119 setverdict(fail);
3120 } else {
3121 log("Found L3 Info: ", rsl_ho_cmd_l3);
3122 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3123 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3124 setverdict(fail);
3125 } else {
3126 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3127 setverdict(pass);
3128 }
3129 }
3130
3131 f_sleep(0.2);
3132 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3133
3134 /* Should tell the MSC about the failure */
3135 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3136
3137 f_sleep(1.0);
3138
3139 /* The old lchan and conn should still be active. See that arbitrary L3
3140 * is still going through. */
3141 var octetstring l3 := '0123456789'O;
3142 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3143 var template PDU_BSSAP exp_data := {
3144 discriminator := '1'B,
3145 spare := '0000000'B,
3146 dlci := '00'O,
3147 lengthIndicator := 5,
3148 pdu := {
3149 dtap := l3
3150 }
3151 };
3152 BSSAP.receive(exp_data);
3153 setverdict(pass);
3154 f_sleep(1.0);
3155
3156 setverdict(pass);
3157 f_sleep(1.0);
3158}
3159testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
3160 var MSC_ConnHdlr vc_conn;
3161
3162 f_init(1, true);
3163 f_sleep(1.0);
3164
3165 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
3166 vc_conn.done;
3167}
3168
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003169/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
3170 * (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 +02003171 * and the lchan is released. */
3172private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003173 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003174
3175 var PDU_BSSAP ass_req := f_gen_ass_req();
3176 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3177 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3178 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3179 f_establish_fully(ass_req, exp_compl);
3180
Neels Hofmeyr7e2769f2019-08-14 19:17:53 +02003181 f_bts_0_cfg({"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003182 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3183
3184 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3185
3186 f_sleep(0.5);
3187 /* The MSC negotiates Handover Request and Handover Request Ack with
3188 * the other BSS and comes back with a BSSMAP Handover Command
3189 * containing an RR Handover Command coming from the target BSS... */
3190
3191 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3192 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3193 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3194 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3195 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3196
3197 /* expect the Handover Command to go out on RR */
3198 var RSL_Message rsl_ho_cmd
3199 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3200 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3201 var RSL_IE_Body rsl_ho_cmd_l3;
3202 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3203 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3204 setverdict(fail);
3205 } else {
3206 log("Found L3 Info: ", rsl_ho_cmd_l3);
3207 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3208 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3209 setverdict(fail);
3210 } else {
3211 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3212 setverdict(pass);
3213 }
3214 }
3215
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003216 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
3217 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
3218 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003219
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003220 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02003221 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
3222 log("Got BSSMAP Clear Request");
3223 /* Instruct BSC to clear channel */
3224 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3225 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3226
3227 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003228 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01003229 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
3230 log("Got Deact SACCH");
3231 }
Harald Welte924b6ea2019-02-04 01:05:34 +01003232 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01003233 log("Got RR Release");
3234 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003235 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
3236 log("Got RF Chan Rel");
3237 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
3238 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003239 }
3240
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003241 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003242
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003243 setverdict(pass);
3244 f_sleep(1.0);
3245}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003246testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003247 var MSC_ConnHdlr vc_conn;
3248
3249 f_init(1, true);
3250 f_sleep(1.0);
3251
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003252 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003253 vc_conn.done;
3254}
3255
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003256private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
3257 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3258 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3259 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3260 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3261 * before we get started. */
3262 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3263 f_rslem_register(0, new_chan_nr);
3264 g_chan_nr := new_chan_nr;
3265 f_sleep(1.0);
3266
3267 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3268 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3269 activate(as_Media());
3270
3271 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3272 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003273 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003274
3275 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3276
3277 var PDU_BSSAP rx_bssap;
3278 var octetstring ho_command_str;
3279
3280 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02003281
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003282 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3283 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3284 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3285 log("L3 Info in HO Request Ack is ", ho_command);
3286
3287 var GsmArfcn arfcn;
3288 var RslChannelNr actual_new_chan_nr;
3289 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3290 actual_new_chan_nr, arfcn);
3291
3292 if (actual_new_chan_nr != new_chan_nr) {
3293 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3294 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3295 setverdict(fail);
3296 return;
3297 }
3298 log("Handover Command chan_nr is", actual_new_chan_nr);
3299
3300 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3301 * tells the MS to handover to the new lchan. Here comes the new MS on
3302 * the new lchan with a Handover RACH: */
3303
3304 /* send handover detect */
3305
3306 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3307
3308 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3309
3310 /* send handover complete over the new channel */
3311
3312 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
3313 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
3314 enc_PDU_ML3_MS_NW(l3_tx)));
3315
3316 BSSAP.receive(tr_BSSMAP_HandoverComplete);
3317 setverdict(pass);
3318}
3319testcase TC_ho_into_this_bsc() runs on test_CT {
3320 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003321 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003322
3323 f_init(1, true);
3324 f_sleep(1.0);
3325
3326 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3327 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3328
3329 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
3330 vc_conn.done;
3331}
3332
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003333private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
3334 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3335 f_rslem_register(0, new_chan_nr);
3336 g_chan_nr := new_chan_nr;
3337 f_sleep(1.0);
3338
3339 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3340 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3341 activate(as_Media());
3342
3343 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3344 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003345 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003346
3347 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3348
3349 var PDU_BSSAP rx_bssap;
3350 var octetstring ho_command_str;
3351
3352 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3353
3354 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3355 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3356 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3357 log("L3 Info in HO Request Ack is ", ho_command);
3358
3359 var GsmArfcn arfcn;
3360 var RslChannelNr actual_new_chan_nr;
3361 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3362 actual_new_chan_nr, arfcn);
3363
3364 if (actual_new_chan_nr != new_chan_nr) {
3365 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3366 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3367 setverdict(fail);
3368 return;
3369 }
3370 log("Handover Command chan_nr is", actual_new_chan_nr);
3371
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02003372 /* For deterministic test results, give some time for the MGW endpoint to be configured */
3373 f_sleep(1.0);
3374
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003375 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3376 * tells the MS to handover to the new lchan. In this case, the MS
3377 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
3378 * Handover Failure to the MSC. The procedure according to 3GPP TS
3379 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
3380 * BSSMAP Clear Command: */
3381
3382 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3383 var BssmapCause cause := enum2int(cause_val);
3384 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3385
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003386 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003387 setverdict(pass);
3388 f_sleep(1.0);
3389
3390 setverdict(pass);
3391}
3392testcase TC_ho_in_fail_msc_clears() runs on test_CT {
3393 var MSC_ConnHdlr vc_conn;
3394 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3395
3396 f_init(1, true);
3397 f_sleep(1.0);
3398
3399 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3400 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3401
3402 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
3403 vc_conn.done;
3404}
3405
3406private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
3407 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3408 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3409 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3410 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3411 * before we get started. */
3412 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3413 f_rslem_register(0, new_chan_nr);
3414 g_chan_nr := new_chan_nr;
3415 f_sleep(1.0);
3416
3417 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3418 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3419 activate(as_Media());
3420
3421 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3422 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003423 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003424
3425 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3426
3427 var PDU_BSSAP rx_bssap;
3428 var octetstring ho_command_str;
3429
3430 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3431
3432 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3433 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3434 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3435 log("L3 Info in HO Request Ack is ", ho_command);
3436
3437 var GsmArfcn arfcn;
3438 var RslChannelNr actual_new_chan_nr;
3439 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3440 actual_new_chan_nr, arfcn);
3441
3442 if (actual_new_chan_nr != new_chan_nr) {
3443 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3444 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3445 setverdict(fail);
3446 return;
3447 }
3448 log("Handover Command chan_nr is", actual_new_chan_nr);
3449
3450 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3451 * tells the MS to handover to the new lchan. Here comes the new MS on
3452 * the new lchan with a Handover RACH: */
3453
3454 /* send handover detect */
3455
3456 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3457
3458 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3459
3460 /* The MSC chooses to clear the connection now, maybe we got the
3461 * Handover RACH on the new cell but the MS still signaled Handover
3462 * Failure to the old BSS? */
3463
3464 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3465 var BssmapCause cause := enum2int(cause_val);
3466 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3467
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003468 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003469 setverdict(pass);
3470 f_sleep(1.0);
3471}
3472testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
3473 var MSC_ConnHdlr vc_conn;
3474 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3475
3476 f_init(1, true);
3477 f_sleep(1.0);
3478
3479 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3480 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3481
3482 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
3483 vc_conn.done;
3484}
3485
3486/* The new BSS's lchan times out before the MSC decides that handover failed. */
3487private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
3488 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3489 f_rslem_register(0, new_chan_nr);
3490 g_chan_nr := new_chan_nr;
3491 f_sleep(1.0);
3492
3493 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3494 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3495 activate(as_Media());
3496
3497 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3498 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003499 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003500
3501 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3502
3503 var PDU_BSSAP rx_bssap;
3504 var octetstring ho_command_str;
3505
3506 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3507
3508 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3509 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3510 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3511 log("L3 Info in HO Request Ack is ", ho_command);
3512
3513 var GsmArfcn arfcn;
3514 var RslChannelNr actual_new_chan_nr;
3515 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3516 actual_new_chan_nr, arfcn);
3517
3518 if (actual_new_chan_nr != new_chan_nr) {
3519 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3520 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3521 setverdict(fail);
3522 return;
3523 }
3524 log("Handover Command chan_nr is", actual_new_chan_nr);
3525
3526 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3527 * tells the MS to handover to the new lchan. But the MS never shows up
3528 * on the new lchan. */
3529
3530 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3531
3532 /* Did osmo-bsc also send a Clear Request? */
3533 timer T := 0.5;
3534 T.start;
3535 alt {
3536 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
3537 [] T.timeout { }
3538 }
3539
3540 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
3541 * asked for it, this is a Handover Failure after all). */
3542
3543 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3544 var BssmapCause cause := enum2int(cause_val);
3545 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3546
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003547 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003548 setverdict(pass);
3549 f_sleep(1.0);
3550
3551 setverdict(pass);
3552}
3553testcase TC_ho_in_fail_no_detect() runs on test_CT {
3554 var MSC_ConnHdlr vc_conn;
3555 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3556
3557 f_init(1, true);
3558 f_sleep(1.0);
3559
3560 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3561 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3562
3563 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
3564 vc_conn.done;
3565}
3566
3567/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
3568private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
3569 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3570 f_rslem_register(0, new_chan_nr);
3571 g_chan_nr := new_chan_nr;
3572 f_sleep(1.0);
3573
3574 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3575 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3576 activate(as_Media());
3577
3578 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3579 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003580 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003581
3582 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3583
3584 var PDU_BSSAP rx_bssap;
3585 var octetstring ho_command_str;
3586
3587 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3588
3589 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3590 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3591 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3592 log("L3 Info in HO Request Ack is ", ho_command);
3593
3594 var GsmArfcn arfcn;
3595 var RslChannelNr actual_new_chan_nr;
3596 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3597 actual_new_chan_nr, arfcn);
3598
3599 if (actual_new_chan_nr != new_chan_nr) {
3600 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3601 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3602 setverdict(fail);
3603 return;
3604 }
3605 log("Handover Command chan_nr is", actual_new_chan_nr);
3606
3607 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3608 * tells the MS to handover to the new lchan. But the MS never shows up
3609 * on the new lchan. */
3610
3611 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3612
3613 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003614 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003615
3616 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003617 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3618 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3619 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003620 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003621 setverdict(pass);
3622 f_sleep(1.0);
3623}
3624testcase TC_ho_in_fail_no_detect2() runs on test_CT {
3625 var MSC_ConnHdlr vc_conn;
3626 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3627
3628 f_init(1, true);
3629 f_sleep(1.0);
3630
3631 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3632 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3633
3634 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
3635 vc_conn.done;
3636}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003637
Neels Hofmeyr91401012019-07-11 00:42:35 +02003638type record of charstring Commands;
3639
3640private function f_bts_0_cfg(Commands cmds := {}) runs on MSC_ConnHdlr
3641{
3642 f_vty_enter_cfg_bts(BSCVTY, 0);
3643 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
3644 f_vty_transceive(BSCVTY, cmds[i]);
3645 }
3646 f_vty_transceive(BSCVTY, "end");
3647}
3648
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01003649private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
3650{
3651 f_vty_enter_cfg_cs7_inst(pt, 0);
3652 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
3653 f_vty_transceive(pt, cmds[i]);
3654 }
3655 f_vty_transceive(pt, "end");
3656}
3657
Neels Hofmeyr91401012019-07-11 00:42:35 +02003658private function f_probe_for_handover(charstring log_label,
3659 charstring log_descr,
3660 charstring handover_vty_cmd,
3661 boolean expect_handover,
3662 boolean is_inter_bsc_handover := false)
3663runs on MSC_ConnHdlr
3664{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02003665 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
3666 * lchans to be established on bts 1 or bts 2. */
3667 f_rslem_suspend(RSL1_PROC);
3668 f_rslem_suspend(RSL2_PROC);
3669
Neels Hofmeyr91401012019-07-11 00:42:35 +02003670 var RSL_Message rsl;
3671
3672 var charstring log_msg := " (expecting handover)"
3673 if (not expect_handover) {
3674 log_msg := " (expecting NO handover)";
3675 }
3676 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
3677 f_vty_transceive(BSCVTY, handover_vty_cmd);
3678
Neels Hofmeyr91401012019-07-11 00:42:35 +02003679 timer T := 2.0;
3680 T.start;
3681
3682 alt {
3683 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
3684 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
3685 log("Rx L3 from net: ", l3);
3686 if (ischosen(l3.msgs.rrm.handoverCommand)) {
3687 var RslChannelNr new_chan_nr;
3688 var GsmArfcn arfcn;
3689 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
3690 new_chan_nr, arfcn);
3691 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
3692 log(l3.msgs.rrm.handoverCommand);
3693
3694 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
3695 * matter on which BTS it really is, we're not going to follow through an entire handover
3696 * anyway. */
3697 f_rslem_register(0, new_chan_nr, RSL1_PROC);
3698 f_rslem_resume(RSL1_PROC);
3699 f_rslem_register(0, new_chan_nr, RSL2_PROC);
3700 f_rslem_resume(RSL2_PROC);
3701
3702 if (expect_handover and not is_inter_bsc_handover) {
3703 setverdict(pass);
3704 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
3705 } else {
3706 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
3707 & log_label & ": " & log_descr);
3708 }
3709
3710 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
3711 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
3712 * Handover Failure. */
3713 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3714
3715 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
3716 f_sleep(0.5);
3717 RSL1.clear;
3718 RSL2.clear;
3719 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
3720 break;
3721 } else {
3722 repeat;
3723 }
3724 }
3725 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
3726 if (expect_handover and is_inter_bsc_handover) {
3727 setverdict(pass);
3728 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
3729 } else {
3730 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
3731 & log_label & ": " & log_descr);
3732 }
3733
3734 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
3735
3736 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
3737 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
3738 * setting a short timeout and waiting is the only way. */
3739 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
3740 f_sleep(1.5);
3741 log("f_probe_for_handover(" & log_label & "): ...done");
3742
3743 break;
3744 }
3745 [] T.timeout {
3746 if (expect_handover) {
3747 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
3748 & log_label & ": " & log_descr);
3749 } else {
3750 setverdict(pass);
3751 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
3752 }
3753 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
3754 break;
3755 }
3756 }
3757
3758 f_rslem_resume(RSL1_PROC);
3759 f_rslem_resume(RSL2_PROC);
3760 f_sleep(3.0);
3761 RSL.clear;
3762
3763 log("f_probe_for_handover(" & log_label & "): done clearing");
3764}
3765
3766/* Test the effect of various neighbor configuration scenarios:
3767 *
3768 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
3769 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
3770 */
3771private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
3772 g_pars := f_gen_test_hdlr_pars();
3773 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3774 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3775 const OCT8 kc := '0001020304050607'O;
3776
3777 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3778 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3779
3780 /* Establish lchan at bts 0 */
3781 f_establish_fully(ass_cmd, exp_compl);
3782
3783 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
3784 f_vty_enter_cfg_network(BSCVTY);
3785 f_vty_transceive(BSCVTY, "timer T7 1");
3786 f_vty_transceive(BSCVTY, "end");
3787}
3788
3789private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
3790 f_tc_ho_neighbor_config_start();
3791
3792 /*
3793 * bts 0 ARFCN 871 BSIC 10
3794 * bts 1 ARFCN 871 BSIC 11
3795 * bts 2 ARFCN 871 BSIC 12
3796 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3797 */
3798
3799 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
3800 f_bts_0_cfg({"no neighbors"});
3801 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
3802 "handover any to arfcn 871 bsic 11",
3803 true);
3804
3805 f_probe_for_handover("1.b", "HO to unknown cell does not start",
3806 "handover any to arfcn 13 bsic 39",
3807 false);
3808
3809 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
3810 "handover any to arfcn 871 bsic 12",
3811 false);
3812
3813 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
3814 "handover any to arfcn 871 bsic 11",
3815 true);
3816}
3817private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
3818 f_tc_ho_neighbor_config_start();
3819
3820 /*
3821 * bts 0 ARFCN 871 BSIC 10
3822 * bts 1 ARFCN 871 BSIC 11
3823 * bts 2 ARFCN 871 BSIC 12
3824 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3825 */
3826
3827 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
3828 f_bts_0_cfg({"neighbor bts 1"});
3829 f_sleep(0.5);
3830
3831 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
3832 "handover any to arfcn 871 bsic 11",
3833 true);
3834
3835 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
3836 "handover any to arfcn 871 bsic 12",
3837 false);
3838}
3839private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
3840 f_tc_ho_neighbor_config_start();
3841
3842 /*
3843 * bts 0 ARFCN 871 BSIC 10
3844 * bts 1 ARFCN 871 BSIC 11
3845 * bts 2 ARFCN 871 BSIC 12
3846 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3847 */
3848
3849 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
3850 f_bts_0_cfg({"no neighbors", "neighbor bts 2"});
3851 f_sleep(0.5);
3852
3853 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
3854 "handover any to arfcn 871 bsic 11",
3855 false);
3856 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",
3857 "handover any to arfcn 871 bsic 12",
3858 true);
3859}
3860private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
3861 f_tc_ho_neighbor_config_start();
3862
3863 /*
3864 * bts 0 ARFCN 871 BSIC 10
3865 * bts 1 ARFCN 871 BSIC 11
3866 * bts 2 ARFCN 871 BSIC 12
3867 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3868 */
3869
3870 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
3871 f_bts_0_cfg({"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
3872 f_sleep(0.5);
3873
3874 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
3875 "handover any to arfcn 871 bsic 11",
3876 false);
3877 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
3878 "handover any to arfcn 871 bsic 12",
3879 false);
3880 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
3881 "handover any to arfcn 123 bsic 45",
3882 true, true);
3883}
3884private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
3885 f_tc_ho_neighbor_config_start();
3886
3887 /*
3888 * bts 0 ARFCN 871 BSIC 10
3889 * bts 1 ARFCN 871 BSIC 11
3890 * bts 2 ARFCN 871 BSIC 12
3891 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3892 */
3893
3894 log("f_tc_ho_neighbor_config: 5. explicit remote neighbor re-using ARFCN+BSIC: 'neighbor lac 99 arfcn 871 bsic 12'");
3895 f_bts_0_cfg({"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
3896 f_sleep(0.5);
3897
3898 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
3899 "handover any to arfcn 871 bsic 12",
3900 true, true);
3901}
3902private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
3903 f_tc_ho_neighbor_config_start();
3904
3905 /*
3906 * bts 0 ARFCN 871 BSIC 10
3907 * bts 1 ARFCN 871 BSIC 11
3908 * bts 2 ARFCN 871 BSIC 12
3909 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3910 */
3911
3912 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
3913 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
3914 f_bts_0_cfg({"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
3915 f_sleep(0.5);
3916
3917 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
3918 "handover any to arfcn 871 bsic 12",
3919 false);
3920}
3921private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
3922 f_tc_ho_neighbor_config_start();
3923
3924 /*
3925 * bts 0 ARFCN 871 BSIC 10
3926 * bts 1 ARFCN 871 BSIC 11
3927 * bts 2 ARFCN 871 BSIC 12
3928 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
3929 */
3930
3931 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
3932 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
3933 f_bts_0_cfg({"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
3934 f_sleep(0.5);
3935
3936 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
3937 "handover any to arfcn 871 bsic 12",
3938 true);
3939 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
3940 "handover any to arfcn 123 bsic 45",
3941 true, true);
3942}
3943
3944testcase TC_ho_neighbor_config_1() runs on test_CT {
3945 var MSC_ConnHdlr vc_conn;
3946 f_init(3, true);
3947 f_sleep(1.0);
3948 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
3949 vc_conn.done;
3950}
3951testcase TC_ho_neighbor_config_2() runs on test_CT {
3952 var MSC_ConnHdlr vc_conn;
3953 f_init(3, true);
3954 f_sleep(1.0);
3955 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
3956 vc_conn.done;
3957}
3958testcase TC_ho_neighbor_config_3() runs on test_CT {
3959 var MSC_ConnHdlr vc_conn;
3960 f_init(3, true);
3961 f_sleep(1.0);
3962 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
3963 vc_conn.done;
3964}
3965testcase TC_ho_neighbor_config_4() runs on test_CT {
3966 var MSC_ConnHdlr vc_conn;
3967 f_init(3, true);
3968 f_sleep(1.0);
3969 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
3970 vc_conn.done;
3971}
3972testcase TC_ho_neighbor_config_5() runs on test_CT {
3973 var MSC_ConnHdlr vc_conn;
3974 f_init(3, true);
3975 f_sleep(1.0);
3976 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
3977 vc_conn.done;
3978}
3979testcase TC_ho_neighbor_config_6() runs on test_CT {
3980 var MSC_ConnHdlr vc_conn;
3981 f_init(3, true);
3982 f_sleep(1.0);
3983 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
3984 vc_conn.done;
3985}
3986testcase TC_ho_neighbor_config_7() runs on test_CT {
3987 var MSC_ConnHdlr vc_conn;
3988 f_init(3, true);
3989 f_sleep(1.0);
3990 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
3991 vc_conn.done;
3992}
3993
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003994/* OS#3041: Open and close N connections in a normal fashion, and expect no
3995 * BSSMAP Reset just because of that. */
3996testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
3997 var default d;
3998 var integer i;
3999 var DchanTuple dt;
4000
4001 f_init();
4002
4003 /* Wait for initial BSSMAP Reset to pass */
4004 f_sleep(4.0);
4005
4006 d := activate(no_bssmap_reset());
4007
4008 /* Setup up a number of connections and RLSD them again from the MSC
4009 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4010 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02004011 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004012 /* Since we're doing a lot of runs, give each one a fresh
4013 * T_guard from the top. */
4014 T_guard.start;
4015
4016 /* Setup a BSSAP connection and clear it right away. This is
4017 * the MSC telling the BSC about a planned release, it's not an
4018 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004019 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004020
4021 /* MSC disconnects (RLSD). */
4022 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
4023 }
4024
4025 /* In the buggy behavior, a timeout of 2 seconds happens between above
4026 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4027 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4028 f_sleep(4.0);
4029
4030 deactivate(d);
4031 f_shutdown_helper();
4032}
Harald Welte552620d2017-12-16 23:21:36 +01004033
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004034/* OS#3041: Open and close N connections in a normal fashion, and expect no
4035 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
4036 * the MSC. */
4037testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
4038 var default d;
4039 var integer i;
4040 var DchanTuple dt;
4041 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004042 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
4043 var BssmapCause cause := enum2int(cause_val);
4044
4045 f_init();
4046
4047 /* Wait for initial BSSMAP Reset to pass */
4048 f_sleep(4.0);
4049
4050 d := activate(no_bssmap_reset());
4051
4052 /* Setup up a number of connections and RLSD them again from the MSC
4053 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4054 * Let's do it some more times for good measure. */
4055 for (i := 0; i < 8; i := i+1) {
4056 /* Since we're doing a lot of runs, give each one a fresh
4057 * T_guard from the top. */
4058 T_guard.start;
4059
4060 /* Setup a BSSAP connection and clear it right away. This is
4061 * the MSC telling the BSC about a planned release, it's not an
4062 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004063 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004064
4065 /* Instruct BSC to clear channel */
4066 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4067
4068 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004069 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004070 }
4071
4072 /* In the buggy behavior, a timeout of 2 seconds happens between above
4073 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4074 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4075 f_sleep(4.0);
4076
4077 deactivate(d);
4078 f_shutdown_helper();
4079}
4080
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004081/* OS#3041: Open and close N connections in a normal fashion, and expect no
4082 * BSSMAP Reset just because of that. Close connections from the MS side with a
4083 * Release Ind on RSL. */
4084testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
4085 var default d;
4086 var integer i;
4087 var DchanTuple dt;
4088 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004089 var integer j;
4090
4091 f_init();
4092
4093 /* Wait for initial BSSMAP Reset to pass */
4094 f_sleep(4.0);
4095
4096 d := activate(no_bssmap_reset());
4097
4098 /* Setup up a number of connections and RLSD them again from the MSC
4099 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4100 * Let's do it some more times for good measure. */
4101 for (i := 0; i < 8; i := i+1) {
4102 /* Since we're doing a lot of runs, give each one a fresh
4103 * T_guard from the top. */
4104 T_guard.start;
4105
4106 /* Setup a BSSAP connection and clear it right away. This is
4107 * the MSC telling the BSC about a planned release, it's not an
4108 * erratic loss of a connection. */
4109 dt := f_est_dchan('23'O, 23, '00010203040506'O);
4110
4111 /* simulate RLL REL IND */
4112 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
4113
4114 /* expect Clear Request on MSC side */
4115 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
4116
4117 /* Instruct BSC to clear channel */
4118 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
4119 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4120
4121 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004122 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004123 }
4124
4125 /* In the buggy behavior, a timeout of 2 seconds happens between above
4126 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4127 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4128 f_sleep(4.0);
4129
4130 deactivate(d);
4131 f_shutdown_helper();
4132}
4133
Harald Welte94e0c342018-04-07 11:33:23 +02004134/***********************************************************************
4135 * IPA style dynamic PDCH
4136 ***********************************************************************/
4137
4138private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4139 template (omit) RSL_Cause nack := omit)
4140runs on test_CT {
4141 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4142 var RSL_Message rsl_unused;
4143 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4144 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
4145 /* expect the BSC to issue the related RSL command */
4146 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4147 if (istemplatekind(nack, "omit")) {
4148 /* respond with a related acknowledgement */
4149 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4150 } else {
4151 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
4152 }
4153}
4154
4155private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4156 template (omit) RSL_Cause nack := omit)
4157runs on test_CT {
4158 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4159 var RSL_Message rsl_unused;
4160 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4161 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
4162 /* expect the BSC to issue the related RSL command */
4163 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
4164 if (istemplatekind(nack, "omit")) {
4165 /* respond with a related acknowledgement */
4166 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
4167 } else {
4168 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
4169 }
4170}
4171
4172private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
4173runs on test_CT return charstring {
4174 var charstring cmd, resp;
4175 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01004176 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02004177}
4178
4179private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
4180 template charstring exp)
4181runs on test_CT {
4182 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
4183 if (not match(mode, exp)) {
4184 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02004185 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02004186 }
4187}
4188
4189private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
4190runs on test_CT {
4191 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
4192 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
4193 f_vty_transceive(BSCVTY, "end");
4194}
4195
4196private const charstring TCHF_MODE := "TCH/F mode";
4197private const charstring TCHH_MODE := "TCH/H mode";
4198private const charstring PDCH_MODE := "PDCH mode";
4199private const charstring NONE_MODE := "NONE mode";
4200
4201/* Test IPA PDCH activation / deactivation triggered by VTY */
4202testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
4203 var RSL_Message rsl_unused;
4204
4205 /* change Timeslot 6 before f_init() starts RSL */
4206 f_init_vty();
4207 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4208 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4209
4210 f_init(1, false);
4211 f_sleep(1.0);
4212
4213 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4214
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004215 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004216 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4217 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4218 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4219 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4220 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004221 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004222 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4223
4224 /* De-activate it via VTY */
4225 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4226 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004227 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004228 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4229
4230 /* re-activate it via VTY */
4231 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
4232 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004233 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004234 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4235
4236 /* and finally de-activate it again */
4237 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4238 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004239 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004240 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4241
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004242 /* clean up config */
4243 f_ts_set_chcomb(0, 0, 6, "PDCH");
4244
Harald Welte94e0c342018-04-07 11:33:23 +02004245 setverdict(pass);
4246}
4247
4248/* Test IPA PDCH activation NACK */
4249testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
4250 var RSL_Message rsl_unused;
4251
4252 /* change Timeslot 6 before f_init() starts RSL */
4253 f_init_vty();
4254 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4255 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4256
4257 f_init(1, false);
4258 f_sleep(1.0);
4259
4260 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4261
4262 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4263 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4264 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4265 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4266 f_sleep(1.0);
4267 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4268
4269 /* De-activate it via VTY */
4270 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4271 f_sleep(1.0);
4272 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4273
4274 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
4275 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
4276 f_sleep(1.0);
4277 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4278
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004279 /* clean up config */
4280 f_ts_set_chcomb(0, 0, 6, "PDCH");
4281
Harald Welte94e0c342018-04-07 11:33:23 +02004282 setverdict(pass);
4283}
4284
4285
4286/***********************************************************************
4287 * Osmocom style dynamic PDCH
4288 ***********************************************************************/
4289
4290private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4291 template (omit) RSL_Cause nack := omit)
4292runs on test_CT {
4293 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4294 var RSL_Message rsl_unused;
4295 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4296 /* FIXME: no VTY command to activate Osmocom PDCH !! */
4297 /* expect the BSC to issue the related RSL command */
4298 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
4299 if (istemplatekind(nack, "omit")) {
4300 /* respond with a related acknowledgement */
4301 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
4302 } else {
4303 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
4304 }
4305}
4306
4307private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4308 template (omit) RSL_Cause nack := omit)
4309runs on test_CT {
4310 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4311 var RSL_Message rsl_unused;
4312 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4313 /* FIXME: no VTY command to activate Osmocom PDCH !! */
4314 /* expect the BSC to issue the related RSL command */
4315 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
4316 if (istemplatekind(nack, "omit")) {
4317 /* respond with a related acknowledgement */
4318 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
4319 } else {
4320 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
4321 }
4322}
4323
4324/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
4325testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
4326 var RSL_Message rsl_unused;
4327
4328 /* change Timeslot 6 before f_init() starts RSL */
4329 f_init_vty();
4330 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
4331 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4332
4333 f_init(1, false);
4334 f_sleep(1.0);
4335
4336 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
4337
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004338 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004339 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4340 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4341 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
4342
4343 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
4344 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004345 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 +02004346 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4347
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004348 /* clean up config */
4349 f_ts_set_chcomb(0, 0, 6, "PDCH");
4350
Harald Welte94e0c342018-04-07 11:33:23 +02004351 setverdict(pass);
4352}
4353
4354/* Test Osmocom dyn PDCH activation NACK behavior */
4355testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
4356 var RSL_Message rsl_unused;
4357
4358 /* change Timeslot 6 before f_init() starts RSL */
4359 f_init_vty();
4360 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
4361 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4362
4363 f_init(1, false);
4364 f_sleep(1.0);
4365
4366 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
4367
4368 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4369 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4370 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
4371
4372 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
4373 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
4374 f_sleep(1.0);
4375 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
4376
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004377 /* clean up config */
4378 f_ts_set_chcomb(0, 0, 6, "PDCH");
4379
Harald Welte94e0c342018-04-07 11:33:23 +02004380 setverdict(pass);
4381}
4382
Stefan Sperling0796a822018-10-05 13:01:39 +02004383testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02004384 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02004385 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
4386 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
4387 }
4388}
4389
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004390testcase TC_chopped_ipa_payload() runs on test_CT {
4391 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
4392 /* TODO: mp_bsc_ctrl_port does not work yet */};
4393 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
4394 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
4395 }
4396}
4397
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01004398/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
4399 the BTS does autonomous MS power control loop */
4400testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
4401 var MSC_ConnHdlr vc_conn;
4402 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4403 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
4404 pars.exp_ms_power_params := true;
4405
4406 f_init(1, true);
4407 f_sleep(1.0);
4408 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
4409 vc_conn.done;
4410}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004411
Harald Welte0ea2d5e2018-04-07 21:40:29 +02004412/* Dyn PDCH todo:
4413 * activate OSMO as TCH/F
4414 * activate OSMO as TCH/H
4415 * does the BSC-located PCU socket get the updated INFO?
4416 * what if no PCU is connected at the time?
4417 * is the info correct on delayed PCU (re)connect?
4418 */
Harald Welte94e0c342018-04-07 11:33:23 +02004419
Harald Welte28d943e2017-11-25 15:00:50 +01004420control {
Harald Welte898113b2018-01-31 18:32:21 +01004421 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01004422 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01004423 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01004424 execute( TC_ctrl() );
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02004425 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
4426 execute( TC_ctrl_location() );
4427 }
Harald Welte898113b2018-01-31 18:32:21 +01004428
4429 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01004430 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01004431 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01004432 execute( TC_chan_act_ack_noest() );
4433 execute( TC_chan_act_ack_est_ind_noreply() );
4434 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01004435 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01004436 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07004437 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01004438 execute( TC_chan_rel_rll_rel_ind() );
4439 execute( TC_chan_rel_conn_fail() );
4440 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01004441 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01004442 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02004443 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01004444 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01004445 execute( TC_chan_rel_sccp_tiar_timeout() );
Harald Welte6f521d82017-12-11 19:52:02 +01004446
Harald Weltecfe2c962017-12-15 12:09:32 +01004447 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01004448
4449 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01004450 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01004451 execute( TC_assignment_csd() );
4452 execute( TC_assignment_ctm() );
4453 execute( TC_assignment_sign() );
4454 execute( TC_assignment_fr_a5_0() );
4455 execute( TC_assignment_fr_a5_1() );
Harald Welte8f67d1d2018-05-25 20:38:42 +02004456 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
4457 execute( TC_assignment_fr_a5_1_codec_missing() );
4458 }
Harald Welte235ebf12017-12-15 14:18:16 +01004459 execute( TC_assignment_fr_a5_3() );
4460 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02004461 execute( TC_ciph_mode_a5_0() );
4462 execute( TC_ciph_mode_a5_1() );
4463 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01004464
Harald Welte60aa5762018-03-21 19:33:13 +01004465 execute( TC_assignment_codec_fr() );
4466 execute( TC_assignment_codec_hr() );
4467 execute( TC_assignment_codec_efr() );
4468 execute( TC_assignment_codec_amr_f() );
4469 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01004470
4471 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
4472 execute( TC_assignment_codec_amr_f_S1() );
4473 execute( TC_assignment_codec_amr_h_S1() );
4474 execute( TC_assignment_codec_amr_f_S124() );
4475 execute( TC_assignment_codec_amr_h_S124() );
4476 execute( TC_assignment_codec_amr_f_S0() );
4477 execute( TC_assignment_codec_amr_f_S02() );
4478 execute( TC_assignment_codec_amr_f_S024() );
4479 execute( TC_assignment_codec_amr_f_S0247() );
4480 execute( TC_assignment_codec_amr_h_S0() );
4481 execute( TC_assignment_codec_amr_h_S02() );
4482 execute( TC_assignment_codec_amr_h_S024() );
4483 execute( TC_assignment_codec_amr_h_S0247() );
4484 execute( TC_assignment_codec_amr_f_S01234567() );
4485 execute( TC_assignment_codec_amr_f_S0234567() );
4486 execute( TC_assignment_codec_amr_f_zero() );
4487 execute( TC_assignment_codec_amr_f_unsupp() );
4488 execute( TC_assignment_codec_amr_h_S7() );
4489 }
Harald Welte60aa5762018-03-21 19:33:13 +01004490
Philipp Maierac09bfc2019-01-08 13:41:39 +01004491 execute( TC_assignment_codec_fr_exhausted_req_hr() );
4492 execute( TC_assignment_codec_fr_exhausted_req_fr() );
4493 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
4494 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
4495 execute( TC_assignment_codec_hr_exhausted_req_fr() );
4496 execute( TC_assignment_codec_hr_exhausted_req_hr() );
4497 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
4498 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
4499 execute( TC_assignment_codec_req_hr_fr() );
4500 execute( TC_assignment_codec_req_fr_hr() );
4501
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02004502 if (mp_enable_osmux_test) {
4503 execute( TC_assignment_osmux() );
4504 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004505
Harald Welte898113b2018-01-31 18:32:21 +01004506 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01004507 execute( TC_rll_est_ind_inact_lchan() );
4508 execute( TC_rll_est_ind_inval_sapi1() );
4509 execute( TC_rll_est_ind_inval_sapi3() );
4510 execute( TC_rll_est_ind_inval_sacch() );
4511
Harald Welte898113b2018-01-31 18:32:21 +01004512 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01004513 execute( TC_paging_imsi_nochan() );
4514 execute( TC_paging_tmsi_nochan() );
4515 execute( TC_paging_tmsi_any() );
4516 execute( TC_paging_tmsi_sdcch() );
4517 execute( TC_paging_tmsi_tch_f() );
4518 execute( TC_paging_tmsi_tch_hf() );
4519 execute( TC_paging_imsi_nochan_cgi() );
4520 execute( TC_paging_imsi_nochan_lac_ci() );
4521 execute( TC_paging_imsi_nochan_ci() );
4522 execute( TC_paging_imsi_nochan_lai() );
4523 execute( TC_paging_imsi_nochan_lac() );
4524 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01004525 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
4526 execute( TC_paging_imsi_nochan_rnc() );
4527 execute( TC_paging_imsi_nochan_lac_rnc() );
4528 execute( TC_paging_imsi_nochan_lacs() );
4529 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01004530 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01004531 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01004532 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01004533 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01004534 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01004535
4536 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01004537 execute( TC_rsl_unknown_unit_id() );
4538
4539 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01004540
4541 execute( TC_classmark() );
4542 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01004543 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004544 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01004545 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01004546 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004547
Harald Welte261af4b2018-02-12 21:20:39 +01004548 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004549
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004550 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004551 execute( TC_ho_out_fail_no_msc_response() );
4552 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004553 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004554
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004555 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004556 execute( TC_ho_in_fail_msc_clears() );
4557 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
4558 execute( TC_ho_in_fail_no_detect() );
4559 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004560
Neels Hofmeyr91401012019-07-11 00:42:35 +02004561 execute( TC_ho_neighbor_config_1() );
4562 execute( TC_ho_neighbor_config_2() );
4563 execute( TC_ho_neighbor_config_3() );
4564 execute( TC_ho_neighbor_config_4() );
4565 execute( TC_ho_neighbor_config_5() );
4566 execute( TC_ho_neighbor_config_6() );
4567 execute( TC_ho_neighbor_config_7() );
4568
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004569 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004570 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004571 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02004572
4573 execute( TC_dyn_pdch_ipa_act_deact() );
4574 execute( TC_dyn_pdch_ipa_act_nack() );
4575 execute( TC_dyn_pdch_osmo_act_deact() );
4576 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004577
Stefan Sperling0796a822018-10-05 13:01:39 +02004578 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004579 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02004580
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01004581 /* Power control related */
4582 execute( TC_assignment_verify_ms_power_params_ie() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004583 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
4584 execute( TC_early_conn_fail() );
4585 execute( TC_late_conn_fail() );
4586
Harald Welte28d943e2017-11-25 15:00:50 +01004587}
4588
4589}