blob: cdc64b8d6393577548a23d39906a95a7e91028cc [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 Welteffe55fc2018-01-17 22:39:54 +0100315 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +0100316
Daniel Willmann191e0d92018-01-17 12:44:35 +0100317 f_init_mgcp("VirtMSC");
Harald Weltebc03c762018-02-12 18:09:38 +0100318 f_init_vty("VirtMSC");
Daniel Willmann191e0d92018-01-17 12:44:35 +0100319
Harald Welte89d42e82017-12-17 16:42:41 +0100320 for (i := 0; i < nr_bts; i := i+1) {
Harald Weltea5d2ab22017-12-09 14:21:42 +0100321 /* wait until osmo-bts-omldummy has respawned */
322 f_wait_oml(i, "degraded", 5.0);
323 /* start RSL connection */
Harald Welte624f9632017-12-16 19:26:04 +0100324 f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i, handler_mode);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100325 /* wait until BSC tells us "connected" */
326 f_wait_oml(i, "connected", 5.0);
Harald Welte696ddb62017-12-08 14:01:43 +0100327 }
328
Harald Welteae026692017-12-09 01:03:01 +0100329 T_guard.start;
330 activate(as_Tguard());
Harald Welte28d943e2017-11-25 15:00:50 +0100331}
332
Harald Welte21b46bd2017-12-17 19:46:32 +0100333/* expect to receive a RSL message matching a specified templaten on a given BTS / stream */
Harald Welteae026692017-12-09 01:03:01 +0100334function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
335runs on test_CT return RSL_Message {
336 var ASP_RSL_Unitdata rx_rsl_ud;
337 timer T := t_secs;
338
339 T.start;
340 alt {
341 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud {
342 T.stop;
343 }
344 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +0100345 [] T.timeout {
346 setverdict(fail, "Timeout expecting ", t_rx);
347 self.stop;
348 }
Harald Welteae026692017-12-09 01:03:01 +0100349 }
350 return rx_rsl_ud.rsl;
351}
352
Harald Welte21b46bd2017-12-17 19:46:32 +0100353/* helper function to transmit RSL on a given BTS/stream */
Harald Welteae026692017-12-09 01:03:01 +0100354function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
355runs on test_CT {
356 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx));
357}
358
359
Harald Welte4003d112017-12-09 22:35:39 +0100360/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +0100361testcase TC_chan_act_noreply() runs on test_CT {
362 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +0100363 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +0100364
Harald Welte89d42e82017-12-17 16:42:41 +0100365 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +0100366
Harald Welteae026692017-12-09 01:03:01 +0100367 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 +0100368 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welteae026692017-12-09 01:03:01 +0100369 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +0100370}
371
Harald Welte4003d112017-12-09 22:35:39 +0100372/* verify if the "chreq:total" counter increments as expected */
373testcase TC_chan_act_counter() runs on test_CT {
374 var BSSAP_N_UNITDATA_ind ud_ind;
375 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +0100376 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +0100377
Harald Welte89d42e82017-12-17 16:42:41 +0100378 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100379
380 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
381 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 +0100382 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +0100383 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
384
385 setverdict(pass);
386}
387
Harald Welteae026692017-12-09 01:03:01 +0100388/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
389testcase TC_chan_act_ack_noest() runs on test_CT {
390 var RSL_Message rx_rsl;
391
Harald Welte89d42e82017-12-17 16:42:41 +0100392 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100393
394 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100395 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100396
397 /* expect BSC to disable the channel again if there's no RLL EST IND */
398 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
399
400 setverdict(pass);
401}
402
403/* Test behavior if MSC never answers to CR */
404testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +0100405 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
406 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +0100407 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +0100408 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +0100409
Harald Welte89d42e82017-12-17 16:42:41 +0100410 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100411
412 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100413 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100414
415 var octetstring l3 := '00010203040506'O
416 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
417
418 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
419
420 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +0100421 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
422 IPA_RSL[0].clear;
423 alt {
424 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) -> value rx_rsl_ud { }
425 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_REL_REQ(chan_nr, ?))) -> value rx_rsl_ud {
426 f_ipa_tx(0, ts_RSL_REL_CONF(chan_nr, main_dcch));
427 repeat;
428 }
429 }
Harald Welteae026692017-12-09 01:03:01 +0100430
431 setverdict(pass);
432}
433
434/* Test behavior if MSC answers with CREF to CR */
435testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
436 var BSSAP_N_CONNECT_ind rx_c_ind;
437 var RSL_Message rx_rsl;
438
Harald Welte89d42e82017-12-17 16:42:41 +0100439 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100440
441 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100442 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100443
444 var octetstring l3 := '00010203040506'O
445 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
446
447 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
448 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
449
450 /* expect BSC to disable the channel */
Harald Welte725844b2018-01-28 16:18:32 +0100451 f_expect_chan_rel(0, chan_nr);
Harald Welteae026692017-12-09 01:03:01 +0100452 setverdict(pass);
453}
454
Harald Welte618ef642017-12-14 14:58:20 +0100455/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
456testcase TC_chan_act_nack() runs on test_CT {
457 var RSL_Message rx_rsl;
458 var integer chact_nack;
459
Harald Welte89d42e82017-12-17 16:42:41 +0100460 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +0100461
462 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
463
464 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
465 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
466 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
467
468 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
469
470 /* wait for some time to hope the NACK arrives before the CTRL GET below */
471 f_sleep(0.5);
472
473 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
474
475 setverdict(pass);
476}
477
Harald Welte799c97b2017-12-14 17:50:30 +0100478/* Test for channel exhaustion due to RACH overload */
479testcase TC_chan_exhaustion() runs on test_CT {
480 var ASP_RSL_Unitdata rsl_ud;
481 var integer i;
482 var integer chreq_total, chreq_nochan;
483
Harald Welte89d42e82017-12-17 16:42:41 +0100484 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +0100485
486 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
487 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
488
489 /* expect 5xTCH/F to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +0200490 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 +0100491 var RslChannelNr chan_nr := f_chreq_act_ack('23'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +0100492 }
493
494 IPA_RSL[0].clear;
495
Harald Weltedd8cbf32018-01-28 12:07:52 +0100496 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200497 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +0100498
499 /* now expect additional channel activations to fail */
500 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
501
502 alt {
503 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
504 tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
505 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
506 }
507 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
508 var GsmRrMessage rr;
509 /* match on IMM ASS REJ */
510 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
511 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
512 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200513 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +0100514 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
515 chreq_nochan+1);
516 setverdict(pass);
517 } else {
518 repeat;
519 }
520 }
521 [] IPA_RSL[0].receive { repeat; }
522 }
523}
524
Harald Weltecfe2c962017-12-15 12:09:32 +0100525/***********************************************************************
526 * Assignment Testing
527 ***********************************************************************/
528
529/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction) */
530testcase TC_outbound_connect() runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +0100531 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +0100532
Harald Weltea4ca4462018-02-09 00:17:14 +0100533 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 +0100534 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
535 setverdict(pass);
536}
537
Harald Welte16a4adf2017-12-14 18:54:01 +0100538/* Test behavior if MSC answers with CREF to CR */
539testcase TC_assignment_cic_only() runs on test_CT {
540 var BSSAP_N_CONNECT_ind rx_c_ind;
541 var RSL_Message rx_rsl;
542 var DchanTuple dt;
543
Harald Welte89d42e82017-12-17 16:42:41 +0100544 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +0100545
546 dt := f_est_dchan('23'O, 23, '00000000'O);
Harald Welte17b27da2018-05-25 20:33:53 +0200547 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
548 /* send assignment without AoIP IEs */
549 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
550 } else {
551 /* Send assignmetn without CIC in IPA case */
552 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
553 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
554 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
555 }
Harald Welte16a4adf2017-12-14 18:54:01 +0100556 alt {
557 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
558 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
559 }
Harald Welte235ebf12017-12-15 14:18:16 +0100560 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +0100561 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
562 setverdict(pass);
563 }
564 [] BSSAP.receive { repeat; }
565 }
566}
567
Harald Welteed848512018-05-24 22:27:58 +0200568/* generate an assignment request for either AoIP or SCCPlite */
569private function f_gen_ass_req() return PDU_BSSAP {
570 var PDU_BSSAP ass_cmd;
571 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
572 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
573 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
574 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
575 } else {
576 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
577 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
578 }
579 return ass_cmd;
580}
581
582/* generate an assignment complete template for either AoIP or SCCPlite */
583private function f_gen_exp_compl() return template PDU_BSSAP {
584 var template PDU_BSSAP exp_compl;
585 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
586 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
587 } else {
588 /* CIC is optional "*" as the MSC allocated it */
589 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
590 }
591 return exp_compl;
592}
593
Harald Welte235ebf12017-12-15 14:18:16 +0100594/* Run everything required up to sending a caller-specified assignment command and expect response */
595function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
596runs on test_CT {
597 var BSSAP_N_CONNECT_ind rx_c_ind;
598 var RSL_Message rx_rsl;
599 var DchanTuple dt;
600
Harald Welte89d42e82017-12-17 16:42:41 +0100601 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +0100602
603 dt := f_est_dchan('23'O, 23, '00000000'O);
604 /* send assignment without AoIP IEs */
605 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
606 alt {
607 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
608 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
609 setverdict(pass);
610 } else {
611 setverdict(fail, fail_text);
612 }
613 }
614 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
615 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
616 setverdict(pass);
617 } else {
618 setverdict(fail, fail_text);
619 }
620 }
621 [] BSSAP.receive { repeat; }
622 }
623}
624testcase TC_assignment_csd() runs on test_CT {
625 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200626 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100627 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
628 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
629 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
630}
631
632testcase TC_assignment_ctm() runs on test_CT {
633 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200634 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100635 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
636 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
637 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
638}
639
Harald Welte4003d112017-12-09 22:35:39 +0100640type record DchanTuple {
641 integer sccp_conn_id,
642 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +0100643}
644
Harald Welted6939652017-12-13 21:02:46 +0100645/* Send CHAN RQD and wait for allocation; acknowledge it */
646private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
647runs on test_CT return RslChannelNr {
648 var RSL_Message rx_rsl;
649 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
650 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
651 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
652 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
653 return chan_nr;
654}
655
Harald Welte4003d112017-12-09 22:35:39 +0100656/* helper function to establish a dedicated channel via BTS and MSC */
657function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
658runs on test_CT return DchanTuple {
659 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +0100660 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100661
Harald Welte4003d112017-12-09 22:35:39 +0100662 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100663 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +0100664
665 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
666
667 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
668 dt.sccp_conn_id := rx_c_ind.connectionId;
669 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
670
671 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100672}
673
Harald Welte4003d112017-12-09 22:35:39 +0100674/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
675testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
676 var RSL_Message rx_rsl;
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100677 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100678 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +0100679
Harald Welte89d42e82017-12-17 16:42:41 +0100680 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +0100681
Harald Welte4003d112017-12-09 22:35:39 +0100682 dt := f_est_dchan('23'O, 23, '00010203040506'O);
683
684 /* simulate RLL REL IND */
685 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
686
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100687 /* expect Clear Request on MSC side */
688 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
689
690 /* Instruct BSC to clear channel */
691 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
692 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
693
Harald Welte4003d112017-12-09 22:35:39 +0100694 /* expect BSC to disable the channel */
695 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
696 /* respond with CHAN REL ACK */
697 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
698
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100699 /* expect Clear Complete from BSC */
700 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
701
702 /* release the SCCP connection */
703 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
704
705 /* wait for SCCP emulation to do its job */
706 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +0100707
708 setverdict(pass);
709}
710
711/* Test behavior of channel release after CONN FAIL IND from BTS */
712testcase TC_chan_rel_conn_fail() runs on test_CT {
713 var BSSAP_N_DATA_ind rx_di;
714 var RSL_Message rx_rsl;
715 var DchanTuple dt;
716
Harald Welte89d42e82017-12-17 16:42:41 +0100717 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100718
719 dt := f_est_dchan('23'O, 23, '00010203040506'O);
720
721 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +0100722 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 +0100723 /* TODO: different cause values? */
724
Harald Welte4003d112017-12-09 22:35:39 +0100725 /* expect Clear Request from BSC */
726 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
727
728 /* Instruct BSC to clear channel */
729 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
730 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
731
Harald Welte6ff76ea2018-01-28 13:08:01 +0100732 /* expect BSC to disable the channel */
733 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
734 /* respond with CHAN REL ACK */
735 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
736
Harald Welte4003d112017-12-09 22:35:39 +0100737 /* expect Clear Complete from BSC */
738 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
739
740 /* release the SCCP connection */
741 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
742
743 /* wait for SCCP emulation to do its job */
744 f_sleep(1.0);
745
746 setverdict(pass);
747}
748
Harald Welte91d54a52018-01-28 15:35:07 +0100749function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr, boolean flush := true,
750 boolean handle_rll_rel := true) runs on test_CT {
751
752 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
753 if (flush) {
754 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
755 IPA_RSL[bts_nr].clear;
756 }
757 alt {
758 /* ignore DEACTIVATE SACCH (if any) */
759 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
760 tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
761 repeat;
762 }
763 /* acknowledge RLL release (if any)*/
764 [handle_rll_rel] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
765 tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
766 /* FIXME: Why are we getting this for LinkID SACCH? */
767 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
768 repeat;
769 }
770 /* Expect RF channel release from BSC on Abis */
771 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
772 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
773 /* respond with CHAN REL ACK */
774 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
775 }
776 /* ignore any user data */
777 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) {
778 repeat;
779 }
780 }
781}
782
Harald Welte4003d112017-12-09 22:35:39 +0100783/* Test behavior of channel release after hard Clear Command from MSC */
784testcase TC_chan_rel_hard_clear() runs on test_CT {
785 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100786 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +0100787
Harald Welte89d42e82017-12-17 16:42:41 +0100788 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100789
790 dt := f_est_dchan('23'O, 23, '00010203040506'O);
791
792 /* Instruct BSC to clear channel */
793 var BssmapCause cause := 0;
794 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
795
796 /* expect Clear Complete from BSC on A */
797 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
798 /* release the SCCP connection */
799 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
800 }
801
Harald Welte91d54a52018-01-28 15:35:07 +0100802 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welte4003d112017-12-09 22:35:39 +0100803 setverdict(pass);
804}
805
Harald Welted8c36cd2017-12-09 23:05:31 +0100806/* Test behavior of channel release after hard RLSD from MSC */
807testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +0100808 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +0100809
Harald Welte89d42e82017-12-17 16:42:41 +0100810 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +0100811
812 dt := f_est_dchan('23'O, 23, '00010203040506'O);
813
814 /* release the SCCP connection */
815 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
816
Harald Welte91d54a52018-01-28 15:35:07 +0100817 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welted8c36cd2017-12-09 23:05:31 +0100818 setverdict(pass);
819}
820
Harald Welte85804d42017-12-10 14:11:58 +0100821/* Test behavior of channel release after BSSMAP RESET from MSC */
822testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +0100823 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +0100824
Harald Welte89d42e82017-12-17 16:42:41 +0100825 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +0100826
827 dt := f_est_dchan('23'O, 23, '00010203040506'O);
828
829 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
830 IPA_RSL[0].clear;
831
832 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Harald Weltea4ca4462018-02-09 00:17:14 +0100833 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 +0100834 interleave {
Harald Weltea4ca4462018-02-09 00:17:14 +0100835 [] 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 +0100836 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
837 }
838
Philipp Maiere8f38ed2018-02-09 10:30:31 +0100839 f_expect_chan_rel(0, dt.rsl_chan_nr, false);
Harald Welte85804d42017-12-10 14:11:58 +0100840 setverdict(pass);
841}
842
Harald Welte5cd20ed2017-12-13 21:03:20 +0100843/* Test behavior if RSL EST IND for non-active channel */
844testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
845 timer T := 2.0;
846
Harald Welte89d42e82017-12-17 16:42:41 +0100847 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100848
849 var octetstring l3 := '00010203040506'O;
850 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
851 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
852
853 T.start;
854 alt {
855 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
856 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
857 }
858 [] BSSAP.receive {}
859 [] IPA_RSL[0].receive {}
860 [] T.timeout {}
861 }
862
863 setverdict(pass);
864}
865
866/* Test behavior if RSL EST IND for invalid SAPI */
867testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
868 var RslChannelNr chan_nr;
869
Harald Welte89d42e82017-12-17 16:42:41 +0100870 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100871
872 chan_nr := f_chreq_act_ack()
873
874 var octetstring l3 := '00010203040506'O;
875 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
876
877 timer T := 2.0;
878 T.start;
879 alt {
880 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
881 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
882 }
883 [] BSSAP.receive { repeat; }
884 [] IPA_RSL[0].receive { repeat; }
885 [] T.timeout {}
886 }
887
888 setverdict(pass);
889}
890
891/* Test behavior if RSL EST IND for invalid SAPI */
892testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
893 timer T := 2.0;
894
Harald Welte89d42e82017-12-17 16:42:41 +0100895 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100896
897 var RslChannelNr chan_nr := f_chreq_act_ack();
898
899 var octetstring l3 := '00010203040506'O;
900 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
901
902 T.start;
903 alt {
904 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
905 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
906 }
907 [] BSSAP.receive { repeat; }
908 [] IPA_RSL[0].receive { repeat; }
909 [] T.timeout {}
910 }
911
912 setverdict(pass);
913}
914
915/* Test behavior if RSL EST IND for invalid SACCH */
916testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
917 timer T := 2.0;
918
Harald Welte89d42e82017-12-17 16:42:41 +0100919 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100920
921 var RslChannelNr chan_nr := f_chreq_act_ack();
922
923 var octetstring l3 := '00010203040506'O;
924 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
925
926 T.start;
927 alt {
928 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
929 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
930 }
931 [] BSSAP.receive { repeat; }
932 [] IPA_RSL[0].receive { repeat; }
933 [] T.timeout {}
934 }
935
936 setverdict(pass);
937}
938
939
940
Harald Welte4003d112017-12-09 22:35:39 +0100941
942testcase TC_ctrl_msc_connection_status() runs on test_CT {
943 var charstring ctrl_resp;
944
Harald Welte89d42e82017-12-17 16:42:41 +0100945 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100946
947 /* See https://osmocom.org/issues/2729 */
948 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
949 setverdict(pass);
950}
951
Stefan Sperlingb041b3d2018-01-03 17:14:55 +0100952testcase TC_ctrl_msc0_connection_status() runs on test_CT {
953 var charstring ctrl_resp;
954
955 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +0100956
957 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
958 setverdict(pass);
959}
960
Harald Welte4003d112017-12-09 22:35:39 +0100961testcase TC_ctrl() runs on test_CT {
962 var charstring ctrl_resp;
963
Harald Welte89d42e82017-12-17 16:42:41 +0100964 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100965
966 /* all below values must match the osmo-bsc.cfg config file used */
967
Harald Welte6a129692018-03-17 17:30:14 +0100968 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
969 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Harald Welte44bdaa52017-12-17 17:01:47 +0100970 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "3");
Harald Welte4003d112017-12-09 22:35:39 +0100971
972 var integer bts_nr := 0;
973 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
974 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
975 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
976 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
977 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
978 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
979 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
980
981 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
982 f_sleep(2.0);
983 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
984 setverdict(fail, "oml-uptime not incrementing as expected");
985 }
986 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
987
988 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
989
990 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +0100991}
992
Harald Welte6f521d82017-12-11 19:52:02 +0100993function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100994 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, bssap));
Harald Welte6f521d82017-12-11 19:52:02 +0100995}
996
997
998/***********************************************************************
999 * Paging Testing
1000 ***********************************************************************/
1001
1002type record Cell_Identity {
1003 GsmMcc mcc,
1004 GsmMnc mnc,
1005 GsmLac lac,
1006 GsmCellId ci
1007};
Harald Welte24135bd2018-03-17 19:27:53 +01001008private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001009private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001010
Harald Welte5d1a2202017-12-13 19:51:29 +01001011type set of integer BtsIdList;
1012
1013private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1014 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1015 if (bts_id == bts_ids[j]) {
1016 return true;
1017 }
1018 }
1019 return false;
1020}
Harald Welte6f521d82017-12-11 19:52:02 +01001021
1022/* core paging test helper function; used by most paging test cases */
1023private function f_pageing_helper(hexstring imsi,
1024 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001025 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001026 template RSL_ChanNeeded rsl_chneed := omit,
1027 template OCT4 tmsi := omit) runs on test_CT
1028{
1029 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
1030 var MobileIdentity mi;
1031 var template octetstring id_enc; /* FIXME */
1032 var RSL_Message rx_rsl;
1033 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001034 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001035
1036 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001037
1038 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001039 for (i := 0; i < NUM_BTS; i := i + 1) {
1040 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001041 }
Harald Welte6f521d82017-12-11 19:52:02 +01001042
1043 if (isvalue(rsl_chneed)) {
1044 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1045 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1046 } else {
1047 bssmap_chneed := omit;
1048 }
1049
1050 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
1051
1052/* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder
1053 if (isvalue(tmsi)) {
1054 mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi))));
1055 } else {
1056 mi := valueof(ts_Osmo_MI_IMSI(imsi));
1057 }
1058 id_enc := enc_MobileIdentity(mi);
1059*/
1060 id_enc := ?;
Harald Welte5d1a2202017-12-13 19:51:29 +01001061 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
1062 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc));
1063 /* check channel type, paging group */
1064 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1065 setverdict(fail, "Paging for wrong paging group");
1066 }
1067 if (ispresent(rsl_chneed) and
1068 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1069 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1070 }
Harald Welte6f521d82017-12-11 19:52:02 +01001071 }
Harald Welte2fccd982018-01-31 15:48:19 +01001072 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001073 /* do a quick check on all not-included BTSs if they received paging */
1074 for (i := 0; i < NUM_BTS; i := i + 1) {
1075 timer T := 0.1;
1076 if (f_bts_in_list(i, bts_ids)) {
1077 continue;
1078 }
1079 T.start;
1080 alt {
1081 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) {
1082 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1083 }
1084 [] IPA_RSL[i].receive { repeat; }
1085 [] T.timeout { }
1086 }
Harald Welte6f521d82017-12-11 19:52:02 +01001087 }
1088
1089 setverdict(pass);
1090}
1091
Harald Welte5d1a2202017-12-13 19:51:29 +01001092const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001093const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001094const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1095const BtsIdList c_BtsId_LAC2 := { 2 };
1096
Harald Welte6f521d82017-12-11 19:52:02 +01001097/* PAGING by IMSI + TMSI */
1098testcase TC_paging_imsi_nochan() runs on test_CT {
1099 var BSSMAP_FIELD_CellIdentificationList cid_list;
1100 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001101 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001102 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001103}
1104
1105/* PAGING by IMSI + TMSI */
1106testcase TC_paging_tmsi_nochan() runs on test_CT {
1107 var BSSMAP_FIELD_CellIdentificationList cid_list;
1108 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001109 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001110 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001111}
1112
1113/* Paging with different "channel needed' values */
1114testcase TC_paging_tmsi_any() runs on test_CT {
1115 var BSSMAP_FIELD_CellIdentificationList cid_list;
1116 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001117 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001118 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001119}
1120testcase TC_paging_tmsi_sdcch() runs on test_CT {
1121 var BSSMAP_FIELD_CellIdentificationList cid_list;
1122 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001123 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001124 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001125}
1126testcase TC_paging_tmsi_tch_f() runs on test_CT {
1127 var BSSMAP_FIELD_CellIdentificationList cid_list;
1128 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001129 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001130 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001131}
1132testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1133 var BSSMAP_FIELD_CellIdentificationList cid_list;
1134 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001135 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001136 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001137}
1138
1139/* Paging by CGI */
1140testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1141 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1142 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001143 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001144 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001145}
1146
1147/* Paging by LAC+CI */
1148testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1149 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1150 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001151 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001152 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001153}
1154
1155/* Paging by CI */
1156testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1157 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1158 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001159 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001160 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001161}
1162
1163/* Paging by LAI */
1164testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1165 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1166 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001167 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001168 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001169}
1170
1171/* Paging by LAC */
1172testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1173 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1174 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001175 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001176 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001177}
1178
1179/* Paging by "all in BSS" */
1180testcase TC_paging_imsi_nochan_all() runs on test_CT {
1181 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1182 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001183 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001184 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001185}
1186
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001187/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001188testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1189 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1190 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 +01001191 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001192 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001193}
Harald Welte6f521d82017-12-11 19:52:02 +01001194
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001195/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001196testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1197 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1198 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001199 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001200 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001201}
1202
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001203/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001204testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1205 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1206 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001207 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001208 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001209}
1210
Harald Welte6f521d82017-12-11 19:52:02 +01001211/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001212testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1213 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1214 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1215 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001216 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001217}
1218
1219/* Paging on empty list: Verify none of them page */
1220testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1221 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1222 cid_list := { cIl_LAC := { } };
1223 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001224 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001225}
1226
Stefan Sperling049a86e2018-03-20 15:51:00 +01001227/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1228testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1229 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1230 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1231 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1232 f_shutdown_helper();
1233}
1234
Harald Welte6f521d82017-12-11 19:52:02 +01001235/* Verify paging retransmission interval + count */
1236/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001237/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001238
Harald Weltee65d40e2017-12-13 00:09:06 +01001239/* Verify PCH load */
1240testcase TC_paging_imsi_load() runs on test_CT {
1241 var BSSMAP_FIELD_CellIdentificationList cid_list;
1242 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001243 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001244 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001245 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001246
1247 /* tell BSC there is no paging space anymore */
1248 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001249 f_sleep(0.2);
1250 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001251
1252 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1253 * there would be 8 retransmissions during 4 seconds */
1254 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001255 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001256 alt {
1257 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1258 setverdict(fail, "Received PAGING after LOAD_IND(0)");
1259 self.stop;
1260 }
Harald Welte2caa1062018-03-17 18:19:05 +01001261 [] T_retrans.timeout {
1262 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1263 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1264 T_retrans.start;
1265 repeat;
1266 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001267 [] T.timeout {
1268 setverdict(pass);
1269 }
1270 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001271
1272 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001273}
1274
Harald Welte235ebf12017-12-15 14:18:16 +01001275/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001276testcase TC_paging_counter() runs on test_CT {
1277 var BSSMAP_FIELD_CellIdentificationList cid_list;
1278 timer T := 4.0;
1279 var integer i;
1280 var integer paging_attempted_bsc;
1281 var integer paging_attempted_bts[NUM_BTS];
1282 var integer paging_expired_bts[NUM_BTS];
1283 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1284
1285 f_init();
1286
1287 /* read counters before paging */
1288 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1289 for (i := 0; i < NUM_BTS; i := i+1) {
1290 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1291 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1292 }
1293
1294 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1295
1296 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1297 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1298 for (i := 0; i < NUM_BTS; i := i+1) {
1299 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1300 paging_attempted_bts[i]+1);
1301 }
1302
1303 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1304 f_sleep(12.0);
1305 for (i := 0; i < NUM_BTS; i := i+1) {
1306 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1307 paging_expired_bts[i]+1);
1308 }
Harald Welte1ff69992017-12-14 12:31:17 +01001309
Philipp Maier282ca4b2018-02-27 17:17:00 +01001310 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001311}
1312
1313
Harald Welte10985002017-12-12 09:29:15 +01001314/* Verify paging stops after A-RESET */
1315testcase TC_paging_imsi_a_reset() runs on test_CT {
1316 var BSSMAP_FIELD_CellIdentificationList cid_list;
1317 timer T := 3.0;
1318 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001319 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001320
1321 /* Perform a BSSMAP Reset and wait for ACK */
Harald Weltea4ca4462018-02-09 00:17:14 +01001322 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 +01001323 alt {
Harald Weltea4ca4462018-02-09 00:17:14 +01001324 [] 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 +01001325 [] BSSAP.receive { repeat; }
1326 }
1327
1328 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001329 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1330 IPA_RSL[i].clear;
1331 }
Harald Welte10985002017-12-12 09:29:15 +01001332
1333 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1334 T.start;
1335 alt {
1336 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1337 setverdict(fail, "Received PAGING after A-RESET");
1338 self.stop;
1339 }
Harald Welte5d1a2202017-12-13 19:51:29 +01001340 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1341 setverdict(fail, "Received PAGING after A-RESET");
1342 self.stop;
1343 }
1344 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1345 setverdict(fail, "Received PAGING after A-RESET");
1346 self.stop;
1347 }
Harald Welte10985002017-12-12 09:29:15 +01001348 [] T.timeout {
1349 setverdict(pass);
1350 }
1351 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001352
1353 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001354}
Harald Welteae026692017-12-09 01:03:01 +01001355
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001356/* Test RSL link drop causes counter increment */
1357testcase TC_rsl_drop_counter() runs on test_CT {
1358 var integer rsl_fail;
1359
Harald Welte89d42e82017-12-17 16:42:41 +01001360 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001361
1362 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1363
1364 bts[0].rsl.vc_IPA.stop;
1365
1366 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1367
1368 setverdict(pass);
1369}
1370
1371/* TODO: Test OML link drop causes counter increment */
1372
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001373/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1374function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1375 timer T := 10.0;
1376
1377 bts[0].rsl.id := "IPA-0-RSL";
1378 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1379 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1380 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
1381 bts[0].rsl.ccm_pars.unit_id := "0/0/0"; /* value which is unknown at BTS */
1382
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001383 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1384
1385 f_init_mgcp("VirtMSC");
1386
1387 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1388 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1389 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1390 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1391
1392 /* wait for IPA OML link to connect and then disconnect */
1393 T.start;
1394 alt {
1395 [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) {
1396 T.stop;
1397 return true;
1398 }
1399 [] IPA_RSL[0].receive { repeat }
1400 [] T.timeout {
1401 self.stop;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001402 }
1403 }
1404
1405 return false;
1406}
1407
1408/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1409testcase TC_rsl_unknown_unit_id() runs on test_CT {
1410 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1411 setverdict(pass);
1412 } else {
1413 setverdict(fail, "Timeout RSL waiting for connection to close");
1414 }
1415}
1416
1417
1418/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1419testcase TC_oml_unknown_unit_id() runs on test_CT {
1420 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1421 setverdict(pass);
1422 } else {
1423 setverdict(fail, "Timeout OML waiting for connection to close");
1424 }
1425}
1426
1427
Harald Weltec1a2fff2017-12-17 11:06:19 +01001428/***********************************************************************
1429 * "New world" test cases using RSL_Emulation + BSSMAP_Emulation
1430 ***********************************************************************/
1431
1432import from BSSMAP_Emulation all;
1433import from RSL_Emulation all;
1434import from MSC_ConnectionHandler all;
1435
1436type function void_fn(charstring id) runs on MSC_ConnHdlr;
1437
1438/* helper function to create, connect and start a MSC_ConnHdlr component */
Harald Welte8863fa12018-05-10 20:15:27 +02001439function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
Harald Weltea0630032018-03-20 21:09:55 +01001440runs on test_CT return MSC_ConnHdlr {
Harald Welte8863fa12018-05-10 20:15:27 +02001441 var charstring id := testcasename();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001442 var MSC_ConnHdlr vc_conn;
1443
1444 vc_conn := MSC_ConnHdlr.create(id);
Harald Weltea4ca4462018-02-09 00:17:14 +01001445 connect(vc_conn:BSSMAPEM, g_bssap.vc_BSSMAP:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001446 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001447 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001448 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001449 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001450 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1451 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1452 }
Harald Weltea4ca4462018-02-09 00:17:14 +01001453 connect(vc_conn:BSSAP, g_bssap.vc_BSSMAP:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001454 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Harald Weltea0630032018-03-20 21:09:55 +01001455 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001456 return vc_conn;
1457}
1458
Harald Weltea0630032018-03-20 21:09:55 +01001459/* first function inside ConnHdlr component; sets g_pars + starts function */
1460private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1461runs on MSC_ConnHdlr {
1462 if (isvalue(pars)) {
1463 g_pars := valueof(pars);
1464 }
1465 fn.apply(id);
1466}
1467
Harald Welte3c86ea02018-05-10 22:28:05 +02001468/* Establish signalling channel (non-assignment case) followed by cipher mode */
1469private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001470 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1471 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001472 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
1473
1474 // Disable generation of ASSIGNMENT CMD, as OsmoBSC currently performs MODE MODFIY sign->sign (OS#2936)
1475 //f_establish_fully(ass_cmd, exp_compl);
1476 f_establish_fully(omit, exp_compl);
1477}
1478testcase TC_ciph_mode_a5_0() runs on test_CT {
1479 var MSC_ConnHdlr vc_conn;
1480 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1481 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1482
1483 f_init(1, true);
1484 f_sleep(1.0);
1485 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1486 vc_conn.done;
1487}
1488testcase TC_ciph_mode_a5_1() runs on test_CT {
1489 var MSC_ConnHdlr vc_conn;
1490 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1491 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1492
1493 f_init(1, true);
1494 f_sleep(1.0);
1495 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1496 vc_conn.done;
1497}
1498testcase TC_ciph_mode_a5_3() runs on test_CT {
1499 var MSC_ConnHdlr vc_conn;
1500 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1501 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1502
1503 f_init(1, true);
1504 f_sleep(1.0);
1505 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1506 vc_conn.done;
1507}
1508
1509
1510/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001511private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001512 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1513 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001514
Harald Welte552620d2017-12-16 23:21:36 +01001515 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1516 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001517
Harald Weltea0630032018-03-20 21:09:55 +01001518 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001519}
Harald Welte552620d2017-12-16 23:21:36 +01001520testcase TC_assignment_fr_a5_0() runs on test_CT {
1521 var MSC_ConnHdlr vc_conn;
Harald Welte651fcdc2018-05-10 20:23:16 +02001522 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1523 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001524
Harald Welte89d42e82017-12-17 16:42:41 +01001525 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001526 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001527 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001528 vc_conn.done;
1529}
Harald Welte552620d2017-12-16 23:21:36 +01001530testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001531 var MSC_ConnHdlr vc_conn;
Harald Welte651fcdc2018-05-10 20:23:16 +02001532 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1533 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001534
Harald Welte89d42e82017-12-17 16:42:41 +01001535 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001536 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001537 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1538 vc_conn.done;
1539}
1540testcase TC_assignment_fr_a5_3() runs on test_CT {
1541 var MSC_ConnHdlr vc_conn;
1542 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1543 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001544
Harald Welte651fcdc2018-05-10 20:23:16 +02001545 f_init(1, true);
1546 f_sleep(1.0);
1547 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001548 vc_conn.done;
1549}
1550
Harald Welte552620d2017-12-16 23:21:36 +01001551/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1552private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001553 g_pars := valueof(t_def_TestHdlrPars);
Harald Welte552620d2017-12-16 23:21:36 +01001554 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001555 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001556 const OCT8 kc := '0001020304050607'O;
1557
1558 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Harald Weltea0630032018-03-20 21:09:55 +01001559 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001560}
Harald Welte552620d2017-12-16 23:21:36 +01001561testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1562 var MSC_ConnHdlr vc_conn;
1563
Harald Welte89d42e82017-12-17 16:42:41 +01001564 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001565 f_sleep(1.0);
1566
Harald Welte8863fa12018-05-10 20:15:27 +02001567 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001568 vc_conn.done;
1569}
1570
Harald Welte552620d2017-12-16 23:21:36 +01001571private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001572 g_pars := valueof(t_def_TestHdlrPars);
Harald Welteed848512018-05-24 22:27:58 +02001573 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1574 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001575 const OCT8 kc := '0001020304050607'O;
1576 const OCT16 kc128 := kc & kc;
1577
1578 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1579 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001580 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001581 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001582 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001583}
Harald Welte552620d2017-12-16 23:21:36 +01001584testcase TC_assignment_fr_a5_4() runs on test_CT {
1585 var MSC_ConnHdlr vc_conn;
1586
Harald Welte89d42e82017-12-17 16:42:41 +01001587 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001588 f_sleep(1.0);
1589
Harald Welte8863fa12018-05-10 20:15:27 +02001590 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001591 vc_conn.done;
1592}
1593
1594
Harald Welte4532e0a2017-12-23 02:05:44 +01001595private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier6a50c7c2018-04-16 16:15:59 +02001596 g_pars := valueof(t_def_TestHdlrPars);
Harald Welte4532e0a2017-12-23 02:05:44 +01001597 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
1598 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, omit));
1599
1600 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001601 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001602}
1603
1604testcase TC_assignment_sign() runs on test_CT {
1605 var MSC_ConnHdlr vc_conn;
1606
1607 f_init(1, true);
1608 f_sleep(1.0);
1609
Harald Welte8863fa12018-05-10 20:15:27 +02001610 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001611 vc_conn.done;
1612}
1613
Harald Welte60aa5762018-03-21 19:33:13 +01001614/***********************************************************************
1615 * Codec (list) testing
1616 ***********************************************************************/
1617
1618/* check if the given rsl_mode is compatible with the a_elem */
1619private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1620return boolean {
1621 select (a_elem.codecType) {
1622 case (GSM_FR) {
1623 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1624 return true;
1625 }
1626 }
1627 case (GSM_HR) {
1628 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1629 return true;
1630 }
1631 }
1632 case (GSM_EFR) {
1633 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1634 return true;
1635 }
1636 }
1637 case (FR_AMR) {
1638 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1639 return true;
1640 }
1641 }
1642 case (HR_AMR) {
1643 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1644 return true;
1645 }
1646 }
1647 case else { }
1648 }
1649 return false;
1650}
1651
1652/* check if the given rsl_mode is compatible with the a_list */
1653private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
1654return boolean {
1655 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
1656 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
1657 return true;
1658 }
1659 }
1660 return false;
1661}
1662
1663/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
1664private function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
1665return BSSMAP_IE_ChannelType {
1666 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
1667 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
1668 select (a_elem.codecType) {
1669 case (GSM_FR) {
1670 ret.channelRateAndType := ChRate_TCHF;
1671 ret.speechId_DataIndicator := Spdi_TCHF_FR;
1672 }
1673 case (GSM_HR) {
1674 ret.channelRateAndType := ChRate_TCHH;
1675 ret.speechId_DataIndicator := Spdi_TCHH_HR;
1676 }
1677 case (GSM_EFR) {
1678 ret.channelRateAndType := ChRate_TCHF;
1679 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
1680 }
1681 case (FR_AMR) {
1682 ret.channelRateAndType := ChRate_TCHF;
1683 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
1684 }
1685 case (HR_AMR) {
1686 ret.channelRateAndType := ChRate_TCHH;
1687 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
1688 }
1689 case else {
1690 setverdict(fail, "Unsupported codec ", a_elem);
1691 self.stop;
1692 }
1693 }
1694 return ret;
1695}
1696
Harald Weltea63b9102018-03-22 20:36:16 +01001697private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
1698return template RSL_IE_Body {
1699 var template RSL_IE_Body mode_ie := {
1700 chan_mode := {
1701 len := ?,
1702 reserved := ?,
1703 dtx_d := ?,
1704 dtx_u := ?,
1705 spd_ind := RSL_SPDI_SPEECH,
1706 ch_rate_type := -,
1707 coding_alg_rate := -
1708 }
1709 }
1710
1711 select (a_elem.codecType) {
1712 case (GSM_FR) {
1713 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1714 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1715 }
1716 case (GSM_HR) {
1717 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1718 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1719 }
1720 case (GSM_EFR) {
1721 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1722 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
1723 }
1724 case (FR_AMR) {
1725 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1726 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1727 }
1728 case (HR_AMR) {
1729 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1730 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1731 }
1732 }
1733 return mode_ie;
1734}
1735
Harald Welte60aa5762018-03-21 19:33:13 +01001736type record CodecListTest {
1737 BSSMAP_IE_SpeechCodecList codec_list,
1738 charstring id
1739}
1740type record of CodecListTest CodecListTests
1741
1742private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001743 var PDU_BSSAP ass_cmd := f_gen_ass_req();
1744 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
Harald Welte60aa5762018-03-21 19:33:13 +01001745
1746 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Harald Welte79f3f542018-05-25 20:02:37 +02001747 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
1748 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
1749 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
1750 g_pars.ass_codec_list.codecElements[0];
1751 }
Harald Welte60aa5762018-03-21 19:33:13 +01001752 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
1753 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01001754 log("expecting ASS COMPL like this: ", exp_compl);
1755
1756 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01001757
1758 /* Verify that the RSL-side activation actually matches our expectations */
1759 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
1760
1761 var RSL_IE_Body mode_ie;
1762 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
1763 setverdict(fail, "Couldn't find CHAN_MODE IE");
1764 self.stop;
1765 }
1766 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
1767 if (not match(mode_ie, t_mode_ie)) {
1768 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
1769 }
Harald Welte60aa5762018-03-21 19:33:13 +01001770}
1771
1772testcase TC_assignment_codec_fr() runs on test_CT {
1773 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1774 var MSC_ConnHdlr vc_conn;
1775
1776 f_init(1, true);
1777 f_sleep(1.0);
1778
1779 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001780 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001781 vc_conn.done;
1782}
1783
1784testcase TC_assignment_codec_hr() runs on test_CT {
1785 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1786 var MSC_ConnHdlr vc_conn;
1787
1788 f_init(1, true);
1789 f_sleep(1.0);
1790
1791 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001792 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001793 vc_conn.done;
1794}
1795
1796testcase TC_assignment_codec_efr() runs on test_CT {
1797 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1798 var MSC_ConnHdlr vc_conn;
1799
1800 f_init(1, true);
1801 f_sleep(1.0);
1802
1803 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001804 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001805 vc_conn.done;
1806}
1807
1808testcase TC_assignment_codec_amr_f() runs on test_CT {
1809 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1810 var MSC_ConnHdlr vc_conn;
1811
1812 f_init(1, true);
1813 f_sleep(1.0);
1814
1815 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Harald Welte8863fa12018-05-10 20:15:27 +02001816 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001817 vc_conn.done;
1818}
1819
1820testcase TC_assignment_codec_amr_h() runs on test_CT {
1821 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1822 var MSC_ConnHdlr vc_conn;
1823
1824 f_init(1, true);
1825 f_sleep(1.0);
1826
1827 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Harald Welte8863fa12018-05-10 20:15:27 +02001828 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001829 vc_conn.done;
1830}
1831
1832
1833
Harald Welte898113b2018-01-31 18:32:21 +01001834/* test if L3 RR CLASSMARK CHANGE is translated to BSSMAP CLASSMARK UPDATE */
1835private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001836 g_pars := valueof(t_def_TestHdlrPars);
1837 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01001838 /* we should now have a COMPL_L3 at the MSC */
1839 BSSAP.receive(tr_BSSMAP_ComplL3);
1840
1841 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
1842 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
1843 setverdict(pass);
1844}
1845testcase TC_classmark() runs on test_CT {
1846 var MSC_ConnHdlr vc_conn;
1847 f_init(1, true);
1848 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001849 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01001850 vc_conn.done;
1851}
1852
Harald Weltee3bd6582018-01-31 22:51:25 +01001853private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001854 g_pars := valueof(t_def_TestHdlrPars);
1855 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01001856 /* we should now have a COMPL_L3 at the MSC */
1857 BSSAP.receive(tr_BSSMAP_ComplL3);
1858
Harald Weltee3bd6582018-01-31 22:51:25 +01001859 /* send the single message we want to send */
1860 f_rsl_send_l3(l3);
1861}
1862
1863private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
1864 timer T := sec;
1865 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01001866 T.start;
1867 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01001868 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
1869 setverdict(fail, "Unexpected BSSMAP ", bssap);
1870 self.stop;
Harald Welte898113b2018-01-31 18:32:21 +01001871 }
1872 [] T.timeout {
1873 setverdict(pass);
1874 }
1875 }
1876}
1877
Harald Weltee3bd6582018-01-31 22:51:25 +01001878/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
1879private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
1880 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
1881 f_bssap_expect_nothing();
1882}
Harald Welte898113b2018-01-31 18:32:21 +01001883testcase TC_unsol_ass_fail() runs on test_CT {
1884 var MSC_ConnHdlr vc_conn;
1885 f_init(1, true);
1886 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001887 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01001888 vc_conn.done;
1889}
Harald Welte552620d2017-12-16 23:21:36 +01001890
Harald Welteea99a002018-01-31 20:46:43 +01001891
1892/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
1893private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01001894 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
1895 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01001896}
1897testcase TC_unsol_ass_compl() runs on test_CT {
1898 var MSC_ConnHdlr vc_conn;
1899 f_init(1, true);
1900 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001901 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01001902 vc_conn.done;
1903}
1904
1905
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001906/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
1907private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01001908 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
1909 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001910}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001911testcase TC_unsol_ho_fail() runs on test_CT {
1912 var MSC_ConnHdlr vc_conn;
1913 f_init(1, true);
1914 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001915 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001916 vc_conn.done;
1917}
1918
1919
Harald Weltee3bd6582018-01-31 22:51:25 +01001920/* short message from MS should be ignored */
1921private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001922 g_pars := valueof(t_def_TestHdlrPars);
1923 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01001924 /* we should now have a COMPL_L3 at the MSC */
1925 BSSAP.receive(tr_BSSMAP_ComplL3);
1926
1927 /* send short message */
1928 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
1929 f_bssap_expect_nothing();
1930}
1931testcase TC_err_82_short_msg() runs on test_CT {
1932 var MSC_ConnHdlr vc_conn;
1933 f_init(1, true);
1934 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001935 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01001936 vc_conn.done;
1937}
1938
1939
Harald Weltee9e02e42018-01-31 23:36:25 +01001940/* 24.008 8.4 Unknown message must trigger RR STATUS */
1941private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
1942 f_est_single_l3(ts_RRM_UL_REL('00'O));
1943 timer T := 3.0
1944 alt {
1945 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
1946 setverdict(pass);
1947 }
1948 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01001949 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01001950 }
1951}
1952testcase TC_err_84_unknown_msg() runs on test_CT {
1953 var MSC_ConnHdlr vc_conn;
1954 f_init(1, true);
1955 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001956 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01001957 vc_conn.done;
1958}
1959
Harald Welte94e0c342018-04-07 11:33:23 +02001960/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
1961private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
1962runs on test_CT {
1963 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
1964 " timeslot "&int2str(ts_nr)&" ";
1965 f_vty_transceive(BSCVTY, cmd & suffix);
1966}
1967
Harald Welte261af4b2018-02-12 21:20:39 +01001968/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
1969private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
1970runs on MSC_ConnHdlr {
1971 /* FIXME: resolve those from component-global state */
1972 var integer ts_nr := chan_nr.tn;
1973 var integer ss_nr;
1974 if (ischosen(chan_nr.u.ch0)) {
1975 ss_nr := 0;
1976 } else if (ischosen(chan_nr.u.lm)) {
1977 ss_nr := chan_nr.u.lm.sub_chan;
1978 } else if (ischosen(chan_nr.u.sdcch4)) {
1979 ss_nr := chan_nr.u.sdcch4.sub_chan;
1980 } else if (ischosen(chan_nr.u.sdcch8)) {
1981 ss_nr := chan_nr.u.sdcch8.sub_chan;
1982 } else {
1983 setverdict(fail, "Invalid ChanNr ", chan_nr);
1984 self.stop;
1985 }
1986
1987 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
1988 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
1989 f_vty_transceive(BSCVTY, cmd & suffix);
1990}
1991
1992private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
1993 integer new_bts_nr)
1994runs on MSC_ConnHdlr {
1995 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
1996}
1997
1998/* intra-BSC hand-over between BTS0 and BTS1 */
1999private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01002000 g_pars := valueof(t_def_TestHdlrPars);
Harald Welteed848512018-05-24 22:27:58 +02002001 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2002 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01002003 const OCT8 kc := '0001020304050607'O;
2004
2005 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2006 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2007
Harald Weltea0630032018-03-20 21:09:55 +01002008 f_establish_fully(ass_cmd, exp_compl);
Harald Welte261af4b2018-02-12 21:20:39 +01002009
2010 var HandoverState hs := {
2011 rr_ho_cmpl_seen := false,
2012 handover_done := false,
2013 old_chan_nr := -
2014 };
2015 /* issue hand-over command on VTY */
2016 f_vty_handover(0, 0, g_chan_nr, 1);
2017 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2018 f_rslem_suspend(RSL1_PROC);
2019 alt {
2020 [] as_handover(hs);
2021 /* FIXME: somehow determine that the hand-over has completed, by MGCP MDCX? */
2022 }
2023}
2024
2025testcase TC_ho_int() runs on test_CT {
2026 var MSC_ConnHdlr vc_conn;
2027 f_init(2, true);
2028 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002029 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002030 vc_conn.done;
2031}
Harald Weltee9e02e42018-01-31 23:36:25 +01002032
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01002033/* OS#3041: Open and close N connections in a normal fashion, and expect no
2034 * BSSMAP Reset just because of that. */
2035testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
2036 var default d;
2037 var integer i;
2038 var DchanTuple dt;
2039
2040 f_init();
2041
2042 /* Wait for initial BSSMAP Reset to pass */
2043 f_sleep(4.0);
2044
2045 d := activate(no_bssmap_reset());
2046
2047 /* Setup up a number of connections and RLSD them again from the MSC
2048 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2049 * Let's do it some more times for good measure. */
2050 for (i := 0; i < 8; i := i+1) {
2051 /* Since we're doing a lot of runs, give each one a fresh
2052 * T_guard from the top. */
2053 T_guard.start;
2054
2055 /* Setup a BSSAP connection and clear it right away. This is
2056 * the MSC telling the BSC about a planned release, it's not an
2057 * erratic loss of a connection. */
2058 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2059
2060 /* MSC disconnects (RLSD). */
2061 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2062 }
2063
2064 /* In the buggy behavior, a timeout of 2 seconds happens between above
2065 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2066 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2067 f_sleep(4.0);
2068
2069 deactivate(d);
2070 f_shutdown_helper();
2071}
Harald Welte552620d2017-12-16 23:21:36 +01002072
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01002073/* OS#3041: Open and close N connections in a normal fashion, and expect no
2074 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
2075 * the MSC. */
2076testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
2077 var default d;
2078 var integer i;
2079 var DchanTuple dt;
2080 var BSSAP_N_DATA_ind rx_di;
2081 var RSL_Message rx_rsl;
2082 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
2083 var BssmapCause cause := enum2int(cause_val);
2084
2085 f_init();
2086
2087 /* Wait for initial BSSMAP Reset to pass */
2088 f_sleep(4.0);
2089
2090 d := activate(no_bssmap_reset());
2091
2092 /* Setup up a number of connections and RLSD them again from the MSC
2093 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2094 * Let's do it some more times for good measure. */
2095 for (i := 0; i < 8; i := i+1) {
2096 /* Since we're doing a lot of runs, give each one a fresh
2097 * T_guard from the top. */
2098 T_guard.start;
2099
2100 /* Setup a BSSAP connection and clear it right away. This is
2101 * the MSC telling the BSC about a planned release, it's not an
2102 * erratic loss of a connection. */
2103 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2104
2105 /* Instruct BSC to clear channel */
2106 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2107
2108 /* expect BSC to disable the channel */
2109 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
2110 /* respond with CHAN REL ACK */
2111 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
2112
2113 /* expect Clear Complete from BSC */
2114 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
2115
2116 /* MSC disconnects as instructed. */
2117 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2118
2119
2120 /* MSC disconnects (RLSD). */
2121 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2122 }
2123
2124 /* In the buggy behavior, a timeout of 2 seconds happens between above
2125 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2126 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2127 f_sleep(4.0);
2128
2129 deactivate(d);
2130 f_shutdown_helper();
2131}
2132
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01002133/* OS#3041: Open and close N connections in a normal fashion, and expect no
2134 * BSSMAP Reset just because of that. Close connections from the MS side with a
2135 * Release Ind on RSL. */
2136testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
2137 var default d;
2138 var integer i;
2139 var DchanTuple dt;
2140 var BSSAP_N_DATA_ind rx_di;
2141 var RSL_Message rx_rsl;
2142 var integer j;
2143
2144 f_init();
2145
2146 /* Wait for initial BSSMAP Reset to pass */
2147 f_sleep(4.0);
2148
2149 d := activate(no_bssmap_reset());
2150
2151 /* Setup up a number of connections and RLSD them again from the MSC
2152 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2153 * Let's do it some more times for good measure. */
2154 for (i := 0; i < 8; i := i+1) {
2155 /* Since we're doing a lot of runs, give each one a fresh
2156 * T_guard from the top. */
2157 T_guard.start;
2158
2159 /* Setup a BSSAP connection and clear it right away. This is
2160 * the MSC telling the BSC about a planned release, it's not an
2161 * erratic loss of a connection. */
2162 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2163
2164 /* simulate RLL REL IND */
2165 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
2166
2167 /* expect Clear Request on MSC side */
2168 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
2169
2170 /* Instruct BSC to clear channel */
2171 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
2172 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2173
2174 /* expect BSC to disable the channel */
2175 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
2176 /* respond with CHAN REL ACK */
2177 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
2178
2179 /* expect Clear Complete from BSC */
2180 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
2181
2182 /* MSC disconnects as instructed. */
2183 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2184 }
2185
2186 /* In the buggy behavior, a timeout of 2 seconds happens between above
2187 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2188 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2189 f_sleep(4.0);
2190
2191 deactivate(d);
2192 f_shutdown_helper();
2193}
2194
Harald Welte94e0c342018-04-07 11:33:23 +02002195/***********************************************************************
2196 * IPA style dynamic PDCH
2197 ***********************************************************************/
2198
2199private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
2200 template (omit) RSL_Cause nack := omit)
2201runs on test_CT {
2202 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
2203 var RSL_Message rsl_unused;
2204 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2205 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
2206 /* expect the BSC to issue the related RSL command */
2207 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2208 if (istemplatekind(nack, "omit")) {
2209 /* respond with a related acknowledgement */
2210 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2211 } else {
2212 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
2213 }
2214}
2215
2216private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
2217 template (omit) RSL_Cause nack := omit)
2218runs on test_CT {
2219 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
2220 var RSL_Message rsl_unused;
2221 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2222 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
2223 /* expect the BSC to issue the related RSL command */
2224 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
2225 if (istemplatekind(nack, "omit")) {
2226 /* respond with a related acknowledgement */
2227 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
2228 } else {
2229 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
2230 }
2231}
2232
2233private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
2234runs on test_CT return charstring {
2235 var charstring cmd, resp;
2236 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
2237 resp := f_vty_transceive_ret(BSCVTY, cmd);
2238 return regexp(resp, "*\((*)\)*", 0);
2239}
2240
2241private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
2242 template charstring exp)
2243runs on test_CT {
2244 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
2245 if (not match(mode, exp)) {
2246 setverdict(fail, "Unexpected TS Mode: ", mode);
2247 self.stop;
2248 }
2249}
2250
2251private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
2252runs on test_CT {
2253 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
2254 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
2255 f_vty_transceive(BSCVTY, "end");
2256}
2257
2258private const charstring TCHF_MODE := "TCH/F mode";
2259private const charstring TCHH_MODE := "TCH/H mode";
2260private const charstring PDCH_MODE := "PDCH mode";
2261private const charstring NONE_MODE := "NONE mode";
2262
2263/* Test IPA PDCH activation / deactivation triggered by VTY */
2264testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
2265 var RSL_Message rsl_unused;
2266
2267 /* change Timeslot 6 before f_init() starts RSL */
2268 f_init_vty();
2269 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
2270 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2271
2272 f_init(1, false);
2273 f_sleep(1.0);
2274
2275 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2276
2277 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2278 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2279 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2280 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2281 f_sleep(1.0);
2282 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2283
2284 /* De-activate it via VTY */
2285 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2286 f_sleep(1.0);
2287 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2288
2289 /* re-activate it via VTY */
2290 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
2291 f_sleep(1.0);
2292 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2293
2294 /* and finally de-activate it again */
2295 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2296 f_sleep(1.0);
2297 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2298
2299 setverdict(pass);
2300}
2301
2302/* Test IPA PDCH activation NACK */
2303testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
2304 var RSL_Message rsl_unused;
2305
2306 /* change Timeslot 6 before f_init() starts RSL */
2307 f_init_vty();
2308 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
2309 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2310
2311 f_init(1, false);
2312 f_sleep(1.0);
2313
2314 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2315
2316 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2317 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2318 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2319 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2320 f_sleep(1.0);
2321 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2322
2323 /* De-activate it via VTY */
2324 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2325 f_sleep(1.0);
2326 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2327
2328 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
2329 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
2330 f_sleep(1.0);
2331 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2332
2333 setverdict(pass);
2334}
2335
2336
2337/***********************************************************************
2338 * Osmocom style dynamic PDCH
2339 ***********************************************************************/
2340
2341private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
2342 template (omit) RSL_Cause nack := omit)
2343runs on test_CT {
2344 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
2345 var RSL_Message rsl_unused;
2346 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2347 /* FIXME: no VTY command to activate Osmocom PDCH !! */
2348 /* expect the BSC to issue the related RSL command */
2349 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
2350 if (istemplatekind(nack, "omit")) {
2351 /* respond with a related acknowledgement */
2352 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
2353 } else {
2354 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
2355 }
2356}
2357
2358private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
2359 template (omit) RSL_Cause nack := omit)
2360runs on test_CT {
2361 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
2362 var RSL_Message rsl_unused;
2363 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2364 /* FIXME: no VTY command to activate Osmocom PDCH !! */
2365 /* expect the BSC to issue the related RSL command */
2366 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
2367 if (istemplatekind(nack, "omit")) {
2368 /* respond with a related acknowledgement */
2369 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
2370 } else {
2371 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
2372 }
2373}
2374
2375/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
2376testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
2377 var RSL_Message rsl_unused;
2378
2379 /* change Timeslot 6 before f_init() starts RSL */
2380 f_init_vty();
2381 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
2382 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2383
2384 f_init(1, false);
2385 f_sleep(1.0);
2386
2387 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
2388
2389 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2390 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2391 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
2392
2393 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
2394 f_sleep(1.0);
2395 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2396
2397 setverdict(pass);
2398}
2399
2400/* Test Osmocom dyn PDCH activation NACK behavior */
2401testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
2402 var RSL_Message rsl_unused;
2403
2404 /* change Timeslot 6 before f_init() starts RSL */
2405 f_init_vty();
2406 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
2407 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2408
2409 f_init(1, false);
2410 f_sleep(1.0);
2411
2412 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
2413
2414 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2415 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2416 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
2417
2418 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
2419 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
2420 f_sleep(1.0);
2421 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2422
2423 setverdict(pass);
2424}
2425
Harald Welte0ea2d5e2018-04-07 21:40:29 +02002426/* Dyn PDCH todo:
2427 * activate OSMO as TCH/F
2428 * activate OSMO as TCH/H
2429 * does the BSC-located PCU socket get the updated INFO?
2430 * what if no PCU is connected at the time?
2431 * is the info correct on delayed PCU (re)connect?
2432 */
Harald Welte94e0c342018-04-07 11:33:23 +02002433
Harald Welte28d943e2017-11-25 15:00:50 +01002434control {
Harald Welte898113b2018-01-31 18:32:21 +01002435 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01002436 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002437 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01002438 execute( TC_ctrl() );
Harald Welte898113b2018-01-31 18:32:21 +01002439
2440 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01002441 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01002442 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01002443 execute( TC_chan_act_ack_noest() );
2444 execute( TC_chan_act_ack_est_ind_noreply() );
2445 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01002446 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01002447 execute( TC_chan_exhaustion() );
Harald Welte4003d112017-12-09 22:35:39 +01002448 execute( TC_chan_rel_rll_rel_ind() );
2449 execute( TC_chan_rel_conn_fail() );
2450 execute( TC_chan_rel_hard_clear() );
Harald Welted8c36cd2017-12-09 23:05:31 +01002451 execute( TC_chan_rel_hard_rlsd() );
Harald Welte85804d42017-12-10 14:11:58 +01002452 execute( TC_chan_rel_a_reset() );
Harald Welte6f521d82017-12-11 19:52:02 +01002453
Harald Weltecfe2c962017-12-15 12:09:32 +01002454 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01002455
2456 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01002457 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01002458 execute( TC_assignment_csd() );
2459 execute( TC_assignment_ctm() );
2460 execute( TC_assignment_sign() );
2461 execute( TC_assignment_fr_a5_0() );
2462 execute( TC_assignment_fr_a5_1() );
Harald Weltef1b64e22017-12-15 14:55:14 +01002463 execute( TC_assignment_fr_a5_1_codec_missing() );
Harald Welte235ebf12017-12-15 14:18:16 +01002464 execute( TC_assignment_fr_a5_3() );
2465 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02002466 execute( TC_ciph_mode_a5_0() );
2467 execute( TC_ciph_mode_a5_1() );
2468 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01002469
Harald Welte60aa5762018-03-21 19:33:13 +01002470 execute( TC_assignment_codec_fr() );
2471 execute( TC_assignment_codec_hr() );
2472 execute( TC_assignment_codec_efr() );
2473 execute( TC_assignment_codec_amr_f() );
2474 execute( TC_assignment_codec_amr_h() );
2475
Harald Welte898113b2018-01-31 18:32:21 +01002476 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01002477 execute( TC_rll_est_ind_inact_lchan() );
2478 execute( TC_rll_est_ind_inval_sapi1() );
2479 execute( TC_rll_est_ind_inval_sapi3() );
2480 execute( TC_rll_est_ind_inval_sacch() );
2481
Harald Welte898113b2018-01-31 18:32:21 +01002482 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01002483 execute( TC_paging_imsi_nochan() );
2484 execute( TC_paging_tmsi_nochan() );
2485 execute( TC_paging_tmsi_any() );
2486 execute( TC_paging_tmsi_sdcch() );
2487 execute( TC_paging_tmsi_tch_f() );
2488 execute( TC_paging_tmsi_tch_hf() );
2489 execute( TC_paging_imsi_nochan_cgi() );
2490 execute( TC_paging_imsi_nochan_lac_ci() );
2491 execute( TC_paging_imsi_nochan_ci() );
2492 execute( TC_paging_imsi_nochan_lai() );
2493 execute( TC_paging_imsi_nochan_lac() );
2494 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01002495 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
2496 execute( TC_paging_imsi_nochan_rnc() );
2497 execute( TC_paging_imsi_nochan_lac_rnc() );
2498 execute( TC_paging_imsi_nochan_lacs() );
2499 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01002500 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01002501 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01002502 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01002503 execute( TC_paging_counter() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002504
2505 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002506 execute( TC_rsl_unknown_unit_id() );
2507
2508 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01002509
2510 execute( TC_classmark() );
2511 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01002512 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002513 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01002514 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01002515 execute( TC_err_84_unknown_msg() );
Harald Welte261af4b2018-02-12 21:20:39 +01002516 execute( TC_ho_int() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01002517
2518 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01002519 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01002520 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02002521
2522 execute( TC_dyn_pdch_ipa_act_deact() );
2523 execute( TC_dyn_pdch_ipa_act_nack() );
2524 execute( TC_dyn_pdch_osmo_act_deact() );
2525 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte28d943e2017-11-25 15:00:50 +01002526}
2527
2528}