blob: af32b8c8e71785d460fa685b66e3b87586dcb191 [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 *
10 * This test suite tests OsmoBSC while emulating both multiple BTS + MS as
11 * well as the MSC. See README for more details.
12 *
13 * There are test cases that run in so-called 'handler mode' and test cases
14 * that run directly on top of the BSSAP and RSL CodecPorts. The "handler mode"
15 * tests abstract the multiplexing/demultiplexing of multiple SCCP connections
16 * and/or RSL channels and are hence suitable for higher-level test cases, while
17 * the "raw" tests directly on top of the CodecPorts are more suitable for lower-
18 * level testing.
19 */
20
Harald Welte4003d112017-12-09 22:35:39 +010021import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010022import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010023import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010024import from IPL4asp_Types all;
25
Harald Welte6f521d82017-12-11 19:52:02 +010026import from BSSAP_Types all;
Harald Welteae026692017-12-09 01:03:01 +010027import from BSSAP_Adapter all;
28import from BSSAP_CodecPort all;
29import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010030import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010031import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010032import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020033import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010034import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010035import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010036import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010037import from MGCP_Templates all;
38import from MGCP_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010039
Harald Welte96c94412017-12-09 03:12:45 +010040import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010041import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010042import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010043
Harald Weltebc03c762018-02-12 18:09:38 +010044import from Osmocom_VTY_Functions all;
45import from TELNETasp_PortType all;
46
Harald Welte6f521d82017-12-11 19:52:02 +010047import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010048import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010049import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010050import from L3_Templates all;
51import from GSM_RR_Types all;
52
Stefan Sperlingc307e682018-06-14 15:15:46 +020053import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010054import from BSSMAP_Templates all;
55
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010056import from SCCPasp_Types all;
57
Harald Welte5d1a2202017-12-13 19:51:29 +010058const integer NUM_BTS := 3;
Harald Welteae026692017-12-09 01:03:01 +010059const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010060
Harald Welte799c97b2017-12-14 17:50:30 +010061/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020062const integer NUM_TCHH_PER_BTS := 2;
63const integer NUM_TCHF_PER_BTS := 4;
Harald Weltedd8cbf32018-01-28 12:07:52 +010064const integer NUM_SDCCH_PER_BTS := 4;
Harald Welte799c97b2017-12-14 17:50:30 +010065
Harald Welte4003d112017-12-09 22:35:39 +010066
Harald Welte21b46bd2017-12-17 19:46:32 +010067/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010068type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010069 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010070 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010071}
72
Harald Weltea4ca4462018-02-09 00:17:14 +010073type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +010074 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +010075 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +010076 /* RSL common Channel Port (for RSL_Emulation) */
77 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +010078 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +010079 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +010080 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Harald Weltea5d2ab22017-12-09 14:21:42 +010081
Daniel Willmann191e0d92018-01-17 12:44:35 +010082 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +010083 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +010084
Harald Weltea4ca4462018-02-09 00:17:14 +010085 var BSSAP_Adapter g_bssap;
86 /* for old legacy-tests only */
87 port BSSAP_CODEC_PT BSSAP;
88
Harald Welte21b46bd2017-12-17 19:46:32 +010089 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +010090 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +010091
92 /* global test case guard timer */
Harald Welteae026692017-12-09 01:03:01 +010093 timer T_guard := 30.0;
94
Harald Welte28d943e2017-11-25 15:00:50 +010095}
96
97modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +010098 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +010099 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100100 /* port number to which to establish the IPA OML connections */
101 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100102 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100103 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100104 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100105 integer mp_bsc_ctrl_port := 4249;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100106 /* IP address at which the test binds */
107 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100108
109 BSSAP_Configuration mp_bssap_cfg := {
Harald Welte7ef51aa2018-04-16 19:16:01 +0200110 transport := BSSAP_TRANSPORT_AoIP,
Harald Weltea4ca4462018-02-09 00:17:14 +0100111 sccp_service_type := "mtp3_itu",
112 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
113 own_pc := 185,
114 own_ssn := 254,
115 peer_pc := 187,
116 peer_ssn := 254,
Philipp Maier38d68942018-03-29 15:38:09 +0200117 sio := '83'O,
118 rctx := 0
Harald Weltea4ca4462018-02-09 00:17:14 +0100119 };
120}
121
Philipp Maier48604732018-10-09 15:00:37 +0200122private function f_gen_test_hdlr_pars() return TestHdlrParams {
123
124 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
125 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
126 pars.aoip := true;
127 } else {
128 pars.aoip := false;
129 }
130
131 return pars;
132}
133
Philipp Maier282ca4b2018-02-27 17:17:00 +0100134private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200135 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100136 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200137 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100138}
139
Harald Weltea4ca4462018-02-09 00:17:14 +0100140private function f_legacy_bssap_reset() runs on test_CT {
141 var BSSAP_N_UNITDATA_ind ud_ind;
142 timer T := 5.0;
143 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0)));
144 T.start;
145 alt {
146 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck)) {
147 log("Received RESET-ACK in response to RESET, we're ready to go!");
148 }
149 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind {
150 log("Respoding to inbound RESET with RESET-ACK");
151 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
152 ts_BSSMAP_ResetAck));
153 repeat;
154 }
155 [] BSSAP.receive { repeat; }
156 [] T.timeout { setverdict(fail, "Waiting for RESET-ACK after sending RESET"); }
157 }
Harald Welte28d943e2017-11-25 15:00:50 +0100158}
159
Harald Welteae026692017-12-09 01:03:01 +0100160type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100161 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100162 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100163 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100164 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100165 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100166 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100167 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100168 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100169}
170
Harald Welte21b46bd2017-12-17 19:46:32 +0100171/*! Start the IPA/RSL related bits for one IPA_Client.
172 * \param clnt IPA_Client for which to establish
173 * \param bsc_host IP address / hostname of the BSC
174 * \param bsc_port TCP port number of the BSC
175 * \param i number identifying this BTS
176 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100177function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
178 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100179runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100180 timer T := 10.0;
181
Harald Welte96c94412017-12-09 03:12:45 +0100182 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100183 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
184 clnt.ccm_pars := c_IPA_default_ccm_pars;
185 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
186 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100187 if (handler_mode) {
188 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100189 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100190 }
Harald Welteae026692017-12-09 01:03:01 +0100191
192 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100193 if (handler_mode) {
194 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
195 } else {
196 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
197 }
Harald Welteae026692017-12-09 01:03:01 +0100198
Harald Welte5d1a2202017-12-13 19:51:29 +0100199 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100200 if (handler_mode) {
201 clnt.vc_RSL.start(RSL_Emulation.main());
202 return;
203 }
Harald Welteae026692017-12-09 01:03:01 +0100204
205 /* wait for IPA RSL link to connect and send ID ACK */
206 T.start;
207 alt {
208 [] IPA_RSL[i].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_ID_ACK}) {
209 T.stop;
210 IPA_RSL[i].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23)));
211 }
Harald Welte60e823a2017-12-10 14:10:59 +0100212 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100213 [] IPA_RSL[i].receive { repeat }
214 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100215 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200216 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100217 }
218 }
219}
220
Harald Welte12055472018-03-17 20:10:08 +0100221function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
222 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
223 return;
224 }
225 clnt.vc_IPA.stop;
226 if (isbound(clnt.vc_RSL)) {
227 clnt.vc_RSL.stop;
228 }
229}
230
Harald Welte21b46bd2017-12-17 19:46:32 +0100231/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100232function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
233 timer T := secs_max;
234 T.start;
235 while (true) {
236 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
237 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100238 /* the 'degraded' state exists from OML connection time, and we have to wait
239 * until all MO's are initialized */
240 T.start(1.0);
241 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100242 return;
243 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100244 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100245 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100246 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200247 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100248 }
249 }
250}
251
Harald Welte21b46bd2017-12-17 19:46:32 +0100252/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100253altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100254 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100255 [] T_guard.timeout {
256 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200257 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100258 }
Harald Welte60e823a2017-12-10 14:10:59 +0100259 /* always respond with RESET ACK to RESET */
260 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind {
261 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
262 ts_BSSMAP_ResetAck));
Harald Welte69c1c262017-12-13 21:02:08 +0100263 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100264 }
Harald Welte28d943e2017-11-25 15:00:50 +0100265}
266
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100267altstep no_bssmap_reset() runs on test_CT {
268 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) {
269 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200270 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100271 }
272}
273
Daniel Willmann191e0d92018-01-17 12:44:35 +0100274function f_init_mgcp(charstring id) runs on test_CT {
275 id := id & "-MGCP";
276
277 var MGCPOps ops := {
278 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
279 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
280 };
281 var MGCP_conn_parameters mgcp_pars := {
282 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100283 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100284 mgw_ip := mp_test_ip,
285 mgw_udp_port := 2427
286 };
287
288 vc_MGCP := MGCP_Emulation_CT.create(id);
289 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
290}
291
Max2253c0b2018-11-06 19:28:05 +0100292function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200293 if (BSCVTY.checkstate("Mapped")) {
294 /* skip initialization if already executed once */
295 return;
296 }
Harald Weltebc03c762018-02-12 18:09:38 +0100297 map(self:BSCVTY, system:BSCVTY);
298 f_vty_set_prompts(BSCVTY);
299 f_vty_transceive(BSCVTY, "enable");
300}
301
Harald Welte21b46bd2017-12-17 19:46:32 +0100302/* global initialization function
303 * \param nr_bts Number of BTSs we should start/bring up
304 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte89d42e82017-12-17 16:42:41 +0100305function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false) runs on test_CT {
Harald Welte28d943e2017-11-25 15:00:50 +0100306 var integer i;
Harald Welte28d943e2017-11-25 15:00:50 +0100307
Harald Welteae026692017-12-09 01:03:01 +0100308 if (g_initialized) {
309 return;
Harald Welte28d943e2017-11-25 15:00:50 +0100310 }
Harald Welteae026692017-12-09 01:03:01 +0100311 g_initialized := true;
312
Daniel Willmanne68f9272018-11-27 15:15:28 +0100313 T_guard.start;
314 activate(as_Tguard());
315
Harald Welteae026692017-12-09 01:03:01 +0100316 /* Call a function of our 'parent component' BSSAP_Adapter_CT to start the
317 * MSC-side BSSAP emulation */
Harald Welte67089ee2018-01-17 22:19:03 +0100318 if (handler_mode) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100319 f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", MSC_BssmapOps);
Harald Welte4bcbd172018-05-27 19:47:44 +0200320 f_bssap_start(g_bssap);
Harald Welte67089ee2018-01-17 22:19:03 +0100321 } else {
Harald Weltea4ca4462018-02-09 00:17:14 +0100322 f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", omit);
323 connect(self:BSSAP, g_bssap.vc_SCCP:SCCP_SP_PORT);
Harald Welte4bcbd172018-05-27 19:47:44 +0200324 f_bssap_start(g_bssap);
Harald Weltea4ca4462018-02-09 00:17:14 +0100325 f_legacy_bssap_reset();
Harald Welte67089ee2018-01-17 22:19:03 +0100326 }
Harald Welted5833a82018-05-27 16:52:56 +0200327
Harald Welteffe55fc2018-01-17 22:39:54 +0100328 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +0100329
Daniel Willmann191e0d92018-01-17 12:44:35 +0100330 f_init_mgcp("VirtMSC");
Harald Weltebc03c762018-02-12 18:09:38 +0100331 f_init_vty("VirtMSC");
Daniel Willmann191e0d92018-01-17 12:44:35 +0100332
Harald Welte89d42e82017-12-17 16:42:41 +0100333 for (i := 0; i < nr_bts; i := i+1) {
Harald Weltea5d2ab22017-12-09 14:21:42 +0100334 /* wait until osmo-bts-omldummy has respawned */
335 f_wait_oml(i, "degraded", 5.0);
336 /* start RSL connection */
Harald Welte624f9632017-12-16 19:26:04 +0100337 f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i, handler_mode);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100338 /* wait until BSC tells us "connected" */
339 f_wait_oml(i, "connected", 5.0);
Harald Welte696ddb62017-12-08 14:01:43 +0100340 }
341
Harald Welte28d943e2017-11-25 15:00:50 +0100342}
343
Maxd4e56962018-10-31 19:08:25 +0100344/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welteae026692017-12-09 01:03:01 +0100345function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
346runs on test_CT return RSL_Message {
347 var ASP_RSL_Unitdata rx_rsl_ud;
348 timer T := t_secs;
349
350 T.start;
351 alt {
352 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud {
353 T.stop;
354 }
355 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +0100356 [] T.timeout {
357 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +0200358 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +0100359 }
Harald Welteae026692017-12-09 01:03:01 +0100360 }
361 return rx_rsl_ud.rsl;
362}
363
Harald Welte21b46bd2017-12-17 19:46:32 +0100364/* helper function to transmit RSL on a given BTS/stream */
Harald Welteae026692017-12-09 01:03:01 +0100365function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
366runs on test_CT {
367 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx));
368}
369
370
Harald Welte4003d112017-12-09 22:35:39 +0100371/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +0100372testcase TC_chan_act_noreply() runs on test_CT {
373 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +0100374 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +0100375
Harald Welte89d42e82017-12-17 16:42:41 +0100376 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +0100377
Harald Welteae026692017-12-09 01:03:01 +0100378 IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +0100379 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welteae026692017-12-09 01:03:01 +0100380 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +0100381}
382
Harald Welte4003d112017-12-09 22:35:39 +0100383/* verify if the "chreq:total" counter increments as expected */
384testcase TC_chan_act_counter() runs on test_CT {
385 var BSSAP_N_UNITDATA_ind ud_ind;
386 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +0100387 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +0100388
Harald Welte89d42e82017-12-17 16:42:41 +0100389 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100390
391 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
392 IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +0100393 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +0100394 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
395
396 setverdict(pass);
397}
398
Harald Welteae026692017-12-09 01:03:01 +0100399/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
400testcase TC_chan_act_ack_noest() runs on test_CT {
401 var RSL_Message rx_rsl;
402
Harald Welte89d42e82017-12-17 16:42:41 +0100403 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100404
405 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100406 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100407
408 /* expect BSC to disable the channel again if there's no RLL EST IND */
409 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
410
411 setverdict(pass);
412}
413
414/* Test behavior if MSC never answers to CR */
415testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +0100416 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
417 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +0100418 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +0100419 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +0100420
Harald Welte89d42e82017-12-17 16:42:41 +0100421 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100422
423 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100424 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100425
426 var octetstring l3 := '00010203040506'O
427 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
428
429 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
430
431 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +0100432 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100433 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +0100434 setverdict(pass);
435}
436
437/* Test behavior if MSC answers with CREF to CR */
438testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
439 var BSSAP_N_CONNECT_ind rx_c_ind;
440 var RSL_Message rx_rsl;
441
Harald Welte89d42e82017-12-17 16:42:41 +0100442 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100443
444 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100445 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100446
447 var octetstring l3 := '00010203040506'O
448 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
449
450 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
451 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
452
453 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100454 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +0100455 setverdict(pass);
456}
457
Harald Welte618ef642017-12-14 14:58:20 +0100458/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
459testcase TC_chan_act_nack() runs on test_CT {
460 var RSL_Message rx_rsl;
461 var integer chact_nack;
462
Harald Welte89d42e82017-12-17 16:42:41 +0100463 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +0100464
465 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
466
467 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
468 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
469 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
470
471 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
472
473 /* wait for some time to hope the NACK arrives before the CTRL GET below */
474 f_sleep(0.5);
475
476 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
477
478 setverdict(pass);
479}
480
Harald Welte799c97b2017-12-14 17:50:30 +0100481/* Test for channel exhaustion due to RACH overload */
482testcase TC_chan_exhaustion() runs on test_CT {
483 var ASP_RSL_Unitdata rsl_ud;
484 var integer i;
485 var integer chreq_total, chreq_nochan;
486
Harald Welte89d42e82017-12-17 16:42:41 +0100487 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +0100488
489 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
490 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
491
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +0100492 /* GSM 04.08 Table 9.9a:
493 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
494 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +0200495 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 +0100496 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +0100497 }
498
499 IPA_RSL[0].clear;
500
Harald Weltedd8cbf32018-01-28 12:07:52 +0100501 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200502 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +0100503
504 /* now expect additional channel activations to fail */
505 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
506
507 alt {
508 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
509 tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
510 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
511 }
512 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
513 var GsmRrMessage rr;
514 /* match on IMM ASS REJ */
515 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
516 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
517 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200518 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +0100519 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
520 chreq_nochan+1);
521 setverdict(pass);
522 } else {
523 repeat;
524 }
525 }
526 [] IPA_RSL[0].receive { repeat; }
527 }
528}
529
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +0700530/* Test channel deactivation due to silence from MS */
531testcase TC_chan_deact_silence() runs on test_CT {
532 var RslChannelNr chan_nr;
533
534 f_init(1);
535
536 /* Request for a dedicated channel */
537 chan_nr := f_chreq_act_ack('23'O);
538
539 /* Wait some time until the channel is released */
540 f_sleep(2.0);
541
542 /* Expect CHANnel RELease */
543 alt {
544 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
545 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
546 log("Received CHANnel RELease");
547 setverdict(pass);
548 }
549 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
550 tr_RSL_IMM_ASSIGN(?))) {
551 /* See OS#3709, OsmoBSC should not send Immediate
552 * Assignment Reject since a dedicated channel was
553 * already allocated, and Immediate Assignment was
554 * already sent. */
555 setverdict(fail, "Unexpected Immediate Assignment!");
556 }
557 [] IPA_RSL[0].receive {
558 setverdict(fail, "Unexpected RSL message!");
559 }
560 }
561}
562
Harald Weltecfe2c962017-12-15 12:09:32 +0100563/***********************************************************************
564 * Assignment Testing
565 ***********************************************************************/
566
Neels Hofmeyrda4a6952018-06-14 04:02:49 +0200567/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
568 * except for the inter-BSC handover, MT side) */
Harald Weltecfe2c962017-12-15 12:09:32 +0100569testcase TC_outbound_connect() runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +0100570 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +0100571
Harald Weltea4ca4462018-02-09 00:17:14 +0100572 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 +0100573 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
574 setverdict(pass);
575}
576
Harald Welte16a4adf2017-12-14 18:54:01 +0100577/* Test behavior if MSC answers with CREF to CR */
578testcase TC_assignment_cic_only() runs on test_CT {
579 var BSSAP_N_CONNECT_ind rx_c_ind;
580 var RSL_Message rx_rsl;
581 var DchanTuple dt;
582
Harald Welte89d42e82017-12-17 16:42:41 +0100583 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +0100584
585 dt := f_est_dchan('23'O, 23, '00000000'O);
Harald Welte17b27da2018-05-25 20:33:53 +0200586 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
587 /* send assignment without AoIP IEs */
588 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
589 } else {
590 /* Send assignmetn without CIC in IPA case */
591 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
592 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
593 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
594 }
Harald Welte16a4adf2017-12-14 18:54:01 +0100595 alt {
596 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
597 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
598 }
Harald Welte235ebf12017-12-15 14:18:16 +0100599 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +0100600 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
601 setverdict(pass);
602 }
603 [] BSSAP.receive { repeat; }
604 }
605}
606
Harald Welteed848512018-05-24 22:27:58 +0200607/* generate an assignment request for either AoIP or SCCPlite */
Harald Weltee102eae2018-05-31 21:03:47 +0200608function f_gen_ass_req() return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200609 var PDU_BSSAP ass_cmd;
610 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
611 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
612 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
613 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
614 } else {
615 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
616 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
617 }
618 return ass_cmd;
619}
620
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100621function f_gen_handover_req() return PDU_BSSAP {
622 var PDU_BSSAP ho_req;
623 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
624 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
625 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
626 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
627 } else {
628 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
629 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
630 }
631 return ho_req;
632}
633
Harald Welteed848512018-05-24 22:27:58 +0200634/* generate an assignment complete template for either AoIP or SCCPlite */
Harald Weltee102eae2018-05-31 21:03:47 +0200635function f_gen_exp_compl() return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200636 var template PDU_BSSAP exp_compl;
637 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
638 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
639 } else {
640 /* CIC is optional "*" as the MSC allocated it */
641 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
642 }
643 return exp_compl;
644}
645
Harald Welte235ebf12017-12-15 14:18:16 +0100646/* Run everything required up to sending a caller-specified assignment command and expect response */
647function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
648runs on test_CT {
649 var BSSAP_N_CONNECT_ind rx_c_ind;
650 var RSL_Message rx_rsl;
651 var DchanTuple dt;
652
Harald Welte89d42e82017-12-17 16:42:41 +0100653 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +0100654
655 dt := f_est_dchan('23'O, 23, '00000000'O);
656 /* send assignment without AoIP IEs */
657 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
658 alt {
659 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
660 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
661 setverdict(pass);
662 } else {
663 setverdict(fail, fail_text);
664 }
665 }
666 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
667 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
668 setverdict(pass);
669 } else {
670 setverdict(fail, fail_text);
671 }
672 }
673 [] BSSAP.receive { repeat; }
674 }
675}
676testcase TC_assignment_csd() runs on test_CT {
677 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200678 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100679 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
680 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
681 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
682}
683
684testcase TC_assignment_ctm() runs on test_CT {
685 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200686 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100687 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
688 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
689 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
690}
691
Harald Welte4003d112017-12-09 22:35:39 +0100692type record DchanTuple {
693 integer sccp_conn_id,
694 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +0100695}
696
Harald Welted6939652017-12-13 21:02:46 +0100697/* Send CHAN RQD and wait for allocation; acknowledge it */
698private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
699runs on test_CT return RslChannelNr {
700 var RSL_Message rx_rsl;
701 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
702 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
703 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
704 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +0200705 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +0100706 return chan_nr;
707}
708
Harald Welte4003d112017-12-09 22:35:39 +0100709/* helper function to establish a dedicated channel via BTS and MSC */
710function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
711runs on test_CT return DchanTuple {
712 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +0100713 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100714
Harald Welte4003d112017-12-09 22:35:39 +0100715 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100716 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +0100717
718 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
719
720 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
721 dt.sccp_conn_id := rx_c_ind.connectionId;
722 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
723
724 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100725}
726
Harald Welte641fcbe2018-06-14 10:58:35 +0200727/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
728private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
729 var RSL_Message rx_rsl;
730 /* expect BSC to disable the channel */
731 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
732 /* respond with CHAN REL ACK */
733 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
734
735 /* expect Clear Complete from BSC */
736 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
737
738 /* MSC disconnects as instructed. */
739 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
740}
741
Harald Welte4003d112017-12-09 22:35:39 +0100742/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
743testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100744 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100745 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +0100746
Harald Welte89d42e82017-12-17 16:42:41 +0100747 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +0100748
Harald Welte4003d112017-12-09 22:35:39 +0100749 dt := f_est_dchan('23'O, 23, '00010203040506'O);
750
751 /* simulate RLL REL IND */
752 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
753
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100754 /* expect Clear Request on MSC side */
755 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
756
757 /* Instruct BSC to clear channel */
758 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
759 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
760
Harald Welte4003d112017-12-09 22:35:39 +0100761 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +0200762 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100763
764 /* wait for SCCP emulation to do its job */
765 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +0100766
767 setverdict(pass);
768}
769
770/* Test behavior of channel release after CONN FAIL IND from BTS */
771testcase TC_chan_rel_conn_fail() runs on test_CT {
772 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100773 var DchanTuple dt;
774
Harald Welte89d42e82017-12-17 16:42:41 +0100775 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100776
777 dt := f_est_dchan('23'O, 23, '00010203040506'O);
778
779 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +0100780 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 +0100781 /* TODO: different cause values? */
782
Harald Welte4003d112017-12-09 22:35:39 +0100783 /* expect Clear Request from BSC */
784 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
785
786 /* Instruct BSC to clear channel */
787 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
788 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
789
Harald Welte6ff76ea2018-01-28 13:08:01 +0100790 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +0200791 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +0100792
793 /* wait for SCCP emulation to do its job */
794 f_sleep(1.0);
795
796 setverdict(pass);
797}
798
Harald Welte99f3ca02018-06-14 13:40:29 +0200799/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
800/* See also https://www.osmocom.org/issues/3182 */
801testcase TC_early_conn_fail() runs on test_CT {
802 var RSL_Message rx_rsl;
803 var DchanTuple dt;
804
805 f_init(1);
806
807 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
808 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_octstring(1), 23);
809
810 /* BTS->BSC: simulate CONN FAIL IND */
811 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
812
813 /* BTS->BSC: Expect RF channel release from BSC on Abis */
814 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
815
816 /* BTS<-BSC: respond with CHAN REL ACK */
817 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
818
819 setverdict(pass);
820}
821
822/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
823/* See also https://www.osmocom.org/issues/3182 */
824testcase TC_late_conn_fail() runs on test_CT {
825 var RSL_Message rx_rsl;
826 var DchanTuple dt;
827
828 f_init(1);
829
830 dt := f_est_dchan('23'O, 23, '00010203040506'O);
831
832 /* BSC<-MSC: Instruct BSC to clear connection */
833 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
834
835 /* BTS->BSC: expect BSC to deactivate SACCH */
836 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
837
838 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
839 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
840
841 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
842 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
843 /* BTS->BSC: respond with CHAN REL ACK */
844 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
845
846 /* BSC->MSC: expect Clear Complete from BSC */
847 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
848
849 /* BSC<-MSC: MSC disconnects as requested. */
850 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
851
852 setverdict(pass);
853}
854
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +0100855function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100856 boolean expect_deact_sacch := true,
857 boolean expect_rr_chan_rel := true,
858 boolean expect_rll_rel_req := true,
859 boolean handle_rll_rel := true
860 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +0100861
862 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyr211169d2018-11-07 00:37:29 +0100863 var octetstring l3_rr_chan_rel := '060D00'O;
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100864 var boolean got_deact_sacch := false;
865 var boolean got_rr_chan_rel := false;
866 var boolean got_rll_rel_req := false;
867 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
868 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +0100869 alt {
Harald Welte91d54a52018-01-28 15:35:07 +0100870 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
871 tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100872 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100873 repeat;
874 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +0100875 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_DATA_REQ(rsl_chan_nr, ?, l3_rr_chan_rel))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100876 got_rr_chan_rel := true;
Neels Hofmeyr211169d2018-11-07 00:37:29 +0100877 repeat;
878 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100879 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
Harald Welte91d54a52018-01-28 15:35:07 +0100880 tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100881 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100882 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100883 if (handle_rll_rel) {
884 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
885 }
Harald Welte91d54a52018-01-28 15:35:07 +0100886 repeat;
887 }
Harald Welte91d54a52018-01-28 15:35:07 +0100888 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
889 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
890 /* respond with CHAN REL ACK */
891 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
892 }
893 /* ignore any user data */
894 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) {
895 repeat;
896 }
897 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100898
899 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
900 " got_rll_rel_req=", got_rll_rel_req);
901
902 if (expect_deact_sacch != got_deact_sacch) {
903 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
904 }
905 if (expect_rr_chan_rel != got_rr_chan_rel) {
906 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
907 }
908 if (expect_rll_rel_req != got_rll_rel_req) {
909 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
910 }
Harald Welte91d54a52018-01-28 15:35:07 +0100911}
912
Harald Welte4003d112017-12-09 22:35:39 +0100913/* Test behavior of channel release after hard Clear Command from MSC */
914testcase TC_chan_rel_hard_clear() runs on test_CT {
915 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100916 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +0100917
Harald Welte89d42e82017-12-17 16:42:41 +0100918 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100919
920 dt := f_est_dchan('23'O, 23, '00010203040506'O);
921
922 /* Instruct BSC to clear channel */
923 var BssmapCause cause := 0;
924 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
925
926 /* expect Clear Complete from BSC on A */
927 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
928 /* release the SCCP connection */
929 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
930 }
931
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100932 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte4003d112017-12-09 22:35:39 +0100933 setverdict(pass);
934}
935
Harald Welted8c36cd2017-12-09 23:05:31 +0100936/* Test behavior of channel release after hard RLSD from MSC */
937testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +0100938 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +0100939
Harald Welte89d42e82017-12-17 16:42:41 +0100940 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +0100941
942 dt := f_est_dchan('23'O, 23, '00010203040506'O);
943
944 /* release the SCCP connection */
945 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
946
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100947 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welted8c36cd2017-12-09 23:05:31 +0100948 setverdict(pass);
949}
950
Harald Welte550daf92018-06-11 19:22:13 +0200951/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
952testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
953 var DchanTuple dt;
954
955 f_init(1);
956
957 dt := f_est_dchan('23'O, 23, '00010203040506'O);
958
959 /* release the SCCP connection */
960 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
961
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100962 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte550daf92018-06-11 19:22:13 +0200963 setverdict(pass);
964}
965
Harald Welte85804d42017-12-10 14:11:58 +0100966/* Test behavior of channel release after BSSMAP RESET from MSC */
967testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +0100968 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +0100969
Harald Welte89d42e82017-12-17 16:42:41 +0100970 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +0100971
972 dt := f_est_dchan('23'O, 23, '00010203040506'O);
973
974 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
975 IPA_RSL[0].clear;
976
977 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Harald Weltea4ca4462018-02-09 00:17:14 +0100978 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0)));
Harald Welte85804d42017-12-10 14:11:58 +0100979 interleave {
Harald Weltea4ca4462018-02-09 00:17:14 +0100980 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck)) { }
Harald Welte85804d42017-12-10 14:11:58 +0100981 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
982 }
983
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100984 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte85804d42017-12-10 14:11:58 +0100985 setverdict(pass);
986}
987
Harald Welte5cd20ed2017-12-13 21:03:20 +0100988/* Test behavior if RSL EST IND for non-active channel */
989testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
990 timer T := 2.0;
991
Harald Welte89d42e82017-12-17 16:42:41 +0100992 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100993
994 var octetstring l3 := '00010203040506'O;
995 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
996 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
997
998 T.start;
999 alt {
1000 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1001 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1002 }
1003 [] BSSAP.receive {}
1004 [] IPA_RSL[0].receive {}
1005 [] T.timeout {}
1006 }
1007
1008 setverdict(pass);
1009}
1010
1011/* Test behavior if RSL EST IND for invalid SAPI */
1012testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1013 var RslChannelNr chan_nr;
1014
Harald Welte89d42e82017-12-17 16:42:41 +01001015 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001016
1017 chan_nr := f_chreq_act_ack()
1018
1019 var octetstring l3 := '00010203040506'O;
1020 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1021
1022 timer T := 2.0;
1023 T.start;
1024 alt {
1025 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1026 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1027 }
1028 [] BSSAP.receive { repeat; }
1029 [] IPA_RSL[0].receive { repeat; }
1030 [] T.timeout {}
1031 }
1032
1033 setverdict(pass);
1034}
1035
1036/* Test behavior if RSL EST IND for invalid SAPI */
1037testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
1038 timer T := 2.0;
1039
Harald Welte89d42e82017-12-17 16:42:41 +01001040 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001041
1042 var RslChannelNr chan_nr := f_chreq_act_ack();
1043
1044 var octetstring l3 := '00010203040506'O;
1045 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
1046
1047 T.start;
1048 alt {
1049 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1050 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
1051 }
1052 [] BSSAP.receive { repeat; }
1053 [] IPA_RSL[0].receive { repeat; }
1054 [] T.timeout {}
1055 }
1056
1057 setverdict(pass);
1058}
1059
1060/* Test behavior if RSL EST IND for invalid SACCH */
1061testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
1062 timer T := 2.0;
1063
Harald Welte89d42e82017-12-17 16:42:41 +01001064 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001065
1066 var RslChannelNr chan_nr := f_chreq_act_ack();
1067
1068 var octetstring l3 := '00010203040506'O;
1069 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
1070
1071 T.start;
1072 alt {
1073 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1074 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
1075 }
1076 [] BSSAP.receive { repeat; }
1077 [] IPA_RSL[0].receive { repeat; }
1078 [] T.timeout {}
1079 }
1080
1081 setverdict(pass);
1082}
1083
1084
1085
Harald Welte4003d112017-12-09 22:35:39 +01001086
1087testcase TC_ctrl_msc_connection_status() runs on test_CT {
1088 var charstring ctrl_resp;
1089
Harald Welte89d42e82017-12-17 16:42:41 +01001090 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001091
1092 /* See https://osmocom.org/issues/2729 */
1093 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
1094 setverdict(pass);
1095}
1096
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001097testcase TC_ctrl_msc0_connection_status() runs on test_CT {
1098 var charstring ctrl_resp;
1099
1100 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001101
1102 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
1103 setverdict(pass);
1104}
1105
Harald Welte4003d112017-12-09 22:35:39 +01001106testcase TC_ctrl() runs on test_CT {
1107 var charstring ctrl_resp;
1108
Harald Welte89d42e82017-12-17 16:42:41 +01001109 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001110
1111 /* all below values must match the osmo-bsc.cfg config file used */
1112
Harald Welte6a129692018-03-17 17:30:14 +01001113 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
1114 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Harald Welte44bdaa52017-12-17 17:01:47 +01001115 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "3");
Harald Welte4003d112017-12-09 22:35:39 +01001116
1117 var integer bts_nr := 0;
1118 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
1119 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
1120 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
1121 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
1122 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
1123 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
1124 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
1125
1126 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
1127 f_sleep(2.0);
1128 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
1129 setverdict(fail, "oml-uptime not incrementing as expected");
1130 }
1131 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
1132
1133 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
1134
1135 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +01001136}
1137
Harald Welte6f521d82017-12-11 19:52:02 +01001138function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +01001139 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, bssap));
Harald Welte6f521d82017-12-11 19:52:02 +01001140}
1141
1142
1143/***********************************************************************
1144 * Paging Testing
1145 ***********************************************************************/
1146
1147type record Cell_Identity {
1148 GsmMcc mcc,
1149 GsmMnc mnc,
1150 GsmLac lac,
1151 GsmCellId ci
1152};
Harald Welte24135bd2018-03-17 19:27:53 +01001153private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001154private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001155
Harald Welte5d1a2202017-12-13 19:51:29 +01001156type set of integer BtsIdList;
1157
1158private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1159 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1160 if (bts_id == bts_ids[j]) {
1161 return true;
1162 }
1163 }
1164 return false;
1165}
Harald Welte6f521d82017-12-11 19:52:02 +01001166
1167/* core paging test helper function; used by most paging test cases */
1168private function f_pageing_helper(hexstring imsi,
1169 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001170 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001171 template RSL_ChanNeeded rsl_chneed := omit,
1172 template OCT4 tmsi := omit) runs on test_CT
1173{
1174 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
1175 var MobileIdentity mi;
1176 var template octetstring id_enc; /* FIXME */
1177 var RSL_Message rx_rsl;
1178 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001179 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001180
1181 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001182
1183 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001184 for (i := 0; i < NUM_BTS; i := i + 1) {
1185 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001186 }
Harald Welte6f521d82017-12-11 19:52:02 +01001187
1188 if (isvalue(rsl_chneed)) {
1189 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1190 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1191 } else {
1192 bssmap_chneed := omit;
1193 }
1194
1195 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
1196
1197/* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder
1198 if (isvalue(tmsi)) {
1199 mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi))));
1200 } else {
1201 mi := valueof(ts_Osmo_MI_IMSI(imsi));
1202 }
1203 id_enc := enc_MobileIdentity(mi);
1204*/
1205 id_enc := ?;
Harald Welte5d1a2202017-12-13 19:51:29 +01001206 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
1207 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc));
1208 /* check channel type, paging group */
1209 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1210 setverdict(fail, "Paging for wrong paging group");
1211 }
1212 if (ispresent(rsl_chneed) and
1213 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1214 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1215 }
Harald Welte6f521d82017-12-11 19:52:02 +01001216 }
Harald Welte2fccd982018-01-31 15:48:19 +01001217 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001218 /* do a quick check on all not-included BTSs if they received paging */
1219 for (i := 0; i < NUM_BTS; i := i + 1) {
1220 timer T := 0.1;
1221 if (f_bts_in_list(i, bts_ids)) {
1222 continue;
1223 }
1224 T.start;
1225 alt {
1226 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) {
1227 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1228 }
1229 [] IPA_RSL[i].receive { repeat; }
1230 [] T.timeout { }
1231 }
Harald Welte6f521d82017-12-11 19:52:02 +01001232 }
1233
1234 setverdict(pass);
1235}
1236
Harald Welte5d1a2202017-12-13 19:51:29 +01001237const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001238const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001239const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1240const BtsIdList c_BtsId_LAC2 := { 2 };
1241
Harald Welte6f521d82017-12-11 19:52:02 +01001242/* PAGING by IMSI + TMSI */
1243testcase TC_paging_imsi_nochan() runs on test_CT {
1244 var BSSMAP_FIELD_CellIdentificationList cid_list;
1245 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001246 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001247 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001248}
1249
1250/* PAGING by IMSI + TMSI */
1251testcase TC_paging_tmsi_nochan() runs on test_CT {
1252 var BSSMAP_FIELD_CellIdentificationList cid_list;
1253 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001254 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001255 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001256}
1257
1258/* Paging with different "channel needed' values */
1259testcase TC_paging_tmsi_any() runs on test_CT {
1260 var BSSMAP_FIELD_CellIdentificationList cid_list;
1261 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001262 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001263 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001264}
1265testcase TC_paging_tmsi_sdcch() runs on test_CT {
1266 var BSSMAP_FIELD_CellIdentificationList cid_list;
1267 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001268 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001269 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001270}
1271testcase TC_paging_tmsi_tch_f() runs on test_CT {
1272 var BSSMAP_FIELD_CellIdentificationList cid_list;
1273 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001274 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001275 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001276}
1277testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1278 var BSSMAP_FIELD_CellIdentificationList cid_list;
1279 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001280 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001281 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001282}
1283
1284/* Paging by CGI */
1285testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1286 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1287 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001288 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001289 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001290}
1291
1292/* Paging by LAC+CI */
1293testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1294 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1295 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001296 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001297 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001298}
1299
1300/* Paging by CI */
1301testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1302 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1303 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001304 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001305 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001306}
1307
1308/* Paging by LAI */
1309testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1310 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1311 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001312 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001313 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001314}
1315
1316/* Paging by LAC */
1317testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1318 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1319 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001320 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001321 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001322}
1323
1324/* Paging by "all in BSS" */
1325testcase TC_paging_imsi_nochan_all() runs on test_CT {
1326 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1327 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001328 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001329 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001330}
1331
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001332/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001333testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1334 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1335 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 +01001336 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001337 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001338}
Harald Welte6f521d82017-12-11 19:52:02 +01001339
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001340/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001341testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1342 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1343 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001344 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001345 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001346}
1347
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001348/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001349testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1350 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1351 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001352 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001353 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001354}
1355
Harald Welte6f521d82017-12-11 19:52:02 +01001356/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001357testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1358 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1359 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1360 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001361 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001362}
1363
1364/* Paging on empty list: Verify none of them page */
1365testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1366 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1367 cid_list := { cIl_LAC := { } };
1368 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001369 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001370}
1371
Stefan Sperling049a86e2018-03-20 15:51:00 +01001372/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1373testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1374 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1375 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1376 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1377 f_shutdown_helper();
1378}
1379
Harald Welte6f521d82017-12-11 19:52:02 +01001380/* Verify paging retransmission interval + count */
1381/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001382/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001383
Harald Weltee65d40e2017-12-13 00:09:06 +01001384/* Verify PCH load */
1385testcase TC_paging_imsi_load() runs on test_CT {
1386 var BSSMAP_FIELD_CellIdentificationList cid_list;
1387 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001388 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001389 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001390 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001391
1392 /* tell BSC there is no paging space anymore */
1393 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001394 f_sleep(0.2);
1395 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001396
1397 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1398 * there would be 8 retransmissions during 4 seconds */
1399 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001400 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001401 alt {
1402 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1403 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02001404 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01001405 }
Harald Welte2caa1062018-03-17 18:19:05 +01001406 [] T_retrans.timeout {
1407 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1408 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1409 T_retrans.start;
1410 repeat;
1411 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001412 [] T.timeout {
1413 setverdict(pass);
1414 }
1415 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001416
1417 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001418}
1419
Harald Welte235ebf12017-12-15 14:18:16 +01001420/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001421testcase TC_paging_counter() runs on test_CT {
1422 var BSSMAP_FIELD_CellIdentificationList cid_list;
1423 timer T := 4.0;
1424 var integer i;
1425 var integer paging_attempted_bsc;
1426 var integer paging_attempted_bts[NUM_BTS];
1427 var integer paging_expired_bts[NUM_BTS];
1428 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1429
1430 f_init();
1431
1432 /* read counters before paging */
1433 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1434 for (i := 0; i < NUM_BTS; i := i+1) {
1435 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1436 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1437 }
1438
1439 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1440
1441 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1442 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1443 for (i := 0; i < NUM_BTS; i := i+1) {
1444 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1445 paging_attempted_bts[i]+1);
1446 }
1447
1448 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1449 f_sleep(12.0);
1450 for (i := 0; i < NUM_BTS; i := i+1) {
1451 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1452 paging_expired_bts[i]+1);
1453 }
Harald Welte1ff69992017-12-14 12:31:17 +01001454
Philipp Maier282ca4b2018-02-27 17:17:00 +01001455 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001456}
1457
1458
Harald Welte10985002017-12-12 09:29:15 +01001459/* Verify paging stops after A-RESET */
1460testcase TC_paging_imsi_a_reset() runs on test_CT {
1461 var BSSMAP_FIELD_CellIdentificationList cid_list;
1462 timer T := 3.0;
1463 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001464 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001465
1466 /* Perform a BSSMAP Reset and wait for ACK */
Harald Weltea4ca4462018-02-09 00:17:14 +01001467 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0)));
Harald Welte10985002017-12-12 09:29:15 +01001468 alt {
Harald Weltea4ca4462018-02-09 00:17:14 +01001469 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck)) { }
Harald Welte10985002017-12-12 09:29:15 +01001470 [] BSSAP.receive { repeat; }
1471 }
1472
Daniel Willmanncbef3982018-07-30 09:22:40 +02001473 /* Wait to avoid a possible race condition if a paging message is
1474 * received right before the reset ACK. */
1475 f_sleep(0.2);
1476
Harald Welte10985002017-12-12 09:29:15 +01001477 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001478 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1479 IPA_RSL[i].clear;
1480 }
Harald Welte10985002017-12-12 09:29:15 +01001481
1482 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1483 T.start;
1484 alt {
1485 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1486 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001487 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01001488 }
Harald Welte5d1a2202017-12-13 19:51:29 +01001489 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1490 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001491 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001492 }
1493 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1494 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001495 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001496 }
Harald Welte10985002017-12-12 09:29:15 +01001497 [] T.timeout {
1498 setverdict(pass);
1499 }
1500 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001501
1502 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001503}
Harald Welteae026692017-12-09 01:03:01 +01001504
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001505/* Verify how we handle unsolicited Paging Response, for instance because we
1506 * receive a Paging Response after T3113 expired (and subscriber information was
1507 * dropped). See OS#3680.
1508 */
1509testcase TC_paging_resp_unsol() runs on test_CT {
1510
1511 f_init(1);
1512
1513 var BSSAP_N_CONNECT_ind rx_c_ind;
1514 var DchanTuple dt;
1515 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
1516
1517 /* Send CHAN RQD and wait for allocation; acknowledge it */
1518 dt.rsl_chan_nr := f_chreq_act_ack();
1519
1520 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
1521 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
1522
1523 /* expect BSC to disable the channel */
Pau Espin Pedrol5ee6f6c2018-12-07 12:07:43 +01001524 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001525 setverdict(pass);
1526
1527}
1528
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001529/* Test RSL link drop causes counter increment */
1530testcase TC_rsl_drop_counter() runs on test_CT {
1531 var integer rsl_fail;
1532
Harald Welte89d42e82017-12-17 16:42:41 +01001533 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001534
1535 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1536
1537 bts[0].rsl.vc_IPA.stop;
1538
1539 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1540
1541 setverdict(pass);
1542}
1543
1544/* TODO: Test OML link drop causes counter increment */
1545
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001546/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1547function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1548 timer T := 10.0;
1549
1550 bts[0].rsl.id := "IPA-0-RSL";
1551 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1552 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1553 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
1554 bts[0].rsl.ccm_pars.unit_id := "0/0/0"; /* value which is unknown at BTS */
1555
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001556 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1557
1558 f_init_mgcp("VirtMSC");
1559
1560 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1561 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1562 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1563 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1564
1565 /* wait for IPA OML link to connect and then disconnect */
1566 T.start;
1567 alt {
1568 [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) {
1569 T.stop;
1570 return true;
1571 }
1572 [] IPA_RSL[0].receive { repeat }
1573 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02001574 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001575 }
1576 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001577 return false;
1578}
1579
1580/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1581testcase TC_rsl_unknown_unit_id() runs on test_CT {
1582 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1583 setverdict(pass);
1584 } else {
1585 setverdict(fail, "Timeout RSL waiting for connection to close");
1586 }
1587}
1588
1589
1590/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1591testcase TC_oml_unknown_unit_id() runs on test_CT {
1592 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1593 setverdict(pass);
1594 } else {
1595 setverdict(fail, "Timeout OML waiting for connection to close");
1596 }
1597}
1598
1599
Harald Weltec1a2fff2017-12-17 11:06:19 +01001600/***********************************************************************
1601 * "New world" test cases using RSL_Emulation + BSSMAP_Emulation
1602 ***********************************************************************/
1603
1604import from BSSMAP_Emulation all;
1605import from RSL_Emulation all;
1606import from MSC_ConnectionHandler all;
1607
1608type function void_fn(charstring id) runs on MSC_ConnHdlr;
1609
Harald Welte336820c2018-05-31 20:34:52 +02001610/* helper function to create and connect a MSC_ConnHdlr component */
Harald Welteff579f92018-05-31 22:19:39 +02001611private function f_connect_handler(inout MSC_ConnHdlr vc_conn) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +01001612 connect(vc_conn:BSSMAPEM, g_bssap.vc_BSSMAP:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001613 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001614 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001615 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001616 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001617 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1618 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1619 }
Harald Weltea4ca4462018-02-09 00:17:14 +01001620 connect(vc_conn:BSSAP, g_bssap.vc_BSSMAP:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001621 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Harald Welte336820c2018-05-31 20:34:52 +02001622}
1623
1624function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
1625runs on test_CT return MSC_ConnHdlr {
1626 var charstring id := testcasename();
1627 var MSC_ConnHdlr vc_conn;
1628 vc_conn := MSC_ConnHdlr.create(id);
1629 f_connect_handler(vc_conn);
Harald Weltea0630032018-03-20 21:09:55 +01001630 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001631 return vc_conn;
1632}
1633
Harald Weltea0630032018-03-20 21:09:55 +01001634/* first function inside ConnHdlr component; sets g_pars + starts function */
1635private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1636runs on MSC_ConnHdlr {
1637 if (isvalue(pars)) {
1638 g_pars := valueof(pars);
1639 }
1640 fn.apply(id);
1641}
1642
Harald Welte3c86ea02018-05-10 22:28:05 +02001643/* Establish signalling channel (non-assignment case) followed by cipher mode */
1644private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001645 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1646 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001647 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02001648 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
1649 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
1650 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
1651 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02001652
Philipp Maier23000732018-05-18 11:25:37 +02001653 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02001654}
1655testcase TC_ciph_mode_a5_0() runs on test_CT {
1656 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001657 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001658 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1659
1660 f_init(1, true);
1661 f_sleep(1.0);
1662 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1663 vc_conn.done;
1664}
1665testcase TC_ciph_mode_a5_1() runs on test_CT {
1666 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001667 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001668 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1669
1670 f_init(1, true);
1671 f_sleep(1.0);
1672 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1673 vc_conn.done;
1674}
1675testcase TC_ciph_mode_a5_3() runs on test_CT {
1676 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001677 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001678 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1679
1680 f_init(1, true);
1681 f_sleep(1.0);
1682 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1683 vc_conn.done;
1684}
1685
1686
1687/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001688private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001689 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1690 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001691
Harald Welte552620d2017-12-16 23:21:36 +01001692 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1693 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001694
Harald Weltea0630032018-03-20 21:09:55 +01001695 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001696}
Harald Welte552620d2017-12-16 23:21:36 +01001697testcase TC_assignment_fr_a5_0() runs on test_CT {
1698 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001699 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001700 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001701
Harald Welte89d42e82017-12-17 16:42:41 +01001702 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001703 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001704 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001705 vc_conn.done;
1706}
Harald Welte552620d2017-12-16 23:21:36 +01001707testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001708 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001709 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001710 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001711
Harald Welte89d42e82017-12-17 16:42:41 +01001712 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001713 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001714 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1715 vc_conn.done;
1716}
1717testcase TC_assignment_fr_a5_3() runs on test_CT {
1718 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001719 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001720 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001721
Harald Welte651fcdc2018-05-10 20:23:16 +02001722 f_init(1, true);
1723 f_sleep(1.0);
1724 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001725 vc_conn.done;
1726}
1727
Harald Welte552620d2017-12-16 23:21:36 +01001728/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1729private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001730 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01001731 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001732 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001733 const OCT8 kc := '0001020304050607'O;
1734
1735 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001736 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
1737
Harald Weltea0630032018-03-20 21:09:55 +01001738 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001739}
Harald Welte552620d2017-12-16 23:21:36 +01001740testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1741 var MSC_ConnHdlr vc_conn;
1742
Harald Welte89d42e82017-12-17 16:42:41 +01001743 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001744 f_sleep(1.0);
1745
Harald Welte8863fa12018-05-10 20:15:27 +02001746 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001747 vc_conn.done;
1748}
1749
Harald Welte552620d2017-12-16 23:21:36 +01001750private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001751 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02001752 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1753 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001754 const OCT8 kc := '0001020304050607'O;
1755 const OCT16 kc128 := kc & kc;
1756
1757 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1758 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001759 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001760 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001761 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001762}
Harald Welte552620d2017-12-16 23:21:36 +01001763testcase TC_assignment_fr_a5_4() runs on test_CT {
1764 var MSC_ConnHdlr vc_conn;
1765
Harald Welte89d42e82017-12-17 16:42:41 +01001766 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001767 f_sleep(1.0);
1768
Harald Welte8863fa12018-05-10 20:15:27 +02001769 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001770 vc_conn.done;
1771}
1772
1773
Harald Welte4532e0a2017-12-23 02:05:44 +01001774private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001775 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01001776 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02001777 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01001778 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001779 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001780}
1781
1782testcase TC_assignment_sign() runs on test_CT {
1783 var MSC_ConnHdlr vc_conn;
1784
1785 f_init(1, true);
1786 f_sleep(1.0);
1787
Harald Welte8863fa12018-05-10 20:15:27 +02001788 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001789 vc_conn.done;
1790}
1791
Harald Welte60aa5762018-03-21 19:33:13 +01001792/***********************************************************************
1793 * Codec (list) testing
1794 ***********************************************************************/
1795
1796/* check if the given rsl_mode is compatible with the a_elem */
1797private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1798return boolean {
1799 select (a_elem.codecType) {
1800 case (GSM_FR) {
1801 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1802 return true;
1803 }
1804 }
1805 case (GSM_HR) {
1806 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1807 return true;
1808 }
1809 }
1810 case (GSM_EFR) {
1811 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1812 return true;
1813 }
1814 }
1815 case (FR_AMR) {
1816 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1817 return true;
1818 }
1819 }
1820 case (HR_AMR) {
1821 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1822 return true;
1823 }
1824 }
1825 case else { }
1826 }
1827 return false;
1828}
1829
1830/* check if the given rsl_mode is compatible with the a_list */
1831private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
1832return boolean {
1833 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
1834 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
1835 return true;
1836 }
1837 }
1838 return false;
1839}
1840
1841/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02001842function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01001843return BSSMAP_IE_ChannelType {
1844 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
1845 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
1846 select (a_elem.codecType) {
1847 case (GSM_FR) {
1848 ret.channelRateAndType := ChRate_TCHF;
1849 ret.speechId_DataIndicator := Spdi_TCHF_FR;
1850 }
1851 case (GSM_HR) {
1852 ret.channelRateAndType := ChRate_TCHH;
1853 ret.speechId_DataIndicator := Spdi_TCHH_HR;
1854 }
1855 case (GSM_EFR) {
1856 ret.channelRateAndType := ChRate_TCHF;
1857 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
1858 }
1859 case (FR_AMR) {
1860 ret.channelRateAndType := ChRate_TCHF;
1861 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
1862 }
1863 case (HR_AMR) {
1864 ret.channelRateAndType := ChRate_TCHH;
1865 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
1866 }
1867 case else {
1868 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02001869 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01001870 }
1871 }
1872 return ret;
1873}
1874
Harald Weltea63b9102018-03-22 20:36:16 +01001875private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
1876return template RSL_IE_Body {
1877 var template RSL_IE_Body mode_ie := {
1878 chan_mode := {
1879 len := ?,
1880 reserved := ?,
1881 dtx_d := ?,
1882 dtx_u := ?,
1883 spd_ind := RSL_SPDI_SPEECH,
1884 ch_rate_type := -,
1885 coding_alg_rate := -
1886 }
1887 }
1888
1889 select (a_elem.codecType) {
1890 case (GSM_FR) {
1891 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1892 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1893 }
1894 case (GSM_HR) {
1895 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1896 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1897 }
1898 case (GSM_EFR) {
1899 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1900 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
1901 }
1902 case (FR_AMR) {
1903 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1904 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1905 }
1906 case (HR_AMR) {
1907 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1908 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1909 }
1910 }
1911 return mode_ie;
1912}
1913
Harald Welte60aa5762018-03-21 19:33:13 +01001914type record CodecListTest {
1915 BSSMAP_IE_SpeechCodecList codec_list,
1916 charstring id
1917}
1918type record of CodecListTest CodecListTests
1919
1920private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001921 var PDU_BSSAP ass_cmd := f_gen_ass_req();
1922 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
Harald Welte60aa5762018-03-21 19:33:13 +01001923
1924 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Harald Welte79f3f542018-05-25 20:02:37 +02001925 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
1926 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
1927 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
1928 g_pars.ass_codec_list.codecElements[0];
1929 }
Harald Welte60aa5762018-03-21 19:33:13 +01001930 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
1931 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01001932 log("expecting ASS COMPL like this: ", exp_compl);
1933
1934 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01001935
1936 /* Verify that the RSL-side activation actually matches our expectations */
1937 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
1938
1939 var RSL_IE_Body mode_ie;
1940 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
1941 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02001942 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01001943 }
1944 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
1945 if (not match(mode_ie, t_mode_ie)) {
1946 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
1947 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02001948
1949 var RSL_IE_Body mr_conf;
1950 if (g_pars.expect_mr_conf_ie != omit) {
1951 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
1952 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02001953 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02001954 }
1955 log("found RSL MR CONFIG IE: ", mr_conf);
1956
1957 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
1958 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
1959 g_pars.expect_mr_conf_ie);
1960 }
1961 } else {
1962 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
1963 log("found RSL MR CONFIG IE: ", mr_conf);
1964 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02001965 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02001966 }
1967 }
Harald Welte60aa5762018-03-21 19:33:13 +01001968}
1969
1970testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02001971 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01001972 var MSC_ConnHdlr vc_conn;
1973
1974 f_init(1, true);
1975 f_sleep(1.0);
1976
1977 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001978 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001979 vc_conn.done;
1980}
1981
1982testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02001983 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01001984 var MSC_ConnHdlr vc_conn;
1985
1986 f_init(1, true);
1987 f_sleep(1.0);
1988
1989 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001990 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001991 vc_conn.done;
1992}
1993
1994testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02001995 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01001996 var MSC_ConnHdlr vc_conn;
1997
1998 f_init(1, true);
1999 f_sleep(1.0);
2000
2001 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002002 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002003 vc_conn.done;
2004}
2005
2006testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002007 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002008 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002009
2010 /* Note: This setups the codec configuration. The parameter payload in
2011 * mr_conf must be consistant with the parameter codecElements in pars
2012 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002013 var RSL_IE_Body mr_conf := {
2014 other := {
2015 len := 2,
2016 payload := '2804'O
2017 }
2018 };
Harald Welte60aa5762018-03-21 19:33:13 +01002019
Philipp Maier7695a0d2018-09-27 17:52:14 +02002020 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2021 pars.ass_codec_list.codecElements[0].s0_7 := '00000110'B;
2022 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
2023 pars.expect_mr_conf_ie := mr_conf;
2024
Harald Welte60aa5762018-03-21 19:33:13 +01002025 f_init(1, true);
2026 f_sleep(1.0);
2027
Harald Welte8863fa12018-05-10 20:15:27 +02002028 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002029 vc_conn.done;
2030}
2031
2032testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002033 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002034 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002035
2036 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002037 var RSL_IE_Body mr_conf := {
2038 other := {
2039 len := 2,
2040 payload := '2804'O
2041 }
2042 };
Harald Welte60aa5762018-03-21 19:33:13 +01002043
Philipp Maier7695a0d2018-09-27 17:52:14 +02002044 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2045 pars.ass_codec_list.codecElements[0].s0_7 := '00000110'B;
2046 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2047 pars.expect_mr_conf_ie := mr_conf;
2048
Harald Welte60aa5762018-03-21 19:33:13 +01002049 f_init(1, true);
2050 f_sleep(1.0);
2051
Harald Welte8863fa12018-05-10 20:15:27 +02002052 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002053 vc_conn.done;
2054}
2055
Philipp Maierac09bfc2019-01-08 13:41:39 +01002056private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002057 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
2058 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
2059 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
2060 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002061}
2062
2063private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002064 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
2065 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002066}
2067
2068private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002069 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
2070 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
2071 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
2072 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
2073 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
2074 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002075}
2076
2077/* Allow HR only */
2078private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
2079 g_pars := f_gen_test_hdlr_pars();
2080 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2081 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2082 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2083 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2084 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2085 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2086 f_establish_fully(ass_cmd, exp_compl);
2087}
2088
2089/* Allow FR only */
2090private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
2091 g_pars := f_gen_test_hdlr_pars();
2092 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2093 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2094 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2095 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2096 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2097 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2098 f_establish_fully(ass_cmd, exp_compl);
2099}
2100
2101/* Allow HR only (expect assignment failure) */
2102private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
2103 g_pars := f_gen_test_hdlr_pars();
2104 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2105 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2106 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2107 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2108 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2109 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2110 f_establish_fully(ass_cmd, exp_fail);
2111}
2112
2113/* Allow FR only (expect assignment failure) */
2114private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
2115 g_pars := f_gen_test_hdlr_pars();
2116 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2117 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2118 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2119 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2120 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2121 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2122 f_establish_fully(ass_cmd, exp_fail);
2123}
2124
2125/* Allow FR and HR, but prefer FR */
2126private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2127 g_pars := f_gen_test_hdlr_pars();
2128 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2129 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2130 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2131 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2132 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2133 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2134 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2135 f_establish_fully(ass_cmd, exp_compl);
2136}
2137
2138/* Allow FR and HR, but prefer HR */
2139private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2140 g_pars := f_gen_test_hdlr_pars();
2141 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2142 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2143 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2144 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2145 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2146 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2147 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2148 f_establish_fully(ass_cmd, exp_compl);
2149}
2150
2151/* Allow FR and HR, but prefer FR */
2152private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2153 g_pars := f_gen_test_hdlr_pars();
2154 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2155 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2156 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2157 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2158 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2159 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2160 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2161 f_establish_fully(ass_cmd, exp_compl);
2162}
2163
2164/* Allow FR and HR, but prefer HR */
2165private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2166 g_pars := f_gen_test_hdlr_pars();
2167 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2168 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2169 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2170 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2171 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2172 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2173 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2174 f_establish_fully(ass_cmd, exp_compl);
2175}
2176
2177/* Request a HR channel while all FR channels are exhausted, this is expected
2178 * to work without conflicts */
2179testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
2180 var MSC_ConnHdlr vc_conn;
2181 f_init(1, true);
2182 f_sleep(1.0);
2183 f_enable_all_tch();
2184 f_disable_all_tch_f();
2185 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
2186 vc_conn.done;
2187 f_enable_all_tch();
2188 setverdict(pass);
2189}
2190
2191/* Request a FR channel while all FR channels are exhausted, this is expected
2192 * to fail. */
2193testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
2194 var MSC_ConnHdlr vc_conn;
2195 f_init(1, true);
2196 f_sleep(1.0);
2197 f_enable_all_tch();
2198 f_disable_all_tch_f();
2199 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
2200 vc_conn.done;
2201 f_enable_all_tch();
2202 setverdict(pass);
2203}
2204
2205/* Request a FR (prefered) or alternatively a HR channel while all FR channels
2206 * are exhausted, this is expected to be resolved by selecting a HR channel. */
2207testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
2208 var MSC_ConnHdlr vc_conn;
2209 f_init(1, true);
2210 f_sleep(1.0);
2211 f_enable_all_tch();
2212 f_disable_all_tch_f();
2213 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
2214 vc_conn.done;
2215 f_enable_all_tch();
2216 setverdict(pass);
2217}
2218
2219/* Request a HR (prefered) or alternatively a FR channel while all FR channels
2220 * are exhausted, this is expected to work without conflicts. */
2221testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
2222 var MSC_ConnHdlr vc_conn;
2223 f_init(1, true);
2224 f_sleep(1.0);
2225 f_enable_all_tch();
2226 f_disable_all_tch_f();
2227 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
2228 vc_conn.done;
2229 f_enable_all_tch();
2230 setverdict(pass);
2231}
2232
2233/* Request a FR channel while all HR channels are exhausted, this is expected
2234 * to work without conflicts */
2235testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
2236 var MSC_ConnHdlr vc_conn;
2237 f_init(1, true);
2238 f_sleep(1.0);
2239 f_enable_all_tch();
2240 f_disable_all_tch_h();
2241 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
2242 vc_conn.done;
2243 f_enable_all_tch();
2244 setverdict(pass);
2245}
2246
2247/* Request a HR channel while all HR channels are exhausted, this is expected
2248 * to fail. */
2249testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
2250 var MSC_ConnHdlr vc_conn;
2251 f_init(1, true);
2252 f_sleep(1.0);
2253 f_enable_all_tch();
2254 f_disable_all_tch_h();
2255 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
2256 vc_conn.done;
2257 f_enable_all_tch();
2258 setverdict(pass);
2259}
2260
2261/* Request a HR (prefered) or alternatively a FR channel while all HR channels
2262 * are exhausted, this is expected to be resolved by selecting a FR channel. */
2263testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
2264 var MSC_ConnHdlr vc_conn;
2265 f_init(1, true);
2266 f_sleep(1.0);
2267 f_enable_all_tch();
2268 f_disable_all_tch_h();
2269 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
2270 vc_conn.done;
2271 f_enable_all_tch();
2272 setverdict(pass);
2273}
2274
2275/* Request a FR (prefered) or alternatively a HR channel while all HR channels
2276 * are exhausted, this is expected to work without conflicts. */
2277testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
2278 var MSC_ConnHdlr vc_conn;
2279 f_init(1, true);
2280 f_sleep(1.0);
2281 f_enable_all_tch();
2282 f_disable_all_tch_h();
2283 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
2284 vc_conn.done;
2285 f_enable_all_tch();
2286 setverdict(pass);
2287}
2288
2289/* Allow FR and HR, but prefer HR */
2290private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2291 g_pars := f_gen_test_hdlr_pars();
2292 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2293 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2294 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2295 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2296 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2297 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2298 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2299 f_establish_fully(ass_cmd, exp_compl);
2300}
2301
2302/* Allow FR and HR, but prefer FR */
2303private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2304 g_pars := f_gen_test_hdlr_pars();
2305 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2306 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2307 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2308 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2309 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2310 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2311 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2312 f_establish_fully(ass_cmd, exp_compl);
2313}
2314
2315/* Request a HR (prefered) or alternatively a FR channel, it is expected that
2316 * HR, which is the prefered type, is selected. */
2317testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
2318 var MSC_ConnHdlr vc_conn;
2319 f_init(1, true);
2320 f_sleep(1.0);
2321 f_enable_all_tch();
2322 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
2323 vc_conn.done;
2324 setverdict(pass);
2325}
2326
2327/* Request a FR (prefered) or alternatively a HR channel, it is expected that
2328 * FR, which is the prefered type, is selected. */
2329testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
2330 var MSC_ConnHdlr vc_conn;
2331 f_init(1, true);
2332 f_sleep(1.0);
2333 f_enable_all_tch();
2334 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
2335 vc_conn.done;
2336 setverdict(pass);
2337}
2338
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002339/* test the procedure of the MSC requesting a Classmark Update:
2340 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
2341 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01002342private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002343 g_pars := f_gen_test_hdlr_pars();
2344
Harald Weltea0630032018-03-20 21:09:55 +01002345 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002346 /* we should now have a COMPL_L3 at the MSC */
2347 BSSAP.receive(tr_BSSMAP_ComplL3);
2348
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002349 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
2350 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
2351
Harald Welte898113b2018-01-31 18:32:21 +01002352 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
2353 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
2354 setverdict(pass);
2355}
2356testcase TC_classmark() runs on test_CT {
2357 var MSC_ConnHdlr vc_conn;
2358 f_init(1, true);
2359 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002360 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01002361 vc_conn.done;
2362}
2363
Harald Weltee3bd6582018-01-31 22:51:25 +01002364private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002365 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002366 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002367 /* we should now have a COMPL_L3 at the MSC */
2368 BSSAP.receive(tr_BSSMAP_ComplL3);
2369
Harald Weltee3bd6582018-01-31 22:51:25 +01002370 /* send the single message we want to send */
2371 f_rsl_send_l3(l3);
2372}
2373
2374private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
2375 timer T := sec;
2376 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01002377 T.start;
2378 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01002379 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
2380 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02002381 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01002382 }
2383 [] T.timeout {
2384 setverdict(pass);
2385 }
2386 }
2387}
2388
Harald Weltee3bd6582018-01-31 22:51:25 +01002389/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2390private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
2391 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
2392 f_bssap_expect_nothing();
2393}
Harald Welte898113b2018-01-31 18:32:21 +01002394testcase TC_unsol_ass_fail() runs on test_CT {
2395 var MSC_ConnHdlr vc_conn;
2396 f_init(1, true);
2397 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002398 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01002399 vc_conn.done;
2400}
Harald Welte552620d2017-12-16 23:21:36 +01002401
Harald Welteea99a002018-01-31 20:46:43 +01002402
2403/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
2404private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002405 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
2406 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01002407}
2408testcase TC_unsol_ass_compl() runs on test_CT {
2409 var MSC_ConnHdlr vc_conn;
2410 f_init(1, true);
2411 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002412 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01002413 vc_conn.done;
2414}
2415
2416
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002417/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2418private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002419 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
2420 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002421}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002422testcase TC_unsol_ho_fail() runs on test_CT {
2423 var MSC_ConnHdlr vc_conn;
2424 f_init(1, true);
2425 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002426 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002427 vc_conn.done;
2428}
2429
2430
Harald Weltee3bd6582018-01-31 22:51:25 +01002431/* short message from MS should be ignored */
2432private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002433 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002434 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01002435 /* we should now have a COMPL_L3 at the MSC */
2436 BSSAP.receive(tr_BSSMAP_ComplL3);
2437
2438 /* send short message */
2439 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
2440 f_bssap_expect_nothing();
2441}
2442testcase TC_err_82_short_msg() runs on test_CT {
2443 var MSC_ConnHdlr vc_conn;
2444 f_init(1, true);
2445 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002446 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01002447 vc_conn.done;
2448}
2449
2450
Harald Weltee9e02e42018-01-31 23:36:25 +01002451/* 24.008 8.4 Unknown message must trigger RR STATUS */
2452private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
2453 f_est_single_l3(ts_RRM_UL_REL('00'O));
2454 timer T := 3.0
2455 alt {
2456 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
2457 setverdict(pass);
2458 }
2459 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01002460 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01002461 }
2462}
2463testcase TC_err_84_unknown_msg() runs on test_CT {
2464 var MSC_ConnHdlr vc_conn;
2465 f_init(1, true);
2466 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002467 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01002468 vc_conn.done;
2469}
2470
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002471/***********************************************************************
2472 * Handover
2473 ***********************************************************************/
2474
Harald Welte94e0c342018-04-07 11:33:23 +02002475/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
2476private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
2477runs on test_CT {
2478 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2479 " timeslot "&int2str(ts_nr)&" ";
2480 f_vty_transceive(BSCVTY, cmd & suffix);
2481}
2482
Harald Welte261af4b2018-02-12 21:20:39 +01002483/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
2484private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
2485runs on MSC_ConnHdlr {
2486 /* FIXME: resolve those from component-global state */
2487 var integer ts_nr := chan_nr.tn;
2488 var integer ss_nr;
2489 if (ischosen(chan_nr.u.ch0)) {
2490 ss_nr := 0;
2491 } else if (ischosen(chan_nr.u.lm)) {
2492 ss_nr := chan_nr.u.lm.sub_chan;
2493 } else if (ischosen(chan_nr.u.sdcch4)) {
2494 ss_nr := chan_nr.u.sdcch4.sub_chan;
2495 } else if (ischosen(chan_nr.u.sdcch8)) {
2496 ss_nr := chan_nr.u.sdcch8.sub_chan;
2497 } else {
2498 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02002499 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01002500 }
2501
2502 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2503 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
2504 f_vty_transceive(BSCVTY, cmd & suffix);
2505}
2506
2507private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
2508 integer new_bts_nr)
2509runs on MSC_ConnHdlr {
2510 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
2511}
2512
2513/* intra-BSC hand-over between BTS0 and BTS1 */
2514private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002515 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02002516 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2517 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01002518 const OCT8 kc := '0001020304050607'O;
2519
2520 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2521 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2522
Harald Weltea0630032018-03-20 21:09:55 +01002523 f_establish_fully(ass_cmd, exp_compl);
Harald Welte261af4b2018-02-12 21:20:39 +01002524
2525 var HandoverState hs := {
2526 rr_ho_cmpl_seen := false,
2527 handover_done := false,
2528 old_chan_nr := -
2529 };
2530 /* issue hand-over command on VTY */
2531 f_vty_handover(0, 0, g_chan_nr, 1);
2532 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2533 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002534
2535 /* From the MGW perspective, a handover is is characterized by
2536 * performing one MDCX operation with the MGW. So we expect to see
2537 * one more MDCX during handover. */
2538 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
2539
Harald Welte261af4b2018-02-12 21:20:39 +01002540 alt {
2541 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01002542 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002543
Philipp Maier4dae0652018-11-12 12:03:26 +01002544 /* Since this is an internal handover we expect the BSC to inform the
2545 * MSC about the event */
2546 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
2547
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002548 /* Check the amount of MGCP transactions is still consistant with the
2549 * test expectation */
2550 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01002551 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01002552}
2553
2554testcase TC_ho_int() runs on test_CT {
2555 var MSC_ConnHdlr vc_conn;
2556 f_init(2, true);
2557 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002558 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002559 vc_conn.done;
2560}
Harald Weltee9e02e42018-01-31 23:36:25 +01002561
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002562private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002563 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002564
2565 var PDU_BSSAP ass_req := f_gen_ass_req();
2566 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2567 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2568 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2569 f_establish_fully(ass_req, exp_compl);
2570
2571 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2572
2573 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2574
2575 f_sleep(0.5);
2576 /* The MSC negotiates Handover Request and Handover Request Ack with
2577 * the other BSS and comes back with a BSSMAP Handover Command
2578 * containing an RR Handover Command coming from the target BSS... */
2579
2580 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
2581 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
2582 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
2583 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
2584 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
2585
2586 /* expect the Handover Command to go out on RR */
2587 var RSL_Message rsl_ho_cmd
2588 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
2589 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
2590 var RSL_IE_Body rsl_ho_cmd_l3;
2591 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
2592 log("RSL message contains no L3 Info IE, expected RR Handover Command");
2593 setverdict(fail);
2594 } else {
2595 log("Found L3 Info: ", rsl_ho_cmd_l3);
2596 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
2597 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
2598 setverdict(fail);
2599 } else {
2600 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
2601 setverdict(pass);
2602 }
2603 }
2604
2605 /* When the other BSS has reported a completed handover, this side is
2606 * torn down. */
2607
2608 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
2609 var BssmapCause cause := enum2int(cause_val);
2610 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
2611
2612 /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
2613 var MgcpCommand mgcp;
2614 interleave {
2615 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
2616 [] MGCP.receive(tr_DLCX()) -> value mgcp {
2617 log("Got first DLCX: ", mgcp);
2618 }
2619 [] MGCP.receive(tr_DLCX()) -> value mgcp {
2620 log("Got second DLCX: ", mgcp);
2621 }
2622 }
2623 setverdict(pass);
2624 f_sleep(1.0);
2625}
2626testcase TC_ho_out_of_this_bsc() runs on test_CT {
2627 var MSC_ConnHdlr vc_conn;
2628
2629 f_init(1, true);
2630 f_sleep(1.0);
2631
2632 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
2633 vc_conn.done;
2634}
2635
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02002636/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
2637 * simply never sends a BSSMAP Handover Command. */
2638private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01002639 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02002640
2641 var PDU_BSSAP ass_req := f_gen_ass_req();
2642 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2643 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2644 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2645 f_establish_fully(ass_req, exp_compl);
2646
2647 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2648
2649 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2650
2651 /* osmo-bsc should time out 10 seconds after the handover started.
2652 * Let's give it a bit extra. */
2653 f_sleep(15.0);
2654
2655 /* The old lchan and conn should still be active. See that arbitrary L3
2656 * is still going through. */
2657 var octetstring l3 := '0123456789'O;
2658 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2659 var template PDU_BSSAP exp_data := {
2660 discriminator := '1'B,
2661 spare := '0000000'B,
2662 dlci := '00'O,
2663 lengthIndicator := 5,
2664 pdu := {
2665 dtap := l3
2666 }
2667 };
2668 BSSAP.receive(exp_data);
2669 setverdict(pass);
2670 f_sleep(1.0);
2671}
2672testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
2673 var MSC_ConnHdlr vc_conn;
2674
2675 f_init(1, true);
2676 f_sleep(1.0);
2677
2678 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
2679 vc_conn.done;
2680}
2681
2682/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
2683 * RR Handover Failure. */
2684private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01002685 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02002686
2687 var PDU_BSSAP ass_req := f_gen_ass_req();
2688 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2689 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2690 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2691 f_establish_fully(ass_req, exp_compl);
2692
2693 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2694
2695 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2696
2697 f_sleep(0.5);
2698 /* The MSC negotiates Handover Request and Handover Request Ack with
2699 * the other BSS and comes back with a BSSMAP Handover Command
2700 * containing an RR Handover Command coming from the target BSS... */
2701
2702 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
2703 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
2704 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
2705 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
2706 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
2707
2708 /* expect the Handover Command to go out on RR */
2709 var RSL_Message rsl_ho_cmd
2710 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
2711 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
2712 var RSL_IE_Body rsl_ho_cmd_l3;
2713 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
2714 log("RSL message contains no L3 Info IE, expected RR Handover Command");
2715 setverdict(fail);
2716 } else {
2717 log("Found L3 Info: ", rsl_ho_cmd_l3);
2718 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
2719 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
2720 setverdict(fail);
2721 } else {
2722 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
2723 setverdict(pass);
2724 }
2725 }
2726
2727 f_sleep(0.2);
2728 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
2729
2730 /* Should tell the MSC about the failure */
2731 BSSAP.receive(tr_BSSMAP_HandoverFailure);
2732
2733 f_sleep(1.0);
2734
2735 /* The old lchan and conn should still be active. See that arbitrary L3
2736 * is still going through. */
2737 var octetstring l3 := '0123456789'O;
2738 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2739 var template PDU_BSSAP exp_data := {
2740 discriminator := '1'B,
2741 spare := '0000000'B,
2742 dlci := '00'O,
2743 lengthIndicator := 5,
2744 pdu := {
2745 dtap := l3
2746 }
2747 };
2748 BSSAP.receive(exp_data);
2749 setverdict(pass);
2750 f_sleep(1.0);
2751
2752 setverdict(pass);
2753 f_sleep(1.0);
2754}
2755testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
2756 var MSC_ConnHdlr vc_conn;
2757
2758 f_init(1, true);
2759 f_sleep(1.0);
2760
2761 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
2762 vc_conn.done;
2763}
2764
2765/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
2766 * RR Handover Failure. */
2767private function f_tc_ho_out_fail_no_ho_detect(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01002768 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02002769
2770 var PDU_BSSAP ass_req := f_gen_ass_req();
2771 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2772 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2773 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2774 f_establish_fully(ass_req, exp_compl);
2775
2776 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2777
2778 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2779
2780 f_sleep(0.5);
2781 /* The MSC negotiates Handover Request and Handover Request Ack with
2782 * the other BSS and comes back with a BSSMAP Handover Command
2783 * containing an RR Handover Command coming from the target BSS... */
2784
2785 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
2786 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
2787 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
2788 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
2789 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
2790
2791 /* expect the Handover Command to go out on RR */
2792 var RSL_Message rsl_ho_cmd
2793 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
2794 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
2795 var RSL_IE_Body rsl_ho_cmd_l3;
2796 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
2797 log("RSL message contains no L3 Info IE, expected RR Handover Command");
2798 setverdict(fail);
2799 } else {
2800 log("Found L3 Info: ", rsl_ho_cmd_l3);
2801 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
2802 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
2803 setverdict(fail);
2804 } else {
2805 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
2806 setverdict(pass);
2807 }
2808 }
2809
2810 /* The MS never shows up on the remote BSS. Eventually the BSC times
2811 * out and we run into 3GPP TS 48.008 3.1.5.3.3 "Abnormal Conditions":
2812 * RR should be released and Clear Request should go to the MSC. */
2813
2814 var MgcpCommand mgcp;
Neels Hofmeyr211169d2018-11-07 00:37:29 +01002815 var octetstring l3_rr_chan_rel := '060D00'O;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02002816 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01002817 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
2818 log("Got Deact SACCH");
2819 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01002820 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, l3_rr_chan_rel)) {
2821 log("Got RR Release");
2822 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02002823 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
2824 log("Got RF Chan Rel");
2825 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
2826 }
2827 [] BSSAP.receive(tr_BSSMAP_ClearRequest) {
2828 log("Got BSSMAP Clear Request");
2829 }
2830 [] MGCP.receive(tr_DLCX()) -> value mgcp {
2831 log("Got first DLCX: ", mgcp);
2832 }
2833 [] MGCP.receive(tr_DLCX()) -> value mgcp {
2834 log("Got second DLCX: ", mgcp);
2835 }
2836 }
2837
2838 setverdict(pass);
2839 f_sleep(1.0);
2840}
2841testcase TC_ho_out_fail_no_ho_detect() runs on test_CT {
2842 var MSC_ConnHdlr vc_conn;
2843
2844 f_init(1, true);
2845 f_sleep(1.0);
2846
2847 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_ho_detect));
2848 vc_conn.done;
2849}
2850
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002851private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
2852 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
2853 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
2854 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
2855 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
2856 * before we get started. */
2857 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
2858 f_rslem_register(0, new_chan_nr);
2859 g_chan_nr := new_chan_nr;
2860 f_sleep(1.0);
2861
2862 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
2863 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
2864 activate(as_Media());
2865
2866 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
2867 f_gen_handover_req()));
2868 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
2869
2870 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
2871
2872 var PDU_BSSAP rx_bssap;
2873 var octetstring ho_command_str;
2874
2875 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
2876
2877 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
2878 log("Received L3 Info in HO Request Ack: ", ho_command_str);
2879 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
2880 log("L3 Info in HO Request Ack is ", ho_command);
2881
2882 var GsmArfcn arfcn;
2883 var RslChannelNr actual_new_chan_nr;
2884 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
2885 actual_new_chan_nr, arfcn);
2886
2887 if (actual_new_chan_nr != new_chan_nr) {
2888 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
2889 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
2890 setverdict(fail);
2891 return;
2892 }
2893 log("Handover Command chan_nr is", actual_new_chan_nr);
2894
2895 /* Now the MSC forwards the RR Handover Command to the other BSC, which
2896 * tells the MS to handover to the new lchan. Here comes the new MS on
2897 * the new lchan with a Handover RACH: */
2898
2899 /* send handover detect */
2900
2901 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
2902
2903 BSSAP.receive(tr_BSSMAP_HandoverDetect);
2904
2905 /* send handover complete over the new channel */
2906
2907 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
2908 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
2909 enc_PDU_ML3_MS_NW(l3_tx)));
2910
2911 BSSAP.receive(tr_BSSMAP_HandoverComplete);
2912 setverdict(pass);
2913}
2914testcase TC_ho_into_this_bsc() runs on test_CT {
2915 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02002916 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002917
2918 f_init(1, true);
2919 f_sleep(1.0);
2920
2921 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
2922 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
2923
2924 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
2925 vc_conn.done;
2926}
2927
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01002928private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
2929 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
2930 f_rslem_register(0, new_chan_nr);
2931 g_chan_nr := new_chan_nr;
2932 f_sleep(1.0);
2933
2934 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
2935 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
2936 activate(as_Media());
2937
2938 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
2939 f_gen_handover_req()));
2940 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
2941
2942 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
2943
2944 var PDU_BSSAP rx_bssap;
2945 var octetstring ho_command_str;
2946
2947 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
2948
2949 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
2950 log("Received L3 Info in HO Request Ack: ", ho_command_str);
2951 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
2952 log("L3 Info in HO Request Ack is ", ho_command);
2953
2954 var GsmArfcn arfcn;
2955 var RslChannelNr actual_new_chan_nr;
2956 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
2957 actual_new_chan_nr, arfcn);
2958
2959 if (actual_new_chan_nr != new_chan_nr) {
2960 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
2961 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
2962 setverdict(fail);
2963 return;
2964 }
2965 log("Handover Command chan_nr is", actual_new_chan_nr);
2966
2967 /* Now the MSC forwards the RR Handover Command to the other BSC, which
2968 * tells the MS to handover to the new lchan. In this case, the MS
2969 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
2970 * Handover Failure to the MSC. The procedure according to 3GPP TS
2971 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
2972 * BSSMAP Clear Command: */
2973
2974 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
2975 var BssmapCause cause := enum2int(cause_val);
2976 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
2977
2978 /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
2979 var MgcpCommand mgcp;
2980 interleave {
2981 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
2982 [] MGCP.receive(tr_DLCX()) -> value mgcp {
2983 log("Got first DLCX: ", mgcp);
2984 }
2985 [] MGCP.receive(tr_DLCX()) -> value mgcp {
2986 log("Got second DLCX: ", mgcp);
2987 }
2988 }
2989 setverdict(pass);
2990 f_sleep(1.0);
2991
2992 setverdict(pass);
2993}
2994testcase TC_ho_in_fail_msc_clears() runs on test_CT {
2995 var MSC_ConnHdlr vc_conn;
2996 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2997
2998 f_init(1, true);
2999 f_sleep(1.0);
3000
3001 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3002 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3003
3004 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
3005 vc_conn.done;
3006}
3007
3008private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
3009 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3010 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3011 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3012 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3013 * before we get started. */
3014 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3015 f_rslem_register(0, new_chan_nr);
3016 g_chan_nr := new_chan_nr;
3017 f_sleep(1.0);
3018
3019 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3020 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3021 activate(as_Media());
3022
3023 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3024 f_gen_handover_req()));
3025 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
3026
3027 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3028
3029 var PDU_BSSAP rx_bssap;
3030 var octetstring ho_command_str;
3031
3032 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3033
3034 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3035 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3036 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3037 log("L3 Info in HO Request Ack is ", ho_command);
3038
3039 var GsmArfcn arfcn;
3040 var RslChannelNr actual_new_chan_nr;
3041 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3042 actual_new_chan_nr, arfcn);
3043
3044 if (actual_new_chan_nr != new_chan_nr) {
3045 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3046 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3047 setverdict(fail);
3048 return;
3049 }
3050 log("Handover Command chan_nr is", actual_new_chan_nr);
3051
3052 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3053 * tells the MS to handover to the new lchan. Here comes the new MS on
3054 * the new lchan with a Handover RACH: */
3055
3056 /* send handover detect */
3057
3058 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3059
3060 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3061
3062 /* The MSC chooses to clear the connection now, maybe we got the
3063 * Handover RACH on the new cell but the MS still signaled Handover
3064 * Failure to the old BSS? */
3065
3066 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3067 var BssmapCause cause := enum2int(cause_val);
3068 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3069
3070 /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
3071 var MgcpCommand mgcp;
3072 interleave {
3073 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
3074 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3075 log("Got first DLCX: ", mgcp);
3076 }
3077 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3078 log("Got second DLCX: ", mgcp);
3079 }
3080 }
3081 setverdict(pass);
3082 f_sleep(1.0);
3083}
3084testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
3085 var MSC_ConnHdlr vc_conn;
3086 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3087
3088 f_init(1, true);
3089 f_sleep(1.0);
3090
3091 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3092 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3093
3094 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
3095 vc_conn.done;
3096}
3097
3098/* The new BSS's lchan times out before the MSC decides that handover failed. */
3099private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
3100 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3101 f_rslem_register(0, new_chan_nr);
3102 g_chan_nr := new_chan_nr;
3103 f_sleep(1.0);
3104
3105 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3106 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3107 activate(as_Media());
3108
3109 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3110 f_gen_handover_req()));
3111 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
3112
3113 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3114
3115 var PDU_BSSAP rx_bssap;
3116 var octetstring ho_command_str;
3117
3118 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3119
3120 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3121 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3122 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3123 log("L3 Info in HO Request Ack is ", ho_command);
3124
3125 var GsmArfcn arfcn;
3126 var RslChannelNr actual_new_chan_nr;
3127 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3128 actual_new_chan_nr, arfcn);
3129
3130 if (actual_new_chan_nr != new_chan_nr) {
3131 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3132 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3133 setverdict(fail);
3134 return;
3135 }
3136 log("Handover Command chan_nr is", actual_new_chan_nr);
3137
3138 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3139 * tells the MS to handover to the new lchan. But the MS never shows up
3140 * on the new lchan. */
3141
3142 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3143
3144 /* Did osmo-bsc also send a Clear Request? */
3145 timer T := 0.5;
3146 T.start;
3147 alt {
3148 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
3149 [] T.timeout { }
3150 }
3151
3152 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
3153 * asked for it, this is a Handover Failure after all). */
3154
3155 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3156 var BssmapCause cause := enum2int(cause_val);
3157 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3158
3159 /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
3160 var MgcpCommand mgcp;
3161 interleave {
3162 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
3163 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3164 log("Got first DLCX: ", mgcp);
3165 }
3166 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3167 log("Got second DLCX: ", mgcp);
3168 }
3169 }
3170 setverdict(pass);
3171 f_sleep(1.0);
3172
3173 setverdict(pass);
3174}
3175testcase TC_ho_in_fail_no_detect() runs on test_CT {
3176 var MSC_ConnHdlr vc_conn;
3177 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3178
3179 f_init(1, true);
3180 f_sleep(1.0);
3181
3182 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3183 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3184
3185 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
3186 vc_conn.done;
3187}
3188
3189/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
3190private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
3191 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3192 f_rslem_register(0, new_chan_nr);
3193 g_chan_nr := new_chan_nr;
3194 f_sleep(1.0);
3195
3196 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3197 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3198 activate(as_Media());
3199
3200 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3201 f_gen_handover_req()));
3202 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
3203
3204 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3205
3206 var PDU_BSSAP rx_bssap;
3207 var octetstring ho_command_str;
3208
3209 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3210
3211 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3212 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3213 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3214 log("L3 Info in HO Request Ack is ", ho_command);
3215
3216 var GsmArfcn arfcn;
3217 var RslChannelNr actual_new_chan_nr;
3218 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3219 actual_new_chan_nr, arfcn);
3220
3221 if (actual_new_chan_nr != new_chan_nr) {
3222 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3223 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3224 setverdict(fail);
3225 return;
3226 }
3227 log("Handover Command chan_nr is", actual_new_chan_nr);
3228
3229 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3230 * tells the MS to handover to the new lchan. But the MS never shows up
3231 * on the new lchan. */
3232
3233 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3234
3235 /* MSC plays dumb and sends no Clear Command */
3236
3237 /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
3238 var PDU_BSSAP rx_clear_request;
3239 var MgcpCommand mgcp;
3240 interleave {
3241 [] BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
3242 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3243 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3244 };
3245 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
3246
3247 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3248 log("Got first DLCX: ", mgcp);
3249 }
3250 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3251 log("Got second DLCX: ", mgcp);
3252 }
3253 }
3254 setverdict(pass);
3255 f_sleep(1.0);
3256}
3257testcase TC_ho_in_fail_no_detect2() runs on test_CT {
3258 var MSC_ConnHdlr vc_conn;
3259 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3260
3261 f_init(1, true);
3262 f_sleep(1.0);
3263
3264 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3265 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3266
3267 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
3268 vc_conn.done;
3269}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003270
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003271/* OS#3041: Open and close N connections in a normal fashion, and expect no
3272 * BSSMAP Reset just because of that. */
3273testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
3274 var default d;
3275 var integer i;
3276 var DchanTuple dt;
3277
3278 f_init();
3279
3280 /* Wait for initial BSSMAP Reset to pass */
3281 f_sleep(4.0);
3282
3283 d := activate(no_bssmap_reset());
3284
3285 /* Setup up a number of connections and RLSD them again from the MSC
3286 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
3287 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02003288 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003289 /* Since we're doing a lot of runs, give each one a fresh
3290 * T_guard from the top. */
3291 T_guard.start;
3292
3293 /* Setup a BSSAP connection and clear it right away. This is
3294 * the MSC telling the BSC about a planned release, it's not an
3295 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02003296 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003297
3298 /* MSC disconnects (RLSD). */
3299 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
3300 }
3301
3302 /* In the buggy behavior, a timeout of 2 seconds happens between above
3303 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
3304 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
3305 f_sleep(4.0);
3306
3307 deactivate(d);
3308 f_shutdown_helper();
3309}
Harald Welte552620d2017-12-16 23:21:36 +01003310
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01003311/* OS#3041: Open and close N connections in a normal fashion, and expect no
3312 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
3313 * the MSC. */
3314testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
3315 var default d;
3316 var integer i;
3317 var DchanTuple dt;
3318 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01003319 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
3320 var BssmapCause cause := enum2int(cause_val);
3321
3322 f_init();
3323
3324 /* Wait for initial BSSMAP Reset to pass */
3325 f_sleep(4.0);
3326
3327 d := activate(no_bssmap_reset());
3328
3329 /* Setup up a number of connections and RLSD them again from the MSC
3330 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
3331 * Let's do it some more times for good measure. */
3332 for (i := 0; i < 8; i := i+1) {
3333 /* Since we're doing a lot of runs, give each one a fresh
3334 * T_guard from the top. */
3335 T_guard.start;
3336
3337 /* Setup a BSSAP connection and clear it right away. This is
3338 * the MSC telling the BSC about a planned release, it's not an
3339 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02003340 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01003341
3342 /* Instruct BSC to clear channel */
3343 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
3344
3345 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02003346 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01003347 }
3348
3349 /* In the buggy behavior, a timeout of 2 seconds happens between above
3350 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
3351 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
3352 f_sleep(4.0);
3353
3354 deactivate(d);
3355 f_shutdown_helper();
3356}
3357
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01003358/* OS#3041: Open and close N connections in a normal fashion, and expect no
3359 * BSSMAP Reset just because of that. Close connections from the MS side with a
3360 * Release Ind on RSL. */
3361testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
3362 var default d;
3363 var integer i;
3364 var DchanTuple dt;
3365 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01003366 var integer j;
3367
3368 f_init();
3369
3370 /* Wait for initial BSSMAP Reset to pass */
3371 f_sleep(4.0);
3372
3373 d := activate(no_bssmap_reset());
3374
3375 /* Setup up a number of connections and RLSD them again from the MSC
3376 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
3377 * Let's do it some more times for good measure. */
3378 for (i := 0; i < 8; i := i+1) {
3379 /* Since we're doing a lot of runs, give each one a fresh
3380 * T_guard from the top. */
3381 T_guard.start;
3382
3383 /* Setup a BSSAP connection and clear it right away. This is
3384 * the MSC telling the BSC about a planned release, it's not an
3385 * erratic loss of a connection. */
3386 dt := f_est_dchan('23'O, 23, '00010203040506'O);
3387
3388 /* simulate RLL REL IND */
3389 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
3390
3391 /* expect Clear Request on MSC side */
3392 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
3393
3394 /* Instruct BSC to clear channel */
3395 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
3396 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
3397
3398 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02003399 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01003400 }
3401
3402 /* In the buggy behavior, a timeout of 2 seconds happens between above
3403 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
3404 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
3405 f_sleep(4.0);
3406
3407 deactivate(d);
3408 f_shutdown_helper();
3409}
3410
Harald Welte94e0c342018-04-07 11:33:23 +02003411/***********************************************************************
3412 * IPA style dynamic PDCH
3413 ***********************************************************************/
3414
3415private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
3416 template (omit) RSL_Cause nack := omit)
3417runs on test_CT {
3418 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
3419 var RSL_Message rsl_unused;
3420 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
3421 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
3422 /* expect the BSC to issue the related RSL command */
3423 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
3424 if (istemplatekind(nack, "omit")) {
3425 /* respond with a related acknowledgement */
3426 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
3427 } else {
3428 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
3429 }
3430}
3431
3432private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
3433 template (omit) RSL_Cause nack := omit)
3434runs on test_CT {
3435 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
3436 var RSL_Message rsl_unused;
3437 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
3438 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
3439 /* expect the BSC to issue the related RSL command */
3440 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
3441 if (istemplatekind(nack, "omit")) {
3442 /* respond with a related acknowledgement */
3443 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
3444 } else {
3445 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
3446 }
3447}
3448
3449private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
3450runs on test_CT return charstring {
3451 var charstring cmd, resp;
3452 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01003453 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02003454}
3455
3456private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
3457 template charstring exp)
3458runs on test_CT {
3459 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
3460 if (not match(mode, exp)) {
3461 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02003462 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02003463 }
3464}
3465
3466private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
3467runs on test_CT {
3468 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
3469 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
3470 f_vty_transceive(BSCVTY, "end");
3471}
3472
3473private const charstring TCHF_MODE := "TCH/F mode";
3474private const charstring TCHH_MODE := "TCH/H mode";
3475private const charstring PDCH_MODE := "PDCH mode";
3476private const charstring NONE_MODE := "NONE mode";
3477
3478/* Test IPA PDCH activation / deactivation triggered by VTY */
3479testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
3480 var RSL_Message rsl_unused;
3481
3482 /* change Timeslot 6 before f_init() starts RSL */
3483 f_init_vty();
3484 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
3485 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
3486
3487 f_init(1, false);
3488 f_sleep(1.0);
3489
3490 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
3491
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003492 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003493 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3494 /* The BSC will activate the dynamic PDCH by default, so confirm that */
3495 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
3496 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
3497 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003498 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003499 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
3500
3501 /* De-activate it via VTY */
3502 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
3503 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003504 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003505 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3506
3507 /* re-activate it via VTY */
3508 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
3509 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003510 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003511 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
3512
3513 /* and finally de-activate it again */
3514 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
3515 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003516 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003517 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3518
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02003519 /* clean up config */
3520 f_ts_set_chcomb(0, 0, 6, "PDCH");
3521
Harald Welte94e0c342018-04-07 11:33:23 +02003522 setverdict(pass);
3523}
3524
3525/* Test IPA PDCH activation NACK */
3526testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
3527 var RSL_Message rsl_unused;
3528
3529 /* change Timeslot 6 before f_init() starts RSL */
3530 f_init_vty();
3531 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
3532 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
3533
3534 f_init(1, false);
3535 f_sleep(1.0);
3536
3537 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
3538
3539 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3540 /* The BSC will activate the dynamic PDCH by default, so confirm that */
3541 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
3542 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
3543 f_sleep(1.0);
3544 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
3545
3546 /* De-activate it via VTY */
3547 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
3548 f_sleep(1.0);
3549 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3550
3551 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
3552 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
3553 f_sleep(1.0);
3554 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3555
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02003556 /* clean up config */
3557 f_ts_set_chcomb(0, 0, 6, "PDCH");
3558
Harald Welte94e0c342018-04-07 11:33:23 +02003559 setverdict(pass);
3560}
3561
3562
3563/***********************************************************************
3564 * Osmocom style dynamic PDCH
3565 ***********************************************************************/
3566
3567private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
3568 template (omit) RSL_Cause nack := omit)
3569runs on test_CT {
3570 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
3571 var RSL_Message rsl_unused;
3572 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
3573 /* FIXME: no VTY command to activate Osmocom PDCH !! */
3574 /* expect the BSC to issue the related RSL command */
3575 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
3576 if (istemplatekind(nack, "omit")) {
3577 /* respond with a related acknowledgement */
3578 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
3579 } else {
3580 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
3581 }
3582}
3583
3584private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
3585 template (omit) RSL_Cause nack := omit)
3586runs on test_CT {
3587 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
3588 var RSL_Message rsl_unused;
3589 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
3590 /* FIXME: no VTY command to activate Osmocom PDCH !! */
3591 /* expect the BSC to issue the related RSL command */
3592 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
3593 if (istemplatekind(nack, "omit")) {
3594 /* respond with a related acknowledgement */
3595 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
3596 } else {
3597 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
3598 }
3599}
3600
3601/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
3602testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
3603 var RSL_Message rsl_unused;
3604
3605 /* change Timeslot 6 before f_init() starts RSL */
3606 f_init_vty();
3607 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
3608 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
3609
3610 f_init(1, false);
3611 f_sleep(1.0);
3612
3613 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
3614
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003615 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003616 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
3617 /* The BSC will activate the dynamic PDCH by default, so confirm that */
3618 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
3619
3620 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
3621 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003622 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 +02003623 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
3624
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02003625 /* clean up config */
3626 f_ts_set_chcomb(0, 0, 6, "PDCH");
3627
Harald Welte94e0c342018-04-07 11:33:23 +02003628 setverdict(pass);
3629}
3630
3631/* Test Osmocom dyn PDCH activation NACK behavior */
3632testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
3633 var RSL_Message rsl_unused;
3634
3635 /* change Timeslot 6 before f_init() starts RSL */
3636 f_init_vty();
3637 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
3638 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
3639
3640 f_init(1, false);
3641 f_sleep(1.0);
3642
3643 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
3644
3645 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
3646 /* The BSC will activate the dynamic PDCH by default, so confirm that */
3647 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
3648
3649 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
3650 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
3651 f_sleep(1.0);
3652 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
3653
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02003654 /* clean up config */
3655 f_ts_set_chcomb(0, 0, 6, "PDCH");
3656
Harald Welte94e0c342018-04-07 11:33:23 +02003657 setverdict(pass);
3658}
3659
Stefan Sperling0796a822018-10-05 13:01:39 +02003660testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02003661 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02003662 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
3663 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
3664 }
3665}
3666
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02003667testcase TC_chopped_ipa_payload() runs on test_CT {
3668 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
3669 /* TODO: mp_bsc_ctrl_port does not work yet */};
3670 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
3671 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
3672 }
3673}
3674
3675
Harald Welte0ea2d5e2018-04-07 21:40:29 +02003676/* Dyn PDCH todo:
3677 * activate OSMO as TCH/F
3678 * activate OSMO as TCH/H
3679 * does the BSC-located PCU socket get the updated INFO?
3680 * what if no PCU is connected at the time?
3681 * is the info correct on delayed PCU (re)connect?
3682 */
Harald Welte94e0c342018-04-07 11:33:23 +02003683
Harald Welte28d943e2017-11-25 15:00:50 +01003684control {
Harald Welte898113b2018-01-31 18:32:21 +01003685 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01003686 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01003687 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01003688 execute( TC_ctrl() );
Harald Welte898113b2018-01-31 18:32:21 +01003689
3690 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01003691 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01003692 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01003693 execute( TC_chan_act_ack_noest() );
3694 execute( TC_chan_act_ack_est_ind_noreply() );
3695 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01003696 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01003697 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07003698 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01003699 execute( TC_chan_rel_rll_rel_ind() );
3700 execute( TC_chan_rel_conn_fail() );
3701 execute( TC_chan_rel_hard_clear() );
Harald Welted8c36cd2017-12-09 23:05:31 +01003702 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02003703 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01003704 execute( TC_chan_rel_a_reset() );
Harald Welte6f521d82017-12-11 19:52:02 +01003705
Harald Weltecfe2c962017-12-15 12:09:32 +01003706 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01003707
3708 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01003709 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01003710 execute( TC_assignment_csd() );
3711 execute( TC_assignment_ctm() );
3712 execute( TC_assignment_sign() );
3713 execute( TC_assignment_fr_a5_0() );
3714 execute( TC_assignment_fr_a5_1() );
Harald Welte8f67d1d2018-05-25 20:38:42 +02003715 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
3716 execute( TC_assignment_fr_a5_1_codec_missing() );
3717 }
Harald Welte235ebf12017-12-15 14:18:16 +01003718 execute( TC_assignment_fr_a5_3() );
3719 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02003720 execute( TC_ciph_mode_a5_0() );
3721 execute( TC_ciph_mode_a5_1() );
3722 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01003723
Harald Welte60aa5762018-03-21 19:33:13 +01003724 execute( TC_assignment_codec_fr() );
3725 execute( TC_assignment_codec_hr() );
3726 execute( TC_assignment_codec_efr() );
3727 execute( TC_assignment_codec_amr_f() );
3728 execute( TC_assignment_codec_amr_h() );
3729
Philipp Maierac09bfc2019-01-08 13:41:39 +01003730 execute( TC_assignment_codec_fr_exhausted_req_hr() );
3731 execute( TC_assignment_codec_fr_exhausted_req_fr() );
3732 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
3733 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
3734 execute( TC_assignment_codec_hr_exhausted_req_fr() );
3735 execute( TC_assignment_codec_hr_exhausted_req_hr() );
3736 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
3737 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
3738 execute( TC_assignment_codec_req_hr_fr() );
3739 execute( TC_assignment_codec_req_fr_hr() );
3740
Harald Welte898113b2018-01-31 18:32:21 +01003741 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01003742 execute( TC_rll_est_ind_inact_lchan() );
3743 execute( TC_rll_est_ind_inval_sapi1() );
3744 execute( TC_rll_est_ind_inval_sapi3() );
3745 execute( TC_rll_est_ind_inval_sacch() );
3746
Harald Welte898113b2018-01-31 18:32:21 +01003747 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01003748 execute( TC_paging_imsi_nochan() );
3749 execute( TC_paging_tmsi_nochan() );
3750 execute( TC_paging_tmsi_any() );
3751 execute( TC_paging_tmsi_sdcch() );
3752 execute( TC_paging_tmsi_tch_f() );
3753 execute( TC_paging_tmsi_tch_hf() );
3754 execute( TC_paging_imsi_nochan_cgi() );
3755 execute( TC_paging_imsi_nochan_lac_ci() );
3756 execute( TC_paging_imsi_nochan_ci() );
3757 execute( TC_paging_imsi_nochan_lai() );
3758 execute( TC_paging_imsi_nochan_lac() );
3759 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01003760 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
3761 execute( TC_paging_imsi_nochan_rnc() );
3762 execute( TC_paging_imsi_nochan_lac_rnc() );
3763 execute( TC_paging_imsi_nochan_lacs() );
3764 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01003765 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01003766 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01003767 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01003768 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003769 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003770
3771 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003772 execute( TC_rsl_unknown_unit_id() );
3773
3774 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01003775
3776 execute( TC_classmark() );
3777 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01003778 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01003779 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01003780 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01003781 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003782
Harald Welte261af4b2018-02-12 21:20:39 +01003783 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003784
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003785 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003786 execute( TC_ho_out_fail_no_msc_response() );
3787 execute( TC_ho_out_fail_rr_ho_failure() );
3788 execute( TC_ho_out_fail_no_ho_detect() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003789
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003790 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003791 execute( TC_ho_in_fail_msc_clears() );
3792 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
3793 execute( TC_ho_in_fail_no_detect() );
3794 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003795
3796 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01003797 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01003798 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02003799
3800 execute( TC_dyn_pdch_ipa_act_deact() );
3801 execute( TC_dyn_pdch_ipa_act_nack() );
3802 execute( TC_dyn_pdch_osmo_act_deact() );
3803 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02003804
Stefan Sperling0796a822018-10-05 13:01:39 +02003805 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02003806 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02003807
Harald Welte99f3ca02018-06-14 13:40:29 +02003808 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
3809 execute( TC_early_conn_fail() );
3810 execute( TC_late_conn_fail() );
3811
Harald Welte28d943e2017-11-25 15:00:50 +01003812}
3813
3814}