blob: 906e2144e9010f6bd92730ffcfe818798b53f73f [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;
33import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010034import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010035import from MGCP_Emulation all;
Harald Welte28d943e2017-11-25 15:00:50 +010036
Harald Welte96c94412017-12-09 03:12:45 +010037import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010038import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010039import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010040
Harald Weltebc03c762018-02-12 18:09:38 +010041import from Osmocom_VTY_Functions all;
42import from TELNETasp_PortType all;
43
Harald Welte6f521d82017-12-11 19:52:02 +010044import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010045import from MobileL3_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010046import from L3_Templates all;
47import from GSM_RR_Types all;
48
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010049import from BSSMAP_Templates all;
50
Harald Welte5d1a2202017-12-13 19:51:29 +010051const integer NUM_BTS := 3;
Harald Welteae026692017-12-09 01:03:01 +010052const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010053
Harald Welte799c97b2017-12-14 17:50:30 +010054/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020055const integer NUM_TCHH_PER_BTS := 2;
56const integer NUM_TCHF_PER_BTS := 4;
Harald Weltedd8cbf32018-01-28 12:07:52 +010057const integer NUM_SDCCH_PER_BTS := 4;
Harald Welte799c97b2017-12-14 17:50:30 +010058
Harald Welte4003d112017-12-09 22:35:39 +010059
Harald Welte21b46bd2017-12-17 19:46:32 +010060/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010061type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010062 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010063 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010064}
65
Harald Weltea4ca4462018-02-09 00:17:14 +010066type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +010067 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +010068 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +010069 /* RSL common Channel Port (for RSL_Emulation) */
70 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +010071 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +010072 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +010073 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Harald Weltea5d2ab22017-12-09 14:21:42 +010074
Daniel Willmann191e0d92018-01-17 12:44:35 +010075 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +010076 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +010077
Harald Weltea4ca4462018-02-09 00:17:14 +010078 var BSSAP_Adapter g_bssap;
79 /* for old legacy-tests only */
80 port BSSAP_CODEC_PT BSSAP;
81
Harald Welte21b46bd2017-12-17 19:46:32 +010082 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +010083 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +010084
85 /* global test case guard timer */
Harald Welteae026692017-12-09 01:03:01 +010086 timer T_guard := 30.0;
87
Harald Welte28d943e2017-11-25 15:00:50 +010088}
89
90modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +010091 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +010092 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +010093 /* port number to which to establish the IPA OML connections */
94 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +010095 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +010096 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +010097 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +010098 integer mp_bsc_ctrl_port := 4249;
Daniel Willmann191e0d92018-01-17 12:44:35 +010099 /* IP address at which the test binds */
100 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100101
102 BSSAP_Configuration mp_bssap_cfg := {
Harald Welte7ef51aa2018-04-16 19:16:01 +0200103 transport := BSSAP_TRANSPORT_AoIP,
Harald Weltea4ca4462018-02-09 00:17:14 +0100104 sccp_service_type := "mtp3_itu",
105 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
106 own_pc := 185,
107 own_ssn := 254,
108 peer_pc := 187,
109 peer_ssn := 254,
Philipp Maier38d68942018-03-29 15:38:09 +0200110 sio := '83'O,
111 rctx := 0
Harald Weltea4ca4462018-02-09 00:17:14 +0100112 };
113}
114
Philipp Maier282ca4b2018-02-27 17:17:00 +0100115private function f_shutdown_helper() runs on test_CT {
Harald Welte12055472018-03-17 20:10:08 +0100116 for (var integer i := 0; i < NUM_BTS; i := i+1) {
117 if (isbound(bts[i]) and isbound(bts[i].rsl)) {
118 f_ipa_rsl_stop(bts[i].rsl);
119 }
120 }
121 f_ipa_ctrl_stop();
Philipp Maier282ca4b2018-02-27 17:17:00 +0100122 all port.stop;
123 setverdict(pass);
124}
125
Harald Weltea4ca4462018-02-09 00:17:14 +0100126private function f_legacy_bssap_reset() runs on test_CT {
127 var BSSAP_N_UNITDATA_ind ud_ind;
128 timer T := 5.0;
129 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0)));
130 T.start;
131 alt {
132 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck)) {
133 log("Received RESET-ACK in response to RESET, we're ready to go!");
134 }
135 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind {
136 log("Respoding to inbound RESET with RESET-ACK");
137 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
138 ts_BSSMAP_ResetAck));
139 repeat;
140 }
141 [] BSSAP.receive { repeat; }
142 [] T.timeout { setverdict(fail, "Waiting for RESET-ACK after sending RESET"); }
143 }
Harald Welte28d943e2017-11-25 15:00:50 +0100144}
145
Harald Welteae026692017-12-09 01:03:01 +0100146type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100147 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100148 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100149 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100150 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100151 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100152 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100153 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100154 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100155}
156
Harald Welte21b46bd2017-12-17 19:46:32 +0100157/*! Start the IPA/RSL related bits for one IPA_Client.
158 * \param clnt IPA_Client for which to establish
159 * \param bsc_host IP address / hostname of the BSC
160 * \param bsc_port TCP port number of the BSC
161 * \param i number identifying this BTS
162 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100163function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
164 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100165runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100166 timer T := 10.0;
167
Harald Welte96c94412017-12-09 03:12:45 +0100168 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100169 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
170 clnt.ccm_pars := c_IPA_default_ccm_pars;
171 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
172 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100173 if (handler_mode) {
174 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100175 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100176 }
Harald Welteae026692017-12-09 01:03:01 +0100177
178 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100179 if (handler_mode) {
180 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
181 } else {
182 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
183 }
Harald Welteae026692017-12-09 01:03:01 +0100184
Harald Welte5d1a2202017-12-13 19:51:29 +0100185 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100186 if (handler_mode) {
187 clnt.vc_RSL.start(RSL_Emulation.main());
188 return;
189 }
Harald Welteae026692017-12-09 01:03:01 +0100190
191 /* wait for IPA RSL link to connect and send ID ACK */
192 T.start;
193 alt {
194 [] IPA_RSL[i].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_ID_ACK}) {
195 T.stop;
196 IPA_RSL[i].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23)));
197 }
Harald Welte60e823a2017-12-10 14:10:59 +0100198 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100199 [] IPA_RSL[i].receive { repeat }
200 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100201 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Harald Welteae026692017-12-09 01:03:01 +0100202 self.stop;
203 }
204 }
205}
206
Harald Welte12055472018-03-17 20:10:08 +0100207function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
208 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
209 return;
210 }
211 clnt.vc_IPA.stop;
212 if (isbound(clnt.vc_RSL)) {
213 clnt.vc_RSL.stop;
214 }
215}
216
Harald Welte21b46bd2017-12-17 19:46:32 +0100217/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100218function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
219 timer T := secs_max;
220 T.start;
221 while (true) {
222 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
223 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100224 /* the 'degraded' state exists from OML connection time, and we have to wait
225 * until all MO's are initialized */
226 T.start(1.0);
227 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100228 return;
229 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100230 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100231 if (not T.running) {
232 setverdict(fail, "Timeout waiting for oml-connection-state ", status);
233 self.stop;
234 }
235 }
236}
237
Harald Welte21b46bd2017-12-17 19:46:32 +0100238/* sleep for given number of (fractional) seconds */
Harald Welteae026692017-12-09 01:03:01 +0100239function f_sleep(float seconds) {
240 timer T := seconds;
241 T.start;
242 T.timeout;
243}
244
Harald Welte21b46bd2017-12-17 19:46:32 +0100245/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100246altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100247 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100248 [] T_guard.timeout {
249 setverdict(fail, "Timeout of T_guard");
250 self.stop;
251 }
Harald Welte60e823a2017-12-10 14:10:59 +0100252 /* always respond with RESET ACK to RESET */
253 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind {
254 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
255 ts_BSSMAP_ResetAck));
Harald Welte69c1c262017-12-13 21:02:08 +0100256 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100257 }
Harald Welte28d943e2017-11-25 15:00:50 +0100258}
259
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100260altstep no_bssmap_reset() runs on test_CT {
261 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) {
262 setverdict(fail, "unexpected BSSMAP Reset");
263 self.stop;
264 }
265}
266
Daniel Willmann191e0d92018-01-17 12:44:35 +0100267function f_init_mgcp(charstring id) runs on test_CT {
268 id := id & "-MGCP";
269
270 var MGCPOps ops := {
271 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
272 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
273 };
274 var MGCP_conn_parameters mgcp_pars := {
275 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100276 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100277 mgw_ip := mp_test_ip,
278 mgw_udp_port := 2427
279 };
280
281 vc_MGCP := MGCP_Emulation_CT.create(id);
282 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
283}
284
Harald Welte94e0c342018-04-07 11:33:23 +0200285private function f_init_vty(charstring id := "foo") runs on test_CT {
286 if (BSCVTY.checkstate("Mapped")) {
287 /* skip initialization if already executed once */
288 return;
289 }
Harald Weltebc03c762018-02-12 18:09:38 +0100290 map(self:BSCVTY, system:BSCVTY);
291 f_vty_set_prompts(BSCVTY);
292 f_vty_transceive(BSCVTY, "enable");
293}
294
Harald Welte21b46bd2017-12-17 19:46:32 +0100295/* global initialization function
296 * \param nr_bts Number of BTSs we should start/bring up
297 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte89d42e82017-12-17 16:42:41 +0100298function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false) runs on test_CT {
Harald Welte28d943e2017-11-25 15:00:50 +0100299 var integer i;
Harald Welte28d943e2017-11-25 15:00:50 +0100300
Harald Welteae026692017-12-09 01:03:01 +0100301 if (g_initialized) {
302 return;
Harald Welte28d943e2017-11-25 15:00:50 +0100303 }
Harald Welteae026692017-12-09 01:03:01 +0100304 g_initialized := true;
305
306 /* Call a function of our 'parent component' BSSAP_Adapter_CT to start the
307 * MSC-side BSSAP emulation */
Harald Welte67089ee2018-01-17 22:19:03 +0100308 if (handler_mode) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100309 f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", MSC_BssmapOps);
Harald Welte67089ee2018-01-17 22:19:03 +0100310 } else {
Harald Weltea4ca4462018-02-09 00:17:14 +0100311 f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", omit);
312 connect(self:BSSAP, g_bssap.vc_SCCP:SCCP_SP_PORT);
313 f_legacy_bssap_reset();
Harald Welte67089ee2018-01-17 22:19:03 +0100314 }
Harald Welted5833a82018-05-27 16:52:56 +0200315 f_bssap_start(g_bssap);
316
Harald Welteffe55fc2018-01-17 22:39:54 +0100317 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +0100318
Daniel Willmann191e0d92018-01-17 12:44:35 +0100319 f_init_mgcp("VirtMSC");
Harald Weltebc03c762018-02-12 18:09:38 +0100320 f_init_vty("VirtMSC");
Daniel Willmann191e0d92018-01-17 12:44:35 +0100321
Harald Welte89d42e82017-12-17 16:42:41 +0100322 for (i := 0; i < nr_bts; i := i+1) {
Harald Weltea5d2ab22017-12-09 14:21:42 +0100323 /* wait until osmo-bts-omldummy has respawned */
324 f_wait_oml(i, "degraded", 5.0);
325 /* start RSL connection */
Harald Welte624f9632017-12-16 19:26:04 +0100326 f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i, handler_mode);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100327 /* wait until BSC tells us "connected" */
328 f_wait_oml(i, "connected", 5.0);
Harald Welte696ddb62017-12-08 14:01:43 +0100329 }
330
Harald Welteae026692017-12-09 01:03:01 +0100331 T_guard.start;
332 activate(as_Tguard());
Harald Welte28d943e2017-11-25 15:00:50 +0100333}
334
Harald Welte21b46bd2017-12-17 19:46:32 +0100335/* expect to receive a RSL message matching a specified templaten on a given BTS / stream */
Harald Welteae026692017-12-09 01:03:01 +0100336function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
337runs on test_CT return RSL_Message {
338 var ASP_RSL_Unitdata rx_rsl_ud;
339 timer T := t_secs;
340
341 T.start;
342 alt {
343 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud {
344 T.stop;
345 }
346 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +0100347 [] T.timeout {
348 setverdict(fail, "Timeout expecting ", t_rx);
349 self.stop;
350 }
Harald Welteae026692017-12-09 01:03:01 +0100351 }
352 return rx_rsl_ud.rsl;
353}
354
Harald Welte21b46bd2017-12-17 19:46:32 +0100355/* helper function to transmit RSL on a given BTS/stream */
Harald Welteae026692017-12-09 01:03:01 +0100356function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
357runs on test_CT {
358 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx));
359}
360
361
Harald Welte4003d112017-12-09 22:35:39 +0100362/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +0100363testcase TC_chan_act_noreply() runs on test_CT {
364 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +0100365 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +0100366
Harald Welte89d42e82017-12-17 16:42:41 +0100367 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +0100368
Harald Welteae026692017-12-09 01:03:01 +0100369 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 +0100370 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welteae026692017-12-09 01:03:01 +0100371 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +0100372}
373
Harald Welte4003d112017-12-09 22:35:39 +0100374/* verify if the "chreq:total" counter increments as expected */
375testcase TC_chan_act_counter() runs on test_CT {
376 var BSSAP_N_UNITDATA_ind ud_ind;
377 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +0100378 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +0100379
Harald Welte89d42e82017-12-17 16:42:41 +0100380 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100381
382 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
383 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 +0100384 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +0100385 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
386
387 setverdict(pass);
388}
389
Harald Welteae026692017-12-09 01:03:01 +0100390/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
391testcase TC_chan_act_ack_noest() runs on test_CT {
392 var RSL_Message rx_rsl;
393
Harald Welte89d42e82017-12-17 16:42:41 +0100394 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100395
396 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100397 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100398
399 /* expect BSC to disable the channel again if there's no RLL EST IND */
400 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
401
402 setverdict(pass);
403}
404
405/* Test behavior if MSC never answers to CR */
406testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +0100407 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
408 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +0100409 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +0100410 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +0100411
Harald Welte89d42e82017-12-17 16:42:41 +0100412 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100413
414 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100415 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100416
417 var octetstring l3 := '00010203040506'O
418 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
419
420 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
421
422 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +0100423 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
424 IPA_RSL[0].clear;
425 alt {
426 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) -> value rx_rsl_ud { }
427 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_REL_REQ(chan_nr, ?))) -> value rx_rsl_ud {
428 f_ipa_tx(0, ts_RSL_REL_CONF(chan_nr, main_dcch));
429 repeat;
430 }
431 }
Harald Welteae026692017-12-09 01:03:01 +0100432
433 setverdict(pass);
434}
435
436/* Test behavior if MSC answers with CREF to CR */
437testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
438 var BSSAP_N_CONNECT_ind rx_c_ind;
439 var RSL_Message rx_rsl;
440
Harald Welte89d42e82017-12-17 16:42:41 +0100441 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100442
443 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100444 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100445
446 var octetstring l3 := '00010203040506'O
447 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
448
449 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
450 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
451
452 /* expect BSC to disable the channel */
Harald Welte725844b2018-01-28 16:18:32 +0100453 f_expect_chan_rel(0, chan_nr);
Harald Welteae026692017-12-09 01:03:01 +0100454 setverdict(pass);
455}
456
Harald Welte618ef642017-12-14 14:58:20 +0100457/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
458testcase TC_chan_act_nack() runs on test_CT {
459 var RSL_Message rx_rsl;
460 var integer chact_nack;
461
Harald Welte89d42e82017-12-17 16:42:41 +0100462 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +0100463
464 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
465
466 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
467 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
468 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
469
470 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
471
472 /* wait for some time to hope the NACK arrives before the CTRL GET below */
473 f_sleep(0.5);
474
475 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
476
477 setverdict(pass);
478}
479
Harald Welte799c97b2017-12-14 17:50:30 +0100480/* Test for channel exhaustion due to RACH overload */
481testcase TC_chan_exhaustion() runs on test_CT {
482 var ASP_RSL_Unitdata rsl_ud;
483 var integer i;
484 var integer chreq_total, chreq_nochan;
485
Harald Welte89d42e82017-12-17 16:42:41 +0100486 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +0100487
488 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
489 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
490
491 /* expect 5xTCH/F to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +0200492 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
Harald Welte930d0a72018-03-22 22:08:40 +0100493 var RslChannelNr chan_nr := f_chreq_act_ack('23'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +0100494 }
495
496 IPA_RSL[0].clear;
497
Harald Weltedd8cbf32018-01-28 12:07:52 +0100498 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200499 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +0100500
501 /* now expect additional channel activations to fail */
502 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
503
504 alt {
505 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
506 tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
507 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
508 }
509 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
510 var GsmRrMessage rr;
511 /* match on IMM ASS REJ */
512 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
513 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
514 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200515 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +0100516 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
517 chreq_nochan+1);
518 setverdict(pass);
519 } else {
520 repeat;
521 }
522 }
523 [] IPA_RSL[0].receive { repeat; }
524 }
525}
526
Harald Weltecfe2c962017-12-15 12:09:32 +0100527/***********************************************************************
528 * Assignment Testing
529 ***********************************************************************/
530
531/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction) */
532testcase TC_outbound_connect() runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +0100533 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +0100534
Harald Weltea4ca4462018-02-09 00:17:14 +0100535 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 +0100536 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
537 setverdict(pass);
538}
539
Harald Welte16a4adf2017-12-14 18:54:01 +0100540/* Test behavior if MSC answers with CREF to CR */
541testcase TC_assignment_cic_only() runs on test_CT {
542 var BSSAP_N_CONNECT_ind rx_c_ind;
543 var RSL_Message rx_rsl;
544 var DchanTuple dt;
545
Harald Welte89d42e82017-12-17 16:42:41 +0100546 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +0100547
548 dt := f_est_dchan('23'O, 23, '00000000'O);
Harald Welte17b27da2018-05-25 20:33:53 +0200549 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
550 /* send assignment without AoIP IEs */
551 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
552 } else {
553 /* Send assignmetn without CIC in IPA case */
554 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
555 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
556 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
557 }
Harald Welte16a4adf2017-12-14 18:54:01 +0100558 alt {
559 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
560 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
561 }
Harald Welte235ebf12017-12-15 14:18:16 +0100562 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +0100563 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
564 setverdict(pass);
565 }
566 [] BSSAP.receive { repeat; }
567 }
568}
569
Harald Welteed848512018-05-24 22:27:58 +0200570/* generate an assignment request for either AoIP or SCCPlite */
571private function f_gen_ass_req() return PDU_BSSAP {
572 var PDU_BSSAP ass_cmd;
573 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
574 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
575 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
576 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
577 } else {
578 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
579 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
580 }
581 return ass_cmd;
582}
583
584/* generate an assignment complete template for either AoIP or SCCPlite */
585private function f_gen_exp_compl() return template PDU_BSSAP {
586 var template PDU_BSSAP exp_compl;
587 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
588 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
589 } else {
590 /* CIC is optional "*" as the MSC allocated it */
591 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
592 }
593 return exp_compl;
594}
595
Harald Welte235ebf12017-12-15 14:18:16 +0100596/* Run everything required up to sending a caller-specified assignment command and expect response */
597function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
598runs on test_CT {
599 var BSSAP_N_CONNECT_ind rx_c_ind;
600 var RSL_Message rx_rsl;
601 var DchanTuple dt;
602
Harald Welte89d42e82017-12-17 16:42:41 +0100603 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +0100604
605 dt := f_est_dchan('23'O, 23, '00000000'O);
606 /* send assignment without AoIP IEs */
607 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
608 alt {
609 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
610 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
611 setverdict(pass);
612 } else {
613 setverdict(fail, fail_text);
614 }
615 }
616 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
617 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
618 setverdict(pass);
619 } else {
620 setverdict(fail, fail_text);
621 }
622 }
623 [] BSSAP.receive { repeat; }
624 }
625}
626testcase TC_assignment_csd() runs on test_CT {
627 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200628 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100629 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
630 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
631 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
632}
633
634testcase TC_assignment_ctm() runs on test_CT {
635 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200636 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100637 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
638 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
639 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
640}
641
Harald Welte4003d112017-12-09 22:35:39 +0100642type record DchanTuple {
643 integer sccp_conn_id,
644 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +0100645}
646
Harald Welted6939652017-12-13 21:02:46 +0100647/* Send CHAN RQD and wait for allocation; acknowledge it */
648private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
649runs on test_CT return RslChannelNr {
650 var RSL_Message rx_rsl;
651 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
652 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
653 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
654 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
655 return chan_nr;
656}
657
Harald Welte4003d112017-12-09 22:35:39 +0100658/* helper function to establish a dedicated channel via BTS and MSC */
659function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
660runs on test_CT return DchanTuple {
661 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +0100662 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100663
Harald Welte4003d112017-12-09 22:35:39 +0100664 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100665 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +0100666
667 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
668
669 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
670 dt.sccp_conn_id := rx_c_ind.connectionId;
671 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
672
673 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100674}
675
Harald Welte4003d112017-12-09 22:35:39 +0100676/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
677testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
678 var RSL_Message rx_rsl;
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100679 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100680 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +0100681
Harald Welte89d42e82017-12-17 16:42:41 +0100682 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +0100683
Harald Welte4003d112017-12-09 22:35:39 +0100684 dt := f_est_dchan('23'O, 23, '00010203040506'O);
685
686 /* simulate RLL REL IND */
687 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
688
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100689 /* expect Clear Request on MSC side */
690 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
691
692 /* Instruct BSC to clear channel */
693 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
694 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
695
Harald Welte4003d112017-12-09 22:35:39 +0100696 /* expect BSC to disable the channel */
697 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
698 /* respond with CHAN REL ACK */
699 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
700
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100701 /* expect Clear Complete from BSC */
702 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
703
704 /* release the SCCP connection */
705 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
706
707 /* wait for SCCP emulation to do its job */
708 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +0100709
710 setverdict(pass);
711}
712
713/* Test behavior of channel release after CONN FAIL IND from BTS */
714testcase TC_chan_rel_conn_fail() runs on test_CT {
715 var BSSAP_N_DATA_ind rx_di;
716 var RSL_Message rx_rsl;
717 var DchanTuple dt;
718
Harald Welte89d42e82017-12-17 16:42:41 +0100719 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100720
721 dt := f_est_dchan('23'O, 23, '00010203040506'O);
722
723 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +0100724 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 +0100725 /* TODO: different cause values? */
726
Harald Welte4003d112017-12-09 22:35:39 +0100727 /* expect Clear Request from BSC */
728 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
729
730 /* Instruct BSC to clear channel */
731 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
732 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
733
Harald Welte6ff76ea2018-01-28 13:08:01 +0100734 /* expect BSC to disable the channel */
735 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
736 /* respond with CHAN REL ACK */
737 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
738
Harald Welte4003d112017-12-09 22:35:39 +0100739 /* expect Clear Complete from BSC */
740 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
741
742 /* release the SCCP connection */
743 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
744
745 /* wait for SCCP emulation to do its job */
746 f_sleep(1.0);
747
748 setverdict(pass);
749}
750
Harald Welte91d54a52018-01-28 15:35:07 +0100751function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr, boolean flush := true,
752 boolean handle_rll_rel := true) runs on test_CT {
753
754 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
755 if (flush) {
756 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
757 IPA_RSL[bts_nr].clear;
758 }
759 alt {
760 /* ignore DEACTIVATE SACCH (if any) */
761 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
762 tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
763 repeat;
764 }
765 /* acknowledge RLL release (if any)*/
766 [handle_rll_rel] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
767 tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
768 /* FIXME: Why are we getting this for LinkID SACCH? */
769 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
770 repeat;
771 }
772 /* Expect RF channel release from BSC on Abis */
773 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
774 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
775 /* respond with CHAN REL ACK */
776 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
777 }
778 /* ignore any user data */
779 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) {
780 repeat;
781 }
782 }
783}
784
Harald Welte4003d112017-12-09 22:35:39 +0100785/* Test behavior of channel release after hard Clear Command from MSC */
786testcase TC_chan_rel_hard_clear() runs on test_CT {
787 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100788 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +0100789
Harald Welte89d42e82017-12-17 16:42:41 +0100790 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100791
792 dt := f_est_dchan('23'O, 23, '00010203040506'O);
793
794 /* Instruct BSC to clear channel */
795 var BssmapCause cause := 0;
796 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
797
798 /* expect Clear Complete from BSC on A */
799 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
800 /* release the SCCP connection */
801 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
802 }
803
Harald Welte91d54a52018-01-28 15:35:07 +0100804 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welte4003d112017-12-09 22:35:39 +0100805 setverdict(pass);
806}
807
Harald Welted8c36cd2017-12-09 23:05:31 +0100808/* Test behavior of channel release after hard RLSD from MSC */
809testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +0100810 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +0100811
Harald Welte89d42e82017-12-17 16:42:41 +0100812 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +0100813
814 dt := f_est_dchan('23'O, 23, '00010203040506'O);
815
816 /* release the SCCP connection */
817 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
818
Harald Welte91d54a52018-01-28 15:35:07 +0100819 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welted8c36cd2017-12-09 23:05:31 +0100820 setverdict(pass);
821}
822
Harald Welte85804d42017-12-10 14:11:58 +0100823/* Test behavior of channel release after BSSMAP RESET from MSC */
824testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +0100825 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +0100826
Harald Welte89d42e82017-12-17 16:42:41 +0100827 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +0100828
829 dt := f_est_dchan('23'O, 23, '00010203040506'O);
830
831 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
832 IPA_RSL[0].clear;
833
834 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Harald Weltea4ca4462018-02-09 00:17:14 +0100835 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 +0100836 interleave {
Harald Weltea4ca4462018-02-09 00:17:14 +0100837 [] 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 +0100838 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
839 }
840
Philipp Maiere8f38ed2018-02-09 10:30:31 +0100841 f_expect_chan_rel(0, dt.rsl_chan_nr, false);
Harald Welte85804d42017-12-10 14:11:58 +0100842 setverdict(pass);
843}
844
Harald Welte5cd20ed2017-12-13 21:03:20 +0100845/* Test behavior if RSL EST IND for non-active channel */
846testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
847 timer T := 2.0;
848
Harald Welte89d42e82017-12-17 16:42:41 +0100849 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100850
851 var octetstring l3 := '00010203040506'O;
852 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
853 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
854
855 T.start;
856 alt {
857 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
858 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
859 }
860 [] BSSAP.receive {}
861 [] IPA_RSL[0].receive {}
862 [] T.timeout {}
863 }
864
865 setverdict(pass);
866}
867
868/* Test behavior if RSL EST IND for invalid SAPI */
869testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
870 var RslChannelNr chan_nr;
871
Harald Welte89d42e82017-12-17 16:42:41 +0100872 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100873
874 chan_nr := f_chreq_act_ack()
875
876 var octetstring l3 := '00010203040506'O;
877 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
878
879 timer T := 2.0;
880 T.start;
881 alt {
882 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
883 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
884 }
885 [] BSSAP.receive { repeat; }
886 [] IPA_RSL[0].receive { repeat; }
887 [] T.timeout {}
888 }
889
890 setverdict(pass);
891}
892
893/* Test behavior if RSL EST IND for invalid SAPI */
894testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
895 timer T := 2.0;
896
Harald Welte89d42e82017-12-17 16:42:41 +0100897 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100898
899 var RslChannelNr chan_nr := f_chreq_act_ack();
900
901 var octetstring l3 := '00010203040506'O;
902 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
903
904 T.start;
905 alt {
906 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
907 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
908 }
909 [] BSSAP.receive { repeat; }
910 [] IPA_RSL[0].receive { repeat; }
911 [] T.timeout {}
912 }
913
914 setverdict(pass);
915}
916
917/* Test behavior if RSL EST IND for invalid SACCH */
918testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
919 timer T := 2.0;
920
Harald Welte89d42e82017-12-17 16:42:41 +0100921 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100922
923 var RslChannelNr chan_nr := f_chreq_act_ack();
924
925 var octetstring l3 := '00010203040506'O;
926 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
927
928 T.start;
929 alt {
930 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
931 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
932 }
933 [] BSSAP.receive { repeat; }
934 [] IPA_RSL[0].receive { repeat; }
935 [] T.timeout {}
936 }
937
938 setverdict(pass);
939}
940
941
942
Harald Welte4003d112017-12-09 22:35:39 +0100943
944testcase TC_ctrl_msc_connection_status() runs on test_CT {
945 var charstring ctrl_resp;
946
Harald Welte89d42e82017-12-17 16:42:41 +0100947 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100948
949 /* See https://osmocom.org/issues/2729 */
950 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
951 setverdict(pass);
952}
953
Stefan Sperlingb041b3d2018-01-03 17:14:55 +0100954testcase TC_ctrl_msc0_connection_status() runs on test_CT {
955 var charstring ctrl_resp;
956
957 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +0100958
959 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
960 setverdict(pass);
961}
962
Harald Welte4003d112017-12-09 22:35:39 +0100963testcase TC_ctrl() runs on test_CT {
964 var charstring ctrl_resp;
965
Harald Welte89d42e82017-12-17 16:42:41 +0100966 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100967
968 /* all below values must match the osmo-bsc.cfg config file used */
969
Harald Welte6a129692018-03-17 17:30:14 +0100970 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
971 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Harald Welte44bdaa52017-12-17 17:01:47 +0100972 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "3");
Harald Welte4003d112017-12-09 22:35:39 +0100973
974 var integer bts_nr := 0;
975 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
976 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
977 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
978 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
979 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
980 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
981 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
982
983 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
984 f_sleep(2.0);
985 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
986 setverdict(fail, "oml-uptime not incrementing as expected");
987 }
988 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
989
990 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
991
992 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +0100993}
994
Harald Welte6f521d82017-12-11 19:52:02 +0100995function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100996 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, bssap));
Harald Welte6f521d82017-12-11 19:52:02 +0100997}
998
999
1000/***********************************************************************
1001 * Paging Testing
1002 ***********************************************************************/
1003
1004type record Cell_Identity {
1005 GsmMcc mcc,
1006 GsmMnc mnc,
1007 GsmLac lac,
1008 GsmCellId ci
1009};
Harald Welte24135bd2018-03-17 19:27:53 +01001010private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001011private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001012
Harald Welte5d1a2202017-12-13 19:51:29 +01001013type set of integer BtsIdList;
1014
1015private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1016 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1017 if (bts_id == bts_ids[j]) {
1018 return true;
1019 }
1020 }
1021 return false;
1022}
Harald Welte6f521d82017-12-11 19:52:02 +01001023
1024/* core paging test helper function; used by most paging test cases */
1025private function f_pageing_helper(hexstring imsi,
1026 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001027 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001028 template RSL_ChanNeeded rsl_chneed := omit,
1029 template OCT4 tmsi := omit) runs on test_CT
1030{
1031 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
1032 var MobileIdentity mi;
1033 var template octetstring id_enc; /* FIXME */
1034 var RSL_Message rx_rsl;
1035 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001036 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001037
1038 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001039
1040 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001041 for (i := 0; i < NUM_BTS; i := i + 1) {
1042 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001043 }
Harald Welte6f521d82017-12-11 19:52:02 +01001044
1045 if (isvalue(rsl_chneed)) {
1046 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1047 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1048 } else {
1049 bssmap_chneed := omit;
1050 }
1051
1052 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
1053
1054/* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder
1055 if (isvalue(tmsi)) {
1056 mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi))));
1057 } else {
1058 mi := valueof(ts_Osmo_MI_IMSI(imsi));
1059 }
1060 id_enc := enc_MobileIdentity(mi);
1061*/
1062 id_enc := ?;
Harald Welte5d1a2202017-12-13 19:51:29 +01001063 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
1064 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc));
1065 /* check channel type, paging group */
1066 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1067 setverdict(fail, "Paging for wrong paging group");
1068 }
1069 if (ispresent(rsl_chneed) and
1070 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1071 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1072 }
Harald Welte6f521d82017-12-11 19:52:02 +01001073 }
Harald Welte2fccd982018-01-31 15:48:19 +01001074 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001075 /* do a quick check on all not-included BTSs if they received paging */
1076 for (i := 0; i < NUM_BTS; i := i + 1) {
1077 timer T := 0.1;
1078 if (f_bts_in_list(i, bts_ids)) {
1079 continue;
1080 }
1081 T.start;
1082 alt {
1083 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) {
1084 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1085 }
1086 [] IPA_RSL[i].receive { repeat; }
1087 [] T.timeout { }
1088 }
Harald Welte6f521d82017-12-11 19:52:02 +01001089 }
1090
1091 setverdict(pass);
1092}
1093
Harald Welte5d1a2202017-12-13 19:51:29 +01001094const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001095const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001096const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1097const BtsIdList c_BtsId_LAC2 := { 2 };
1098
Harald Welte6f521d82017-12-11 19:52:02 +01001099/* PAGING by IMSI + TMSI */
1100testcase TC_paging_imsi_nochan() runs on test_CT {
1101 var BSSMAP_FIELD_CellIdentificationList cid_list;
1102 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001103 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001104 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001105}
1106
1107/* PAGING by IMSI + TMSI */
1108testcase TC_paging_tmsi_nochan() runs on test_CT {
1109 var BSSMAP_FIELD_CellIdentificationList cid_list;
1110 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001111 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001112 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001113}
1114
1115/* Paging with different "channel needed' values */
1116testcase TC_paging_tmsi_any() runs on test_CT {
1117 var BSSMAP_FIELD_CellIdentificationList cid_list;
1118 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001119 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001120 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001121}
1122testcase TC_paging_tmsi_sdcch() runs on test_CT {
1123 var BSSMAP_FIELD_CellIdentificationList cid_list;
1124 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001125 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001126 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001127}
1128testcase TC_paging_tmsi_tch_f() runs on test_CT {
1129 var BSSMAP_FIELD_CellIdentificationList cid_list;
1130 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001131 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001132 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001133}
1134testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1135 var BSSMAP_FIELD_CellIdentificationList cid_list;
1136 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001137 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001138 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001139}
1140
1141/* Paging by CGI */
1142testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1143 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1144 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001145 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001146 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001147}
1148
1149/* Paging by LAC+CI */
1150testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1151 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1152 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001153 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001154 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001155}
1156
1157/* Paging by CI */
1158testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1159 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1160 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001161 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001162 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001163}
1164
1165/* Paging by LAI */
1166testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1167 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1168 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001169 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001170 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001171}
1172
1173/* Paging by LAC */
1174testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1175 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1176 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001177 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001178 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001179}
1180
1181/* Paging by "all in BSS" */
1182testcase TC_paging_imsi_nochan_all() runs on test_CT {
1183 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1184 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001185 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001186 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001187}
1188
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001189/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001190testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1191 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1192 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 +01001193 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001194 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001195}
Harald Welte6f521d82017-12-11 19:52:02 +01001196
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001197/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001198testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1199 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1200 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001201 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001202 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001203}
1204
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001205/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001206testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1207 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1208 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001209 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001210 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001211}
1212
Harald Welte6f521d82017-12-11 19:52:02 +01001213/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001214testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1215 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1216 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1217 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001218 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001219}
1220
1221/* Paging on empty list: Verify none of them page */
1222testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1223 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1224 cid_list := { cIl_LAC := { } };
1225 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001226 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001227}
1228
Stefan Sperling049a86e2018-03-20 15:51:00 +01001229/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1230testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1231 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1232 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1233 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1234 f_shutdown_helper();
1235}
1236
Harald Welte6f521d82017-12-11 19:52:02 +01001237/* Verify paging retransmission interval + count */
1238/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001239/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001240
Harald Weltee65d40e2017-12-13 00:09:06 +01001241/* Verify PCH load */
1242testcase TC_paging_imsi_load() runs on test_CT {
1243 var BSSMAP_FIELD_CellIdentificationList cid_list;
1244 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001245 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001246 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001247 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001248
1249 /* tell BSC there is no paging space anymore */
1250 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001251 f_sleep(0.2);
1252 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001253
1254 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1255 * there would be 8 retransmissions during 4 seconds */
1256 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001257 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001258 alt {
1259 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1260 setverdict(fail, "Received PAGING after LOAD_IND(0)");
1261 self.stop;
1262 }
Harald Welte2caa1062018-03-17 18:19:05 +01001263 [] T_retrans.timeout {
1264 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1265 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1266 T_retrans.start;
1267 repeat;
1268 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001269 [] T.timeout {
1270 setverdict(pass);
1271 }
1272 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001273
1274 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001275}
1276
Harald Welte235ebf12017-12-15 14:18:16 +01001277/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001278testcase TC_paging_counter() runs on test_CT {
1279 var BSSMAP_FIELD_CellIdentificationList cid_list;
1280 timer T := 4.0;
1281 var integer i;
1282 var integer paging_attempted_bsc;
1283 var integer paging_attempted_bts[NUM_BTS];
1284 var integer paging_expired_bts[NUM_BTS];
1285 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1286
1287 f_init();
1288
1289 /* read counters before paging */
1290 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1291 for (i := 0; i < NUM_BTS; i := i+1) {
1292 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1293 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1294 }
1295
1296 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1297
1298 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1299 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1300 for (i := 0; i < NUM_BTS; i := i+1) {
1301 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1302 paging_attempted_bts[i]+1);
1303 }
1304
1305 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1306 f_sleep(12.0);
1307 for (i := 0; i < NUM_BTS; i := i+1) {
1308 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1309 paging_expired_bts[i]+1);
1310 }
Harald Welte1ff69992017-12-14 12:31:17 +01001311
Philipp Maier282ca4b2018-02-27 17:17:00 +01001312 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001313}
1314
1315
Harald Welte10985002017-12-12 09:29:15 +01001316/* Verify paging stops after A-RESET */
1317testcase TC_paging_imsi_a_reset() runs on test_CT {
1318 var BSSMAP_FIELD_CellIdentificationList cid_list;
1319 timer T := 3.0;
1320 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001321 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001322
1323 /* Perform a BSSMAP Reset and wait for ACK */
Harald Weltea4ca4462018-02-09 00:17:14 +01001324 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 +01001325 alt {
Harald Weltea4ca4462018-02-09 00:17:14 +01001326 [] 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 +01001327 [] BSSAP.receive { repeat; }
1328 }
1329
1330 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001331 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1332 IPA_RSL[i].clear;
1333 }
Harald Welte10985002017-12-12 09:29:15 +01001334
1335 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1336 T.start;
1337 alt {
1338 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1339 setverdict(fail, "Received PAGING after A-RESET");
1340 self.stop;
1341 }
Harald Welte5d1a2202017-12-13 19:51:29 +01001342 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1343 setverdict(fail, "Received PAGING after A-RESET");
1344 self.stop;
1345 }
1346 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1347 setverdict(fail, "Received PAGING after A-RESET");
1348 self.stop;
1349 }
Harald Welte10985002017-12-12 09:29:15 +01001350 [] T.timeout {
1351 setverdict(pass);
1352 }
1353 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001354
1355 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001356}
Harald Welteae026692017-12-09 01:03:01 +01001357
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001358/* Test RSL link drop causes counter increment */
1359testcase TC_rsl_drop_counter() runs on test_CT {
1360 var integer rsl_fail;
1361
Harald Welte89d42e82017-12-17 16:42:41 +01001362 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001363
1364 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1365
1366 bts[0].rsl.vc_IPA.stop;
1367
1368 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1369
1370 setverdict(pass);
1371}
1372
1373/* TODO: Test OML link drop causes counter increment */
1374
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001375/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1376function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1377 timer T := 10.0;
1378
1379 bts[0].rsl.id := "IPA-0-RSL";
1380 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1381 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1382 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
1383 bts[0].rsl.ccm_pars.unit_id := "0/0/0"; /* value which is unknown at BTS */
1384
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001385 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1386
1387 f_init_mgcp("VirtMSC");
1388
1389 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1390 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1391 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1392 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1393
1394 /* wait for IPA OML link to connect and then disconnect */
1395 T.start;
1396 alt {
1397 [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) {
1398 T.stop;
1399 return true;
1400 }
1401 [] IPA_RSL[0].receive { repeat }
1402 [] T.timeout {
1403 self.stop;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001404 }
1405 }
1406
1407 return false;
1408}
1409
1410/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1411testcase TC_rsl_unknown_unit_id() runs on test_CT {
1412 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1413 setverdict(pass);
1414 } else {
1415 setverdict(fail, "Timeout RSL waiting for connection to close");
1416 }
1417}
1418
1419
1420/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1421testcase TC_oml_unknown_unit_id() runs on test_CT {
1422 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1423 setverdict(pass);
1424 } else {
1425 setverdict(fail, "Timeout OML waiting for connection to close");
1426 }
1427}
1428
1429
Harald Weltec1a2fff2017-12-17 11:06:19 +01001430/***********************************************************************
1431 * "New world" test cases using RSL_Emulation + BSSMAP_Emulation
1432 ***********************************************************************/
1433
1434import from BSSMAP_Emulation all;
1435import from RSL_Emulation all;
1436import from MSC_ConnectionHandler all;
1437
1438type function void_fn(charstring id) runs on MSC_ConnHdlr;
1439
1440/* helper function to create, connect and start a MSC_ConnHdlr component */
Harald Welte8863fa12018-05-10 20:15:27 +02001441function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
Harald Weltea0630032018-03-20 21:09:55 +01001442runs on test_CT return MSC_ConnHdlr {
Harald Welte8863fa12018-05-10 20:15:27 +02001443 var charstring id := testcasename();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001444 var MSC_ConnHdlr vc_conn;
1445
1446 vc_conn := MSC_ConnHdlr.create(id);
Harald Weltea4ca4462018-02-09 00:17:14 +01001447 connect(vc_conn:BSSMAPEM, g_bssap.vc_BSSMAP:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001448 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001449 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001450 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001451 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001452 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1453 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1454 }
Harald Weltea4ca4462018-02-09 00:17:14 +01001455 connect(vc_conn:BSSAP, g_bssap.vc_BSSMAP:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001456 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Harald Weltea0630032018-03-20 21:09:55 +01001457 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001458 return vc_conn;
1459}
1460
Harald Weltea0630032018-03-20 21:09:55 +01001461/* first function inside ConnHdlr component; sets g_pars + starts function */
1462private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1463runs on MSC_ConnHdlr {
1464 if (isvalue(pars)) {
1465 g_pars := valueof(pars);
1466 }
1467 fn.apply(id);
1468}
1469
Harald Welte3c86ea02018-05-10 22:28:05 +02001470/* Establish signalling channel (non-assignment case) followed by cipher mode */
1471private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001472 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1473 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001474 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
1475
1476 // Disable generation of ASSIGNMENT CMD, as OsmoBSC currently performs MODE MODFIY sign->sign (OS#2936)
1477 //f_establish_fully(ass_cmd, exp_compl);
1478 f_establish_fully(omit, exp_compl);
1479}
1480testcase TC_ciph_mode_a5_0() runs on test_CT {
1481 var MSC_ConnHdlr vc_conn;
1482 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1483 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1484
1485 f_init(1, true);
1486 f_sleep(1.0);
1487 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1488 vc_conn.done;
1489}
1490testcase TC_ciph_mode_a5_1() runs on test_CT {
1491 var MSC_ConnHdlr vc_conn;
1492 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1493 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1494
1495 f_init(1, true);
1496 f_sleep(1.0);
1497 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1498 vc_conn.done;
1499}
1500testcase TC_ciph_mode_a5_3() runs on test_CT {
1501 var MSC_ConnHdlr vc_conn;
1502 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1503 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1504
1505 f_init(1, true);
1506 f_sleep(1.0);
1507 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1508 vc_conn.done;
1509}
1510
1511
1512/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001513private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001514 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1515 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001516
Harald Welte552620d2017-12-16 23:21:36 +01001517 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1518 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001519
Harald Weltea0630032018-03-20 21:09:55 +01001520 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001521}
Harald Welte552620d2017-12-16 23:21:36 +01001522testcase TC_assignment_fr_a5_0() runs on test_CT {
1523 var MSC_ConnHdlr vc_conn;
Harald Welte651fcdc2018-05-10 20:23:16 +02001524 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1525 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001526
Harald Welte89d42e82017-12-17 16:42:41 +01001527 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001528 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001529 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001530 vc_conn.done;
1531}
Harald Welte552620d2017-12-16 23:21:36 +01001532testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001533 var MSC_ConnHdlr vc_conn;
Harald Welte651fcdc2018-05-10 20:23:16 +02001534 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1535 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001536
Harald Welte89d42e82017-12-17 16:42:41 +01001537 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001538 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001539 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1540 vc_conn.done;
1541}
1542testcase TC_assignment_fr_a5_3() runs on test_CT {
1543 var MSC_ConnHdlr vc_conn;
1544 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1545 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001546
Harald Welte651fcdc2018-05-10 20:23:16 +02001547 f_init(1, true);
1548 f_sleep(1.0);
1549 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001550 vc_conn.done;
1551}
1552
Harald Welte552620d2017-12-16 23:21:36 +01001553/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1554private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001555 g_pars := valueof(t_def_TestHdlrPars);
Harald Welte552620d2017-12-16 23:21:36 +01001556 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001557 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001558 const OCT8 kc := '0001020304050607'O;
1559
1560 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Harald Weltea0630032018-03-20 21:09:55 +01001561 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001562}
Harald Welte552620d2017-12-16 23:21:36 +01001563testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1564 var MSC_ConnHdlr vc_conn;
1565
Harald Welte89d42e82017-12-17 16:42:41 +01001566 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001567 f_sleep(1.0);
1568
Harald Welte8863fa12018-05-10 20:15:27 +02001569 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001570 vc_conn.done;
1571}
1572
Harald Welte552620d2017-12-16 23:21:36 +01001573private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001574 g_pars := valueof(t_def_TestHdlrPars);
Harald Welteed848512018-05-24 22:27:58 +02001575 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1576 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001577 const OCT8 kc := '0001020304050607'O;
1578 const OCT16 kc128 := kc & kc;
1579
1580 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1581 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001582 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001583 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001584 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001585}
Harald Welte552620d2017-12-16 23:21:36 +01001586testcase TC_assignment_fr_a5_4() runs on test_CT {
1587 var MSC_ConnHdlr vc_conn;
1588
Harald Welte89d42e82017-12-17 16:42:41 +01001589 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001590 f_sleep(1.0);
1591
Harald Welte8863fa12018-05-10 20:15:27 +02001592 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001593 vc_conn.done;
1594}
1595
1596
Harald Welte4532e0a2017-12-23 02:05:44 +01001597private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier6a50c7c2018-04-16 16:15:59 +02001598 g_pars := valueof(t_def_TestHdlrPars);
Harald Welte4532e0a2017-12-23 02:05:44 +01001599 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
1600 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, omit));
1601
1602 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001603 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001604}
1605
1606testcase TC_assignment_sign() runs on test_CT {
1607 var MSC_ConnHdlr vc_conn;
1608
1609 f_init(1, true);
1610 f_sleep(1.0);
1611
Harald Welte8863fa12018-05-10 20:15:27 +02001612 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001613 vc_conn.done;
1614}
1615
Harald Welte60aa5762018-03-21 19:33:13 +01001616/***********************************************************************
1617 * Codec (list) testing
1618 ***********************************************************************/
1619
1620/* check if the given rsl_mode is compatible with the a_elem */
1621private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1622return boolean {
1623 select (a_elem.codecType) {
1624 case (GSM_FR) {
1625 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1626 return true;
1627 }
1628 }
1629 case (GSM_HR) {
1630 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1631 return true;
1632 }
1633 }
1634 case (GSM_EFR) {
1635 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1636 return true;
1637 }
1638 }
1639 case (FR_AMR) {
1640 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1641 return true;
1642 }
1643 }
1644 case (HR_AMR) {
1645 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1646 return true;
1647 }
1648 }
1649 case else { }
1650 }
1651 return false;
1652}
1653
1654/* check if the given rsl_mode is compatible with the a_list */
1655private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
1656return boolean {
1657 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
1658 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
1659 return true;
1660 }
1661 }
1662 return false;
1663}
1664
1665/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
1666private function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
1667return BSSMAP_IE_ChannelType {
1668 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
1669 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
1670 select (a_elem.codecType) {
1671 case (GSM_FR) {
1672 ret.channelRateAndType := ChRate_TCHF;
1673 ret.speechId_DataIndicator := Spdi_TCHF_FR;
1674 }
1675 case (GSM_HR) {
1676 ret.channelRateAndType := ChRate_TCHH;
1677 ret.speechId_DataIndicator := Spdi_TCHH_HR;
1678 }
1679 case (GSM_EFR) {
1680 ret.channelRateAndType := ChRate_TCHF;
1681 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
1682 }
1683 case (FR_AMR) {
1684 ret.channelRateAndType := ChRate_TCHF;
1685 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
1686 }
1687 case (HR_AMR) {
1688 ret.channelRateAndType := ChRate_TCHH;
1689 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
1690 }
1691 case else {
1692 setverdict(fail, "Unsupported codec ", a_elem);
1693 self.stop;
1694 }
1695 }
1696 return ret;
1697}
1698
Harald Weltea63b9102018-03-22 20:36:16 +01001699private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
1700return template RSL_IE_Body {
1701 var template RSL_IE_Body mode_ie := {
1702 chan_mode := {
1703 len := ?,
1704 reserved := ?,
1705 dtx_d := ?,
1706 dtx_u := ?,
1707 spd_ind := RSL_SPDI_SPEECH,
1708 ch_rate_type := -,
1709 coding_alg_rate := -
1710 }
1711 }
1712
1713 select (a_elem.codecType) {
1714 case (GSM_FR) {
1715 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1716 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1717 }
1718 case (GSM_HR) {
1719 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1720 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1721 }
1722 case (GSM_EFR) {
1723 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1724 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
1725 }
1726 case (FR_AMR) {
1727 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1728 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1729 }
1730 case (HR_AMR) {
1731 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1732 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1733 }
1734 }
1735 return mode_ie;
1736}
1737
Harald Welte60aa5762018-03-21 19:33:13 +01001738type record CodecListTest {
1739 BSSMAP_IE_SpeechCodecList codec_list,
1740 charstring id
1741}
1742type record of CodecListTest CodecListTests
1743
1744private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001745 var PDU_BSSAP ass_cmd := f_gen_ass_req();
1746 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
Harald Welte60aa5762018-03-21 19:33:13 +01001747
1748 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Harald Welte79f3f542018-05-25 20:02:37 +02001749 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
1750 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
1751 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
1752 g_pars.ass_codec_list.codecElements[0];
1753 }
Harald Welte60aa5762018-03-21 19:33:13 +01001754 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
1755 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01001756 log("expecting ASS COMPL like this: ", exp_compl);
1757
1758 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01001759
1760 /* Verify that the RSL-side activation actually matches our expectations */
1761 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
1762
1763 var RSL_IE_Body mode_ie;
1764 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
1765 setverdict(fail, "Couldn't find CHAN_MODE IE");
1766 self.stop;
1767 }
1768 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
1769 if (not match(mode_ie, t_mode_ie)) {
1770 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
1771 }
Harald Welte60aa5762018-03-21 19:33:13 +01001772}
1773
1774testcase TC_assignment_codec_fr() runs on test_CT {
1775 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1776 var MSC_ConnHdlr vc_conn;
1777
1778 f_init(1, true);
1779 f_sleep(1.0);
1780
1781 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001782 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001783 vc_conn.done;
1784}
1785
1786testcase TC_assignment_codec_hr() runs on test_CT {
1787 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1788 var MSC_ConnHdlr vc_conn;
1789
1790 f_init(1, true);
1791 f_sleep(1.0);
1792
1793 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001794 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001795 vc_conn.done;
1796}
1797
1798testcase TC_assignment_codec_efr() runs on test_CT {
1799 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1800 var MSC_ConnHdlr vc_conn;
1801
1802 f_init(1, true);
1803 f_sleep(1.0);
1804
1805 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001806 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001807 vc_conn.done;
1808}
1809
1810testcase TC_assignment_codec_amr_f() runs on test_CT {
1811 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1812 var MSC_ConnHdlr vc_conn;
1813
1814 f_init(1, true);
1815 f_sleep(1.0);
1816
1817 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Harald Welte8863fa12018-05-10 20:15:27 +02001818 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001819 vc_conn.done;
1820}
1821
1822testcase TC_assignment_codec_amr_h() runs on test_CT {
1823 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1824 var MSC_ConnHdlr vc_conn;
1825
1826 f_init(1, true);
1827 f_sleep(1.0);
1828
1829 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Harald Welte8863fa12018-05-10 20:15:27 +02001830 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001831 vc_conn.done;
1832}
1833
1834
1835
Harald Welte898113b2018-01-31 18:32:21 +01001836/* test if L3 RR CLASSMARK CHANGE is translated to BSSMAP CLASSMARK UPDATE */
1837private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001838 g_pars := valueof(t_def_TestHdlrPars);
1839 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01001840 /* we should now have a COMPL_L3 at the MSC */
1841 BSSAP.receive(tr_BSSMAP_ComplL3);
1842
1843 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
1844 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
1845 setverdict(pass);
1846}
1847testcase TC_classmark() runs on test_CT {
1848 var MSC_ConnHdlr vc_conn;
1849 f_init(1, true);
1850 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001851 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01001852 vc_conn.done;
1853}
1854
Harald Weltee3bd6582018-01-31 22:51:25 +01001855private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001856 g_pars := valueof(t_def_TestHdlrPars);
1857 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01001858 /* we should now have a COMPL_L3 at the MSC */
1859 BSSAP.receive(tr_BSSMAP_ComplL3);
1860
Harald Weltee3bd6582018-01-31 22:51:25 +01001861 /* send the single message we want to send */
1862 f_rsl_send_l3(l3);
1863}
1864
1865private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
1866 timer T := sec;
1867 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01001868 T.start;
1869 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01001870 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
1871 setverdict(fail, "Unexpected BSSMAP ", bssap);
1872 self.stop;
Harald Welte898113b2018-01-31 18:32:21 +01001873 }
1874 [] T.timeout {
1875 setverdict(pass);
1876 }
1877 }
1878}
1879
Harald Weltee3bd6582018-01-31 22:51:25 +01001880/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
1881private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
1882 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
1883 f_bssap_expect_nothing();
1884}
Harald Welte898113b2018-01-31 18:32:21 +01001885testcase TC_unsol_ass_fail() runs on test_CT {
1886 var MSC_ConnHdlr vc_conn;
1887 f_init(1, true);
1888 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001889 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01001890 vc_conn.done;
1891}
Harald Welte552620d2017-12-16 23:21:36 +01001892
Harald Welteea99a002018-01-31 20:46:43 +01001893
1894/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
1895private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01001896 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
1897 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01001898}
1899testcase TC_unsol_ass_compl() runs on test_CT {
1900 var MSC_ConnHdlr vc_conn;
1901 f_init(1, true);
1902 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001903 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01001904 vc_conn.done;
1905}
1906
1907
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001908/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
1909private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01001910 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
1911 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001912}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001913testcase TC_unsol_ho_fail() runs on test_CT {
1914 var MSC_ConnHdlr vc_conn;
1915 f_init(1, true);
1916 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001917 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001918 vc_conn.done;
1919}
1920
1921
Harald Weltee3bd6582018-01-31 22:51:25 +01001922/* short message from MS should be ignored */
1923private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001924 g_pars := valueof(t_def_TestHdlrPars);
1925 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01001926 /* we should now have a COMPL_L3 at the MSC */
1927 BSSAP.receive(tr_BSSMAP_ComplL3);
1928
1929 /* send short message */
1930 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
1931 f_bssap_expect_nothing();
1932}
1933testcase TC_err_82_short_msg() runs on test_CT {
1934 var MSC_ConnHdlr vc_conn;
1935 f_init(1, true);
1936 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001937 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01001938 vc_conn.done;
1939}
1940
1941
Harald Weltee9e02e42018-01-31 23:36:25 +01001942/* 24.008 8.4 Unknown message must trigger RR STATUS */
1943private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
1944 f_est_single_l3(ts_RRM_UL_REL('00'O));
1945 timer T := 3.0
1946 alt {
1947 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
1948 setverdict(pass);
1949 }
1950 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01001951 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01001952 }
1953}
1954testcase TC_err_84_unknown_msg() runs on test_CT {
1955 var MSC_ConnHdlr vc_conn;
1956 f_init(1, true);
1957 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001958 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01001959 vc_conn.done;
1960}
1961
Harald Welte94e0c342018-04-07 11:33:23 +02001962/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
1963private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
1964runs on test_CT {
1965 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
1966 " timeslot "&int2str(ts_nr)&" ";
1967 f_vty_transceive(BSCVTY, cmd & suffix);
1968}
1969
Harald Welte261af4b2018-02-12 21:20:39 +01001970/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
1971private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
1972runs on MSC_ConnHdlr {
1973 /* FIXME: resolve those from component-global state */
1974 var integer ts_nr := chan_nr.tn;
1975 var integer ss_nr;
1976 if (ischosen(chan_nr.u.ch0)) {
1977 ss_nr := 0;
1978 } else if (ischosen(chan_nr.u.lm)) {
1979 ss_nr := chan_nr.u.lm.sub_chan;
1980 } else if (ischosen(chan_nr.u.sdcch4)) {
1981 ss_nr := chan_nr.u.sdcch4.sub_chan;
1982 } else if (ischosen(chan_nr.u.sdcch8)) {
1983 ss_nr := chan_nr.u.sdcch8.sub_chan;
1984 } else {
1985 setverdict(fail, "Invalid ChanNr ", chan_nr);
1986 self.stop;
1987 }
1988
1989 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
1990 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
1991 f_vty_transceive(BSCVTY, cmd & suffix);
1992}
1993
1994private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
1995 integer new_bts_nr)
1996runs on MSC_ConnHdlr {
1997 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
1998}
1999
2000/* intra-BSC hand-over between BTS0 and BTS1 */
2001private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01002002 g_pars := valueof(t_def_TestHdlrPars);
Harald Welteed848512018-05-24 22:27:58 +02002003 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2004 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01002005 const OCT8 kc := '0001020304050607'O;
2006
2007 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2008 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2009
Harald Weltea0630032018-03-20 21:09:55 +01002010 f_establish_fully(ass_cmd, exp_compl);
Harald Welte261af4b2018-02-12 21:20:39 +01002011
2012 var HandoverState hs := {
2013 rr_ho_cmpl_seen := false,
2014 handover_done := false,
2015 old_chan_nr := -
2016 };
2017 /* issue hand-over command on VTY */
2018 f_vty_handover(0, 0, g_chan_nr, 1);
2019 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2020 f_rslem_suspend(RSL1_PROC);
2021 alt {
2022 [] as_handover(hs);
2023 /* FIXME: somehow determine that the hand-over has completed, by MGCP MDCX? */
2024 }
2025}
2026
2027testcase TC_ho_int() runs on test_CT {
2028 var MSC_ConnHdlr vc_conn;
2029 f_init(2, true);
2030 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002031 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002032 vc_conn.done;
2033}
Harald Weltee9e02e42018-01-31 23:36:25 +01002034
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01002035/* OS#3041: Open and close N connections in a normal fashion, and expect no
2036 * BSSMAP Reset just because of that. */
2037testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
2038 var default d;
2039 var integer i;
2040 var DchanTuple dt;
2041
2042 f_init();
2043
2044 /* Wait for initial BSSMAP Reset to pass */
2045 f_sleep(4.0);
2046
2047 d := activate(no_bssmap_reset());
2048
2049 /* Setup up a number of connections and RLSD them again from the MSC
2050 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2051 * Let's do it some more times for good measure. */
2052 for (i := 0; i < 8; i := i+1) {
2053 /* Since we're doing a lot of runs, give each one a fresh
2054 * T_guard from the top. */
2055 T_guard.start;
2056
2057 /* Setup a BSSAP connection and clear it right away. This is
2058 * the MSC telling the BSC about a planned release, it's not an
2059 * erratic loss of a connection. */
2060 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2061
2062 /* MSC disconnects (RLSD). */
2063 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2064 }
2065
2066 /* In the buggy behavior, a timeout of 2 seconds happens between above
2067 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2068 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2069 f_sleep(4.0);
2070
2071 deactivate(d);
2072 f_shutdown_helper();
2073}
Harald Welte552620d2017-12-16 23:21:36 +01002074
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01002075/* OS#3041: Open and close N connections in a normal fashion, and expect no
2076 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
2077 * the MSC. */
2078testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
2079 var default d;
2080 var integer i;
2081 var DchanTuple dt;
2082 var BSSAP_N_DATA_ind rx_di;
2083 var RSL_Message rx_rsl;
2084 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
2085 var BssmapCause cause := enum2int(cause_val);
2086
2087 f_init();
2088
2089 /* Wait for initial BSSMAP Reset to pass */
2090 f_sleep(4.0);
2091
2092 d := activate(no_bssmap_reset());
2093
2094 /* Setup up a number of connections and RLSD them again from the MSC
2095 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2096 * Let's do it some more times for good measure. */
2097 for (i := 0; i < 8; i := i+1) {
2098 /* Since we're doing a lot of runs, give each one a fresh
2099 * T_guard from the top. */
2100 T_guard.start;
2101
2102 /* Setup a BSSAP connection and clear it right away. This is
2103 * the MSC telling the BSC about a planned release, it's not an
2104 * erratic loss of a connection. */
2105 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2106
2107 /* Instruct BSC to clear channel */
2108 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2109
2110 /* expect BSC to disable the channel */
2111 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
2112 /* respond with CHAN REL ACK */
2113 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
2114
2115 /* expect Clear Complete from BSC */
2116 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
2117
2118 /* MSC disconnects as instructed. */
2119 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2120
2121
2122 /* MSC disconnects (RLSD). */
2123 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2124 }
2125
2126 /* In the buggy behavior, a timeout of 2 seconds happens between above
2127 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2128 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2129 f_sleep(4.0);
2130
2131 deactivate(d);
2132 f_shutdown_helper();
2133}
2134
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01002135/* OS#3041: Open and close N connections in a normal fashion, and expect no
2136 * BSSMAP Reset just because of that. Close connections from the MS side with a
2137 * Release Ind on RSL. */
2138testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
2139 var default d;
2140 var integer i;
2141 var DchanTuple dt;
2142 var BSSAP_N_DATA_ind rx_di;
2143 var RSL_Message rx_rsl;
2144 var integer j;
2145
2146 f_init();
2147
2148 /* Wait for initial BSSMAP Reset to pass */
2149 f_sleep(4.0);
2150
2151 d := activate(no_bssmap_reset());
2152
2153 /* Setup up a number of connections and RLSD them again from the MSC
2154 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2155 * Let's do it some more times for good measure. */
2156 for (i := 0; i < 8; i := i+1) {
2157 /* Since we're doing a lot of runs, give each one a fresh
2158 * T_guard from the top. */
2159 T_guard.start;
2160
2161 /* Setup a BSSAP connection and clear it right away. This is
2162 * the MSC telling the BSC about a planned release, it's not an
2163 * erratic loss of a connection. */
2164 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2165
2166 /* simulate RLL REL IND */
2167 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
2168
2169 /* expect Clear Request on MSC side */
2170 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
2171
2172 /* Instruct BSC to clear channel */
2173 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
2174 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2175
2176 /* expect BSC to disable the channel */
2177 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
2178 /* respond with CHAN REL ACK */
2179 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
2180
2181 /* expect Clear Complete from BSC */
2182 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
2183
2184 /* MSC disconnects as instructed. */
2185 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2186 }
2187
2188 /* In the buggy behavior, a timeout of 2 seconds happens between above
2189 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2190 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2191 f_sleep(4.0);
2192
2193 deactivate(d);
2194 f_shutdown_helper();
2195}
2196
Harald Welte94e0c342018-04-07 11:33:23 +02002197/***********************************************************************
2198 * IPA style dynamic PDCH
2199 ***********************************************************************/
2200
2201private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
2202 template (omit) RSL_Cause nack := omit)
2203runs on test_CT {
2204 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
2205 var RSL_Message rsl_unused;
2206 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2207 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
2208 /* expect the BSC to issue the related RSL command */
2209 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2210 if (istemplatekind(nack, "omit")) {
2211 /* respond with a related acknowledgement */
2212 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2213 } else {
2214 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
2215 }
2216}
2217
2218private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
2219 template (omit) RSL_Cause nack := omit)
2220runs on test_CT {
2221 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
2222 var RSL_Message rsl_unused;
2223 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2224 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
2225 /* expect the BSC to issue the related RSL command */
2226 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
2227 if (istemplatekind(nack, "omit")) {
2228 /* respond with a related acknowledgement */
2229 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
2230 } else {
2231 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
2232 }
2233}
2234
2235private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
2236runs on test_CT return charstring {
2237 var charstring cmd, resp;
2238 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
2239 resp := f_vty_transceive_ret(BSCVTY, cmd);
2240 return regexp(resp, "*\((*)\)*", 0);
2241}
2242
2243private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
2244 template charstring exp)
2245runs on test_CT {
2246 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
2247 if (not match(mode, exp)) {
2248 setverdict(fail, "Unexpected TS Mode: ", mode);
2249 self.stop;
2250 }
2251}
2252
2253private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
2254runs on test_CT {
2255 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
2256 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
2257 f_vty_transceive(BSCVTY, "end");
2258}
2259
2260private const charstring TCHF_MODE := "TCH/F mode";
2261private const charstring TCHH_MODE := "TCH/H mode";
2262private const charstring PDCH_MODE := "PDCH mode";
2263private const charstring NONE_MODE := "NONE mode";
2264
2265/* Test IPA PDCH activation / deactivation triggered by VTY */
2266testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
2267 var RSL_Message rsl_unused;
2268
2269 /* change Timeslot 6 before f_init() starts RSL */
2270 f_init_vty();
2271 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
2272 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2273
2274 f_init(1, false);
2275 f_sleep(1.0);
2276
2277 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2278
2279 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2280 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2281 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2282 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2283 f_sleep(1.0);
2284 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2285
2286 /* De-activate it via VTY */
2287 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2288 f_sleep(1.0);
2289 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2290
2291 /* re-activate it via VTY */
2292 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
2293 f_sleep(1.0);
2294 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2295
2296 /* and finally de-activate it again */
2297 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2298 f_sleep(1.0);
2299 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2300
2301 setverdict(pass);
2302}
2303
2304/* Test IPA PDCH activation NACK */
2305testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
2306 var RSL_Message rsl_unused;
2307
2308 /* change Timeslot 6 before f_init() starts RSL */
2309 f_init_vty();
2310 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
2311 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2312
2313 f_init(1, false);
2314 f_sleep(1.0);
2315
2316 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2317
2318 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2319 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2320 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2321 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2322 f_sleep(1.0);
2323 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2324
2325 /* De-activate it via VTY */
2326 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2327 f_sleep(1.0);
2328 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2329
2330 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
2331 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
2332 f_sleep(1.0);
2333 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2334
2335 setverdict(pass);
2336}
2337
2338
2339/***********************************************************************
2340 * Osmocom style dynamic PDCH
2341 ***********************************************************************/
2342
2343private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
2344 template (omit) RSL_Cause nack := omit)
2345runs on test_CT {
2346 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
2347 var RSL_Message rsl_unused;
2348 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2349 /* FIXME: no VTY command to activate Osmocom PDCH !! */
2350 /* expect the BSC to issue the related RSL command */
2351 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
2352 if (istemplatekind(nack, "omit")) {
2353 /* respond with a related acknowledgement */
2354 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
2355 } else {
2356 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
2357 }
2358}
2359
2360private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
2361 template (omit) RSL_Cause nack := omit)
2362runs on test_CT {
2363 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
2364 var RSL_Message rsl_unused;
2365 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2366 /* FIXME: no VTY command to activate Osmocom PDCH !! */
2367 /* expect the BSC to issue the related RSL command */
2368 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
2369 if (istemplatekind(nack, "omit")) {
2370 /* respond with a related acknowledgement */
2371 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
2372 } else {
2373 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
2374 }
2375}
2376
2377/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
2378testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
2379 var RSL_Message rsl_unused;
2380
2381 /* change Timeslot 6 before f_init() starts RSL */
2382 f_init_vty();
2383 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
2384 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2385
2386 f_init(1, false);
2387 f_sleep(1.0);
2388
2389 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
2390
2391 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2392 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2393 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
2394
2395 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
2396 f_sleep(1.0);
2397 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2398
2399 setverdict(pass);
2400}
2401
2402/* Test Osmocom dyn PDCH activation NACK behavior */
2403testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
2404 var RSL_Message rsl_unused;
2405
2406 /* change Timeslot 6 before f_init() starts RSL */
2407 f_init_vty();
2408 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
2409 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2410
2411 f_init(1, false);
2412 f_sleep(1.0);
2413
2414 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
2415
2416 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2417 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2418 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
2419
2420 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
2421 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
2422 f_sleep(1.0);
2423 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2424
2425 setverdict(pass);
2426}
2427
Harald Welte0ea2d5e2018-04-07 21:40:29 +02002428/* Dyn PDCH todo:
2429 * activate OSMO as TCH/F
2430 * activate OSMO as TCH/H
2431 * does the BSC-located PCU socket get the updated INFO?
2432 * what if no PCU is connected at the time?
2433 * is the info correct on delayed PCU (re)connect?
2434 */
Harald Welte94e0c342018-04-07 11:33:23 +02002435
Harald Welte28d943e2017-11-25 15:00:50 +01002436control {
Harald Welte898113b2018-01-31 18:32:21 +01002437 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01002438 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002439 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01002440 execute( TC_ctrl() );
Harald Welte898113b2018-01-31 18:32:21 +01002441
2442 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01002443 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01002444 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01002445 execute( TC_chan_act_ack_noest() );
2446 execute( TC_chan_act_ack_est_ind_noreply() );
2447 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01002448 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01002449 execute( TC_chan_exhaustion() );
Harald Welte4003d112017-12-09 22:35:39 +01002450 execute( TC_chan_rel_rll_rel_ind() );
2451 execute( TC_chan_rel_conn_fail() );
2452 execute( TC_chan_rel_hard_clear() );
Harald Welted8c36cd2017-12-09 23:05:31 +01002453 execute( TC_chan_rel_hard_rlsd() );
Harald Welte85804d42017-12-10 14:11:58 +01002454 execute( TC_chan_rel_a_reset() );
Harald Welte6f521d82017-12-11 19:52:02 +01002455
Harald Weltecfe2c962017-12-15 12:09:32 +01002456 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01002457
2458 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01002459 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01002460 execute( TC_assignment_csd() );
2461 execute( TC_assignment_ctm() );
2462 execute( TC_assignment_sign() );
2463 execute( TC_assignment_fr_a5_0() );
2464 execute( TC_assignment_fr_a5_1() );
Harald Welte8f67d1d2018-05-25 20:38:42 +02002465 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2466 execute( TC_assignment_fr_a5_1_codec_missing() );
2467 }
Harald Welte235ebf12017-12-15 14:18:16 +01002468 execute( TC_assignment_fr_a5_3() );
2469 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02002470 execute( TC_ciph_mode_a5_0() );
2471 execute( TC_ciph_mode_a5_1() );
2472 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01002473
Harald Welte60aa5762018-03-21 19:33:13 +01002474 execute( TC_assignment_codec_fr() );
2475 execute( TC_assignment_codec_hr() );
2476 execute( TC_assignment_codec_efr() );
2477 execute( TC_assignment_codec_amr_f() );
2478 execute( TC_assignment_codec_amr_h() );
2479
Harald Welte898113b2018-01-31 18:32:21 +01002480 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01002481 execute( TC_rll_est_ind_inact_lchan() );
2482 execute( TC_rll_est_ind_inval_sapi1() );
2483 execute( TC_rll_est_ind_inval_sapi3() );
2484 execute( TC_rll_est_ind_inval_sacch() );
2485
Harald Welte898113b2018-01-31 18:32:21 +01002486 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01002487 execute( TC_paging_imsi_nochan() );
2488 execute( TC_paging_tmsi_nochan() );
2489 execute( TC_paging_tmsi_any() );
2490 execute( TC_paging_tmsi_sdcch() );
2491 execute( TC_paging_tmsi_tch_f() );
2492 execute( TC_paging_tmsi_tch_hf() );
2493 execute( TC_paging_imsi_nochan_cgi() );
2494 execute( TC_paging_imsi_nochan_lac_ci() );
2495 execute( TC_paging_imsi_nochan_ci() );
2496 execute( TC_paging_imsi_nochan_lai() );
2497 execute( TC_paging_imsi_nochan_lac() );
2498 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01002499 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
2500 execute( TC_paging_imsi_nochan_rnc() );
2501 execute( TC_paging_imsi_nochan_lac_rnc() );
2502 execute( TC_paging_imsi_nochan_lacs() );
2503 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01002504 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01002505 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01002506 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01002507 execute( TC_paging_counter() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002508
2509 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002510 execute( TC_rsl_unknown_unit_id() );
2511
2512 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01002513
2514 execute( TC_classmark() );
2515 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01002516 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002517 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01002518 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01002519 execute( TC_err_84_unknown_msg() );
Harald Welte261af4b2018-02-12 21:20:39 +01002520 execute( TC_ho_int() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01002521
2522 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01002523 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01002524 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02002525
2526 execute( TC_dyn_pdch_ipa_act_deact() );
2527 execute( TC_dyn_pdch_ipa_act_nack() );
2528 execute( TC_dyn_pdch_osmo_act_deact() );
2529 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte28d943e2017-11-25 15:00:50 +01002530}
2531
2532}