blob: 2534cf6e1ef655882ae6ccd92a15fdf4536f6be1 [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);
547 /* send assignment without AoIP IEs */
Harald Weltecc7e4dc2017-12-14 21:55:10 +0100548 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
Harald Welte16a4adf2017-12-14 18:54:01 +0100549 alt {
550 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
551 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
552 }
Harald Welte235ebf12017-12-15 14:18:16 +0100553 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +0100554 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
555 setverdict(pass);
556 }
557 [] BSSAP.receive { repeat; }
558 }
559}
560
Harald Welteed848512018-05-24 22:27:58 +0200561/* generate an assignment request for either AoIP or SCCPlite */
562private function f_gen_ass_req() return PDU_BSSAP {
563 var PDU_BSSAP ass_cmd;
564 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
565 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
566 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
567 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
568 } else {
569 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
570 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
571 }
572 return ass_cmd;
573}
574
575/* generate an assignment complete template for either AoIP or SCCPlite */
576private function f_gen_exp_compl() return template PDU_BSSAP {
577 var template PDU_BSSAP exp_compl;
578 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
579 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
580 } else {
581 /* CIC is optional "*" as the MSC allocated it */
582 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
583 }
584 return exp_compl;
585}
586
Harald Welte235ebf12017-12-15 14:18:16 +0100587/* Run everything required up to sending a caller-specified assignment command and expect response */
588function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
589runs on test_CT {
590 var BSSAP_N_CONNECT_ind rx_c_ind;
591 var RSL_Message rx_rsl;
592 var DchanTuple dt;
593
Harald Welte89d42e82017-12-17 16:42:41 +0100594 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +0100595
596 dt := f_est_dchan('23'O, 23, '00000000'O);
597 /* send assignment without AoIP IEs */
598 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
599 alt {
600 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
601 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
602 setverdict(pass);
603 } else {
604 setverdict(fail, fail_text);
605 }
606 }
607 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
608 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
609 setverdict(pass);
610 } else {
611 setverdict(fail, fail_text);
612 }
613 }
614 [] BSSAP.receive { repeat; }
615 }
616}
617testcase TC_assignment_csd() runs on test_CT {
618 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200619 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100620 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
621 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
622 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
623}
624
625testcase TC_assignment_ctm() runs on test_CT {
626 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200627 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100628 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
629 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
630 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
631}
632
Harald Welte4003d112017-12-09 22:35:39 +0100633type record DchanTuple {
634 integer sccp_conn_id,
635 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +0100636}
637
Harald Welted6939652017-12-13 21:02:46 +0100638/* Send CHAN RQD and wait for allocation; acknowledge it */
639private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
640runs on test_CT return RslChannelNr {
641 var RSL_Message rx_rsl;
642 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
643 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
644 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
645 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
646 return chan_nr;
647}
648
Harald Welte4003d112017-12-09 22:35:39 +0100649/* helper function to establish a dedicated channel via BTS and MSC */
650function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
651runs on test_CT return DchanTuple {
652 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +0100653 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100654
Harald Welte4003d112017-12-09 22:35:39 +0100655 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100656 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +0100657
658 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
659
660 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
661 dt.sccp_conn_id := rx_c_ind.connectionId;
662 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
663
664 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100665}
666
Harald Welte4003d112017-12-09 22:35:39 +0100667/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
668testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
669 var RSL_Message rx_rsl;
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100670 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100671 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +0100672
Harald Welte89d42e82017-12-17 16:42:41 +0100673 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +0100674
Harald Welte4003d112017-12-09 22:35:39 +0100675 dt := f_est_dchan('23'O, 23, '00010203040506'O);
676
677 /* simulate RLL REL IND */
678 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
679
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100680 /* expect Clear Request on MSC side */
681 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
682
683 /* Instruct BSC to clear channel */
684 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
685 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
686
Harald Welte4003d112017-12-09 22:35:39 +0100687 /* expect BSC to disable the channel */
688 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
689 /* respond with CHAN REL ACK */
690 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
691
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100692 /* expect Clear Complete from BSC */
693 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
694
695 /* release the SCCP connection */
696 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
697
698 /* wait for SCCP emulation to do its job */
699 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +0100700
701 setverdict(pass);
702}
703
704/* Test behavior of channel release after CONN FAIL IND from BTS */
705testcase TC_chan_rel_conn_fail() runs on test_CT {
706 var BSSAP_N_DATA_ind rx_di;
707 var RSL_Message rx_rsl;
708 var DchanTuple dt;
709
Harald Welte89d42e82017-12-17 16:42:41 +0100710 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100711
712 dt := f_est_dchan('23'O, 23, '00010203040506'O);
713
714 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +0100715 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 +0100716 /* TODO: different cause values? */
717
Harald Welte4003d112017-12-09 22:35:39 +0100718 /* expect Clear Request from BSC */
719 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
720
721 /* Instruct BSC to clear channel */
722 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
723 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
724
Harald Welte6ff76ea2018-01-28 13:08:01 +0100725 /* expect BSC to disable the channel */
726 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
727 /* respond with CHAN REL ACK */
728 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
729
Harald Welte4003d112017-12-09 22:35:39 +0100730 /* expect Clear Complete from BSC */
731 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
732
733 /* release the SCCP connection */
734 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
735
736 /* wait for SCCP emulation to do its job */
737 f_sleep(1.0);
738
739 setverdict(pass);
740}
741
Harald Welte91d54a52018-01-28 15:35:07 +0100742function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr, boolean flush := true,
743 boolean handle_rll_rel := true) runs on test_CT {
744
745 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
746 if (flush) {
747 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
748 IPA_RSL[bts_nr].clear;
749 }
750 alt {
751 /* ignore DEACTIVATE SACCH (if any) */
752 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
753 tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
754 repeat;
755 }
756 /* acknowledge RLL release (if any)*/
757 [handle_rll_rel] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
758 tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
759 /* FIXME: Why are we getting this for LinkID SACCH? */
760 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
761 repeat;
762 }
763 /* Expect RF channel release from BSC on Abis */
764 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
765 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
766 /* respond with CHAN REL ACK */
767 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
768 }
769 /* ignore any user data */
770 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) {
771 repeat;
772 }
773 }
774}
775
Harald Welte4003d112017-12-09 22:35:39 +0100776/* Test behavior of channel release after hard Clear Command from MSC */
777testcase TC_chan_rel_hard_clear() runs on test_CT {
778 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100779 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +0100780
Harald Welte89d42e82017-12-17 16:42:41 +0100781 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100782
783 dt := f_est_dchan('23'O, 23, '00010203040506'O);
784
785 /* Instruct BSC to clear channel */
786 var BssmapCause cause := 0;
787 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
788
789 /* expect Clear Complete from BSC on A */
790 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
791 /* release the SCCP connection */
792 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
793 }
794
Harald Welte91d54a52018-01-28 15:35:07 +0100795 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welte4003d112017-12-09 22:35:39 +0100796 setverdict(pass);
797}
798
Harald Welted8c36cd2017-12-09 23:05:31 +0100799/* Test behavior of channel release after hard RLSD from MSC */
800testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +0100801 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +0100802
Harald Welte89d42e82017-12-17 16:42:41 +0100803 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +0100804
805 dt := f_est_dchan('23'O, 23, '00010203040506'O);
806
807 /* release the SCCP connection */
808 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
809
Harald Welte91d54a52018-01-28 15:35:07 +0100810 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welted8c36cd2017-12-09 23:05:31 +0100811 setverdict(pass);
812}
813
Harald Welte85804d42017-12-10 14:11:58 +0100814/* Test behavior of channel release after BSSMAP RESET from MSC */
815testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +0100816 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +0100817
Harald Welte89d42e82017-12-17 16:42:41 +0100818 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +0100819
820 dt := f_est_dchan('23'O, 23, '00010203040506'O);
821
822 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
823 IPA_RSL[0].clear;
824
825 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Harald Weltea4ca4462018-02-09 00:17:14 +0100826 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 +0100827 interleave {
Harald Weltea4ca4462018-02-09 00:17:14 +0100828 [] 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 +0100829 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
830 }
831
Philipp Maiere8f38ed2018-02-09 10:30:31 +0100832 f_expect_chan_rel(0, dt.rsl_chan_nr, false);
Harald Welte85804d42017-12-10 14:11:58 +0100833 setverdict(pass);
834}
835
Harald Welte5cd20ed2017-12-13 21:03:20 +0100836/* Test behavior if RSL EST IND for non-active channel */
837testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
838 timer T := 2.0;
839
Harald Welte89d42e82017-12-17 16:42:41 +0100840 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100841
842 var octetstring l3 := '00010203040506'O;
843 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
844 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
845
846 T.start;
847 alt {
848 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
849 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
850 }
851 [] BSSAP.receive {}
852 [] IPA_RSL[0].receive {}
853 [] T.timeout {}
854 }
855
856 setverdict(pass);
857}
858
859/* Test behavior if RSL EST IND for invalid SAPI */
860testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
861 var RslChannelNr chan_nr;
862
Harald Welte89d42e82017-12-17 16:42:41 +0100863 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100864
865 chan_nr := f_chreq_act_ack()
866
867 var octetstring l3 := '00010203040506'O;
868 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
869
870 timer T := 2.0;
871 T.start;
872 alt {
873 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
874 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
875 }
876 [] BSSAP.receive { repeat; }
877 [] IPA_RSL[0].receive { repeat; }
878 [] T.timeout {}
879 }
880
881 setverdict(pass);
882}
883
884/* Test behavior if RSL EST IND for invalid SAPI */
885testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
886 timer T := 2.0;
887
Harald Welte89d42e82017-12-17 16:42:41 +0100888 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100889
890 var RslChannelNr chan_nr := f_chreq_act_ack();
891
892 var octetstring l3 := '00010203040506'O;
893 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
894
895 T.start;
896 alt {
897 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
898 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
899 }
900 [] BSSAP.receive { repeat; }
901 [] IPA_RSL[0].receive { repeat; }
902 [] T.timeout {}
903 }
904
905 setverdict(pass);
906}
907
908/* Test behavior if RSL EST IND for invalid SACCH */
909testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
910 timer T := 2.0;
911
Harald Welte89d42e82017-12-17 16:42:41 +0100912 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100913
914 var RslChannelNr chan_nr := f_chreq_act_ack();
915
916 var octetstring l3 := '00010203040506'O;
917 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
918
919 T.start;
920 alt {
921 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
922 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
923 }
924 [] BSSAP.receive { repeat; }
925 [] IPA_RSL[0].receive { repeat; }
926 [] T.timeout {}
927 }
928
929 setverdict(pass);
930}
931
932
933
Harald Welte4003d112017-12-09 22:35:39 +0100934
935testcase TC_ctrl_msc_connection_status() runs on test_CT {
936 var charstring ctrl_resp;
937
Harald Welte89d42e82017-12-17 16:42:41 +0100938 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100939
940 /* See https://osmocom.org/issues/2729 */
941 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
942 setverdict(pass);
943}
944
Stefan Sperlingb041b3d2018-01-03 17:14:55 +0100945testcase TC_ctrl_msc0_connection_status() runs on test_CT {
946 var charstring ctrl_resp;
947
948 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +0100949
950 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
951 setverdict(pass);
952}
953
Harald Welte4003d112017-12-09 22:35:39 +0100954testcase TC_ctrl() runs on test_CT {
955 var charstring ctrl_resp;
956
Harald Welte89d42e82017-12-17 16:42:41 +0100957 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100958
959 /* all below values must match the osmo-bsc.cfg config file used */
960
Harald Welte6a129692018-03-17 17:30:14 +0100961 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
962 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Harald Welte44bdaa52017-12-17 17:01:47 +0100963 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "3");
Harald Welte4003d112017-12-09 22:35:39 +0100964
965 var integer bts_nr := 0;
966 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
967 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
968 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
969 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
970 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
971 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
972 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
973
974 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
975 f_sleep(2.0);
976 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
977 setverdict(fail, "oml-uptime not incrementing as expected");
978 }
979 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
980
981 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
982
983 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +0100984}
985
Harald Welte6f521d82017-12-11 19:52:02 +0100986function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100987 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, bssap));
Harald Welte6f521d82017-12-11 19:52:02 +0100988}
989
990
991/***********************************************************************
992 * Paging Testing
993 ***********************************************************************/
994
995type record Cell_Identity {
996 GsmMcc mcc,
997 GsmMnc mnc,
998 GsmLac lac,
999 GsmCellId ci
1000};
Harald Welte24135bd2018-03-17 19:27:53 +01001001private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001002private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001003
Harald Welte5d1a2202017-12-13 19:51:29 +01001004type set of integer BtsIdList;
1005
1006private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1007 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1008 if (bts_id == bts_ids[j]) {
1009 return true;
1010 }
1011 }
1012 return false;
1013}
Harald Welte6f521d82017-12-11 19:52:02 +01001014
1015/* core paging test helper function; used by most paging test cases */
1016private function f_pageing_helper(hexstring imsi,
1017 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001018 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001019 template RSL_ChanNeeded rsl_chneed := omit,
1020 template OCT4 tmsi := omit) runs on test_CT
1021{
1022 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
1023 var MobileIdentity mi;
1024 var template octetstring id_enc; /* FIXME */
1025 var RSL_Message rx_rsl;
1026 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001027 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001028
1029 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001030
1031 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001032 for (i := 0; i < NUM_BTS; i := i + 1) {
1033 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001034 }
Harald Welte6f521d82017-12-11 19:52:02 +01001035
1036 if (isvalue(rsl_chneed)) {
1037 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1038 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1039 } else {
1040 bssmap_chneed := omit;
1041 }
1042
1043 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
1044
1045/* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder
1046 if (isvalue(tmsi)) {
1047 mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi))));
1048 } else {
1049 mi := valueof(ts_Osmo_MI_IMSI(imsi));
1050 }
1051 id_enc := enc_MobileIdentity(mi);
1052*/
1053 id_enc := ?;
Harald Welte5d1a2202017-12-13 19:51:29 +01001054 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
1055 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc));
1056 /* check channel type, paging group */
1057 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1058 setverdict(fail, "Paging for wrong paging group");
1059 }
1060 if (ispresent(rsl_chneed) and
1061 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1062 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1063 }
Harald Welte6f521d82017-12-11 19:52:02 +01001064 }
Harald Welte2fccd982018-01-31 15:48:19 +01001065 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001066 /* do a quick check on all not-included BTSs if they received paging */
1067 for (i := 0; i < NUM_BTS; i := i + 1) {
1068 timer T := 0.1;
1069 if (f_bts_in_list(i, bts_ids)) {
1070 continue;
1071 }
1072 T.start;
1073 alt {
1074 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) {
1075 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1076 }
1077 [] IPA_RSL[i].receive { repeat; }
1078 [] T.timeout { }
1079 }
Harald Welte6f521d82017-12-11 19:52:02 +01001080 }
1081
1082 setverdict(pass);
1083}
1084
Harald Welte5d1a2202017-12-13 19:51:29 +01001085const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001086const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001087const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1088const BtsIdList c_BtsId_LAC2 := { 2 };
1089
Harald Welte6f521d82017-12-11 19:52:02 +01001090/* PAGING by IMSI + TMSI */
1091testcase TC_paging_imsi_nochan() runs on test_CT {
1092 var BSSMAP_FIELD_CellIdentificationList cid_list;
1093 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001094 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001095 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001096}
1097
1098/* PAGING by IMSI + TMSI */
1099testcase TC_paging_tmsi_nochan() runs on test_CT {
1100 var BSSMAP_FIELD_CellIdentificationList cid_list;
1101 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001102 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001103 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001104}
1105
1106/* Paging with different "channel needed' values */
1107testcase TC_paging_tmsi_any() runs on test_CT {
1108 var BSSMAP_FIELD_CellIdentificationList cid_list;
1109 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001110 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001111 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001112}
1113testcase TC_paging_tmsi_sdcch() runs on test_CT {
1114 var BSSMAP_FIELD_CellIdentificationList cid_list;
1115 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001116 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001117 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001118}
1119testcase TC_paging_tmsi_tch_f() runs on test_CT {
1120 var BSSMAP_FIELD_CellIdentificationList cid_list;
1121 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001122 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001123 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001124}
1125testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1126 var BSSMAP_FIELD_CellIdentificationList cid_list;
1127 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001128 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001129 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001130}
1131
1132/* Paging by CGI */
1133testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1134 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1135 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001136 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001137 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001138}
1139
1140/* Paging by LAC+CI */
1141testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1142 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1143 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001144 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001145 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001146}
1147
1148/* Paging by CI */
1149testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1150 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1151 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001152 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001153 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001154}
1155
1156/* Paging by LAI */
1157testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1158 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1159 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001160 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001161 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001162}
1163
1164/* Paging by LAC */
1165testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1166 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1167 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001168 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001169 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001170}
1171
1172/* Paging by "all in BSS" */
1173testcase TC_paging_imsi_nochan_all() runs on test_CT {
1174 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1175 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001176 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001177 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001178}
1179
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001180/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001181testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1182 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1183 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 +01001184 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001185 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001186}
Harald Welte6f521d82017-12-11 19:52:02 +01001187
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001188/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001189testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1190 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1191 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001192 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001193 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001194}
1195
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001196/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001197testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1198 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1199 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001200 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001201 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001202}
1203
Harald Welte6f521d82017-12-11 19:52:02 +01001204/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001205testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1206 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1207 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1208 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001209 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001210}
1211
1212/* Paging on empty list: Verify none of them page */
1213testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1214 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1215 cid_list := { cIl_LAC := { } };
1216 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001217 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001218}
1219
Stefan Sperling049a86e2018-03-20 15:51:00 +01001220/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1221testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1222 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1223 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1224 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1225 f_shutdown_helper();
1226}
1227
Harald Welte6f521d82017-12-11 19:52:02 +01001228/* Verify paging retransmission interval + count */
1229/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001230/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001231
Harald Weltee65d40e2017-12-13 00:09:06 +01001232/* Verify PCH load */
1233testcase TC_paging_imsi_load() runs on test_CT {
1234 var BSSMAP_FIELD_CellIdentificationList cid_list;
1235 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001236 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001237 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001238 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001239
1240 /* tell BSC there is no paging space anymore */
1241 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001242 f_sleep(0.2);
1243 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001244
1245 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1246 * there would be 8 retransmissions during 4 seconds */
1247 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001248 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001249 alt {
1250 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1251 setverdict(fail, "Received PAGING after LOAD_IND(0)");
1252 self.stop;
1253 }
Harald Welte2caa1062018-03-17 18:19:05 +01001254 [] T_retrans.timeout {
1255 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1256 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1257 T_retrans.start;
1258 repeat;
1259 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001260 [] T.timeout {
1261 setverdict(pass);
1262 }
1263 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001264
1265 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001266}
1267
Harald Welte235ebf12017-12-15 14:18:16 +01001268/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001269testcase TC_paging_counter() runs on test_CT {
1270 var BSSMAP_FIELD_CellIdentificationList cid_list;
1271 timer T := 4.0;
1272 var integer i;
1273 var integer paging_attempted_bsc;
1274 var integer paging_attempted_bts[NUM_BTS];
1275 var integer paging_expired_bts[NUM_BTS];
1276 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1277
1278 f_init();
1279
1280 /* read counters before paging */
1281 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1282 for (i := 0; i < NUM_BTS; i := i+1) {
1283 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1284 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1285 }
1286
1287 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1288
1289 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1290 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1291 for (i := 0; i < NUM_BTS; i := i+1) {
1292 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1293 paging_attempted_bts[i]+1);
1294 }
1295
1296 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1297 f_sleep(12.0);
1298 for (i := 0; i < NUM_BTS; i := i+1) {
1299 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1300 paging_expired_bts[i]+1);
1301 }
Harald Welte1ff69992017-12-14 12:31:17 +01001302
Philipp Maier282ca4b2018-02-27 17:17:00 +01001303 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001304}
1305
1306
Harald Welte10985002017-12-12 09:29:15 +01001307/* Verify paging stops after A-RESET */
1308testcase TC_paging_imsi_a_reset() runs on test_CT {
1309 var BSSMAP_FIELD_CellIdentificationList cid_list;
1310 timer T := 3.0;
1311 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001312 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001313
1314 /* Perform a BSSMAP Reset and wait for ACK */
Harald Weltea4ca4462018-02-09 00:17:14 +01001315 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 +01001316 alt {
Harald Weltea4ca4462018-02-09 00:17:14 +01001317 [] 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 +01001318 [] BSSAP.receive { repeat; }
1319 }
1320
1321 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001322 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1323 IPA_RSL[i].clear;
1324 }
Harald Welte10985002017-12-12 09:29:15 +01001325
1326 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1327 T.start;
1328 alt {
1329 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1330 setverdict(fail, "Received PAGING after A-RESET");
1331 self.stop;
1332 }
Harald Welte5d1a2202017-12-13 19:51:29 +01001333 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1334 setverdict(fail, "Received PAGING after A-RESET");
1335 self.stop;
1336 }
1337 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1338 setverdict(fail, "Received PAGING after A-RESET");
1339 self.stop;
1340 }
Harald Welte10985002017-12-12 09:29:15 +01001341 [] T.timeout {
1342 setverdict(pass);
1343 }
1344 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001345
1346 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001347}
Harald Welteae026692017-12-09 01:03:01 +01001348
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001349/* Test RSL link drop causes counter increment */
1350testcase TC_rsl_drop_counter() runs on test_CT {
1351 var integer rsl_fail;
1352
Harald Welte89d42e82017-12-17 16:42:41 +01001353 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001354
1355 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1356
1357 bts[0].rsl.vc_IPA.stop;
1358
1359 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1360
1361 setverdict(pass);
1362}
1363
1364/* TODO: Test OML link drop causes counter increment */
1365
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001366/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1367function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1368 timer T := 10.0;
1369
1370 bts[0].rsl.id := "IPA-0-RSL";
1371 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1372 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1373 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
1374 bts[0].rsl.ccm_pars.unit_id := "0/0/0"; /* value which is unknown at BTS */
1375
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001376 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1377
1378 f_init_mgcp("VirtMSC");
1379
1380 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1381 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1382 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1383 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1384
1385 /* wait for IPA OML link to connect and then disconnect */
1386 T.start;
1387 alt {
1388 [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) {
1389 T.stop;
1390 return true;
1391 }
1392 [] IPA_RSL[0].receive { repeat }
1393 [] T.timeout {
1394 self.stop;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001395 }
1396 }
1397
1398 return false;
1399}
1400
1401/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1402testcase TC_rsl_unknown_unit_id() runs on test_CT {
1403 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1404 setverdict(pass);
1405 } else {
1406 setverdict(fail, "Timeout RSL waiting for connection to close");
1407 }
1408}
1409
1410
1411/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1412testcase TC_oml_unknown_unit_id() runs on test_CT {
1413 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1414 setverdict(pass);
1415 } else {
1416 setverdict(fail, "Timeout OML waiting for connection to close");
1417 }
1418}
1419
1420
Harald Weltec1a2fff2017-12-17 11:06:19 +01001421/***********************************************************************
1422 * "New world" test cases using RSL_Emulation + BSSMAP_Emulation
1423 ***********************************************************************/
1424
1425import from BSSMAP_Emulation all;
1426import from RSL_Emulation all;
1427import from MSC_ConnectionHandler all;
1428
1429type function void_fn(charstring id) runs on MSC_ConnHdlr;
1430
1431/* helper function to create, connect and start a MSC_ConnHdlr component */
Harald Welte8863fa12018-05-10 20:15:27 +02001432function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
Harald Weltea0630032018-03-20 21:09:55 +01001433runs on test_CT return MSC_ConnHdlr {
Harald Welte8863fa12018-05-10 20:15:27 +02001434 var charstring id := testcasename();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001435 var MSC_ConnHdlr vc_conn;
1436
1437 vc_conn := MSC_ConnHdlr.create(id);
Harald Weltea4ca4462018-02-09 00:17:14 +01001438 connect(vc_conn:BSSMAPEM, g_bssap.vc_BSSMAP:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001439 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001440 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001441 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001442 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001443 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1444 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1445 }
Harald Weltea4ca4462018-02-09 00:17:14 +01001446 connect(vc_conn:BSSAP, g_bssap.vc_BSSMAP:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001447 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Harald Weltea0630032018-03-20 21:09:55 +01001448 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001449 return vc_conn;
1450}
1451
Harald Weltea0630032018-03-20 21:09:55 +01001452/* first function inside ConnHdlr component; sets g_pars + starts function */
1453private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1454runs on MSC_ConnHdlr {
1455 if (isvalue(pars)) {
1456 g_pars := valueof(pars);
1457 }
1458 fn.apply(id);
1459}
1460
Harald Welte3c86ea02018-05-10 22:28:05 +02001461/* Establish signalling channel (non-assignment case) followed by cipher mode */
1462private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001463 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1464 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001465 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
1466
1467 // Disable generation of ASSIGNMENT CMD, as OsmoBSC currently performs MODE MODFIY sign->sign (OS#2936)
1468 //f_establish_fully(ass_cmd, exp_compl);
1469 f_establish_fully(omit, exp_compl);
1470}
1471testcase TC_ciph_mode_a5_0() runs on test_CT {
1472 var MSC_ConnHdlr vc_conn;
1473 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1474 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1475
1476 f_init(1, true);
1477 f_sleep(1.0);
1478 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1479 vc_conn.done;
1480}
1481testcase TC_ciph_mode_a5_1() runs on test_CT {
1482 var MSC_ConnHdlr vc_conn;
1483 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1484 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1485
1486 f_init(1, true);
1487 f_sleep(1.0);
1488 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1489 vc_conn.done;
1490}
1491testcase TC_ciph_mode_a5_3() runs on test_CT {
1492 var MSC_ConnHdlr vc_conn;
1493 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1494 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1495
1496 f_init(1, true);
1497 f_sleep(1.0);
1498 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1499 vc_conn.done;
1500}
1501
1502
1503/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001504private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001505 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1506 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001507
Harald Welte552620d2017-12-16 23:21:36 +01001508 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1509 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001510
Harald Weltea0630032018-03-20 21:09:55 +01001511 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001512}
Harald Welte552620d2017-12-16 23:21:36 +01001513testcase TC_assignment_fr_a5_0() runs on test_CT {
1514 var MSC_ConnHdlr vc_conn;
Harald Welte651fcdc2018-05-10 20:23:16 +02001515 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1516 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001517
Harald Welte89d42e82017-12-17 16:42:41 +01001518 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001519 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001520 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001521 vc_conn.done;
1522}
Harald Welte552620d2017-12-16 23:21:36 +01001523testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001524 var MSC_ConnHdlr vc_conn;
Harald Welte651fcdc2018-05-10 20:23:16 +02001525 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1526 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001527
Harald Welte89d42e82017-12-17 16:42:41 +01001528 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001529 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001530 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1531 vc_conn.done;
1532}
1533testcase TC_assignment_fr_a5_3() runs on test_CT {
1534 var MSC_ConnHdlr vc_conn;
1535 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1536 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001537
Harald Welte651fcdc2018-05-10 20:23:16 +02001538 f_init(1, true);
1539 f_sleep(1.0);
1540 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001541 vc_conn.done;
1542}
1543
Harald Welte552620d2017-12-16 23:21:36 +01001544/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1545private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001546 g_pars := valueof(t_def_TestHdlrPars);
Harald Welte552620d2017-12-16 23:21:36 +01001547 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001548 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001549 const OCT8 kc := '0001020304050607'O;
1550
1551 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Harald Weltea0630032018-03-20 21:09:55 +01001552 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001553}
Harald Welte552620d2017-12-16 23:21:36 +01001554testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1555 var MSC_ConnHdlr vc_conn;
1556
Harald Welte89d42e82017-12-17 16:42:41 +01001557 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001558 f_sleep(1.0);
1559
Harald Welte8863fa12018-05-10 20:15:27 +02001560 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001561 vc_conn.done;
1562}
1563
Harald Welte552620d2017-12-16 23:21:36 +01001564private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001565 g_pars := valueof(t_def_TestHdlrPars);
Harald Welteed848512018-05-24 22:27:58 +02001566 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1567 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001568 const OCT8 kc := '0001020304050607'O;
1569 const OCT16 kc128 := kc & kc;
1570
1571 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1572 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001573 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001574 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001575 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001576}
Harald Welte552620d2017-12-16 23:21:36 +01001577testcase TC_assignment_fr_a5_4() runs on test_CT {
1578 var MSC_ConnHdlr vc_conn;
1579
Harald Welte89d42e82017-12-17 16:42:41 +01001580 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001581 f_sleep(1.0);
1582
Harald Welte8863fa12018-05-10 20:15:27 +02001583 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001584 vc_conn.done;
1585}
1586
1587
Harald Welte4532e0a2017-12-23 02:05:44 +01001588private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier6a50c7c2018-04-16 16:15:59 +02001589 g_pars := valueof(t_def_TestHdlrPars);
Harald Welte4532e0a2017-12-23 02:05:44 +01001590 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
1591 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, omit));
1592
1593 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001594 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001595}
1596
1597testcase TC_assignment_sign() runs on test_CT {
1598 var MSC_ConnHdlr vc_conn;
1599
1600 f_init(1, true);
1601 f_sleep(1.0);
1602
Harald Welte8863fa12018-05-10 20:15:27 +02001603 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001604 vc_conn.done;
1605}
1606
Harald Welte60aa5762018-03-21 19:33:13 +01001607/***********************************************************************
1608 * Codec (list) testing
1609 ***********************************************************************/
1610
1611/* check if the given rsl_mode is compatible with the a_elem */
1612private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1613return boolean {
1614 select (a_elem.codecType) {
1615 case (GSM_FR) {
1616 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1617 return true;
1618 }
1619 }
1620 case (GSM_HR) {
1621 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1622 return true;
1623 }
1624 }
1625 case (GSM_EFR) {
1626 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1627 return true;
1628 }
1629 }
1630 case (FR_AMR) {
1631 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1632 return true;
1633 }
1634 }
1635 case (HR_AMR) {
1636 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1637 return true;
1638 }
1639 }
1640 case else { }
1641 }
1642 return false;
1643}
1644
1645/* check if the given rsl_mode is compatible with the a_list */
1646private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
1647return boolean {
1648 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
1649 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
1650 return true;
1651 }
1652 }
1653 return false;
1654}
1655
1656/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
1657private function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
1658return BSSMAP_IE_ChannelType {
1659 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
1660 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
1661 select (a_elem.codecType) {
1662 case (GSM_FR) {
1663 ret.channelRateAndType := ChRate_TCHF;
1664 ret.speechId_DataIndicator := Spdi_TCHF_FR;
1665 }
1666 case (GSM_HR) {
1667 ret.channelRateAndType := ChRate_TCHH;
1668 ret.speechId_DataIndicator := Spdi_TCHH_HR;
1669 }
1670 case (GSM_EFR) {
1671 ret.channelRateAndType := ChRate_TCHF;
1672 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
1673 }
1674 case (FR_AMR) {
1675 ret.channelRateAndType := ChRate_TCHF;
1676 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
1677 }
1678 case (HR_AMR) {
1679 ret.channelRateAndType := ChRate_TCHH;
1680 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
1681 }
1682 case else {
1683 setverdict(fail, "Unsupported codec ", a_elem);
1684 self.stop;
1685 }
1686 }
1687 return ret;
1688}
1689
Harald Weltea63b9102018-03-22 20:36:16 +01001690private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
1691return template RSL_IE_Body {
1692 var template RSL_IE_Body mode_ie := {
1693 chan_mode := {
1694 len := ?,
1695 reserved := ?,
1696 dtx_d := ?,
1697 dtx_u := ?,
1698 spd_ind := RSL_SPDI_SPEECH,
1699 ch_rate_type := -,
1700 coding_alg_rate := -
1701 }
1702 }
1703
1704 select (a_elem.codecType) {
1705 case (GSM_FR) {
1706 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1707 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1708 }
1709 case (GSM_HR) {
1710 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1711 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1712 }
1713 case (GSM_EFR) {
1714 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1715 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
1716 }
1717 case (FR_AMR) {
1718 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1719 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1720 }
1721 case (HR_AMR) {
1722 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1723 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1724 }
1725 }
1726 return mode_ie;
1727}
1728
Harald Welte60aa5762018-03-21 19:33:13 +01001729type record CodecListTest {
1730 BSSMAP_IE_SpeechCodecList codec_list,
1731 charstring id
1732}
1733type record of CodecListTest CodecListTests
1734
1735private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001736 var PDU_BSSAP ass_cmd := f_gen_ass_req();
1737 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
Harald Welte60aa5762018-03-21 19:33:13 +01001738
1739 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Harald Welte79f3f542018-05-25 20:02:37 +02001740 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
1741 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
1742 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
1743 g_pars.ass_codec_list.codecElements[0];
1744 }
Harald Welte60aa5762018-03-21 19:33:13 +01001745 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
1746 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01001747 log("expecting ASS COMPL like this: ", exp_compl);
1748
1749 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01001750
1751 /* Verify that the RSL-side activation actually matches our expectations */
1752 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
1753
1754 var RSL_IE_Body mode_ie;
1755 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
1756 setverdict(fail, "Couldn't find CHAN_MODE IE");
1757 self.stop;
1758 }
1759 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
1760 if (not match(mode_ie, t_mode_ie)) {
1761 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
1762 }
Harald Welte60aa5762018-03-21 19:33:13 +01001763}
1764
1765testcase TC_assignment_codec_fr() runs on test_CT {
1766 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1767 var MSC_ConnHdlr vc_conn;
1768
1769 f_init(1, true);
1770 f_sleep(1.0);
1771
1772 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001773 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001774 vc_conn.done;
1775}
1776
1777testcase TC_assignment_codec_hr() runs on test_CT {
1778 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1779 var MSC_ConnHdlr vc_conn;
1780
1781 f_init(1, true);
1782 f_sleep(1.0);
1783
1784 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001785 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001786 vc_conn.done;
1787}
1788
1789testcase TC_assignment_codec_efr() runs on test_CT {
1790 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1791 var MSC_ConnHdlr vc_conn;
1792
1793 f_init(1, true);
1794 f_sleep(1.0);
1795
1796 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001797 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001798 vc_conn.done;
1799}
1800
1801testcase TC_assignment_codec_amr_f() runs on test_CT {
1802 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1803 var MSC_ConnHdlr vc_conn;
1804
1805 f_init(1, true);
1806 f_sleep(1.0);
1807
1808 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Harald Welte8863fa12018-05-10 20:15:27 +02001809 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001810 vc_conn.done;
1811}
1812
1813testcase TC_assignment_codec_amr_h() runs on test_CT {
1814 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1815 var MSC_ConnHdlr vc_conn;
1816
1817 f_init(1, true);
1818 f_sleep(1.0);
1819
1820 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Harald Welte8863fa12018-05-10 20:15:27 +02001821 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001822 vc_conn.done;
1823}
1824
1825
1826
Harald Welte898113b2018-01-31 18:32:21 +01001827/* test if L3 RR CLASSMARK CHANGE is translated to BSSMAP CLASSMARK UPDATE */
1828private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001829 g_pars := valueof(t_def_TestHdlrPars);
1830 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01001831 /* we should now have a COMPL_L3 at the MSC */
1832 BSSAP.receive(tr_BSSMAP_ComplL3);
1833
1834 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
1835 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
1836 setverdict(pass);
1837}
1838testcase TC_classmark() runs on test_CT {
1839 var MSC_ConnHdlr vc_conn;
1840 f_init(1, true);
1841 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001842 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01001843 vc_conn.done;
1844}
1845
Harald Weltee3bd6582018-01-31 22:51:25 +01001846private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001847 g_pars := valueof(t_def_TestHdlrPars);
1848 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01001849 /* we should now have a COMPL_L3 at the MSC */
1850 BSSAP.receive(tr_BSSMAP_ComplL3);
1851
Harald Weltee3bd6582018-01-31 22:51:25 +01001852 /* send the single message we want to send */
1853 f_rsl_send_l3(l3);
1854}
1855
1856private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
1857 timer T := sec;
1858 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01001859 T.start;
1860 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01001861 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
1862 setverdict(fail, "Unexpected BSSMAP ", bssap);
1863 self.stop;
Harald Welte898113b2018-01-31 18:32:21 +01001864 }
1865 [] T.timeout {
1866 setverdict(pass);
1867 }
1868 }
1869}
1870
Harald Weltee3bd6582018-01-31 22:51:25 +01001871/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
1872private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
1873 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
1874 f_bssap_expect_nothing();
1875}
Harald Welte898113b2018-01-31 18:32:21 +01001876testcase TC_unsol_ass_fail() runs on test_CT {
1877 var MSC_ConnHdlr vc_conn;
1878 f_init(1, true);
1879 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001880 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01001881 vc_conn.done;
1882}
Harald Welte552620d2017-12-16 23:21:36 +01001883
Harald Welteea99a002018-01-31 20:46:43 +01001884
1885/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
1886private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01001887 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
1888 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01001889}
1890testcase TC_unsol_ass_compl() runs on test_CT {
1891 var MSC_ConnHdlr vc_conn;
1892 f_init(1, true);
1893 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001894 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01001895 vc_conn.done;
1896}
1897
1898
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001899/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
1900private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01001901 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
1902 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001903}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001904testcase TC_unsol_ho_fail() runs on test_CT {
1905 var MSC_ConnHdlr vc_conn;
1906 f_init(1, true);
1907 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001908 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001909 vc_conn.done;
1910}
1911
1912
Harald Weltee3bd6582018-01-31 22:51:25 +01001913/* short message from MS should be ignored */
1914private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001915 g_pars := valueof(t_def_TestHdlrPars);
1916 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01001917 /* we should now have a COMPL_L3 at the MSC */
1918 BSSAP.receive(tr_BSSMAP_ComplL3);
1919
1920 /* send short message */
1921 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
1922 f_bssap_expect_nothing();
1923}
1924testcase TC_err_82_short_msg() runs on test_CT {
1925 var MSC_ConnHdlr vc_conn;
1926 f_init(1, true);
1927 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001928 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01001929 vc_conn.done;
1930}
1931
1932
Harald Weltee9e02e42018-01-31 23:36:25 +01001933/* 24.008 8.4 Unknown message must trigger RR STATUS */
1934private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
1935 f_est_single_l3(ts_RRM_UL_REL('00'O));
1936 timer T := 3.0
1937 alt {
1938 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
1939 setverdict(pass);
1940 }
1941 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01001942 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01001943 }
1944}
1945testcase TC_err_84_unknown_msg() runs on test_CT {
1946 var MSC_ConnHdlr vc_conn;
1947 f_init(1, true);
1948 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001949 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01001950 vc_conn.done;
1951}
1952
Harald Welte94e0c342018-04-07 11:33:23 +02001953/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
1954private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
1955runs on test_CT {
1956 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
1957 " timeslot "&int2str(ts_nr)&" ";
1958 f_vty_transceive(BSCVTY, cmd & suffix);
1959}
1960
Harald Welte261af4b2018-02-12 21:20:39 +01001961/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
1962private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
1963runs on MSC_ConnHdlr {
1964 /* FIXME: resolve those from component-global state */
1965 var integer ts_nr := chan_nr.tn;
1966 var integer ss_nr;
1967 if (ischosen(chan_nr.u.ch0)) {
1968 ss_nr := 0;
1969 } else if (ischosen(chan_nr.u.lm)) {
1970 ss_nr := chan_nr.u.lm.sub_chan;
1971 } else if (ischosen(chan_nr.u.sdcch4)) {
1972 ss_nr := chan_nr.u.sdcch4.sub_chan;
1973 } else if (ischosen(chan_nr.u.sdcch8)) {
1974 ss_nr := chan_nr.u.sdcch8.sub_chan;
1975 } else {
1976 setverdict(fail, "Invalid ChanNr ", chan_nr);
1977 self.stop;
1978 }
1979
1980 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
1981 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
1982 f_vty_transceive(BSCVTY, cmd & suffix);
1983}
1984
1985private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
1986 integer new_bts_nr)
1987runs on MSC_ConnHdlr {
1988 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
1989}
1990
1991/* intra-BSC hand-over between BTS0 and BTS1 */
1992private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001993 g_pars := valueof(t_def_TestHdlrPars);
Harald Welteed848512018-05-24 22:27:58 +02001994 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1995 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01001996 const OCT8 kc := '0001020304050607'O;
1997
1998 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1999 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2000
Harald Weltea0630032018-03-20 21:09:55 +01002001 f_establish_fully(ass_cmd, exp_compl);
Harald Welte261af4b2018-02-12 21:20:39 +01002002
2003 var HandoverState hs := {
2004 rr_ho_cmpl_seen := false,
2005 handover_done := false,
2006 old_chan_nr := -
2007 };
2008 /* issue hand-over command on VTY */
2009 f_vty_handover(0, 0, g_chan_nr, 1);
2010 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2011 f_rslem_suspend(RSL1_PROC);
2012 alt {
2013 [] as_handover(hs);
2014 /* FIXME: somehow determine that the hand-over has completed, by MGCP MDCX? */
2015 }
2016}
2017
2018testcase TC_ho_int() runs on test_CT {
2019 var MSC_ConnHdlr vc_conn;
2020 f_init(2, true);
2021 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002022 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002023 vc_conn.done;
2024}
Harald Weltee9e02e42018-01-31 23:36:25 +01002025
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01002026/* OS#3041: Open and close N connections in a normal fashion, and expect no
2027 * BSSMAP Reset just because of that. */
2028testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
2029 var default d;
2030 var integer i;
2031 var DchanTuple dt;
2032
2033 f_init();
2034
2035 /* Wait for initial BSSMAP Reset to pass */
2036 f_sleep(4.0);
2037
2038 d := activate(no_bssmap_reset());
2039
2040 /* Setup up a number of connections and RLSD them again from the MSC
2041 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2042 * Let's do it some more times for good measure. */
2043 for (i := 0; i < 8; i := i+1) {
2044 /* Since we're doing a lot of runs, give each one a fresh
2045 * T_guard from the top. */
2046 T_guard.start;
2047
2048 /* Setup a BSSAP connection and clear it right away. This is
2049 * the MSC telling the BSC about a planned release, it's not an
2050 * erratic loss of a connection. */
2051 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2052
2053 /* MSC disconnects (RLSD). */
2054 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2055 }
2056
2057 /* In the buggy behavior, a timeout of 2 seconds happens between above
2058 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2059 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2060 f_sleep(4.0);
2061
2062 deactivate(d);
2063 f_shutdown_helper();
2064}
Harald Welte552620d2017-12-16 23:21:36 +01002065
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01002066/* OS#3041: Open and close N connections in a normal fashion, and expect no
2067 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
2068 * the MSC. */
2069testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
2070 var default d;
2071 var integer i;
2072 var DchanTuple dt;
2073 var BSSAP_N_DATA_ind rx_di;
2074 var RSL_Message rx_rsl;
2075 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
2076 var BssmapCause cause := enum2int(cause_val);
2077
2078 f_init();
2079
2080 /* Wait for initial BSSMAP Reset to pass */
2081 f_sleep(4.0);
2082
2083 d := activate(no_bssmap_reset());
2084
2085 /* Setup up a number of connections and RLSD them again from the MSC
2086 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2087 * Let's do it some more times for good measure. */
2088 for (i := 0; i < 8; i := i+1) {
2089 /* Since we're doing a lot of runs, give each one a fresh
2090 * T_guard from the top. */
2091 T_guard.start;
2092
2093 /* Setup a BSSAP connection and clear it right away. This is
2094 * the MSC telling the BSC about a planned release, it's not an
2095 * erratic loss of a connection. */
2096 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2097
2098 /* Instruct BSC to clear channel */
2099 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2100
2101 /* expect BSC to disable the channel */
2102 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
2103 /* respond with CHAN REL ACK */
2104 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
2105
2106 /* expect Clear Complete from BSC */
2107 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
2108
2109 /* MSC disconnects as instructed. */
2110 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2111
2112
2113 /* MSC disconnects (RLSD). */
2114 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2115 }
2116
2117 /* In the buggy behavior, a timeout of 2 seconds happens between above
2118 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2119 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2120 f_sleep(4.0);
2121
2122 deactivate(d);
2123 f_shutdown_helper();
2124}
2125
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01002126/* OS#3041: Open and close N connections in a normal fashion, and expect no
2127 * BSSMAP Reset just because of that. Close connections from the MS side with a
2128 * Release Ind on RSL. */
2129testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
2130 var default d;
2131 var integer i;
2132 var DchanTuple dt;
2133 var BSSAP_N_DATA_ind rx_di;
2134 var RSL_Message rx_rsl;
2135 var integer j;
2136
2137 f_init();
2138
2139 /* Wait for initial BSSMAP Reset to pass */
2140 f_sleep(4.0);
2141
2142 d := activate(no_bssmap_reset());
2143
2144 /* Setup up a number of connections and RLSD them again from the MSC
2145 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2146 * Let's do it some more times for good measure. */
2147 for (i := 0; i < 8; i := i+1) {
2148 /* Since we're doing a lot of runs, give each one a fresh
2149 * T_guard from the top. */
2150 T_guard.start;
2151
2152 /* Setup a BSSAP connection and clear it right away. This is
2153 * the MSC telling the BSC about a planned release, it's not an
2154 * erratic loss of a connection. */
2155 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2156
2157 /* simulate RLL REL IND */
2158 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
2159
2160 /* expect Clear Request on MSC side */
2161 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
2162
2163 /* Instruct BSC to clear channel */
2164 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
2165 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2166
2167 /* expect BSC to disable the channel */
2168 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
2169 /* respond with CHAN REL ACK */
2170 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
2171
2172 /* expect Clear Complete from BSC */
2173 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
2174
2175 /* MSC disconnects as instructed. */
2176 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2177 }
2178
2179 /* In the buggy behavior, a timeout of 2 seconds happens between above
2180 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2181 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2182 f_sleep(4.0);
2183
2184 deactivate(d);
2185 f_shutdown_helper();
2186}
2187
Harald Welte94e0c342018-04-07 11:33:23 +02002188/***********************************************************************
2189 * IPA style dynamic PDCH
2190 ***********************************************************************/
2191
2192private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
2193 template (omit) RSL_Cause nack := omit)
2194runs on test_CT {
2195 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
2196 var RSL_Message rsl_unused;
2197 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2198 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
2199 /* expect the BSC to issue the related RSL command */
2200 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2201 if (istemplatekind(nack, "omit")) {
2202 /* respond with a related acknowledgement */
2203 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2204 } else {
2205 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
2206 }
2207}
2208
2209private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
2210 template (omit) RSL_Cause nack := omit)
2211runs on test_CT {
2212 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
2213 var RSL_Message rsl_unused;
2214 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2215 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
2216 /* expect the BSC to issue the related RSL command */
2217 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
2218 if (istemplatekind(nack, "omit")) {
2219 /* respond with a related acknowledgement */
2220 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
2221 } else {
2222 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
2223 }
2224}
2225
2226private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
2227runs on test_CT return charstring {
2228 var charstring cmd, resp;
2229 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
2230 resp := f_vty_transceive_ret(BSCVTY, cmd);
2231 return regexp(resp, "*\((*)\)*", 0);
2232}
2233
2234private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
2235 template charstring exp)
2236runs on test_CT {
2237 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
2238 if (not match(mode, exp)) {
2239 setverdict(fail, "Unexpected TS Mode: ", mode);
2240 self.stop;
2241 }
2242}
2243
2244private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
2245runs on test_CT {
2246 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
2247 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
2248 f_vty_transceive(BSCVTY, "end");
2249}
2250
2251private const charstring TCHF_MODE := "TCH/F mode";
2252private const charstring TCHH_MODE := "TCH/H mode";
2253private const charstring PDCH_MODE := "PDCH mode";
2254private const charstring NONE_MODE := "NONE mode";
2255
2256/* Test IPA PDCH activation / deactivation triggered by VTY */
2257testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
2258 var RSL_Message rsl_unused;
2259
2260 /* change Timeslot 6 before f_init() starts RSL */
2261 f_init_vty();
2262 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
2263 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2264
2265 f_init(1, false);
2266 f_sleep(1.0);
2267
2268 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2269
2270 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2271 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2272 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2273 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2274 f_sleep(1.0);
2275 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2276
2277 /* De-activate it via VTY */
2278 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2279 f_sleep(1.0);
2280 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2281
2282 /* re-activate it via VTY */
2283 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
2284 f_sleep(1.0);
2285 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2286
2287 /* and finally de-activate it again */
2288 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2289 f_sleep(1.0);
2290 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2291
2292 setverdict(pass);
2293}
2294
2295/* Test IPA PDCH activation NACK */
2296testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
2297 var RSL_Message rsl_unused;
2298
2299 /* change Timeslot 6 before f_init() starts RSL */
2300 f_init_vty();
2301 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
2302 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2303
2304 f_init(1, false);
2305 f_sleep(1.0);
2306
2307 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2308
2309 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2310 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2311 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2312 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2313 f_sleep(1.0);
2314 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2315
2316 /* De-activate it via VTY */
2317 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2318 f_sleep(1.0);
2319 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2320
2321 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
2322 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
2323 f_sleep(1.0);
2324 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2325
2326 setverdict(pass);
2327}
2328
2329
2330/***********************************************************************
2331 * Osmocom style dynamic PDCH
2332 ***********************************************************************/
2333
2334private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
2335 template (omit) RSL_Cause nack := omit)
2336runs on test_CT {
2337 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
2338 var RSL_Message rsl_unused;
2339 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2340 /* FIXME: no VTY command to activate Osmocom PDCH !! */
2341 /* expect the BSC to issue the related RSL command */
2342 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
2343 if (istemplatekind(nack, "omit")) {
2344 /* respond with a related acknowledgement */
2345 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
2346 } else {
2347 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
2348 }
2349}
2350
2351private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
2352 template (omit) RSL_Cause nack := omit)
2353runs on test_CT {
2354 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
2355 var RSL_Message rsl_unused;
2356 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2357 /* FIXME: no VTY command to activate Osmocom PDCH !! */
2358 /* expect the BSC to issue the related RSL command */
2359 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
2360 if (istemplatekind(nack, "omit")) {
2361 /* respond with a related acknowledgement */
2362 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
2363 } else {
2364 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
2365 }
2366}
2367
2368/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
2369testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
2370 var RSL_Message rsl_unused;
2371
2372 /* change Timeslot 6 before f_init() starts RSL */
2373 f_init_vty();
2374 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
2375 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2376
2377 f_init(1, false);
2378 f_sleep(1.0);
2379
2380 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
2381
2382 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2383 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2384 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
2385
2386 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
2387 f_sleep(1.0);
2388 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2389
2390 setverdict(pass);
2391}
2392
2393/* Test Osmocom dyn PDCH activation NACK behavior */
2394testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
2395 var RSL_Message rsl_unused;
2396
2397 /* change Timeslot 6 before f_init() starts RSL */
2398 f_init_vty();
2399 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
2400 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2401
2402 f_init(1, false);
2403 f_sleep(1.0);
2404
2405 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
2406
2407 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2408 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2409 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
2410
2411 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
2412 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
2413 f_sleep(1.0);
2414 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2415
2416 setverdict(pass);
2417}
2418
Harald Welte0ea2d5e2018-04-07 21:40:29 +02002419/* Dyn PDCH todo:
2420 * activate OSMO as TCH/F
2421 * activate OSMO as TCH/H
2422 * does the BSC-located PCU socket get the updated INFO?
2423 * what if no PCU is connected at the time?
2424 * is the info correct on delayed PCU (re)connect?
2425 */
Harald Welte94e0c342018-04-07 11:33:23 +02002426
Harald Welte28d943e2017-11-25 15:00:50 +01002427control {
Harald Welte898113b2018-01-31 18:32:21 +01002428 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01002429 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002430 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01002431 execute( TC_ctrl() );
Harald Welte898113b2018-01-31 18:32:21 +01002432
2433 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01002434 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01002435 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01002436 execute( TC_chan_act_ack_noest() );
2437 execute( TC_chan_act_ack_est_ind_noreply() );
2438 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01002439 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01002440 execute( TC_chan_exhaustion() );
Harald Welte4003d112017-12-09 22:35:39 +01002441 execute( TC_chan_rel_rll_rel_ind() );
2442 execute( TC_chan_rel_conn_fail() );
2443 execute( TC_chan_rel_hard_clear() );
Harald Welted8c36cd2017-12-09 23:05:31 +01002444 execute( TC_chan_rel_hard_rlsd() );
Harald Welte85804d42017-12-10 14:11:58 +01002445 execute( TC_chan_rel_a_reset() );
Harald Welte6f521d82017-12-11 19:52:02 +01002446
Harald Weltecfe2c962017-12-15 12:09:32 +01002447 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01002448
2449 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01002450 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01002451 execute( TC_assignment_csd() );
2452 execute( TC_assignment_ctm() );
2453 execute( TC_assignment_sign() );
2454 execute( TC_assignment_fr_a5_0() );
2455 execute( TC_assignment_fr_a5_1() );
Harald Weltef1b64e22017-12-15 14:55:14 +01002456 execute( TC_assignment_fr_a5_1_codec_missing() );
Harald Welte235ebf12017-12-15 14:18:16 +01002457 execute( TC_assignment_fr_a5_3() );
2458 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02002459 execute( TC_ciph_mode_a5_0() );
2460 execute( TC_ciph_mode_a5_1() );
2461 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01002462
Harald Welte60aa5762018-03-21 19:33:13 +01002463 execute( TC_assignment_codec_fr() );
2464 execute( TC_assignment_codec_hr() );
2465 execute( TC_assignment_codec_efr() );
2466 execute( TC_assignment_codec_amr_f() );
2467 execute( TC_assignment_codec_amr_h() );
2468
Harald Welte898113b2018-01-31 18:32:21 +01002469 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01002470 execute( TC_rll_est_ind_inact_lchan() );
2471 execute( TC_rll_est_ind_inval_sapi1() );
2472 execute( TC_rll_est_ind_inval_sapi3() );
2473 execute( TC_rll_est_ind_inval_sacch() );
2474
Harald Welte898113b2018-01-31 18:32:21 +01002475 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01002476 execute( TC_paging_imsi_nochan() );
2477 execute( TC_paging_tmsi_nochan() );
2478 execute( TC_paging_tmsi_any() );
2479 execute( TC_paging_tmsi_sdcch() );
2480 execute( TC_paging_tmsi_tch_f() );
2481 execute( TC_paging_tmsi_tch_hf() );
2482 execute( TC_paging_imsi_nochan_cgi() );
2483 execute( TC_paging_imsi_nochan_lac_ci() );
2484 execute( TC_paging_imsi_nochan_ci() );
2485 execute( TC_paging_imsi_nochan_lai() );
2486 execute( TC_paging_imsi_nochan_lac() );
2487 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01002488 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
2489 execute( TC_paging_imsi_nochan_rnc() );
2490 execute( TC_paging_imsi_nochan_lac_rnc() );
2491 execute( TC_paging_imsi_nochan_lacs() );
2492 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01002493 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01002494 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01002495 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01002496 execute( TC_paging_counter() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002497
2498 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002499 execute( TC_rsl_unknown_unit_id() );
2500
2501 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01002502
2503 execute( TC_classmark() );
2504 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01002505 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002506 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01002507 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01002508 execute( TC_err_84_unknown_msg() );
Harald Welte261af4b2018-02-12 21:20:39 +01002509 execute( TC_ho_int() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01002510
2511 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01002512 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01002513 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02002514
2515 execute( TC_dyn_pdch_ipa_act_deact() );
2516 execute( TC_dyn_pdch_ipa_act_nack() );
2517 execute( TC_dyn_pdch_osmo_act_deact() );
2518 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte28d943e2017-11-25 15:00:50 +01002519}
2520
2521}