blob: 1e89cf36245ddd55030b8d4b670486ef6f52fc18 [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,
Harald Welte99787102019-02-04 10:41:36 +0100859 boolean handle_rll_rel := true,
860 boolean is_csfb := false
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100861 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +0100862
863 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
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 }
Harald Welte99787102019-02-04 10:41:36 +0100875 [is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CSFB))) {
876 got_rr_chan_rel := true;
877 repeat;
878 }
879 [not is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100880 got_rr_chan_rel := true;
Neels Hofmeyr211169d2018-11-07 00:37:29 +0100881 repeat;
882 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100883 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
Harald Welte91d54a52018-01-28 15:35:07 +0100884 tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100885 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +0100886 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100887 if (handle_rll_rel) {
888 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
889 }
Harald Welte91d54a52018-01-28 15:35:07 +0100890 repeat;
891 }
Harald Welte91d54a52018-01-28 15:35:07 +0100892 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
893 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
894 /* respond with CHAN REL ACK */
895 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
896 }
897 /* ignore any user data */
898 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) {
899 repeat;
900 }
901 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100902
903 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
904 " got_rll_rel_req=", got_rll_rel_req);
905
906 if (expect_deact_sacch != got_deact_sacch) {
907 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
908 }
909 if (expect_rr_chan_rel != got_rr_chan_rel) {
910 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
911 }
912 if (expect_rll_rel_req != got_rll_rel_req) {
913 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
914 }
Harald Welte91d54a52018-01-28 15:35:07 +0100915}
916
Harald Welte4003d112017-12-09 22:35:39 +0100917/* Test behavior of channel release after hard Clear Command from MSC */
918testcase TC_chan_rel_hard_clear() runs on test_CT {
919 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100920 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +0100921
Harald Welte89d42e82017-12-17 16:42:41 +0100922 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100923
924 dt := f_est_dchan('23'O, 23, '00010203040506'O);
925
926 /* Instruct BSC to clear channel */
927 var BssmapCause cause := 0;
928 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
929
930 /* expect Clear Complete from BSC on A */
931 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
932 /* release the SCCP connection */
933 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
934 }
935
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100936 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte4003d112017-12-09 22:35:39 +0100937 setverdict(pass);
938}
939
Harald Welte99787102019-02-04 10:41:36 +0100940/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
941testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
942 var BSSAP_N_DATA_ind rx_di;
943 var DchanTuple dt;
944
945 f_init(1);
946
947 dt := f_est_dchan('23'O, 23, '00010203040506'O);
948
949 /* Instruct BSC to clear channel */
950 var BssmapCause cause := 0;
951 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
952
953 /* expect Clear Complete from BSC on A */
954 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
955 /* release the SCCP connection */
956 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
957 }
958
959 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
960 setverdict(pass);
961}
962
Harald Welted8c36cd2017-12-09 23:05:31 +0100963/* Test behavior of channel release after hard RLSD from MSC */
964testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +0100965 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +0100966
Harald Welte89d42e82017-12-17 16:42:41 +0100967 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +0100968
969 dt := f_est_dchan('23'O, 23, '00010203040506'O);
970
971 /* release the SCCP connection */
972 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
973
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100974 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welted8c36cd2017-12-09 23:05:31 +0100975 setverdict(pass);
976}
977
Harald Welte550daf92018-06-11 19:22:13 +0200978/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
979testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
980 var DchanTuple dt;
981
982 f_init(1);
983
984 dt := f_est_dchan('23'O, 23, '00010203040506'O);
985
986 /* release the SCCP connection */
987 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
988
Neels Hofmeyra5302c82018-11-04 23:09:58 +0100989 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte550daf92018-06-11 19:22:13 +0200990 setverdict(pass);
991}
992
Harald Welte85804d42017-12-10 14:11:58 +0100993/* Test behavior of channel release after BSSMAP RESET from MSC */
994testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +0100995 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +0100996
Harald Welte89d42e82017-12-17 16:42:41 +0100997 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +0100998
999 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1000
1001 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1002 IPA_RSL[0].clear;
1003
1004 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Harald Weltea4ca4462018-02-09 00:17:14 +01001005 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 +01001006 interleave {
Harald Weltea4ca4462018-02-09 00:17:14 +01001007 [] 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 +01001008 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1009 }
1010
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001011 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte85804d42017-12-10 14:11:58 +01001012 setverdict(pass);
1013}
1014
Harald Welte5cd20ed2017-12-13 21:03:20 +01001015/* Test behavior if RSL EST IND for non-active channel */
1016testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1017 timer T := 2.0;
1018
Harald Welte89d42e82017-12-17 16:42:41 +01001019 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001020
1021 var octetstring l3 := '00010203040506'O;
1022 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1023 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1024
1025 T.start;
1026 alt {
1027 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1028 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1029 }
1030 [] BSSAP.receive {}
1031 [] IPA_RSL[0].receive {}
1032 [] T.timeout {}
1033 }
1034
1035 setverdict(pass);
1036}
1037
1038/* Test behavior if RSL EST IND for invalid SAPI */
1039testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1040 var RslChannelNr chan_nr;
1041
Harald Welte89d42e82017-12-17 16:42:41 +01001042 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001043
1044 chan_nr := f_chreq_act_ack()
1045
1046 var octetstring l3 := '00010203040506'O;
1047 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1048
1049 timer T := 2.0;
1050 T.start;
1051 alt {
1052 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1053 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1054 }
1055 [] BSSAP.receive { repeat; }
1056 [] IPA_RSL[0].receive { repeat; }
1057 [] T.timeout {}
1058 }
1059
1060 setverdict(pass);
1061}
1062
1063/* Test behavior if RSL EST IND for invalid SAPI */
1064testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
1065 timer T := 2.0;
1066
Harald Welte89d42e82017-12-17 16:42:41 +01001067 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001068
1069 var RslChannelNr chan_nr := f_chreq_act_ack();
1070
1071 var octetstring l3 := '00010203040506'O;
1072 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
1073
1074 T.start;
1075 alt {
1076 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1077 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
1078 }
1079 [] BSSAP.receive { repeat; }
1080 [] IPA_RSL[0].receive { repeat; }
1081 [] T.timeout {}
1082 }
1083
1084 setverdict(pass);
1085}
1086
1087/* Test behavior if RSL EST IND for invalid SACCH */
1088testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
1089 timer T := 2.0;
1090
Harald Welte89d42e82017-12-17 16:42:41 +01001091 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001092
1093 var RslChannelNr chan_nr := f_chreq_act_ack();
1094
1095 var octetstring l3 := '00010203040506'O;
1096 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
1097
1098 T.start;
1099 alt {
1100 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1101 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
1102 }
1103 [] BSSAP.receive { repeat; }
1104 [] IPA_RSL[0].receive { repeat; }
1105 [] T.timeout {}
1106 }
1107
1108 setverdict(pass);
1109}
1110
1111
1112
Harald Welte4003d112017-12-09 22:35:39 +01001113
1114testcase TC_ctrl_msc_connection_status() runs on test_CT {
1115 var charstring ctrl_resp;
1116
Harald Welte89d42e82017-12-17 16:42:41 +01001117 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001118
1119 /* See https://osmocom.org/issues/2729 */
1120 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
1121 setverdict(pass);
1122}
1123
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001124testcase TC_ctrl_msc0_connection_status() runs on test_CT {
1125 var charstring ctrl_resp;
1126
1127 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001128
1129 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
1130 setverdict(pass);
1131}
1132
Harald Welte4003d112017-12-09 22:35:39 +01001133testcase TC_ctrl() runs on test_CT {
1134 var charstring ctrl_resp;
1135
Harald Welte89d42e82017-12-17 16:42:41 +01001136 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001137
1138 /* all below values must match the osmo-bsc.cfg config file used */
1139
Harald Welte6a129692018-03-17 17:30:14 +01001140 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
1141 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Harald Welte44bdaa52017-12-17 17:01:47 +01001142 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "3");
Harald Welte4003d112017-12-09 22:35:39 +01001143
1144 var integer bts_nr := 0;
1145 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
1146 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
1147 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
1148 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
1149 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
1150 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
1151 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
1152
1153 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
1154 f_sleep(2.0);
1155 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
1156 setverdict(fail, "oml-uptime not incrementing as expected");
1157 }
1158 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
1159
1160 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
1161
1162 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +01001163}
1164
Harald Welte6f521d82017-12-11 19:52:02 +01001165function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +01001166 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, bssap));
Harald Welte6f521d82017-12-11 19:52:02 +01001167}
1168
1169
1170/***********************************************************************
1171 * Paging Testing
1172 ***********************************************************************/
1173
1174type record Cell_Identity {
1175 GsmMcc mcc,
1176 GsmMnc mnc,
1177 GsmLac lac,
1178 GsmCellId ci
1179};
Harald Welte24135bd2018-03-17 19:27:53 +01001180private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001181private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001182
Harald Welte5d1a2202017-12-13 19:51:29 +01001183type set of integer BtsIdList;
1184
1185private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1186 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1187 if (bts_id == bts_ids[j]) {
1188 return true;
1189 }
1190 }
1191 return false;
1192}
Harald Welte6f521d82017-12-11 19:52:02 +01001193
1194/* core paging test helper function; used by most paging test cases */
1195private function f_pageing_helper(hexstring imsi,
1196 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001197 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001198 template RSL_ChanNeeded rsl_chneed := omit,
1199 template OCT4 tmsi := omit) runs on test_CT
1200{
1201 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
1202 var MobileIdentity mi;
1203 var template octetstring id_enc; /* FIXME */
1204 var RSL_Message rx_rsl;
1205 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001206 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001207
1208 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001209
1210 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001211 for (i := 0; i < NUM_BTS; i := i + 1) {
1212 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001213 }
Harald Welte6f521d82017-12-11 19:52:02 +01001214
1215 if (isvalue(rsl_chneed)) {
1216 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1217 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1218 } else {
1219 bssmap_chneed := omit;
1220 }
1221
1222 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
1223
1224/* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder
1225 if (isvalue(tmsi)) {
1226 mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi))));
1227 } else {
1228 mi := valueof(ts_Osmo_MI_IMSI(imsi));
1229 }
1230 id_enc := enc_MobileIdentity(mi);
1231*/
1232 id_enc := ?;
Harald Welte5d1a2202017-12-13 19:51:29 +01001233 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
1234 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc));
1235 /* check channel type, paging group */
1236 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1237 setverdict(fail, "Paging for wrong paging group");
1238 }
1239 if (ispresent(rsl_chneed) and
1240 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1241 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1242 }
Harald Welte6f521d82017-12-11 19:52:02 +01001243 }
Harald Welte2fccd982018-01-31 15:48:19 +01001244 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001245 /* do a quick check on all not-included BTSs if they received paging */
1246 for (i := 0; i < NUM_BTS; i := i + 1) {
1247 timer T := 0.1;
1248 if (f_bts_in_list(i, bts_ids)) {
1249 continue;
1250 }
1251 T.start;
1252 alt {
1253 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) {
1254 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1255 }
1256 [] IPA_RSL[i].receive { repeat; }
1257 [] T.timeout { }
1258 }
Harald Welte6f521d82017-12-11 19:52:02 +01001259 }
1260
1261 setverdict(pass);
1262}
1263
Harald Welte5d1a2202017-12-13 19:51:29 +01001264const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001265const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001266const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1267const BtsIdList c_BtsId_LAC2 := { 2 };
1268
Harald Welte6f521d82017-12-11 19:52:02 +01001269/* PAGING by IMSI + TMSI */
1270testcase TC_paging_imsi_nochan() runs on test_CT {
1271 var BSSMAP_FIELD_CellIdentificationList cid_list;
1272 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001273 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001274 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001275}
1276
1277/* PAGING by IMSI + TMSI */
1278testcase TC_paging_tmsi_nochan() runs on test_CT {
1279 var BSSMAP_FIELD_CellIdentificationList cid_list;
1280 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001281 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001282 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001283}
1284
1285/* Paging with different "channel needed' values */
1286testcase TC_paging_tmsi_any() runs on test_CT {
1287 var BSSMAP_FIELD_CellIdentificationList cid_list;
1288 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001289 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001290 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001291}
1292testcase TC_paging_tmsi_sdcch() runs on test_CT {
1293 var BSSMAP_FIELD_CellIdentificationList cid_list;
1294 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001295 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001296 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001297}
1298testcase TC_paging_tmsi_tch_f() runs on test_CT {
1299 var BSSMAP_FIELD_CellIdentificationList cid_list;
1300 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001301 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001302 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001303}
1304testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1305 var BSSMAP_FIELD_CellIdentificationList cid_list;
1306 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001307 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001308 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001309}
1310
1311/* Paging by CGI */
1312testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1313 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1314 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001315 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001316 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001317}
1318
1319/* Paging by LAC+CI */
1320testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1321 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1322 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001323 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001324 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001325}
1326
1327/* Paging by CI */
1328testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1329 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1330 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001331 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001332 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001333}
1334
1335/* Paging by LAI */
1336testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1337 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1338 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001339 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001340 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001341}
1342
1343/* Paging by LAC */
1344testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1345 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1346 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001347 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001348 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001349}
1350
1351/* Paging by "all in BSS" */
1352testcase TC_paging_imsi_nochan_all() runs on test_CT {
1353 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1354 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001355 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001356 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001357}
1358
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001359/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001360testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1361 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1362 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 +01001363 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001364 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001365}
Harald Welte6f521d82017-12-11 19:52:02 +01001366
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001367/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001368testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1369 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1370 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001371 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001372 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001373}
1374
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001375/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001376testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1377 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1378 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001379 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001380 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001381}
1382
Harald Welte6f521d82017-12-11 19:52:02 +01001383/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001384testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1385 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1386 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1387 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001388 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001389}
1390
1391/* Paging on empty list: Verify none of them page */
1392testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1393 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1394 cid_list := { cIl_LAC := { } };
1395 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001396 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001397}
1398
Stefan Sperling049a86e2018-03-20 15:51:00 +01001399/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1400testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1401 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1402 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1403 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1404 f_shutdown_helper();
1405}
1406
Harald Welte6f521d82017-12-11 19:52:02 +01001407/* Verify paging retransmission interval + count */
1408/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001409/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001410
Harald Weltee65d40e2017-12-13 00:09:06 +01001411/* Verify PCH load */
1412testcase TC_paging_imsi_load() runs on test_CT {
1413 var BSSMAP_FIELD_CellIdentificationList cid_list;
1414 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001415 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001416 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001417 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001418
1419 /* tell BSC there is no paging space anymore */
1420 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001421 f_sleep(0.2);
1422 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001423
1424 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1425 * there would be 8 retransmissions during 4 seconds */
1426 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001427 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001428 alt {
1429 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1430 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02001431 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01001432 }
Harald Welte2caa1062018-03-17 18:19:05 +01001433 [] T_retrans.timeout {
1434 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1435 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1436 T_retrans.start;
1437 repeat;
1438 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001439 [] T.timeout {
1440 setverdict(pass);
1441 }
1442 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001443
1444 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001445}
1446
Harald Welte235ebf12017-12-15 14:18:16 +01001447/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001448testcase TC_paging_counter() runs on test_CT {
1449 var BSSMAP_FIELD_CellIdentificationList cid_list;
1450 timer T := 4.0;
1451 var integer i;
1452 var integer paging_attempted_bsc;
1453 var integer paging_attempted_bts[NUM_BTS];
1454 var integer paging_expired_bts[NUM_BTS];
1455 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1456
1457 f_init();
1458
1459 /* read counters before paging */
1460 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1461 for (i := 0; i < NUM_BTS; i := i+1) {
1462 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1463 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1464 }
1465
1466 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1467
1468 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1469 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1470 for (i := 0; i < NUM_BTS; i := i+1) {
1471 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1472 paging_attempted_bts[i]+1);
1473 }
1474
1475 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1476 f_sleep(12.0);
1477 for (i := 0; i < NUM_BTS; i := i+1) {
1478 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1479 paging_expired_bts[i]+1);
1480 }
Harald Welte1ff69992017-12-14 12:31:17 +01001481
Philipp Maier282ca4b2018-02-27 17:17:00 +01001482 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001483}
1484
1485
Harald Welte10985002017-12-12 09:29:15 +01001486/* Verify paging stops after A-RESET */
1487testcase TC_paging_imsi_a_reset() runs on test_CT {
1488 var BSSMAP_FIELD_CellIdentificationList cid_list;
1489 timer T := 3.0;
1490 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001491 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001492
1493 /* Perform a BSSMAP Reset and wait for ACK */
Harald Weltea4ca4462018-02-09 00:17:14 +01001494 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 +01001495 alt {
Harald Weltea4ca4462018-02-09 00:17:14 +01001496 [] 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 +01001497 [] BSSAP.receive { repeat; }
1498 }
1499
Daniel Willmanncbef3982018-07-30 09:22:40 +02001500 /* Wait to avoid a possible race condition if a paging message is
1501 * received right before the reset ACK. */
1502 f_sleep(0.2);
1503
Harald Welte10985002017-12-12 09:29:15 +01001504 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001505 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1506 IPA_RSL[i].clear;
1507 }
Harald Welte10985002017-12-12 09:29:15 +01001508
1509 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1510 T.start;
1511 alt {
1512 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1513 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001514 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01001515 }
Harald Welte5d1a2202017-12-13 19:51:29 +01001516 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1517 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001518 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001519 }
1520 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1521 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02001522 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01001523 }
Harald Welte10985002017-12-12 09:29:15 +01001524 [] T.timeout {
1525 setverdict(pass);
1526 }
1527 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001528
1529 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001530}
Harald Welteae026692017-12-09 01:03:01 +01001531
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001532/* Verify how we handle unsolicited Paging Response, for instance because we
1533 * receive a Paging Response after T3113 expired (and subscriber information was
1534 * dropped). See OS#3680.
1535 */
1536testcase TC_paging_resp_unsol() runs on test_CT {
1537
1538 f_init(1);
1539
1540 var BSSAP_N_CONNECT_ind rx_c_ind;
1541 var DchanTuple dt;
1542 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
1543
1544 /* Send CHAN RQD and wait for allocation; acknowledge it */
1545 dt.rsl_chan_nr := f_chreq_act_ack();
1546
1547 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
1548 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
1549
1550 /* expect BSC to disable the channel */
Pau Espin Pedrol5ee6f6c2018-12-07 12:07:43 +01001551 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01001552 setverdict(pass);
1553
1554}
1555
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001556/* Test RSL link drop causes counter increment */
1557testcase TC_rsl_drop_counter() runs on test_CT {
1558 var integer rsl_fail;
1559
Harald Welte89d42e82017-12-17 16:42:41 +01001560 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001561
1562 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1563
1564 bts[0].rsl.vc_IPA.stop;
1565
1566 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1567
1568 setverdict(pass);
1569}
1570
1571/* TODO: Test OML link drop causes counter increment */
1572
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001573/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1574function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1575 timer T := 10.0;
1576
1577 bts[0].rsl.id := "IPA-0-RSL";
1578 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1579 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1580 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
1581 bts[0].rsl.ccm_pars.unit_id := "0/0/0"; /* value which is unknown at BTS */
1582
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001583 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1584
1585 f_init_mgcp("VirtMSC");
1586
1587 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1588 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1589 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1590 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1591
1592 /* wait for IPA OML link to connect and then disconnect */
1593 T.start;
1594 alt {
1595 [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) {
1596 T.stop;
1597 return true;
1598 }
1599 [] IPA_RSL[0].receive { repeat }
1600 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02001601 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001602 }
1603 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001604 return false;
1605}
1606
1607/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1608testcase TC_rsl_unknown_unit_id() runs on test_CT {
1609 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1610 setverdict(pass);
1611 } else {
1612 setverdict(fail, "Timeout RSL waiting for connection to close");
1613 }
1614}
1615
1616
1617/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1618testcase TC_oml_unknown_unit_id() runs on test_CT {
1619 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1620 setverdict(pass);
1621 } else {
1622 setverdict(fail, "Timeout OML waiting for connection to close");
1623 }
1624}
1625
1626
Harald Weltec1a2fff2017-12-17 11:06:19 +01001627/***********************************************************************
1628 * "New world" test cases using RSL_Emulation + BSSMAP_Emulation
1629 ***********************************************************************/
1630
1631import from BSSMAP_Emulation all;
1632import from RSL_Emulation all;
1633import from MSC_ConnectionHandler all;
1634
1635type function void_fn(charstring id) runs on MSC_ConnHdlr;
1636
Harald Welte336820c2018-05-31 20:34:52 +02001637/* helper function to create and connect a MSC_ConnHdlr component */
Harald Welteff579f92018-05-31 22:19:39 +02001638private function f_connect_handler(inout MSC_ConnHdlr vc_conn) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +01001639 connect(vc_conn:BSSMAPEM, g_bssap.vc_BSSMAP:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001640 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001641 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001642 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001643 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001644 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1645 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1646 }
Harald Weltea4ca4462018-02-09 00:17:14 +01001647 connect(vc_conn:BSSAP, g_bssap.vc_BSSMAP:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001648 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Harald Welte336820c2018-05-31 20:34:52 +02001649}
1650
1651function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
1652runs on test_CT return MSC_ConnHdlr {
1653 var charstring id := testcasename();
1654 var MSC_ConnHdlr vc_conn;
1655 vc_conn := MSC_ConnHdlr.create(id);
1656 f_connect_handler(vc_conn);
Harald Weltea0630032018-03-20 21:09:55 +01001657 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001658 return vc_conn;
1659}
1660
Harald Weltea0630032018-03-20 21:09:55 +01001661/* first function inside ConnHdlr component; sets g_pars + starts function */
1662private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1663runs on MSC_ConnHdlr {
1664 if (isvalue(pars)) {
1665 g_pars := valueof(pars);
1666 }
1667 fn.apply(id);
1668}
1669
Harald Welte3c86ea02018-05-10 22:28:05 +02001670/* Establish signalling channel (non-assignment case) followed by cipher mode */
1671private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001672 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1673 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001674 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02001675 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
1676 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
1677 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
1678 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02001679
Philipp Maier23000732018-05-18 11:25:37 +02001680 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02001681}
1682testcase TC_ciph_mode_a5_0() runs on test_CT {
1683 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001684 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001685 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1686
1687 f_init(1, true);
1688 f_sleep(1.0);
1689 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1690 vc_conn.done;
1691}
1692testcase TC_ciph_mode_a5_1() runs on test_CT {
1693 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001694 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001695 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1696
1697 f_init(1, true);
1698 f_sleep(1.0);
1699 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1700 vc_conn.done;
1701}
1702testcase TC_ciph_mode_a5_3() runs on test_CT {
1703 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001704 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02001705 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1706
1707 f_init(1, true);
1708 f_sleep(1.0);
1709 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1710 vc_conn.done;
1711}
1712
1713
1714/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001715private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001716 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1717 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001718
Harald Welte552620d2017-12-16 23:21:36 +01001719 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1720 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001721
Harald Weltea0630032018-03-20 21:09:55 +01001722 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001723}
Harald Welte552620d2017-12-16 23:21:36 +01001724testcase TC_assignment_fr_a5_0() runs on test_CT {
1725 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001726 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001727 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001728
Harald Welte89d42e82017-12-17 16:42:41 +01001729 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001730 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001731 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001732 vc_conn.done;
1733}
Harald Welte552620d2017-12-16 23:21:36 +01001734testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001735 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001736 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001737 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001738
Harald Welte89d42e82017-12-17 16:42:41 +01001739 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001740 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001741 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1742 vc_conn.done;
1743}
1744testcase TC_assignment_fr_a5_3() runs on test_CT {
1745 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02001746 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02001747 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001748
Harald Welte651fcdc2018-05-10 20:23:16 +02001749 f_init(1, true);
1750 f_sleep(1.0);
1751 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001752 vc_conn.done;
1753}
1754
Harald Welte552620d2017-12-16 23:21:36 +01001755/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1756private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001757 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01001758 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001759 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001760 const OCT8 kc := '0001020304050607'O;
1761
1762 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001763 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
1764
Harald Weltea0630032018-03-20 21:09:55 +01001765 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001766}
Harald Welte552620d2017-12-16 23:21:36 +01001767testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1768 var MSC_ConnHdlr vc_conn;
1769
Harald Welte89d42e82017-12-17 16:42:41 +01001770 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001771 f_sleep(1.0);
1772
Harald Welte8863fa12018-05-10 20:15:27 +02001773 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001774 vc_conn.done;
1775}
1776
Harald Welte552620d2017-12-16 23:21:36 +01001777private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001778 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02001779 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1780 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001781 const OCT8 kc := '0001020304050607'O;
1782 const OCT16 kc128 := kc & kc;
1783
1784 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1785 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001786 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001787 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001788 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001789}
Harald Welte552620d2017-12-16 23:21:36 +01001790testcase TC_assignment_fr_a5_4() runs on test_CT {
1791 var MSC_ConnHdlr vc_conn;
1792
Harald Welte89d42e82017-12-17 16:42:41 +01001793 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001794 f_sleep(1.0);
1795
Harald Welte8863fa12018-05-10 20:15:27 +02001796 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001797 vc_conn.done;
1798}
1799
1800
Harald Welte4532e0a2017-12-23 02:05:44 +01001801private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02001802 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01001803 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02001804 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01001805 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001806 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001807}
1808
1809testcase TC_assignment_sign() runs on test_CT {
1810 var MSC_ConnHdlr vc_conn;
1811
1812 f_init(1, true);
1813 f_sleep(1.0);
1814
Harald Welte8863fa12018-05-10 20:15:27 +02001815 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001816 vc_conn.done;
1817}
1818
Harald Welte60aa5762018-03-21 19:33:13 +01001819/***********************************************************************
1820 * Codec (list) testing
1821 ***********************************************************************/
1822
1823/* check if the given rsl_mode is compatible with the a_elem */
1824private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1825return boolean {
1826 select (a_elem.codecType) {
1827 case (GSM_FR) {
1828 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1829 return true;
1830 }
1831 }
1832 case (GSM_HR) {
1833 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1834 return true;
1835 }
1836 }
1837 case (GSM_EFR) {
1838 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1839 return true;
1840 }
1841 }
1842 case (FR_AMR) {
1843 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1844 return true;
1845 }
1846 }
1847 case (HR_AMR) {
1848 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1849 return true;
1850 }
1851 }
1852 case else { }
1853 }
1854 return false;
1855}
1856
1857/* check if the given rsl_mode is compatible with the a_list */
1858private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
1859return boolean {
1860 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
1861 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
1862 return true;
1863 }
1864 }
1865 return false;
1866}
1867
1868/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02001869function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01001870return BSSMAP_IE_ChannelType {
1871 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
1872 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
1873 select (a_elem.codecType) {
1874 case (GSM_FR) {
1875 ret.channelRateAndType := ChRate_TCHF;
1876 ret.speechId_DataIndicator := Spdi_TCHF_FR;
1877 }
1878 case (GSM_HR) {
1879 ret.channelRateAndType := ChRate_TCHH;
1880 ret.speechId_DataIndicator := Spdi_TCHH_HR;
1881 }
1882 case (GSM_EFR) {
1883 ret.channelRateAndType := ChRate_TCHF;
1884 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
1885 }
1886 case (FR_AMR) {
1887 ret.channelRateAndType := ChRate_TCHF;
1888 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
1889 }
1890 case (HR_AMR) {
1891 ret.channelRateAndType := ChRate_TCHH;
1892 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
1893 }
1894 case else {
1895 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02001896 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01001897 }
1898 }
1899 return ret;
1900}
1901
Harald Weltea63b9102018-03-22 20:36:16 +01001902private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
1903return template RSL_IE_Body {
1904 var template RSL_IE_Body mode_ie := {
1905 chan_mode := {
1906 len := ?,
1907 reserved := ?,
1908 dtx_d := ?,
1909 dtx_u := ?,
1910 spd_ind := RSL_SPDI_SPEECH,
1911 ch_rate_type := -,
1912 coding_alg_rate := -
1913 }
1914 }
1915
1916 select (a_elem.codecType) {
1917 case (GSM_FR) {
1918 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1919 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1920 }
1921 case (GSM_HR) {
1922 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1923 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1924 }
1925 case (GSM_EFR) {
1926 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1927 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
1928 }
1929 case (FR_AMR) {
1930 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1931 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1932 }
1933 case (HR_AMR) {
1934 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1935 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1936 }
1937 }
1938 return mode_ie;
1939}
1940
Harald Welte60aa5762018-03-21 19:33:13 +01001941type record CodecListTest {
1942 BSSMAP_IE_SpeechCodecList codec_list,
1943 charstring id
1944}
1945type record of CodecListTest CodecListTests
1946
1947private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001948 var PDU_BSSAP ass_cmd := f_gen_ass_req();
1949 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
Harald Welte60aa5762018-03-21 19:33:13 +01001950
1951 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Harald Welte79f3f542018-05-25 20:02:37 +02001952 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
1953 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
1954 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
1955 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01001956 if (isvalue(g_pars.expect_mr_s0_s7)) {
1957 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
1958 g_pars.expect_mr_s0_s7;
1959 }
Harald Welte79f3f542018-05-25 20:02:37 +02001960 }
Harald Welte60aa5762018-03-21 19:33:13 +01001961 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
1962 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01001963 log("expecting ASS COMPL like this: ", exp_compl);
1964
1965 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01001966
1967 /* Verify that the RSL-side activation actually matches our expectations */
1968 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
1969
1970 var RSL_IE_Body mode_ie;
1971 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
1972 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02001973 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01001974 }
1975 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
1976 if (not match(mode_ie, t_mode_ie)) {
1977 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
1978 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02001979
1980 var RSL_IE_Body mr_conf;
1981 if (g_pars.expect_mr_conf_ie != omit) {
1982 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
1983 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02001984 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02001985 }
1986 log("found RSL MR CONFIG IE: ", mr_conf);
1987
1988 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
1989 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
1990 g_pars.expect_mr_conf_ie);
1991 }
1992 } else {
1993 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
1994 log("found RSL MR CONFIG IE: ", mr_conf);
1995 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02001996 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02001997 }
1998 }
Harald Welte60aa5762018-03-21 19:33:13 +01001999}
2000
Philipp Maierd0e64b02019-03-13 14:15:23 +01002001private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
2002
2003 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2004 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2005
2006 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
2007 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2008 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2009 }
2010 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2011 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
2012 log("expecting ASS FAIL like this: ", exp_fail);
2013
2014 f_establish_fully(ass_cmd, exp_fail);
2015}
2016
Harald Welte60aa5762018-03-21 19:33:13 +01002017testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002018 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002019 var MSC_ConnHdlr vc_conn;
2020
2021 f_init(1, true);
2022 f_sleep(1.0);
2023
2024 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002025 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002026 vc_conn.done;
2027}
2028
2029testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002030 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002031 var MSC_ConnHdlr vc_conn;
2032
2033 f_init(1, true);
2034 f_sleep(1.0);
2035
2036 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002037 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002038 vc_conn.done;
2039}
2040
2041testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002042 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002043 var MSC_ConnHdlr vc_conn;
2044
2045 f_init(1, true);
2046 f_sleep(1.0);
2047
2048 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002049 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002050 vc_conn.done;
2051}
2052
Philipp Maierd0e64b02019-03-13 14:15:23 +01002053/* Allow 5,90k only (current default config) */
2054private function f_allow_amr_rate_5_90k() runs on test_CT {
2055 f_vty_enter_cfg_msc(BSCVTY, 0);
2056 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
2057 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2058 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2059 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
2060 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2061 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2062 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2063 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
2064 f_vty_transceive(BSCVTY, "exit");
2065 f_vty_transceive(BSCVTY, "exit");
2066}
2067
2068/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
2069 * ("Config-NB-Code = 1") */
2070private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
2071 f_vty_enter_cfg_msc(BSCVTY, 0);
2072 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
2073 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2074 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2075 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
2076 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2077 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2078 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2079 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
2080 f_vty_transceive(BSCVTY, "exit");
2081 f_vty_transceive(BSCVTY, "exit");
2082}
2083
Harald Welte60aa5762018-03-21 19:33:13 +01002084testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002085 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002086 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002087
2088 /* Note: This setups the codec configuration. The parameter payload in
2089 * mr_conf must be consistant with the parameter codecElements in pars
2090 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002091 var RSL_IE_Body mr_conf := {
2092 other := {
2093 len := 2,
2094 payload := '2804'O
2095 }
2096 };
Harald Welte60aa5762018-03-21 19:33:13 +01002097
Philipp Maier7695a0d2018-09-27 17:52:14 +02002098 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002099 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002100 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
2101 pars.expect_mr_conf_ie := mr_conf;
2102
Harald Welte60aa5762018-03-21 19:33:13 +01002103 f_init(1, true);
2104 f_sleep(1.0);
2105
Harald Welte8863fa12018-05-10 20:15:27 +02002106 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002107 vc_conn.done;
2108}
2109
2110testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002111 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002112 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002113
2114 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002115 var RSL_IE_Body mr_conf := {
2116 other := {
2117 len := 2,
2118 payload := '2804'O
2119 }
2120 };
Harald Welte60aa5762018-03-21 19:33:13 +01002121
Philipp Maier7695a0d2018-09-27 17:52:14 +02002122 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002123 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002124 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2125 pars.expect_mr_conf_ie := mr_conf;
2126
Harald Welte60aa5762018-03-21 19:33:13 +01002127 f_init(1, true);
2128 f_sleep(1.0);
2129
Harald Welte8863fa12018-05-10 20:15:27 +02002130 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002131 vc_conn.done;
2132}
2133
Philipp Maierd0e64b02019-03-13 14:15:23 +01002134function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
2135runs on test_CT {
2136
2137 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2138 var MSC_ConnHdlr vc_conn;
2139
2140 /* See note above */
2141 var RSL_IE_Body mr_conf := {
2142 other := {
2143 len := lengthof(mrconf),
2144 payload := mrconf
2145 }
2146 };
2147
2148 if (fr) {
2149 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2150 } else {
2151 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2152 }
2153 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2154 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2155 pars.expect_mr_conf_ie := mr_conf;
2156 pars.expect_mr_s0_s7 := exp_s8_s0;
2157
2158 f_init(1, true);
2159 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2160 f_sleep(1.0);
2161
2162 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2163 vc_conn.done;
2164 f_allow_amr_rate_5_90k();
2165}
2166
2167function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
2168runs on test_CT {
2169
2170 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2171 var MSC_ConnHdlr vc_conn;
2172
2173 if (fr) {
2174 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2175 } else {
2176 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2177 }
2178 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2179 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2180
2181 f_init(1, true);
2182 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2183 f_sleep(1.0);
2184
2185 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
2186 vc_conn.done;
2187 f_allow_amr_rate_5_90k();
2188}
2189
2190
2191/* Set S1, we expect an AMR multirate configuration IE with all four rates
2192 * set. */
2193testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
2194 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
2195}
2196
2197/* Set S1, we expect an AMR multirate configuration IE with the lower three
2198 * rates set. */
2199testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
2200 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
2201}
2202
2203/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2204 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2205testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
2206 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
2207}
2208
2209/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2210 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2211testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
2212 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
2213}
2214
2215/* The following block of tests selects more and more rates until all four
2216 * possible rates are in the active set (full rate) */
2217testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
2218 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
2219}
2220
2221testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
2222 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
2223}
2224
2225testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
2226 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
2227}
2228
2229testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
2230 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
2231}
2232
2233/* The following block of tests selects more and more rates until all three
2234 * possible rates are in the active set (half rate) */
2235testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
2236 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
2237}
2238
2239testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
2240 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
2241}
2242
2243testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
2244 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
2245}
2246
2247/* The following block tests what happens when the MSC does offer rate
2248 * configurations that are not supported by the BSC. Normally such situations
2249 * should not happen because the MSC gets informed by the BSC in advance via
2250 * the L3 COMPLETE message which rates are applicable. The MSC should not try
2251 * to offer rates that are not applicable anyway. */
2252
2253testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
2254 /* Try to include 12,2k in into the active set even though the channel
2255 * is half rate only. The BSC is expected to remove the 12,0k */
2256 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
2257}
2258
2259testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
2260 /* See what happens when all rates are selected at once. Since then
2261 * Also S1 is selected, this setting will be prefered and we should
2262 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
2263 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
2264}
2265
2266testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
2267 /* Same as above, but with S1 missing, the MSC is then expected to
2268 * select the currently supported rates, which are also 12.2k, 7,40k,
2269 * 5,90k, and 4,75k, into the active set. */
2270 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
2271}
2272
2273testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
2274 /* Try to select no rates at all */
2275 f_TC_assignment_codec_amr_fail(true, '00000000'B);
2276}
2277
2278testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
2279 /* Try to select only unsupported rates */
2280 f_TC_assignment_codec_amr_fail(true, '01101000'B);
2281}
2282
2283testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
2284 /* Try to select 12,2k for half rate */
2285 f_TC_assignment_codec_amr_fail(false, '10000000'B);
2286}
2287
Philipp Maierac09bfc2019-01-08 13:41:39 +01002288private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002289 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
2290 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
2291 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
2292 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002293}
2294
2295private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002296 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
2297 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002298}
2299
2300private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01002301 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
2302 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
2303 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
2304 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
2305 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
2306 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01002307}
2308
2309/* Allow HR only */
2310private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
2311 g_pars := f_gen_test_hdlr_pars();
2312 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2313 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2314 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2315 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2316 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2317 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2318 f_establish_fully(ass_cmd, exp_compl);
2319}
2320
2321/* Allow FR only */
2322private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
2323 g_pars := f_gen_test_hdlr_pars();
2324 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2325 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2326 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2327 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2328 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2329 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2330 f_establish_fully(ass_cmd, exp_compl);
2331}
2332
2333/* Allow HR only (expect assignment failure) */
2334private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
2335 g_pars := f_gen_test_hdlr_pars();
2336 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2337 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2338 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2339 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
2340 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
2341 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
2342 f_establish_fully(ass_cmd, exp_fail);
2343}
2344
2345/* Allow FR only (expect assignment failure) */
2346private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
2347 g_pars := f_gen_test_hdlr_pars();
2348 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2349 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2350 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2351 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
2352 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
2353 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2354 f_establish_fully(ass_cmd, exp_fail);
2355}
2356
2357/* Allow FR and HR, but prefer FR */
2358private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2359 g_pars := f_gen_test_hdlr_pars();
2360 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2361 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2362 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2363 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2364 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2365 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2366 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2367 f_establish_fully(ass_cmd, exp_compl);
2368}
2369
2370/* Allow FR and HR, but prefer HR */
2371private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2372 g_pars := f_gen_test_hdlr_pars();
2373 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2374 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2375 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2376 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2377 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2378 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2379 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2380 f_establish_fully(ass_cmd, exp_compl);
2381}
2382
2383/* Allow FR and HR, but prefer FR */
2384private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2385 g_pars := f_gen_test_hdlr_pars();
2386 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2387 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2388 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2389 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2390 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2391 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2392 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2393 f_establish_fully(ass_cmd, exp_compl);
2394}
2395
2396/* Allow FR and HR, but prefer HR */
2397private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2398 g_pars := f_gen_test_hdlr_pars();
2399 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2400 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2401 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2402 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2403 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2404 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2405 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2406 f_establish_fully(ass_cmd, exp_compl);
2407}
2408
2409/* Request a HR channel while all FR channels are exhausted, this is expected
2410 * to work without conflicts */
2411testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
2412 var MSC_ConnHdlr vc_conn;
2413 f_init(1, true);
2414 f_sleep(1.0);
2415 f_enable_all_tch();
2416 f_disable_all_tch_f();
2417 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
2418 vc_conn.done;
2419 f_enable_all_tch();
2420 setverdict(pass);
2421}
2422
2423/* Request a FR channel while all FR channels are exhausted, this is expected
2424 * to fail. */
2425testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
2426 var MSC_ConnHdlr vc_conn;
2427 f_init(1, true);
2428 f_sleep(1.0);
2429 f_enable_all_tch();
2430 f_disable_all_tch_f();
2431 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
2432 vc_conn.done;
2433 f_enable_all_tch();
2434 setverdict(pass);
2435}
2436
2437/* Request a FR (prefered) or alternatively a HR channel while all FR channels
2438 * are exhausted, this is expected to be resolved by selecting a HR channel. */
2439testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
2440 var MSC_ConnHdlr vc_conn;
2441 f_init(1, true);
2442 f_sleep(1.0);
2443 f_enable_all_tch();
2444 f_disable_all_tch_f();
2445 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
2446 vc_conn.done;
2447 f_enable_all_tch();
2448 setverdict(pass);
2449}
2450
2451/* Request a HR (prefered) or alternatively a FR channel while all FR channels
2452 * are exhausted, this is expected to work without conflicts. */
2453testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
2454 var MSC_ConnHdlr vc_conn;
2455 f_init(1, true);
2456 f_sleep(1.0);
2457 f_enable_all_tch();
2458 f_disable_all_tch_f();
2459 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
2460 vc_conn.done;
2461 f_enable_all_tch();
2462 setverdict(pass);
2463}
2464
2465/* Request a FR channel while all HR channels are exhausted, this is expected
2466 * to work without conflicts */
2467testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
2468 var MSC_ConnHdlr vc_conn;
2469 f_init(1, true);
2470 f_sleep(1.0);
2471 f_enable_all_tch();
2472 f_disable_all_tch_h();
2473 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
2474 vc_conn.done;
2475 f_enable_all_tch();
2476 setverdict(pass);
2477}
2478
2479/* Request a HR channel while all HR channels are exhausted, this is expected
2480 * to fail. */
2481testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
2482 var MSC_ConnHdlr vc_conn;
2483 f_init(1, true);
2484 f_sleep(1.0);
2485 f_enable_all_tch();
2486 f_disable_all_tch_h();
2487 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
2488 vc_conn.done;
2489 f_enable_all_tch();
2490 setverdict(pass);
2491}
2492
2493/* Request a HR (prefered) or alternatively a FR channel while all HR channels
2494 * are exhausted, this is expected to be resolved by selecting a FR channel. */
2495testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
2496 var MSC_ConnHdlr vc_conn;
2497 f_init(1, true);
2498 f_sleep(1.0);
2499 f_enable_all_tch();
2500 f_disable_all_tch_h();
2501 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
2502 vc_conn.done;
2503 f_enable_all_tch();
2504 setverdict(pass);
2505}
2506
2507/* Request a FR (prefered) or alternatively a HR channel while all HR channels
2508 * are exhausted, this is expected to work without conflicts. */
2509testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
2510 var MSC_ConnHdlr vc_conn;
2511 f_init(1, true);
2512 f_sleep(1.0);
2513 f_enable_all_tch();
2514 f_disable_all_tch_h();
2515 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
2516 vc_conn.done;
2517 f_enable_all_tch();
2518 setverdict(pass);
2519}
2520
2521/* Allow FR and HR, but prefer HR */
2522private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
2523 g_pars := f_gen_test_hdlr_pars();
2524 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2525 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2526 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2527 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
2528 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
2529 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
2530 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
2531 f_establish_fully(ass_cmd, exp_compl);
2532}
2533
2534/* Allow FR and HR, but prefer FR */
2535private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
2536 g_pars := f_gen_test_hdlr_pars();
2537 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2538 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2539 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2540 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
2541 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
2542 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
2543 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
2544 f_establish_fully(ass_cmd, exp_compl);
2545}
2546
2547/* Request a HR (prefered) or alternatively a FR channel, it is expected that
2548 * HR, which is the prefered type, is selected. */
2549testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
2550 var MSC_ConnHdlr vc_conn;
2551 f_init(1, true);
2552 f_sleep(1.0);
2553 f_enable_all_tch();
2554 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
2555 vc_conn.done;
2556 setverdict(pass);
2557}
2558
2559/* Request a FR (prefered) or alternatively a HR channel, it is expected that
2560 * FR, which is the prefered type, is selected. */
2561testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
2562 var MSC_ConnHdlr vc_conn;
2563 f_init(1, true);
2564 f_sleep(1.0);
2565 f_enable_all_tch();
2566 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
2567 vc_conn.done;
2568 setverdict(pass);
2569}
2570
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002571/* test the procedure of the MSC requesting a Classmark Update:
2572 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
2573 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01002574private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002575 g_pars := f_gen_test_hdlr_pars();
2576
Harald Weltea0630032018-03-20 21:09:55 +01002577 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002578 /* we should now have a COMPL_L3 at the MSC */
2579 BSSAP.receive(tr_BSSMAP_ComplL3);
2580
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02002581 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
2582 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
2583
Harald Welte898113b2018-01-31 18:32:21 +01002584 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
2585 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
2586 setverdict(pass);
2587}
2588testcase TC_classmark() runs on test_CT {
2589 var MSC_ConnHdlr vc_conn;
2590 f_init(1, true);
2591 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002592 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01002593 vc_conn.done;
2594}
2595
Harald Weltee3bd6582018-01-31 22:51:25 +01002596private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002597 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002598 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01002599 /* we should now have a COMPL_L3 at the MSC */
2600 BSSAP.receive(tr_BSSMAP_ComplL3);
2601
Harald Weltee3bd6582018-01-31 22:51:25 +01002602 /* send the single message we want to send */
2603 f_rsl_send_l3(l3);
2604}
2605
2606private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
2607 timer T := sec;
2608 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01002609 T.start;
2610 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01002611 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
2612 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02002613 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01002614 }
2615 [] T.timeout {
2616 setverdict(pass);
2617 }
2618 }
2619}
2620
Harald Weltee3bd6582018-01-31 22:51:25 +01002621/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2622private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
2623 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
2624 f_bssap_expect_nothing();
2625}
Harald Welte898113b2018-01-31 18:32:21 +01002626testcase TC_unsol_ass_fail() runs on test_CT {
2627 var MSC_ConnHdlr vc_conn;
2628 f_init(1, true);
2629 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002630 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01002631 vc_conn.done;
2632}
Harald Welte552620d2017-12-16 23:21:36 +01002633
Harald Welteea99a002018-01-31 20:46:43 +01002634
2635/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
2636private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002637 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
2638 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01002639}
2640testcase TC_unsol_ass_compl() runs on test_CT {
2641 var MSC_ConnHdlr vc_conn;
2642 f_init(1, true);
2643 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002644 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01002645 vc_conn.done;
2646}
2647
2648
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002649/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
2650private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01002651 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
2652 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002653}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002654testcase TC_unsol_ho_fail() runs on test_CT {
2655 var MSC_ConnHdlr vc_conn;
2656 f_init(1, true);
2657 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002658 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002659 vc_conn.done;
2660}
2661
2662
Harald Weltee3bd6582018-01-31 22:51:25 +01002663/* short message from MS should be ignored */
2664private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002665 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01002666 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01002667 /* we should now have a COMPL_L3 at the MSC */
2668 BSSAP.receive(tr_BSSMAP_ComplL3);
2669
2670 /* send short message */
2671 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
2672 f_bssap_expect_nothing();
2673}
2674testcase TC_err_82_short_msg() runs on test_CT {
2675 var MSC_ConnHdlr vc_conn;
2676 f_init(1, true);
2677 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002678 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01002679 vc_conn.done;
2680}
2681
2682
Harald Weltee9e02e42018-01-31 23:36:25 +01002683/* 24.008 8.4 Unknown message must trigger RR STATUS */
2684private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
2685 f_est_single_l3(ts_RRM_UL_REL('00'O));
2686 timer T := 3.0
2687 alt {
2688 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
2689 setverdict(pass);
2690 }
2691 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01002692 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01002693 }
2694}
2695testcase TC_err_84_unknown_msg() runs on test_CT {
2696 var MSC_ConnHdlr vc_conn;
2697 f_init(1, true);
2698 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002699 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01002700 vc_conn.done;
2701}
2702
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002703/***********************************************************************
2704 * Handover
2705 ***********************************************************************/
2706
Harald Welte94e0c342018-04-07 11:33:23 +02002707/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
2708private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
2709runs on test_CT {
2710 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2711 " timeslot "&int2str(ts_nr)&" ";
2712 f_vty_transceive(BSCVTY, cmd & suffix);
2713}
2714
Harald Welte261af4b2018-02-12 21:20:39 +01002715/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
2716private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
2717runs on MSC_ConnHdlr {
2718 /* FIXME: resolve those from component-global state */
2719 var integer ts_nr := chan_nr.tn;
2720 var integer ss_nr;
2721 if (ischosen(chan_nr.u.ch0)) {
2722 ss_nr := 0;
2723 } else if (ischosen(chan_nr.u.lm)) {
2724 ss_nr := chan_nr.u.lm.sub_chan;
2725 } else if (ischosen(chan_nr.u.sdcch4)) {
2726 ss_nr := chan_nr.u.sdcch4.sub_chan;
2727 } else if (ischosen(chan_nr.u.sdcch8)) {
2728 ss_nr := chan_nr.u.sdcch8.sub_chan;
2729 } else {
2730 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02002731 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01002732 }
2733
2734 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
2735 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
2736 f_vty_transceive(BSCVTY, cmd & suffix);
2737}
2738
2739private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
2740 integer new_bts_nr)
2741runs on MSC_ConnHdlr {
2742 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
2743}
2744
2745/* intra-BSC hand-over between BTS0 and BTS1 */
2746private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002747 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02002748 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2749 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01002750 const OCT8 kc := '0001020304050607'O;
2751
2752 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2753 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2754
Harald Weltea0630032018-03-20 21:09:55 +01002755 f_establish_fully(ass_cmd, exp_compl);
Harald Welte261af4b2018-02-12 21:20:39 +01002756
2757 var HandoverState hs := {
2758 rr_ho_cmpl_seen := false,
2759 handover_done := false,
2760 old_chan_nr := -
2761 };
2762 /* issue hand-over command on VTY */
2763 f_vty_handover(0, 0, g_chan_nr, 1);
2764 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2765 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002766
2767 /* From the MGW perspective, a handover is is characterized by
2768 * performing one MDCX operation with the MGW. So we expect to see
2769 * one more MDCX during handover. */
2770 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
2771
Harald Welte261af4b2018-02-12 21:20:39 +01002772 alt {
2773 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01002774 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002775
Philipp Maier4dae0652018-11-12 12:03:26 +01002776 /* Since this is an internal handover we expect the BSC to inform the
2777 * MSC about the event */
2778 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
2779
Philipp Maier3e2af5d2018-07-11 17:01:05 +02002780 /* Check the amount of MGCP transactions is still consistant with the
2781 * test expectation */
2782 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01002783 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01002784}
2785
2786testcase TC_ho_int() runs on test_CT {
2787 var MSC_ConnHdlr vc_conn;
2788 f_init(2, true);
2789 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002790 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002791 vc_conn.done;
2792}
Harald Weltee9e02e42018-01-31 23:36:25 +01002793
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002794private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002795 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01002796
2797 var PDU_BSSAP ass_req := f_gen_ass_req();
2798 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2799 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2800 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2801 f_establish_fully(ass_req, exp_compl);
2802
2803 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2804
2805 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2806
2807 f_sleep(0.5);
2808 /* The MSC negotiates Handover Request and Handover Request Ack with
2809 * the other BSS and comes back with a BSSMAP Handover Command
2810 * containing an RR Handover Command coming from the target BSS... */
2811
2812 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
2813 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
2814 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
2815 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
2816 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
2817
2818 /* expect the Handover Command to go out on RR */
2819 var RSL_Message rsl_ho_cmd
2820 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
2821 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
2822 var RSL_IE_Body rsl_ho_cmd_l3;
2823 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
2824 log("RSL message contains no L3 Info IE, expected RR Handover Command");
2825 setverdict(fail);
2826 } else {
2827 log("Found L3 Info: ", rsl_ho_cmd_l3);
2828 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
2829 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
2830 setverdict(fail);
2831 } else {
2832 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
2833 setverdict(pass);
2834 }
2835 }
2836
2837 /* When the other BSS has reported a completed handover, this side is
2838 * torn down. */
2839
2840 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
2841 var BssmapCause cause := enum2int(cause_val);
2842 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
2843
2844 /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
2845 var MgcpCommand mgcp;
2846 interleave {
2847 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
2848 [] MGCP.receive(tr_DLCX()) -> value mgcp {
2849 log("Got first DLCX: ", mgcp);
2850 }
2851 [] MGCP.receive(tr_DLCX()) -> value mgcp {
2852 log("Got second DLCX: ", mgcp);
2853 }
2854 }
2855 setverdict(pass);
2856 f_sleep(1.0);
2857}
2858testcase TC_ho_out_of_this_bsc() runs on test_CT {
2859 var MSC_ConnHdlr vc_conn;
2860
2861 f_init(1, true);
2862 f_sleep(1.0);
2863
2864 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
2865 vc_conn.done;
2866}
2867
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02002868/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
2869 * simply never sends a BSSMAP Handover Command. */
2870private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01002871 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02002872
2873 var PDU_BSSAP ass_req := f_gen_ass_req();
2874 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2875 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2876 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2877 f_establish_fully(ass_req, exp_compl);
2878
2879 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2880
2881 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2882
2883 /* osmo-bsc should time out 10 seconds after the handover started.
2884 * Let's give it a bit extra. */
2885 f_sleep(15.0);
2886
2887 /* The old lchan and conn should still be active. See that arbitrary L3
2888 * is still going through. */
2889 var octetstring l3 := '0123456789'O;
2890 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2891 var template PDU_BSSAP exp_data := {
2892 discriminator := '1'B,
2893 spare := '0000000'B,
2894 dlci := '00'O,
2895 lengthIndicator := 5,
2896 pdu := {
2897 dtap := l3
2898 }
2899 };
2900 BSSAP.receive(exp_data);
2901 setverdict(pass);
2902 f_sleep(1.0);
2903}
2904testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
2905 var MSC_ConnHdlr vc_conn;
2906
2907 f_init(1, true);
2908 f_sleep(1.0);
2909
2910 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
2911 vc_conn.done;
2912}
2913
2914/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
2915 * RR Handover Failure. */
2916private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01002917 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02002918
2919 var PDU_BSSAP ass_req := f_gen_ass_req();
2920 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2921 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2922 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2923 f_establish_fully(ass_req, exp_compl);
2924
2925 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
2926
2927 BSSAP.receive(tr_BSSMAP_HandoverRequired);
2928
2929 f_sleep(0.5);
2930 /* The MSC negotiates Handover Request and Handover Request Ack with
2931 * the other BSS and comes back with a BSSMAP Handover Command
2932 * containing an RR Handover Command coming from the target BSS... */
2933
2934 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
2935 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
2936 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
2937 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
2938 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
2939
2940 /* expect the Handover Command to go out on RR */
2941 var RSL_Message rsl_ho_cmd
2942 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
2943 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
2944 var RSL_IE_Body rsl_ho_cmd_l3;
2945 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
2946 log("RSL message contains no L3 Info IE, expected RR Handover Command");
2947 setverdict(fail);
2948 } else {
2949 log("Found L3 Info: ", rsl_ho_cmd_l3);
2950 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
2951 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
2952 setverdict(fail);
2953 } else {
2954 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
2955 setverdict(pass);
2956 }
2957 }
2958
2959 f_sleep(0.2);
2960 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
2961
2962 /* Should tell the MSC about the failure */
2963 BSSAP.receive(tr_BSSMAP_HandoverFailure);
2964
2965 f_sleep(1.0);
2966
2967 /* The old lchan and conn should still be active. See that arbitrary L3
2968 * is still going through. */
2969 var octetstring l3 := '0123456789'O;
2970 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2971 var template PDU_BSSAP exp_data := {
2972 discriminator := '1'B,
2973 spare := '0000000'B,
2974 dlci := '00'O,
2975 lengthIndicator := 5,
2976 pdu := {
2977 dtap := l3
2978 }
2979 };
2980 BSSAP.receive(exp_data);
2981 setverdict(pass);
2982 f_sleep(1.0);
2983
2984 setverdict(pass);
2985 f_sleep(1.0);
2986}
2987testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
2988 var MSC_ConnHdlr vc_conn;
2989
2990 f_init(1, true);
2991 f_sleep(1.0);
2992
2993 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
2994 vc_conn.done;
2995}
2996
2997/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
2998 * RR Handover Failure. */
2999private function f_tc_ho_out_fail_no_ho_detect(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003000 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003001
3002 var PDU_BSSAP ass_req := f_gen_ass_req();
3003 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3004 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3005 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3006 f_establish_fully(ass_req, exp_compl);
3007
3008 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3009
3010 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3011
3012 f_sleep(0.5);
3013 /* The MSC negotiates Handover Request and Handover Request Ack with
3014 * the other BSS and comes back with a BSSMAP Handover Command
3015 * containing an RR Handover Command coming from the target BSS... */
3016
3017 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3018 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3019 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3020 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3021 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3022
3023 /* expect the Handover Command to go out on RR */
3024 var RSL_Message rsl_ho_cmd
3025 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3026 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3027 var RSL_IE_Body rsl_ho_cmd_l3;
3028 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3029 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3030 setverdict(fail);
3031 } else {
3032 log("Found L3 Info: ", rsl_ho_cmd_l3);
3033 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3034 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3035 setverdict(fail);
3036 } else {
3037 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3038 setverdict(pass);
3039 }
3040 }
3041
3042 /* The MS never shows up on the remote BSS. Eventually the BSC times
3043 * out and we run into 3GPP TS 48.008 3.1.5.3.3 "Abnormal Conditions":
3044 * RR should be released and Clear Request should go to the MSC. */
3045
3046 var MgcpCommand mgcp;
3047 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01003048 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
3049 log("Got Deact SACCH");
3050 }
Harald Welte924b6ea2019-02-04 01:05:34 +01003051 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01003052 log("Got RR Release");
3053 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003054 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
3055 log("Got RF Chan Rel");
3056 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
3057 }
3058 [] BSSAP.receive(tr_BSSMAP_ClearRequest) {
3059 log("Got BSSMAP Clear Request");
3060 }
3061 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3062 log("Got first DLCX: ", mgcp);
3063 }
3064 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3065 log("Got second DLCX: ", mgcp);
3066 }
3067 }
3068
3069 setverdict(pass);
3070 f_sleep(1.0);
3071}
3072testcase TC_ho_out_fail_no_ho_detect() runs on test_CT {
3073 var MSC_ConnHdlr vc_conn;
3074
3075 f_init(1, true);
3076 f_sleep(1.0);
3077
3078 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_ho_detect));
3079 vc_conn.done;
3080}
3081
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003082private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
3083 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3084 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3085 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3086 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3087 * before we get started. */
3088 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3089 f_rslem_register(0, new_chan_nr);
3090 g_chan_nr := new_chan_nr;
3091 f_sleep(1.0);
3092
3093 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3094 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3095 activate(as_Media());
3096
3097 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3098 f_gen_handover_req()));
3099 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
3100
3101 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3102
3103 var PDU_BSSAP rx_bssap;
3104 var octetstring ho_command_str;
3105
3106 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3107
3108 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3109 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3110 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3111 log("L3 Info in HO Request Ack is ", ho_command);
3112
3113 var GsmArfcn arfcn;
3114 var RslChannelNr actual_new_chan_nr;
3115 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3116 actual_new_chan_nr, arfcn);
3117
3118 if (actual_new_chan_nr != new_chan_nr) {
3119 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3120 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3121 setverdict(fail);
3122 return;
3123 }
3124 log("Handover Command chan_nr is", actual_new_chan_nr);
3125
3126 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3127 * tells the MS to handover to the new lchan. Here comes the new MS on
3128 * the new lchan with a Handover RACH: */
3129
3130 /* send handover detect */
3131
3132 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3133
3134 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3135
3136 /* send handover complete over the new channel */
3137
3138 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
3139 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
3140 enc_PDU_ML3_MS_NW(l3_tx)));
3141
3142 BSSAP.receive(tr_BSSMAP_HandoverComplete);
3143 setverdict(pass);
3144}
3145testcase TC_ho_into_this_bsc() runs on test_CT {
3146 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003147 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003148
3149 f_init(1, true);
3150 f_sleep(1.0);
3151
3152 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3153 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3154
3155 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
3156 vc_conn.done;
3157}
3158
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01003159private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
3160 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3161 f_rslem_register(0, new_chan_nr);
3162 g_chan_nr := new_chan_nr;
3163 f_sleep(1.0);
3164
3165 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3166 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3167 activate(as_Media());
3168
3169 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3170 f_gen_handover_req()));
3171 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
3172
3173 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3174
3175 var PDU_BSSAP rx_bssap;
3176 var octetstring ho_command_str;
3177
3178 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3179
3180 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3181 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3182 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3183 log("L3 Info in HO Request Ack is ", ho_command);
3184
3185 var GsmArfcn arfcn;
3186 var RslChannelNr actual_new_chan_nr;
3187 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3188 actual_new_chan_nr, arfcn);
3189
3190 if (actual_new_chan_nr != new_chan_nr) {
3191 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3192 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3193 setverdict(fail);
3194 return;
3195 }
3196 log("Handover Command chan_nr is", actual_new_chan_nr);
3197
3198 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3199 * tells the MS to handover to the new lchan. In this case, the MS
3200 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
3201 * Handover Failure to the MSC. The procedure according to 3GPP TS
3202 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
3203 * BSSMAP Clear Command: */
3204
3205 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3206 var BssmapCause cause := enum2int(cause_val);
3207 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3208
3209 /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
3210 var MgcpCommand mgcp;
3211 interleave {
3212 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
3213 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3214 log("Got first DLCX: ", mgcp);
3215 }
3216 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3217 log("Got second DLCX: ", mgcp);
3218 }
3219 }
3220 setverdict(pass);
3221 f_sleep(1.0);
3222
3223 setverdict(pass);
3224}
3225testcase TC_ho_in_fail_msc_clears() runs on test_CT {
3226 var MSC_ConnHdlr vc_conn;
3227 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3228
3229 f_init(1, true);
3230 f_sleep(1.0);
3231
3232 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3233 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3234
3235 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
3236 vc_conn.done;
3237}
3238
3239private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
3240 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3241 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3242 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3243 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3244 * before we get started. */
3245 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3246 f_rslem_register(0, new_chan_nr);
3247 g_chan_nr := new_chan_nr;
3248 f_sleep(1.0);
3249
3250 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3251 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3252 activate(as_Media());
3253
3254 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3255 f_gen_handover_req()));
3256 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
3257
3258 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3259
3260 var PDU_BSSAP rx_bssap;
3261 var octetstring ho_command_str;
3262
3263 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3264
3265 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3266 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3267 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3268 log("L3 Info in HO Request Ack is ", ho_command);
3269
3270 var GsmArfcn arfcn;
3271 var RslChannelNr actual_new_chan_nr;
3272 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3273 actual_new_chan_nr, arfcn);
3274
3275 if (actual_new_chan_nr != new_chan_nr) {
3276 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3277 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3278 setverdict(fail);
3279 return;
3280 }
3281 log("Handover Command chan_nr is", actual_new_chan_nr);
3282
3283 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3284 * tells the MS to handover to the new lchan. Here comes the new MS on
3285 * the new lchan with a Handover RACH: */
3286
3287 /* send handover detect */
3288
3289 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
3290
3291 BSSAP.receive(tr_BSSMAP_HandoverDetect);
3292
3293 /* The MSC chooses to clear the connection now, maybe we got the
3294 * Handover RACH on the new cell but the MS still signaled Handover
3295 * Failure to the old BSS? */
3296
3297 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3298 var BssmapCause cause := enum2int(cause_val);
3299 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3300
3301 /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
3302 var MgcpCommand mgcp;
3303 interleave {
3304 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
3305 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3306 log("Got first DLCX: ", mgcp);
3307 }
3308 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3309 log("Got second DLCX: ", mgcp);
3310 }
3311 }
3312 setverdict(pass);
3313 f_sleep(1.0);
3314}
3315testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
3316 var MSC_ConnHdlr vc_conn;
3317 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3318
3319 f_init(1, true);
3320 f_sleep(1.0);
3321
3322 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3323 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3324
3325 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
3326 vc_conn.done;
3327}
3328
3329/* The new BSS's lchan times out before the MSC decides that handover failed. */
3330private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
3331 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3332 f_rslem_register(0, new_chan_nr);
3333 g_chan_nr := new_chan_nr;
3334 f_sleep(1.0);
3335
3336 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3337 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3338 activate(as_Media());
3339
3340 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3341 f_gen_handover_req()));
3342 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
3343
3344 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3345
3346 var PDU_BSSAP rx_bssap;
3347 var octetstring ho_command_str;
3348
3349 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3350
3351 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3352 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3353 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3354 log("L3 Info in HO Request Ack is ", ho_command);
3355
3356 var GsmArfcn arfcn;
3357 var RslChannelNr actual_new_chan_nr;
3358 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3359 actual_new_chan_nr, arfcn);
3360
3361 if (actual_new_chan_nr != new_chan_nr) {
3362 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3363 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3364 setverdict(fail);
3365 return;
3366 }
3367 log("Handover Command chan_nr is", actual_new_chan_nr);
3368
3369 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3370 * tells the MS to handover to the new lchan. But the MS never shows up
3371 * on the new lchan. */
3372
3373 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3374
3375 /* Did osmo-bsc also send a Clear Request? */
3376 timer T := 0.5;
3377 T.start;
3378 alt {
3379 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
3380 [] T.timeout { }
3381 }
3382
3383 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
3384 * asked for it, this is a Handover Failure after all). */
3385
3386 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
3387 var BssmapCause cause := enum2int(cause_val);
3388 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3389
3390 /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
3391 var MgcpCommand mgcp;
3392 interleave {
3393 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
3394 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3395 log("Got first DLCX: ", mgcp);
3396 }
3397 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3398 log("Got second DLCX: ", mgcp);
3399 }
3400 }
3401 setverdict(pass);
3402 f_sleep(1.0);
3403
3404 setverdict(pass);
3405}
3406testcase TC_ho_in_fail_no_detect() runs on test_CT {
3407 var MSC_ConnHdlr vc_conn;
3408 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3409
3410 f_init(1, true);
3411 f_sleep(1.0);
3412
3413 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3414 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3415
3416 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
3417 vc_conn.done;
3418}
3419
3420/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
3421private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
3422 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3423 f_rslem_register(0, new_chan_nr);
3424 g_chan_nr := new_chan_nr;
3425 f_sleep(1.0);
3426
3427 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3428 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3429 activate(as_Media());
3430
3431 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc,
3432 f_gen_handover_req()));
3433 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
3434
3435 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3436
3437 var PDU_BSSAP rx_bssap;
3438 var octetstring ho_command_str;
3439
3440 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
3441
3442 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3443 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3444 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3445 log("L3 Info in HO Request Ack is ", ho_command);
3446
3447 var GsmArfcn arfcn;
3448 var RslChannelNr actual_new_chan_nr;
3449 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3450 actual_new_chan_nr, arfcn);
3451
3452 if (actual_new_chan_nr != new_chan_nr) {
3453 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3454 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
3455 setverdict(fail);
3456 return;
3457 }
3458 log("Handover Command chan_nr is", actual_new_chan_nr);
3459
3460 /* Now the MSC forwards the RR Handover Command to the other BSC, which
3461 * tells the MS to handover to the new lchan. But the MS never shows up
3462 * on the new lchan. */
3463
3464 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3465
3466 /* MSC plays dumb and sends no Clear Command */
3467
3468 /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
3469 var PDU_BSSAP rx_clear_request;
3470 var MgcpCommand mgcp;
3471 interleave {
3472 [] BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
3473 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3474 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3475 };
3476 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
3477
3478 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3479 log("Got first DLCX: ", mgcp);
3480 }
3481 [] MGCP.receive(tr_DLCX()) -> value mgcp {
3482 log("Got second DLCX: ", mgcp);
3483 }
3484 }
3485 setverdict(pass);
3486 f_sleep(1.0);
3487}
3488testcase TC_ho_in_fail_no_detect2() runs on test_CT {
3489 var MSC_ConnHdlr vc_conn;
3490 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3491
3492 f_init(1, true);
3493 f_sleep(1.0);
3494
3495 pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own;
3496 pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer;
3497
3498 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
3499 vc_conn.done;
3500}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003501
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003502/* OS#3041: Open and close N connections in a normal fashion, and expect no
3503 * BSSMAP Reset just because of that. */
3504testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
3505 var default d;
3506 var integer i;
3507 var DchanTuple dt;
3508
3509 f_init();
3510
3511 /* Wait for initial BSSMAP Reset to pass */
3512 f_sleep(4.0);
3513
3514 d := activate(no_bssmap_reset());
3515
3516 /* Setup up a number of connections and RLSD them again from the MSC
3517 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
3518 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02003519 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003520 /* Since we're doing a lot of runs, give each one a fresh
3521 * T_guard from the top. */
3522 T_guard.start;
3523
3524 /* Setup a BSSAP connection and clear it right away. This is
3525 * the MSC telling the BSC about a planned release, it's not an
3526 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02003527 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01003528
3529 /* MSC disconnects (RLSD). */
3530 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
3531 }
3532
3533 /* In the buggy behavior, a timeout of 2 seconds happens between above
3534 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
3535 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
3536 f_sleep(4.0);
3537
3538 deactivate(d);
3539 f_shutdown_helper();
3540}
Harald Welte552620d2017-12-16 23:21:36 +01003541
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01003542/* OS#3041: Open and close N connections in a normal fashion, and expect no
3543 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
3544 * the MSC. */
3545testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
3546 var default d;
3547 var integer i;
3548 var DchanTuple dt;
3549 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01003550 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
3551 var BssmapCause cause := enum2int(cause_val);
3552
3553 f_init();
3554
3555 /* Wait for initial BSSMAP Reset to pass */
3556 f_sleep(4.0);
3557
3558 d := activate(no_bssmap_reset());
3559
3560 /* Setup up a number of connections and RLSD them again from the MSC
3561 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
3562 * Let's do it some more times for good measure. */
3563 for (i := 0; i < 8; i := i+1) {
3564 /* Since we're doing a lot of runs, give each one a fresh
3565 * T_guard from the top. */
3566 T_guard.start;
3567
3568 /* Setup a BSSAP connection and clear it right away. This is
3569 * the MSC telling the BSC about a planned release, it's not an
3570 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02003571 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01003572
3573 /* Instruct BSC to clear channel */
3574 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
3575
3576 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02003577 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01003578 }
3579
3580 /* In the buggy behavior, a timeout of 2 seconds happens between above
3581 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
3582 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
3583 f_sleep(4.0);
3584
3585 deactivate(d);
3586 f_shutdown_helper();
3587}
3588
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01003589/* OS#3041: Open and close N connections in a normal fashion, and expect no
3590 * BSSMAP Reset just because of that. Close connections from the MS side with a
3591 * Release Ind on RSL. */
3592testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
3593 var default d;
3594 var integer i;
3595 var DchanTuple dt;
3596 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01003597 var integer j;
3598
3599 f_init();
3600
3601 /* Wait for initial BSSMAP Reset to pass */
3602 f_sleep(4.0);
3603
3604 d := activate(no_bssmap_reset());
3605
3606 /* Setup up a number of connections and RLSD them again from the MSC
3607 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
3608 * Let's do it some more times for good measure. */
3609 for (i := 0; i < 8; i := i+1) {
3610 /* Since we're doing a lot of runs, give each one a fresh
3611 * T_guard from the top. */
3612 T_guard.start;
3613
3614 /* Setup a BSSAP connection and clear it right away. This is
3615 * the MSC telling the BSC about a planned release, it's not an
3616 * erratic loss of a connection. */
3617 dt := f_est_dchan('23'O, 23, '00010203040506'O);
3618
3619 /* simulate RLL REL IND */
3620 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
3621
3622 /* expect Clear Request on MSC side */
3623 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
3624
3625 /* Instruct BSC to clear channel */
3626 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
3627 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
3628
3629 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02003630 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01003631 }
3632
3633 /* In the buggy behavior, a timeout of 2 seconds happens between above
3634 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
3635 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
3636 f_sleep(4.0);
3637
3638 deactivate(d);
3639 f_shutdown_helper();
3640}
3641
Harald Welte94e0c342018-04-07 11:33:23 +02003642/***********************************************************************
3643 * IPA style dynamic PDCH
3644 ***********************************************************************/
3645
3646private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
3647 template (omit) RSL_Cause nack := omit)
3648runs on test_CT {
3649 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
3650 var RSL_Message rsl_unused;
3651 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
3652 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
3653 /* expect the BSC to issue the related RSL command */
3654 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
3655 if (istemplatekind(nack, "omit")) {
3656 /* respond with a related acknowledgement */
3657 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
3658 } else {
3659 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
3660 }
3661}
3662
3663private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
3664 template (omit) RSL_Cause nack := omit)
3665runs on test_CT {
3666 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
3667 var RSL_Message rsl_unused;
3668 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
3669 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
3670 /* expect the BSC to issue the related RSL command */
3671 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
3672 if (istemplatekind(nack, "omit")) {
3673 /* respond with a related acknowledgement */
3674 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
3675 } else {
3676 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
3677 }
3678}
3679
3680private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
3681runs on test_CT return charstring {
3682 var charstring cmd, resp;
3683 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01003684 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02003685}
3686
3687private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
3688 template charstring exp)
3689runs on test_CT {
3690 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
3691 if (not match(mode, exp)) {
3692 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02003693 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02003694 }
3695}
3696
3697private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
3698runs on test_CT {
3699 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
3700 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
3701 f_vty_transceive(BSCVTY, "end");
3702}
3703
3704private const charstring TCHF_MODE := "TCH/F mode";
3705private const charstring TCHH_MODE := "TCH/H mode";
3706private const charstring PDCH_MODE := "PDCH mode";
3707private const charstring NONE_MODE := "NONE mode";
3708
3709/* Test IPA PDCH activation / deactivation triggered by VTY */
3710testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
3711 var RSL_Message rsl_unused;
3712
3713 /* change Timeslot 6 before f_init() starts RSL */
3714 f_init_vty();
3715 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
3716 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
3717
3718 f_init(1, false);
3719 f_sleep(1.0);
3720
3721 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
3722
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003723 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003724 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3725 /* The BSC will activate the dynamic PDCH by default, so confirm that */
3726 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
3727 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
3728 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003729 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003730 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
3731
3732 /* De-activate it via VTY */
3733 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
3734 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003735 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003736 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3737
3738 /* re-activate it via VTY */
3739 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
3740 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003741 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003742 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
3743
3744 /* and finally de-activate it again */
3745 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
3746 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003747 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003748 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3749
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02003750 /* clean up config */
3751 f_ts_set_chcomb(0, 0, 6, "PDCH");
3752
Harald Welte94e0c342018-04-07 11:33:23 +02003753 setverdict(pass);
3754}
3755
3756/* Test IPA PDCH activation NACK */
3757testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
3758 var RSL_Message rsl_unused;
3759
3760 /* change Timeslot 6 before f_init() starts RSL */
3761 f_init_vty();
3762 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
3763 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
3764
3765 f_init(1, false);
3766 f_sleep(1.0);
3767
3768 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
3769
3770 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3771 /* The BSC will activate the dynamic PDCH by default, so confirm that */
3772 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
3773 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
3774 f_sleep(1.0);
3775 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
3776
3777 /* De-activate it via VTY */
3778 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
3779 f_sleep(1.0);
3780 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3781
3782 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
3783 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
3784 f_sleep(1.0);
3785 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
3786
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02003787 /* clean up config */
3788 f_ts_set_chcomb(0, 0, 6, "PDCH");
3789
Harald Welte94e0c342018-04-07 11:33:23 +02003790 setverdict(pass);
3791}
3792
3793
3794/***********************************************************************
3795 * Osmocom style dynamic PDCH
3796 ***********************************************************************/
3797
3798private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
3799 template (omit) RSL_Cause nack := omit)
3800runs on test_CT {
3801 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
3802 var RSL_Message rsl_unused;
3803 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
3804 /* FIXME: no VTY command to activate Osmocom PDCH !! */
3805 /* expect the BSC to issue the related RSL command */
3806 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
3807 if (istemplatekind(nack, "omit")) {
3808 /* respond with a related acknowledgement */
3809 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
3810 } else {
3811 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
3812 }
3813}
3814
3815private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
3816 template (omit) RSL_Cause nack := omit)
3817runs on test_CT {
3818 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
3819 var RSL_Message rsl_unused;
3820 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
3821 /* FIXME: no VTY command to activate Osmocom PDCH !! */
3822 /* expect the BSC to issue the related RSL command */
3823 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
3824 if (istemplatekind(nack, "omit")) {
3825 /* respond with a related acknowledgement */
3826 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
3827 } else {
3828 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
3829 }
3830}
3831
3832/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
3833testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
3834 var RSL_Message rsl_unused;
3835
3836 /* change Timeslot 6 before f_init() starts RSL */
3837 f_init_vty();
3838 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
3839 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
3840
3841 f_init(1, false);
3842 f_sleep(1.0);
3843
3844 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
3845
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003846 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02003847 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
3848 /* The BSC will activate the dynamic PDCH by default, so confirm that */
3849 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
3850
3851 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
3852 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003853 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 +02003854 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
3855
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02003856 /* clean up config */
3857 f_ts_set_chcomb(0, 0, 6, "PDCH");
3858
Harald Welte94e0c342018-04-07 11:33:23 +02003859 setverdict(pass);
3860}
3861
3862/* Test Osmocom dyn PDCH activation NACK behavior */
3863testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
3864 var RSL_Message rsl_unused;
3865
3866 /* change Timeslot 6 before f_init() starts RSL */
3867 f_init_vty();
3868 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
3869 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
3870
3871 f_init(1, false);
3872 f_sleep(1.0);
3873
3874 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
3875
3876 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
3877 /* The BSC will activate the dynamic PDCH by default, so confirm that */
3878 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
3879
3880 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
3881 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
3882 f_sleep(1.0);
3883 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
3884
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02003885 /* clean up config */
3886 f_ts_set_chcomb(0, 0, 6, "PDCH");
3887
Harald Welte94e0c342018-04-07 11:33:23 +02003888 setverdict(pass);
3889}
3890
Stefan Sperling0796a822018-10-05 13:01:39 +02003891testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02003892 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02003893 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
3894 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
3895 }
3896}
3897
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02003898testcase TC_chopped_ipa_payload() runs on test_CT {
3899 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
3900 /* TODO: mp_bsc_ctrl_port does not work yet */};
3901 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
3902 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
3903 }
3904}
3905
3906
Harald Welte0ea2d5e2018-04-07 21:40:29 +02003907/* Dyn PDCH todo:
3908 * activate OSMO as TCH/F
3909 * activate OSMO as TCH/H
3910 * does the BSC-located PCU socket get the updated INFO?
3911 * what if no PCU is connected at the time?
3912 * is the info correct on delayed PCU (re)connect?
3913 */
Harald Welte94e0c342018-04-07 11:33:23 +02003914
Harald Welte28d943e2017-11-25 15:00:50 +01003915control {
Harald Welte898113b2018-01-31 18:32:21 +01003916 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01003917 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01003918 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01003919 execute( TC_ctrl() );
Harald Welte898113b2018-01-31 18:32:21 +01003920
3921 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01003922 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01003923 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01003924 execute( TC_chan_act_ack_noest() );
3925 execute( TC_chan_act_ack_est_ind_noreply() );
3926 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01003927 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01003928 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07003929 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01003930 execute( TC_chan_rel_rll_rel_ind() );
3931 execute( TC_chan_rel_conn_fail() );
3932 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01003933 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01003934 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02003935 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01003936 execute( TC_chan_rel_a_reset() );
Harald Welte6f521d82017-12-11 19:52:02 +01003937
Harald Weltecfe2c962017-12-15 12:09:32 +01003938 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01003939
3940 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01003941 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01003942 execute( TC_assignment_csd() );
3943 execute( TC_assignment_ctm() );
3944 execute( TC_assignment_sign() );
3945 execute( TC_assignment_fr_a5_0() );
3946 execute( TC_assignment_fr_a5_1() );
Harald Welte8f67d1d2018-05-25 20:38:42 +02003947 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
3948 execute( TC_assignment_fr_a5_1_codec_missing() );
3949 }
Harald Welte235ebf12017-12-15 14:18:16 +01003950 execute( TC_assignment_fr_a5_3() );
3951 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02003952 execute( TC_ciph_mode_a5_0() );
3953 execute( TC_ciph_mode_a5_1() );
3954 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01003955
Harald Welte60aa5762018-03-21 19:33:13 +01003956 execute( TC_assignment_codec_fr() );
3957 execute( TC_assignment_codec_hr() );
3958 execute( TC_assignment_codec_efr() );
3959 execute( TC_assignment_codec_amr_f() );
3960 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01003961
3962 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
3963 execute( TC_assignment_codec_amr_f_S1() );
3964 execute( TC_assignment_codec_amr_h_S1() );
3965 execute( TC_assignment_codec_amr_f_S124() );
3966 execute( TC_assignment_codec_amr_h_S124() );
3967 execute( TC_assignment_codec_amr_f_S0() );
3968 execute( TC_assignment_codec_amr_f_S02() );
3969 execute( TC_assignment_codec_amr_f_S024() );
3970 execute( TC_assignment_codec_amr_f_S0247() );
3971 execute( TC_assignment_codec_amr_h_S0() );
3972 execute( TC_assignment_codec_amr_h_S02() );
3973 execute( TC_assignment_codec_amr_h_S024() );
3974 execute( TC_assignment_codec_amr_h_S0247() );
3975 execute( TC_assignment_codec_amr_f_S01234567() );
3976 execute( TC_assignment_codec_amr_f_S0234567() );
3977 execute( TC_assignment_codec_amr_f_zero() );
3978 execute( TC_assignment_codec_amr_f_unsupp() );
3979 execute( TC_assignment_codec_amr_h_S7() );
3980 }
Harald Welte60aa5762018-03-21 19:33:13 +01003981
Philipp Maierac09bfc2019-01-08 13:41:39 +01003982 execute( TC_assignment_codec_fr_exhausted_req_hr() );
3983 execute( TC_assignment_codec_fr_exhausted_req_fr() );
3984 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
3985 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
3986 execute( TC_assignment_codec_hr_exhausted_req_fr() );
3987 execute( TC_assignment_codec_hr_exhausted_req_hr() );
3988 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
3989 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
3990 execute( TC_assignment_codec_req_hr_fr() );
3991 execute( TC_assignment_codec_req_fr_hr() );
3992
Harald Welte898113b2018-01-31 18:32:21 +01003993 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01003994 execute( TC_rll_est_ind_inact_lchan() );
3995 execute( TC_rll_est_ind_inval_sapi1() );
3996 execute( TC_rll_est_ind_inval_sapi3() );
3997 execute( TC_rll_est_ind_inval_sacch() );
3998
Harald Welte898113b2018-01-31 18:32:21 +01003999 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01004000 execute( TC_paging_imsi_nochan() );
4001 execute( TC_paging_tmsi_nochan() );
4002 execute( TC_paging_tmsi_any() );
4003 execute( TC_paging_tmsi_sdcch() );
4004 execute( TC_paging_tmsi_tch_f() );
4005 execute( TC_paging_tmsi_tch_hf() );
4006 execute( TC_paging_imsi_nochan_cgi() );
4007 execute( TC_paging_imsi_nochan_lac_ci() );
4008 execute( TC_paging_imsi_nochan_ci() );
4009 execute( TC_paging_imsi_nochan_lai() );
4010 execute( TC_paging_imsi_nochan_lac() );
4011 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01004012 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
4013 execute( TC_paging_imsi_nochan_rnc() );
4014 execute( TC_paging_imsi_nochan_lac_rnc() );
4015 execute( TC_paging_imsi_nochan_lacs() );
4016 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01004017 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01004018 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01004019 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01004020 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01004021 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01004022
4023 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01004024 execute( TC_rsl_unknown_unit_id() );
4025
4026 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01004027
4028 execute( TC_classmark() );
4029 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01004030 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004031 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01004032 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01004033 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004034
Harald Welte261af4b2018-02-12 21:20:39 +01004035 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004036
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004037 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004038 execute( TC_ho_out_fail_no_msc_response() );
4039 execute( TC_ho_out_fail_rr_ho_failure() );
4040 execute( TC_ho_out_fail_no_ho_detect() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004041
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004042 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004043 execute( TC_ho_in_fail_msc_clears() );
4044 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
4045 execute( TC_ho_in_fail_no_detect() );
4046 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004047
4048 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004049 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004050 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02004051
4052 execute( TC_dyn_pdch_ipa_act_deact() );
4053 execute( TC_dyn_pdch_ipa_act_nack() );
4054 execute( TC_dyn_pdch_osmo_act_deact() );
4055 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02004056
Stefan Sperling0796a822018-10-05 13:01:39 +02004057 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004058 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02004059
Harald Welte99f3ca02018-06-14 13:40:29 +02004060 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
4061 execute( TC_early_conn_fail() );
4062 execute( TC_late_conn_fail() );
4063
Harald Welte28d943e2017-11-25 15:00:50 +01004064}
4065
4066}