blob: 9c0ec62cd89b04644ba5bcf2104ce34b3d650b36 [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/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100239altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100240 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100241 [] T_guard.timeout {
242 setverdict(fail, "Timeout of T_guard");
243 self.stop;
244 }
Harald Welte60e823a2017-12-10 14:10:59 +0100245 /* always respond with RESET ACK to RESET */
246 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind {
247 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
248 ts_BSSMAP_ResetAck));
Harald Welte69c1c262017-12-13 21:02:08 +0100249 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100250 }
Harald Welte28d943e2017-11-25 15:00:50 +0100251}
252
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100253altstep no_bssmap_reset() runs on test_CT {
254 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) {
255 setverdict(fail, "unexpected BSSMAP Reset");
256 self.stop;
257 }
258}
259
Daniel Willmann191e0d92018-01-17 12:44:35 +0100260function f_init_mgcp(charstring id) runs on test_CT {
261 id := id & "-MGCP";
262
263 var MGCPOps ops := {
264 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
265 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
266 };
267 var MGCP_conn_parameters mgcp_pars := {
268 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100269 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100270 mgw_ip := mp_test_ip,
271 mgw_udp_port := 2427
272 };
273
274 vc_MGCP := MGCP_Emulation_CT.create(id);
275 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
276}
277
Harald Welte94e0c342018-04-07 11:33:23 +0200278private function f_init_vty(charstring id := "foo") runs on test_CT {
279 if (BSCVTY.checkstate("Mapped")) {
280 /* skip initialization if already executed once */
281 return;
282 }
Harald Weltebc03c762018-02-12 18:09:38 +0100283 map(self:BSCVTY, system:BSCVTY);
284 f_vty_set_prompts(BSCVTY);
285 f_vty_transceive(BSCVTY, "enable");
286}
287
Harald Welte21b46bd2017-12-17 19:46:32 +0100288/* global initialization function
289 * \param nr_bts Number of BTSs we should start/bring up
290 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte89d42e82017-12-17 16:42:41 +0100291function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false) runs on test_CT {
Harald Welte28d943e2017-11-25 15:00:50 +0100292 var integer i;
Harald Welte28d943e2017-11-25 15:00:50 +0100293
Harald Welteae026692017-12-09 01:03:01 +0100294 if (g_initialized) {
295 return;
Harald Welte28d943e2017-11-25 15:00:50 +0100296 }
Harald Welteae026692017-12-09 01:03:01 +0100297 g_initialized := true;
298
299 /* Call a function of our 'parent component' BSSAP_Adapter_CT to start the
300 * MSC-side BSSAP emulation */
Harald Welte67089ee2018-01-17 22:19:03 +0100301 if (handler_mode) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100302 f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", MSC_BssmapOps);
Harald Welte4bcbd172018-05-27 19:47:44 +0200303 f_bssap_start(g_bssap);
Harald Welte67089ee2018-01-17 22:19:03 +0100304 } else {
Harald Weltea4ca4462018-02-09 00:17:14 +0100305 f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", omit);
306 connect(self:BSSAP, g_bssap.vc_SCCP:SCCP_SP_PORT);
Harald Welte4bcbd172018-05-27 19:47:44 +0200307 f_bssap_start(g_bssap);
Harald Weltea4ca4462018-02-09 00:17:14 +0100308 f_legacy_bssap_reset();
Harald Welte67089ee2018-01-17 22:19:03 +0100309 }
Harald Welted5833a82018-05-27 16:52:56 +0200310
Harald Welteffe55fc2018-01-17 22:39:54 +0100311 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +0100312
Daniel Willmann191e0d92018-01-17 12:44:35 +0100313 f_init_mgcp("VirtMSC");
Harald Weltebc03c762018-02-12 18:09:38 +0100314 f_init_vty("VirtMSC");
Daniel Willmann191e0d92018-01-17 12:44:35 +0100315
Harald Welte89d42e82017-12-17 16:42:41 +0100316 for (i := 0; i < nr_bts; i := i+1) {
Harald Weltea5d2ab22017-12-09 14:21:42 +0100317 /* wait until osmo-bts-omldummy has respawned */
318 f_wait_oml(i, "degraded", 5.0);
319 /* start RSL connection */
Harald Welte624f9632017-12-16 19:26:04 +0100320 f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i, handler_mode);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100321 /* wait until BSC tells us "connected" */
322 f_wait_oml(i, "connected", 5.0);
Harald Welte696ddb62017-12-08 14:01:43 +0100323 }
324
Harald Welteae026692017-12-09 01:03:01 +0100325 T_guard.start;
326 activate(as_Tguard());
Harald Welte28d943e2017-11-25 15:00:50 +0100327}
328
Harald Welte21b46bd2017-12-17 19:46:32 +0100329/* expect to receive a RSL message matching a specified templaten on a given BTS / stream */
Harald Welteae026692017-12-09 01:03:01 +0100330function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
331runs on test_CT return RSL_Message {
332 var ASP_RSL_Unitdata rx_rsl_ud;
333 timer T := t_secs;
334
335 T.start;
336 alt {
337 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud {
338 T.stop;
339 }
340 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +0100341 [] T.timeout {
342 setverdict(fail, "Timeout expecting ", t_rx);
343 self.stop;
344 }
Harald Welteae026692017-12-09 01:03:01 +0100345 }
346 return rx_rsl_ud.rsl;
347}
348
Harald Welte21b46bd2017-12-17 19:46:32 +0100349/* helper function to transmit RSL on a given BTS/stream */
Harald Welteae026692017-12-09 01:03:01 +0100350function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
351runs on test_CT {
352 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx));
353}
354
355
Harald Welte4003d112017-12-09 22:35:39 +0100356/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +0100357testcase TC_chan_act_noreply() runs on test_CT {
358 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +0100359 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +0100360
Harald Welte89d42e82017-12-17 16:42:41 +0100361 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +0100362
Harald Welteae026692017-12-09 01:03:01 +0100363 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 +0100364 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welteae026692017-12-09 01:03:01 +0100365 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +0100366}
367
Harald Welte4003d112017-12-09 22:35:39 +0100368/* verify if the "chreq:total" counter increments as expected */
369testcase TC_chan_act_counter() runs on test_CT {
370 var BSSAP_N_UNITDATA_ind ud_ind;
371 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +0100372 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +0100373
Harald Welte89d42e82017-12-17 16:42:41 +0100374 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100375
376 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
377 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 +0100378 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +0100379 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
380
381 setverdict(pass);
382}
383
Harald Welteae026692017-12-09 01:03:01 +0100384/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
385testcase TC_chan_act_ack_noest() runs on test_CT {
386 var RSL_Message rx_rsl;
387
Harald Welte89d42e82017-12-17 16:42:41 +0100388 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100389
390 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100391 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100392
393 /* expect BSC to disable the channel again if there's no RLL EST IND */
394 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
395
396 setverdict(pass);
397}
398
399/* Test behavior if MSC never answers to CR */
400testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +0100401 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
402 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +0100403 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +0100404 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +0100405
Harald Welte89d42e82017-12-17 16:42:41 +0100406 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100407
408 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100409 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100410
411 var octetstring l3 := '00010203040506'O
412 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
413
414 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
415
416 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +0100417 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
418 IPA_RSL[0].clear;
419 alt {
420 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) -> value rx_rsl_ud { }
421 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_REL_REQ(chan_nr, ?))) -> value rx_rsl_ud {
422 f_ipa_tx(0, ts_RSL_REL_CONF(chan_nr, main_dcch));
423 repeat;
424 }
425 }
Harald Welteae026692017-12-09 01:03:01 +0100426
427 setverdict(pass);
428}
429
430/* Test behavior if MSC answers with CREF to CR */
431testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
432 var BSSAP_N_CONNECT_ind rx_c_ind;
433 var RSL_Message rx_rsl;
434
Harald Welte89d42e82017-12-17 16:42:41 +0100435 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100436
437 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100438 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100439
440 var octetstring l3 := '00010203040506'O
441 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
442
443 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
444 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
445
446 /* expect BSC to disable the channel */
Harald Welte725844b2018-01-28 16:18:32 +0100447 f_expect_chan_rel(0, chan_nr);
Harald Welteae026692017-12-09 01:03:01 +0100448 setverdict(pass);
449}
450
Harald Welte618ef642017-12-14 14:58:20 +0100451/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
452testcase TC_chan_act_nack() runs on test_CT {
453 var RSL_Message rx_rsl;
454 var integer chact_nack;
455
Harald Welte89d42e82017-12-17 16:42:41 +0100456 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +0100457
458 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
459
460 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
461 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
462 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
463
464 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
465
466 /* wait for some time to hope the NACK arrives before the CTRL GET below */
467 f_sleep(0.5);
468
469 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
470
471 setverdict(pass);
472}
473
Harald Welte799c97b2017-12-14 17:50:30 +0100474/* Test for channel exhaustion due to RACH overload */
475testcase TC_chan_exhaustion() runs on test_CT {
476 var ASP_RSL_Unitdata rsl_ud;
477 var integer i;
478 var integer chreq_total, chreq_nochan;
479
Harald Welte89d42e82017-12-17 16:42:41 +0100480 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +0100481
482 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
483 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
484
485 /* expect 5xTCH/F to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +0200486 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 +0100487 var RslChannelNr chan_nr := f_chreq_act_ack('23'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +0100488 }
489
490 IPA_RSL[0].clear;
491
Harald Weltedd8cbf32018-01-28 12:07:52 +0100492 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200493 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +0100494
495 /* now expect additional channel activations to fail */
496 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
497
498 alt {
499 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
500 tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
501 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
502 }
503 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
504 var GsmRrMessage rr;
505 /* match on IMM ASS REJ */
506 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
507 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
508 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +0200509 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +0100510 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
511 chreq_nochan+1);
512 setverdict(pass);
513 } else {
514 repeat;
515 }
516 }
517 [] IPA_RSL[0].receive { repeat; }
518 }
519}
520
Harald Weltecfe2c962017-12-15 12:09:32 +0100521/***********************************************************************
522 * Assignment Testing
523 ***********************************************************************/
524
525/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction) */
526testcase TC_outbound_connect() runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +0100527 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +0100528
Harald Weltea4ca4462018-02-09 00:17:14 +0100529 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 +0100530 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
531 setverdict(pass);
532}
533
Harald Welte16a4adf2017-12-14 18:54:01 +0100534/* Test behavior if MSC answers with CREF to CR */
535testcase TC_assignment_cic_only() runs on test_CT {
536 var BSSAP_N_CONNECT_ind rx_c_ind;
537 var RSL_Message rx_rsl;
538 var DchanTuple dt;
539
Harald Welte89d42e82017-12-17 16:42:41 +0100540 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +0100541
542 dt := f_est_dchan('23'O, 23, '00000000'O);
Harald Welte17b27da2018-05-25 20:33:53 +0200543 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
544 /* send assignment without AoIP IEs */
545 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
546 } else {
547 /* Send assignmetn without CIC in IPA case */
548 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
549 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
550 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
551 }
Harald Welte16a4adf2017-12-14 18:54:01 +0100552 alt {
553 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
554 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
555 }
Harald Welte235ebf12017-12-15 14:18:16 +0100556 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +0100557 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
558 setverdict(pass);
559 }
560 [] BSSAP.receive { repeat; }
561 }
562}
563
Harald Welteed848512018-05-24 22:27:58 +0200564/* generate an assignment request for either AoIP or SCCPlite */
Harald Weltee102eae2018-05-31 21:03:47 +0200565function f_gen_ass_req() return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200566 var PDU_BSSAP ass_cmd;
567 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
568 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
569 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
570 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
571 } else {
572 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
573 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
574 }
575 return ass_cmd;
576}
577
578/* generate an assignment complete template for either AoIP or SCCPlite */
Harald Weltee102eae2018-05-31 21:03:47 +0200579function f_gen_exp_compl() return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +0200580 var template PDU_BSSAP exp_compl;
581 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
582 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
583 } else {
584 /* CIC is optional "*" as the MSC allocated it */
585 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
586 }
587 return exp_compl;
588}
589
Harald Welte235ebf12017-12-15 14:18:16 +0100590/* Run everything required up to sending a caller-specified assignment command and expect response */
591function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
592runs on test_CT {
593 var BSSAP_N_CONNECT_ind rx_c_ind;
594 var RSL_Message rx_rsl;
595 var DchanTuple dt;
596
Harald Welte89d42e82017-12-17 16:42:41 +0100597 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +0100598
599 dt := f_est_dchan('23'O, 23, '00000000'O);
600 /* send assignment without AoIP IEs */
601 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
602 alt {
603 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
604 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
605 setverdict(pass);
606 } else {
607 setverdict(fail, fail_text);
608 }
609 }
610 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
611 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
612 setverdict(pass);
613 } else {
614 setverdict(fail, fail_text);
615 }
616 }
617 [] BSSAP.receive { repeat; }
618 }
619}
620testcase TC_assignment_csd() runs on test_CT {
621 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200622 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100623 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
624 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
625 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
626}
627
628testcase TC_assignment_ctm() runs on test_CT {
629 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +0200630 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +0100631 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
632 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
633 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
634}
635
Harald Welte4003d112017-12-09 22:35:39 +0100636type record DchanTuple {
637 integer sccp_conn_id,
638 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +0100639}
640
Harald Welted6939652017-12-13 21:02:46 +0100641/* Send CHAN RQD and wait for allocation; acknowledge it */
642private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
643runs on test_CT return RslChannelNr {
644 var RSL_Message rx_rsl;
645 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
646 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
647 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
648 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
649 return chan_nr;
650}
651
Harald Welte4003d112017-12-09 22:35:39 +0100652/* helper function to establish a dedicated channel via BTS and MSC */
653function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
654runs on test_CT return DchanTuple {
655 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +0100656 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100657
Harald Welte4003d112017-12-09 22:35:39 +0100658 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100659 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +0100660
661 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
662
663 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
664 dt.sccp_conn_id := rx_c_ind.connectionId;
665 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
666
667 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100668}
669
Harald Welte4003d112017-12-09 22:35:39 +0100670/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
671testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
672 var RSL_Message rx_rsl;
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100673 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100674 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +0100675
Harald Welte89d42e82017-12-17 16:42:41 +0100676 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +0100677
Harald Welte4003d112017-12-09 22:35:39 +0100678 dt := f_est_dchan('23'O, 23, '00010203040506'O);
679
680 /* simulate RLL REL IND */
681 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
682
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100683 /* expect Clear Request on MSC side */
684 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
685
686 /* Instruct BSC to clear channel */
687 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
688 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
689
Harald Welte4003d112017-12-09 22:35:39 +0100690 /* expect BSC to disable the channel */
691 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
692 /* respond with CHAN REL ACK */
693 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
694
Neels Hofmeyr27f64362018-03-12 01:44:00 +0100695 /* expect Clear Complete from BSC */
696 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
697
698 /* release the SCCP connection */
699 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
700
701 /* wait for SCCP emulation to do its job */
702 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +0100703
704 setverdict(pass);
705}
706
707/* Test behavior of channel release after CONN FAIL IND from BTS */
708testcase TC_chan_rel_conn_fail() runs on test_CT {
709 var BSSAP_N_DATA_ind rx_di;
710 var RSL_Message rx_rsl;
711 var DchanTuple dt;
712
Harald Welte89d42e82017-12-17 16:42:41 +0100713 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100714
715 dt := f_est_dchan('23'O, 23, '00010203040506'O);
716
717 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +0100718 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 +0100719 /* TODO: different cause values? */
720
Harald Welte4003d112017-12-09 22:35:39 +0100721 /* expect Clear Request from BSC */
722 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
723
724 /* Instruct BSC to clear channel */
725 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
726 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
727
Harald Welte6ff76ea2018-01-28 13:08:01 +0100728 /* expect BSC to disable the channel */
729 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
730 /* respond with CHAN REL ACK */
731 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
732
Harald Welte4003d112017-12-09 22:35:39 +0100733 /* expect Clear Complete from BSC */
734 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
735
736 /* release the SCCP connection */
737 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
738
739 /* wait for SCCP emulation to do its job */
740 f_sleep(1.0);
741
742 setverdict(pass);
743}
744
Harald Welte91d54a52018-01-28 15:35:07 +0100745function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr, boolean flush := true,
746 boolean handle_rll_rel := true) runs on test_CT {
747
748 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
749 if (flush) {
750 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
751 IPA_RSL[bts_nr].clear;
752 }
753 alt {
754 /* ignore DEACTIVATE SACCH (if any) */
755 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
756 tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
757 repeat;
758 }
759 /* acknowledge RLL release (if any)*/
760 [handle_rll_rel] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
761 tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
762 /* FIXME: Why are we getting this for LinkID SACCH? */
763 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
764 repeat;
765 }
766 /* Expect RF channel release from BSC on Abis */
767 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
768 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
769 /* respond with CHAN REL ACK */
770 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
771 }
772 /* ignore any user data */
773 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) {
774 repeat;
775 }
776 }
777}
778
Harald Welte4003d112017-12-09 22:35:39 +0100779/* Test behavior of channel release after hard Clear Command from MSC */
780testcase TC_chan_rel_hard_clear() runs on test_CT {
781 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100782 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +0100783
Harald Welte89d42e82017-12-17 16:42:41 +0100784 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100785
786 dt := f_est_dchan('23'O, 23, '00010203040506'O);
787
788 /* Instruct BSC to clear channel */
789 var BssmapCause cause := 0;
790 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
791
792 /* expect Clear Complete from BSC on A */
793 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
794 /* release the SCCP connection */
795 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
796 }
797
Harald Welte91d54a52018-01-28 15:35:07 +0100798 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welte4003d112017-12-09 22:35:39 +0100799 setverdict(pass);
800}
801
Harald Welted8c36cd2017-12-09 23:05:31 +0100802/* Test behavior of channel release after hard RLSD from MSC */
803testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +0100804 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +0100805
Harald Welte89d42e82017-12-17 16:42:41 +0100806 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +0100807
808 dt := f_est_dchan('23'O, 23, '00010203040506'O);
809
810 /* release the SCCP connection */
811 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
812
Harald Welte91d54a52018-01-28 15:35:07 +0100813 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welted8c36cd2017-12-09 23:05:31 +0100814 setverdict(pass);
815}
816
Harald Welte85804d42017-12-10 14:11:58 +0100817/* Test behavior of channel release after BSSMAP RESET from MSC */
818testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +0100819 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +0100820
Harald Welte89d42e82017-12-17 16:42:41 +0100821 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +0100822
823 dt := f_est_dchan('23'O, 23, '00010203040506'O);
824
825 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
826 IPA_RSL[0].clear;
827
828 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Harald Weltea4ca4462018-02-09 00:17:14 +0100829 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 +0100830 interleave {
Harald Weltea4ca4462018-02-09 00:17:14 +0100831 [] 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 +0100832 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
833 }
834
Philipp Maiere8f38ed2018-02-09 10:30:31 +0100835 f_expect_chan_rel(0, dt.rsl_chan_nr, false);
Harald Welte85804d42017-12-10 14:11:58 +0100836 setverdict(pass);
837}
838
Harald Welte5cd20ed2017-12-13 21:03:20 +0100839/* Test behavior if RSL EST IND for non-active channel */
840testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
841 timer T := 2.0;
842
Harald Welte89d42e82017-12-17 16:42:41 +0100843 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100844
845 var octetstring l3 := '00010203040506'O;
846 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
847 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
848
849 T.start;
850 alt {
851 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
852 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
853 }
854 [] BSSAP.receive {}
855 [] IPA_RSL[0].receive {}
856 [] T.timeout {}
857 }
858
859 setverdict(pass);
860}
861
862/* Test behavior if RSL EST IND for invalid SAPI */
863testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
864 var RslChannelNr chan_nr;
865
Harald Welte89d42e82017-12-17 16:42:41 +0100866 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100867
868 chan_nr := f_chreq_act_ack()
869
870 var octetstring l3 := '00010203040506'O;
871 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
872
873 timer T := 2.0;
874 T.start;
875 alt {
876 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
877 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
878 }
879 [] BSSAP.receive { repeat; }
880 [] IPA_RSL[0].receive { repeat; }
881 [] T.timeout {}
882 }
883
884 setverdict(pass);
885}
886
887/* Test behavior if RSL EST IND for invalid SAPI */
888testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
889 timer T := 2.0;
890
Harald Welte89d42e82017-12-17 16:42:41 +0100891 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100892
893 var RslChannelNr chan_nr := f_chreq_act_ack();
894
895 var octetstring l3 := '00010203040506'O;
896 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
897
898 T.start;
899 alt {
900 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
901 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
902 }
903 [] BSSAP.receive { repeat; }
904 [] IPA_RSL[0].receive { repeat; }
905 [] T.timeout {}
906 }
907
908 setverdict(pass);
909}
910
911/* Test behavior if RSL EST IND for invalid SACCH */
912testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
913 timer T := 2.0;
914
Harald Welte89d42e82017-12-17 16:42:41 +0100915 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100916
917 var RslChannelNr chan_nr := f_chreq_act_ack();
918
919 var octetstring l3 := '00010203040506'O;
920 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
921
922 T.start;
923 alt {
924 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
925 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
926 }
927 [] BSSAP.receive { repeat; }
928 [] IPA_RSL[0].receive { repeat; }
929 [] T.timeout {}
930 }
931
932 setverdict(pass);
933}
934
935
936
Harald Welte4003d112017-12-09 22:35:39 +0100937
938testcase TC_ctrl_msc_connection_status() runs on test_CT {
939 var charstring ctrl_resp;
940
Harald Welte89d42e82017-12-17 16:42:41 +0100941 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100942
943 /* See https://osmocom.org/issues/2729 */
944 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
945 setverdict(pass);
946}
947
Stefan Sperlingb041b3d2018-01-03 17:14:55 +0100948testcase TC_ctrl_msc0_connection_status() runs on test_CT {
949 var charstring ctrl_resp;
950
951 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +0100952
953 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
954 setverdict(pass);
955}
956
Harald Welte4003d112017-12-09 22:35:39 +0100957testcase TC_ctrl() runs on test_CT {
958 var charstring ctrl_resp;
959
Harald Welte89d42e82017-12-17 16:42:41 +0100960 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100961
962 /* all below values must match the osmo-bsc.cfg config file used */
963
Harald Welte6a129692018-03-17 17:30:14 +0100964 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
965 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Harald Welte44bdaa52017-12-17 17:01:47 +0100966 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "3");
Harald Welte4003d112017-12-09 22:35:39 +0100967
968 var integer bts_nr := 0;
969 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
970 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
971 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
972 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
973 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
974 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
975 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
976
977 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
978 f_sleep(2.0);
979 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
980 setverdict(fail, "oml-uptime not incrementing as expected");
981 }
982 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
983
984 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
985
986 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +0100987}
988
Harald Welte6f521d82017-12-11 19:52:02 +0100989function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100990 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, bssap));
Harald Welte6f521d82017-12-11 19:52:02 +0100991}
992
993
994/***********************************************************************
995 * Paging Testing
996 ***********************************************************************/
997
998type record Cell_Identity {
999 GsmMcc mcc,
1000 GsmMnc mnc,
1001 GsmLac lac,
1002 GsmCellId ci
1003};
Harald Welte24135bd2018-03-17 19:27:53 +01001004private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001005private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001006
Harald Welte5d1a2202017-12-13 19:51:29 +01001007type set of integer BtsIdList;
1008
1009private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1010 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1011 if (bts_id == bts_ids[j]) {
1012 return true;
1013 }
1014 }
1015 return false;
1016}
Harald Welte6f521d82017-12-11 19:52:02 +01001017
1018/* core paging test helper function; used by most paging test cases */
1019private function f_pageing_helper(hexstring imsi,
1020 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001021 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001022 template RSL_ChanNeeded rsl_chneed := omit,
1023 template OCT4 tmsi := omit) runs on test_CT
1024{
1025 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
1026 var MobileIdentity mi;
1027 var template octetstring id_enc; /* FIXME */
1028 var RSL_Message rx_rsl;
1029 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001030 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001031
1032 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001033
1034 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001035 for (i := 0; i < NUM_BTS; i := i + 1) {
1036 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001037 }
Harald Welte6f521d82017-12-11 19:52:02 +01001038
1039 if (isvalue(rsl_chneed)) {
1040 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1041 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1042 } else {
1043 bssmap_chneed := omit;
1044 }
1045
1046 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
1047
1048/* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder
1049 if (isvalue(tmsi)) {
1050 mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi))));
1051 } else {
1052 mi := valueof(ts_Osmo_MI_IMSI(imsi));
1053 }
1054 id_enc := enc_MobileIdentity(mi);
1055*/
1056 id_enc := ?;
Harald Welte5d1a2202017-12-13 19:51:29 +01001057 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
1058 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc));
1059 /* check channel type, paging group */
1060 if (rx_rsl.ies[1].body.paging_group != paging_group) {
1061 setverdict(fail, "Paging for wrong paging group");
1062 }
1063 if (ispresent(rsl_chneed) and
1064 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
1065 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
1066 }
Harald Welte6f521d82017-12-11 19:52:02 +01001067 }
Harald Welte2fccd982018-01-31 15:48:19 +01001068 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01001069 /* do a quick check on all not-included BTSs if they received paging */
1070 for (i := 0; i < NUM_BTS; i := i + 1) {
1071 timer T := 0.1;
1072 if (f_bts_in_list(i, bts_ids)) {
1073 continue;
1074 }
1075 T.start;
1076 alt {
1077 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) {
1078 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
1079 }
1080 [] IPA_RSL[i].receive { repeat; }
1081 [] T.timeout { }
1082 }
Harald Welte6f521d82017-12-11 19:52:02 +01001083 }
1084
1085 setverdict(pass);
1086}
1087
Harald Welte5d1a2202017-12-13 19:51:29 +01001088const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01001089const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01001090const BtsIdList c_BtsId_LAC1 := { 0, 1 };
1091const BtsIdList c_BtsId_LAC2 := { 2 };
1092
Harald Welte6f521d82017-12-11 19:52:02 +01001093/* PAGING by IMSI + TMSI */
1094testcase TC_paging_imsi_nochan() runs on test_CT {
1095 var BSSMAP_FIELD_CellIdentificationList cid_list;
1096 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01001097 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001098 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001099}
1100
1101/* PAGING by IMSI + TMSI */
1102testcase TC_paging_tmsi_nochan() runs on test_CT {
1103 var BSSMAP_FIELD_CellIdentificationList cid_list;
1104 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001105 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001106 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001107}
1108
1109/* Paging with different "channel needed' values */
1110testcase TC_paging_tmsi_any() runs on test_CT {
1111 var BSSMAP_FIELD_CellIdentificationList cid_list;
1112 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001113 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001114 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001115}
1116testcase TC_paging_tmsi_sdcch() runs on test_CT {
1117 var BSSMAP_FIELD_CellIdentificationList cid_list;
1118 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001119 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001120 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001121}
1122testcase TC_paging_tmsi_tch_f() runs on test_CT {
1123 var BSSMAP_FIELD_CellIdentificationList cid_list;
1124 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001125 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001126 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001127}
1128testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1129 var BSSMAP_FIELD_CellIdentificationList cid_list;
1130 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001131 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001132 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001133}
1134
1135/* Paging by CGI */
1136testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1137 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1138 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001139 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001140 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001141}
1142
1143/* Paging by LAC+CI */
1144testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1145 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1146 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001147 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001148 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001149}
1150
1151/* Paging by CI */
1152testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1153 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1154 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001155 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01001156 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001157}
1158
1159/* Paging by LAI */
1160testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1161 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1162 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001163 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001164 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001165}
1166
1167/* Paging by LAC */
1168testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1169 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1170 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001171 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001172 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001173}
1174
1175/* Paging by "all in BSS" */
1176testcase TC_paging_imsi_nochan_all() runs on test_CT {
1177 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1178 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001179 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001180 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01001181}
1182
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001183/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001184testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
1185 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1186 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 +01001187 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001188 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001189}
Harald Welte6f521d82017-12-11 19:52:02 +01001190
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001191/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001192testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
1193 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1194 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001195 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001196 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001197}
1198
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001199/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01001200testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
1201 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1202 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01001203 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001204 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001205}
1206
Harald Welte6f521d82017-12-11 19:52:02 +01001207/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01001208testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
1209 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1210 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
1211 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001212 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001213}
1214
1215/* Paging on empty list: Verify none of them page */
1216testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
1217 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1218 cid_list := { cIl_LAC := { } };
1219 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01001220 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01001221}
1222
Stefan Sperling049a86e2018-03-20 15:51:00 +01001223/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
1224testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
1225 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1226 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
1227 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
1228 f_shutdown_helper();
1229}
1230
Harald Welte6f521d82017-12-11 19:52:02 +01001231/* Verify paging retransmission interval + count */
1232/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001233/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001234
Harald Weltee65d40e2017-12-13 00:09:06 +01001235/* Verify PCH load */
1236testcase TC_paging_imsi_load() runs on test_CT {
1237 var BSSMAP_FIELD_CellIdentificationList cid_list;
1238 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01001239 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01001240 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001241 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001242
1243 /* tell BSC there is no paging space anymore */
1244 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01001245 f_sleep(0.2);
1246 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01001247
1248 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1249 * there would be 8 retransmissions during 4 seconds */
1250 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01001251 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01001252 alt {
1253 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1254 setverdict(fail, "Received PAGING after LOAD_IND(0)");
1255 self.stop;
1256 }
Harald Welte2caa1062018-03-17 18:19:05 +01001257 [] T_retrans.timeout {
1258 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
1259 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1260 T_retrans.start;
1261 repeat;
1262 }
Harald Weltee65d40e2017-12-13 00:09:06 +01001263 [] T.timeout {
1264 setverdict(pass);
1265 }
1266 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001267
1268 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01001269}
1270
Harald Welte235ebf12017-12-15 14:18:16 +01001271/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001272testcase TC_paging_counter() runs on test_CT {
1273 var BSSMAP_FIELD_CellIdentificationList cid_list;
1274 timer T := 4.0;
1275 var integer i;
1276 var integer paging_attempted_bsc;
1277 var integer paging_attempted_bts[NUM_BTS];
1278 var integer paging_expired_bts[NUM_BTS];
1279 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1280
1281 f_init();
1282
1283 /* read counters before paging */
1284 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1285 for (i := 0; i < NUM_BTS; i := i+1) {
1286 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1287 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1288 }
1289
1290 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1291
1292 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1293 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1294 for (i := 0; i < NUM_BTS; i := i+1) {
1295 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1296 paging_attempted_bts[i]+1);
1297 }
1298
1299 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1300 f_sleep(12.0);
1301 for (i := 0; i < NUM_BTS; i := i+1) {
1302 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1303 paging_expired_bts[i]+1);
1304 }
Harald Welte1ff69992017-12-14 12:31:17 +01001305
Philipp Maier282ca4b2018-02-27 17:17:00 +01001306 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01001307}
1308
1309
Harald Welte10985002017-12-12 09:29:15 +01001310/* Verify paging stops after A-RESET */
1311testcase TC_paging_imsi_a_reset() runs on test_CT {
1312 var BSSMAP_FIELD_CellIdentificationList cid_list;
1313 timer T := 3.0;
1314 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001315 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001316
1317 /* Perform a BSSMAP Reset and wait for ACK */
Harald Weltea4ca4462018-02-09 00:17:14 +01001318 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 +01001319 alt {
Harald Weltea4ca4462018-02-09 00:17:14 +01001320 [] 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 +01001321 [] BSSAP.receive { repeat; }
1322 }
1323
1324 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01001325 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
1326 IPA_RSL[i].clear;
1327 }
Harald Welte10985002017-12-12 09:29:15 +01001328
1329 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1330 T.start;
1331 alt {
1332 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1333 setverdict(fail, "Received PAGING after A-RESET");
1334 self.stop;
1335 }
Harald Welte5d1a2202017-12-13 19:51:29 +01001336 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1337 setverdict(fail, "Received PAGING after A-RESET");
1338 self.stop;
1339 }
1340 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1341 setverdict(fail, "Received PAGING after A-RESET");
1342 self.stop;
1343 }
Harald Welte10985002017-12-12 09:29:15 +01001344 [] T.timeout {
1345 setverdict(pass);
1346 }
1347 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01001348
1349 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01001350}
Harald Welteae026692017-12-09 01:03:01 +01001351
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001352/* Test RSL link drop causes counter increment */
1353testcase TC_rsl_drop_counter() runs on test_CT {
1354 var integer rsl_fail;
1355
Harald Welte89d42e82017-12-17 16:42:41 +01001356 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001357
1358 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1359
1360 bts[0].rsl.vc_IPA.stop;
1361
1362 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1363
1364 setverdict(pass);
1365}
1366
1367/* TODO: Test OML link drop causes counter increment */
1368
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001369/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
1370function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
1371 timer T := 10.0;
1372
1373 bts[0].rsl.id := "IPA-0-RSL";
1374 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
1375 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
1376 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
1377 bts[0].rsl.ccm_pars.unit_id := "0/0/0"; /* value which is unknown at BTS */
1378
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001379 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
1380
1381 f_init_mgcp("VirtMSC");
1382
1383 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
1384 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
1385 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
1386 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
1387
1388 /* wait for IPA OML link to connect and then disconnect */
1389 T.start;
1390 alt {
1391 [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) {
1392 T.stop;
1393 return true;
1394 }
1395 [] IPA_RSL[0].receive { repeat }
1396 [] T.timeout {
1397 self.stop;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01001398 }
1399 }
1400
1401 return false;
1402}
1403
1404/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1405testcase TC_rsl_unknown_unit_id() runs on test_CT {
1406 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
1407 setverdict(pass);
1408 } else {
1409 setverdict(fail, "Timeout RSL waiting for connection to close");
1410 }
1411}
1412
1413
1414/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
1415testcase TC_oml_unknown_unit_id() runs on test_CT {
1416 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
1417 setverdict(pass);
1418 } else {
1419 setverdict(fail, "Timeout OML waiting for connection to close");
1420 }
1421}
1422
1423
Harald Weltec1a2fff2017-12-17 11:06:19 +01001424/***********************************************************************
1425 * "New world" test cases using RSL_Emulation + BSSMAP_Emulation
1426 ***********************************************************************/
1427
1428import from BSSMAP_Emulation all;
1429import from RSL_Emulation all;
1430import from MSC_ConnectionHandler all;
1431
1432type function void_fn(charstring id) runs on MSC_ConnHdlr;
1433
Harald Welte336820c2018-05-31 20:34:52 +02001434/* helper function to create and connect a MSC_ConnHdlr component */
Harald Welteff579f92018-05-31 22:19:39 +02001435private function f_connect_handler(inout MSC_ConnHdlr vc_conn) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +01001436 connect(vc_conn:BSSMAPEM, g_bssap.vc_BSSMAP:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001437 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001438 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01001439 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01001440 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01001441 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
1442 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
1443 }
Harald Weltea4ca4462018-02-09 00:17:14 +01001444 connect(vc_conn:BSSAP, g_bssap.vc_BSSMAP:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001445 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Harald Welte336820c2018-05-31 20:34:52 +02001446}
1447
1448function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
1449runs on test_CT return MSC_ConnHdlr {
1450 var charstring id := testcasename();
1451 var MSC_ConnHdlr vc_conn;
1452 vc_conn := MSC_ConnHdlr.create(id);
1453 f_connect_handler(vc_conn);
Harald Weltea0630032018-03-20 21:09:55 +01001454 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001455 return vc_conn;
1456}
1457
Harald Weltea0630032018-03-20 21:09:55 +01001458/* first function inside ConnHdlr component; sets g_pars + starts function */
1459private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
1460runs on MSC_ConnHdlr {
1461 if (isvalue(pars)) {
1462 g_pars := valueof(pars);
1463 }
1464 fn.apply(id);
1465}
1466
Harald Welte3c86ea02018-05-10 22:28:05 +02001467/* Establish signalling channel (non-assignment case) followed by cipher mode */
1468private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001469 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1470 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02001471 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02001472 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
1473 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
1474 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
1475 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02001476
Philipp Maier23000732018-05-18 11:25:37 +02001477 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02001478}
1479testcase TC_ciph_mode_a5_0() runs on test_CT {
1480 var MSC_ConnHdlr vc_conn;
1481 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1482 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
1483
1484 f_init(1, true);
1485 f_sleep(1.0);
1486 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1487 vc_conn.done;
1488}
1489testcase TC_ciph_mode_a5_1() runs on test_CT {
1490 var MSC_ConnHdlr vc_conn;
1491 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1492 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
1493
1494 f_init(1, true);
1495 f_sleep(1.0);
1496 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1497 vc_conn.done;
1498}
1499testcase TC_ciph_mode_a5_3() runs on test_CT {
1500 var MSC_ConnHdlr vc_conn;
1501 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1502 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
1503
1504 f_init(1, true);
1505 f_sleep(1.0);
1506 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
1507 vc_conn.done;
1508}
1509
1510
1511/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02001512private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001513 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1514 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01001515
Harald Welte552620d2017-12-16 23:21:36 +01001516 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1517 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001518
Harald Weltea0630032018-03-20 21:09:55 +01001519 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01001520}
Harald Welte552620d2017-12-16 23:21:36 +01001521testcase TC_assignment_fr_a5_0() runs on test_CT {
1522 var MSC_ConnHdlr vc_conn;
Harald Welte651fcdc2018-05-10 20:23:16 +02001523 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1524 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01001525
Harald Welte89d42e82017-12-17 16:42:41 +01001526 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001527 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001528 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01001529 vc_conn.done;
1530}
Harald Welte552620d2017-12-16 23:21:36 +01001531testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001532 var MSC_ConnHdlr vc_conn;
Harald Welte651fcdc2018-05-10 20:23:16 +02001533 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1534 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001535
Harald Welte89d42e82017-12-17 16:42:41 +01001536 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001537 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02001538 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
1539 vc_conn.done;
1540}
1541testcase TC_assignment_fr_a5_3() runs on test_CT {
1542 var MSC_ConnHdlr vc_conn;
1543 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1544 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001545
Harald Welte651fcdc2018-05-10 20:23:16 +02001546 f_init(1, true);
1547 f_sleep(1.0);
1548 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001549 vc_conn.done;
1550}
1551
Harald Welte552620d2017-12-16 23:21:36 +01001552/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1553private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001554 g_pars := valueof(t_def_TestHdlrPars);
Harald Welte552620d2017-12-16 23:21:36 +01001555 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001556 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001557 const OCT8 kc := '0001020304050607'O;
1558
1559 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Harald Weltea0630032018-03-20 21:09:55 +01001560 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01001561}
Harald Welte552620d2017-12-16 23:21:36 +01001562testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1563 var MSC_ConnHdlr vc_conn;
1564
Harald Welte89d42e82017-12-17 16:42:41 +01001565 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001566 f_sleep(1.0);
1567
Harald Welte8863fa12018-05-10 20:15:27 +02001568 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01001569 vc_conn.done;
1570}
1571
Harald Welte552620d2017-12-16 23:21:36 +01001572private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001573 g_pars := valueof(t_def_TestHdlrPars);
Harald Welteed848512018-05-24 22:27:58 +02001574 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
1575 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01001576 const OCT8 kc := '0001020304050607'O;
1577 const OCT16 kc128 := kc & kc;
1578
1579 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1580 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01001581 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01001582 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001583 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001584}
Harald Welte552620d2017-12-16 23:21:36 +01001585testcase TC_assignment_fr_a5_4() runs on test_CT {
1586 var MSC_ConnHdlr vc_conn;
1587
Harald Welte89d42e82017-12-17 16:42:41 +01001588 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001589 f_sleep(1.0);
1590
Harald Welte8863fa12018-05-10 20:15:27 +02001591 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01001592 vc_conn.done;
1593}
1594
1595
Harald Welte4532e0a2017-12-23 02:05:44 +01001596private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier6a50c7c2018-04-16 16:15:59 +02001597 g_pars := valueof(t_def_TestHdlrPars);
Harald Welte4532e0a2017-12-23 02:05:44 +01001598 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
1599 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, omit));
1600
1601 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01001602 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01001603}
1604
1605testcase TC_assignment_sign() runs on test_CT {
1606 var MSC_ConnHdlr vc_conn;
1607
1608 f_init(1, true);
1609 f_sleep(1.0);
1610
Harald Welte8863fa12018-05-10 20:15:27 +02001611 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01001612 vc_conn.done;
1613}
1614
Harald Welte60aa5762018-03-21 19:33:13 +01001615/***********************************************************************
1616 * Codec (list) testing
1617 ***********************************************************************/
1618
1619/* check if the given rsl_mode is compatible with the a_elem */
1620private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
1621return boolean {
1622 select (a_elem.codecType) {
1623 case (GSM_FR) {
1624 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
1625 return true;
1626 }
1627 }
1628 case (GSM_HR) {
1629 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
1630 return true;
1631 }
1632 }
1633 case (GSM_EFR) {
1634 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
1635 return true;
1636 }
1637 }
1638 case (FR_AMR) {
1639 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
1640 return true;
1641 }
1642 }
1643 case (HR_AMR) {
1644 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
1645 return true;
1646 }
1647 }
1648 case else { }
1649 }
1650 return false;
1651}
1652
1653/* check if the given rsl_mode is compatible with the a_list */
1654private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
1655return boolean {
1656 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
1657 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
1658 return true;
1659 }
1660 }
1661 return false;
1662}
1663
1664/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
1665private function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
1666return BSSMAP_IE_ChannelType {
1667 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
1668 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
1669 select (a_elem.codecType) {
1670 case (GSM_FR) {
1671 ret.channelRateAndType := ChRate_TCHF;
1672 ret.speechId_DataIndicator := Spdi_TCHF_FR;
1673 }
1674 case (GSM_HR) {
1675 ret.channelRateAndType := ChRate_TCHH;
1676 ret.speechId_DataIndicator := Spdi_TCHH_HR;
1677 }
1678 case (GSM_EFR) {
1679 ret.channelRateAndType := ChRate_TCHF;
1680 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
1681 }
1682 case (FR_AMR) {
1683 ret.channelRateAndType := ChRate_TCHF;
1684 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
1685 }
1686 case (HR_AMR) {
1687 ret.channelRateAndType := ChRate_TCHH;
1688 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
1689 }
1690 case else {
1691 setverdict(fail, "Unsupported codec ", a_elem);
1692 self.stop;
1693 }
1694 }
1695 return ret;
1696}
1697
Harald Weltea63b9102018-03-22 20:36:16 +01001698private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
1699return template RSL_IE_Body {
1700 var template RSL_IE_Body mode_ie := {
1701 chan_mode := {
1702 len := ?,
1703 reserved := ?,
1704 dtx_d := ?,
1705 dtx_u := ?,
1706 spd_ind := RSL_SPDI_SPEECH,
1707 ch_rate_type := -,
1708 coding_alg_rate := -
1709 }
1710 }
1711
1712 select (a_elem.codecType) {
1713 case (GSM_FR) {
1714 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1715 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1716 }
1717 case (GSM_HR) {
1718 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1719 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
1720 }
1721 case (GSM_EFR) {
1722 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1723 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
1724 }
1725 case (FR_AMR) {
1726 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
1727 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1728 }
1729 case (HR_AMR) {
1730 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
1731 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
1732 }
1733 }
1734 return mode_ie;
1735}
1736
Harald Welte60aa5762018-03-21 19:33:13 +01001737type record CodecListTest {
1738 BSSMAP_IE_SpeechCodecList codec_list,
1739 charstring id
1740}
1741type record of CodecListTest CodecListTests
1742
1743private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02001744 var PDU_BSSAP ass_cmd := f_gen_ass_req();
1745 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
Harald Welte60aa5762018-03-21 19:33:13 +01001746
1747 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Harald Welte79f3f542018-05-25 20:02:37 +02001748 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
1749 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
1750 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
1751 g_pars.ass_codec_list.codecElements[0];
1752 }
Harald Welte60aa5762018-03-21 19:33:13 +01001753 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
1754 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01001755 log("expecting ASS COMPL like this: ", exp_compl);
1756
1757 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01001758
1759 /* Verify that the RSL-side activation actually matches our expectations */
1760 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
1761
1762 var RSL_IE_Body mode_ie;
1763 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
1764 setverdict(fail, "Couldn't find CHAN_MODE IE");
1765 self.stop;
1766 }
1767 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
1768 if (not match(mode_ie, t_mode_ie)) {
1769 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
1770 }
Harald Welte60aa5762018-03-21 19:33:13 +01001771}
1772
1773testcase TC_assignment_codec_fr() runs on test_CT {
1774 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1775 var MSC_ConnHdlr vc_conn;
1776
1777 f_init(1, true);
1778 f_sleep(1.0);
1779
1780 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001781 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001782 vc_conn.done;
1783}
1784
1785testcase TC_assignment_codec_hr() runs on test_CT {
1786 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1787 var MSC_ConnHdlr vc_conn;
1788
1789 f_init(1, true);
1790 f_sleep(1.0);
1791
1792 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001793 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001794 vc_conn.done;
1795}
1796
1797testcase TC_assignment_codec_efr() runs on test_CT {
1798 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1799 var MSC_ConnHdlr vc_conn;
1800
1801 f_init(1, true);
1802 f_sleep(1.0);
1803
1804 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02001805 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001806 vc_conn.done;
1807}
1808
1809testcase TC_assignment_codec_amr_f() runs on test_CT {
1810 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1811 var MSC_ConnHdlr vc_conn;
1812
1813 f_init(1, true);
1814 f_sleep(1.0);
1815
1816 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Harald Welte8863fa12018-05-10 20:15:27 +02001817 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001818 vc_conn.done;
1819}
1820
1821testcase TC_assignment_codec_amr_h() runs on test_CT {
1822 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1823 var MSC_ConnHdlr vc_conn;
1824
1825 f_init(1, true);
1826 f_sleep(1.0);
1827
1828 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Harald Welte8863fa12018-05-10 20:15:27 +02001829 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01001830 vc_conn.done;
1831}
1832
Harald Welte898113b2018-01-31 18:32:21 +01001833/* test if L3 RR CLASSMARK CHANGE is translated to BSSMAP CLASSMARK UPDATE */
1834private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001835 g_pars := valueof(t_def_TestHdlrPars);
1836 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01001837 /* we should now have a COMPL_L3 at the MSC */
1838 BSSAP.receive(tr_BSSMAP_ComplL3);
1839
1840 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
1841 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
1842 setverdict(pass);
1843}
1844testcase TC_classmark() runs on test_CT {
1845 var MSC_ConnHdlr vc_conn;
1846 f_init(1, true);
1847 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001848 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01001849 vc_conn.done;
1850}
1851
Harald Weltee3bd6582018-01-31 22:51:25 +01001852private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001853 g_pars := valueof(t_def_TestHdlrPars);
1854 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01001855 /* we should now have a COMPL_L3 at the MSC */
1856 BSSAP.receive(tr_BSSMAP_ComplL3);
1857
Harald Weltee3bd6582018-01-31 22:51:25 +01001858 /* send the single message we want to send */
1859 f_rsl_send_l3(l3);
1860}
1861
1862private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
1863 timer T := sec;
1864 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01001865 T.start;
1866 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01001867 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
1868 setverdict(fail, "Unexpected BSSMAP ", bssap);
1869 self.stop;
Harald Welte898113b2018-01-31 18:32:21 +01001870 }
1871 [] T.timeout {
1872 setverdict(pass);
1873 }
1874 }
1875}
1876
Harald Weltee3bd6582018-01-31 22:51:25 +01001877/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
1878private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
1879 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
1880 f_bssap_expect_nothing();
1881}
Harald Welte898113b2018-01-31 18:32:21 +01001882testcase TC_unsol_ass_fail() runs on test_CT {
1883 var MSC_ConnHdlr vc_conn;
1884 f_init(1, true);
1885 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001886 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01001887 vc_conn.done;
1888}
Harald Welte552620d2017-12-16 23:21:36 +01001889
Harald Welteea99a002018-01-31 20:46:43 +01001890
1891/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
1892private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01001893 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
1894 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01001895}
1896testcase TC_unsol_ass_compl() runs on test_CT {
1897 var MSC_ConnHdlr vc_conn;
1898 f_init(1, true);
1899 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001900 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01001901 vc_conn.done;
1902}
1903
1904
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001905/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
1906private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01001907 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
1908 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001909}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001910testcase TC_unsol_ho_fail() runs on test_CT {
1911 var MSC_ConnHdlr vc_conn;
1912 f_init(1, true);
1913 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001914 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01001915 vc_conn.done;
1916}
1917
1918
Harald Weltee3bd6582018-01-31 22:51:25 +01001919/* short message from MS should be ignored */
1920private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001921 g_pars := valueof(t_def_TestHdlrPars);
1922 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01001923 /* we should now have a COMPL_L3 at the MSC */
1924 BSSAP.receive(tr_BSSMAP_ComplL3);
1925
1926 /* send short message */
1927 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
1928 f_bssap_expect_nothing();
1929}
1930testcase TC_err_82_short_msg() runs on test_CT {
1931 var MSC_ConnHdlr vc_conn;
1932 f_init(1, true);
1933 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001934 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01001935 vc_conn.done;
1936}
1937
1938
Harald Weltee9e02e42018-01-31 23:36:25 +01001939/* 24.008 8.4 Unknown message must trigger RR STATUS */
1940private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
1941 f_est_single_l3(ts_RRM_UL_REL('00'O));
1942 timer T := 3.0
1943 alt {
1944 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
1945 setverdict(pass);
1946 }
1947 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01001948 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01001949 }
1950}
1951testcase TC_err_84_unknown_msg() runs on test_CT {
1952 var MSC_ConnHdlr vc_conn;
1953 f_init(1, true);
1954 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02001955 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01001956 vc_conn.done;
1957}
1958
Harald Welte94e0c342018-04-07 11:33:23 +02001959/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
1960private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
1961runs on test_CT {
1962 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
1963 " timeslot "&int2str(ts_nr)&" ";
1964 f_vty_transceive(BSCVTY, cmd & suffix);
1965}
1966
Harald Welte261af4b2018-02-12 21:20:39 +01001967/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
1968private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
1969runs on MSC_ConnHdlr {
1970 /* FIXME: resolve those from component-global state */
1971 var integer ts_nr := chan_nr.tn;
1972 var integer ss_nr;
1973 if (ischosen(chan_nr.u.ch0)) {
1974 ss_nr := 0;
1975 } else if (ischosen(chan_nr.u.lm)) {
1976 ss_nr := chan_nr.u.lm.sub_chan;
1977 } else if (ischosen(chan_nr.u.sdcch4)) {
1978 ss_nr := chan_nr.u.sdcch4.sub_chan;
1979 } else if (ischosen(chan_nr.u.sdcch8)) {
1980 ss_nr := chan_nr.u.sdcch8.sub_chan;
1981 } else {
1982 setverdict(fail, "Invalid ChanNr ", chan_nr);
1983 self.stop;
1984 }
1985
1986 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
1987 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
1988 f_vty_transceive(BSCVTY, cmd & suffix);
1989}
1990
1991private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
1992 integer new_bts_nr)
1993runs on MSC_ConnHdlr {
1994 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
1995}
1996
1997/* intra-BSC hand-over between BTS0 and BTS1 */
1998private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Harald Weltea0630032018-03-20 21:09:55 +01001999 g_pars := valueof(t_def_TestHdlrPars);
Harald Welteed848512018-05-24 22:27:58 +02002000 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2001 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01002002 const OCT8 kc := '0001020304050607'O;
2003
2004 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2005 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2006
Harald Weltea0630032018-03-20 21:09:55 +01002007 f_establish_fully(ass_cmd, exp_compl);
Harald Welte261af4b2018-02-12 21:20:39 +01002008
2009 var HandoverState hs := {
2010 rr_ho_cmpl_seen := false,
2011 handover_done := false,
2012 old_chan_nr := -
2013 };
2014 /* issue hand-over command on VTY */
2015 f_vty_handover(0, 0, g_chan_nr, 1);
2016 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
2017 f_rslem_suspend(RSL1_PROC);
2018 alt {
2019 [] as_handover(hs);
2020 /* FIXME: somehow determine that the hand-over has completed, by MGCP MDCX? */
2021 }
2022}
2023
2024testcase TC_ho_int() runs on test_CT {
2025 var MSC_ConnHdlr vc_conn;
2026 f_init(2, true);
2027 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02002028 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01002029 vc_conn.done;
2030}
Harald Weltee9e02e42018-01-31 23:36:25 +01002031
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01002032/* OS#3041: Open and close N connections in a normal fashion, and expect no
2033 * BSSMAP Reset just because of that. */
2034testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
2035 var default d;
2036 var integer i;
2037 var DchanTuple dt;
2038
2039 f_init();
2040
2041 /* Wait for initial BSSMAP Reset to pass */
2042 f_sleep(4.0);
2043
2044 d := activate(no_bssmap_reset());
2045
2046 /* Setup up a number of connections and RLSD them again from the MSC
2047 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2048 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02002049 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01002050 /* Since we're doing a lot of runs, give each one a fresh
2051 * T_guard from the top. */
2052 T_guard.start;
2053
2054 /* Setup a BSSAP connection and clear it right away. This is
2055 * the MSC telling the BSC about a planned release, it's not an
2056 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02002057 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01002058
2059 /* MSC disconnects (RLSD). */
2060 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2061 }
2062
2063 /* In the buggy behavior, a timeout of 2 seconds happens between above
2064 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2065 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2066 f_sleep(4.0);
2067
2068 deactivate(d);
2069 f_shutdown_helper();
2070}
Harald Welte552620d2017-12-16 23:21:36 +01002071
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01002072/* OS#3041: Open and close N connections in a normal fashion, and expect no
2073 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
2074 * the MSC. */
2075testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
2076 var default d;
2077 var integer i;
2078 var DchanTuple dt;
2079 var BSSAP_N_DATA_ind rx_di;
2080 var RSL_Message rx_rsl;
2081 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
2082 var BssmapCause cause := enum2int(cause_val);
2083
2084 f_init();
2085
2086 /* Wait for initial BSSMAP Reset to pass */
2087 f_sleep(4.0);
2088
2089 d := activate(no_bssmap_reset());
2090
2091 /* Setup up a number of connections and RLSD them again from the MSC
2092 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2093 * Let's do it some more times for good measure. */
2094 for (i := 0; i < 8; i := i+1) {
2095 /* Since we're doing a lot of runs, give each one a fresh
2096 * T_guard from the top. */
2097 T_guard.start;
2098
2099 /* Setup a BSSAP connection and clear it right away. This is
2100 * the MSC telling the BSC about a planned release, it's not an
2101 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02002102 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01002103
2104 /* Instruct BSC to clear channel */
2105 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2106
2107 /* expect BSC to disable the channel */
2108 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
2109 /* respond with CHAN REL ACK */
2110 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
2111
2112 /* expect Clear Complete from BSC */
2113 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
2114
2115 /* MSC disconnects as instructed. */
2116 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01002117 }
2118
2119 /* In the buggy behavior, a timeout of 2 seconds happens between above
2120 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2121 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2122 f_sleep(4.0);
2123
2124 deactivate(d);
2125 f_shutdown_helper();
2126}
2127
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01002128/* OS#3041: Open and close N connections in a normal fashion, and expect no
2129 * BSSMAP Reset just because of that. Close connections from the MS side with a
2130 * Release Ind on RSL. */
2131testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
2132 var default d;
2133 var integer i;
2134 var DchanTuple dt;
2135 var BSSAP_N_DATA_ind rx_di;
2136 var RSL_Message rx_rsl;
2137 var integer j;
2138
2139 f_init();
2140
2141 /* Wait for initial BSSMAP Reset to pass */
2142 f_sleep(4.0);
2143
2144 d := activate(no_bssmap_reset());
2145
2146 /* Setup up a number of connections and RLSD them again from the MSC
2147 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
2148 * Let's do it some more times for good measure. */
2149 for (i := 0; i < 8; i := i+1) {
2150 /* Since we're doing a lot of runs, give each one a fresh
2151 * T_guard from the top. */
2152 T_guard.start;
2153
2154 /* Setup a BSSAP connection and clear it right away. This is
2155 * the MSC telling the BSC about a planned release, it's not an
2156 * erratic loss of a connection. */
2157 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2158
2159 /* simulate RLL REL IND */
2160 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
2161
2162 /* expect Clear Request on MSC side */
2163 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
2164
2165 /* Instruct BSC to clear channel */
2166 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
2167 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2168
2169 /* expect BSC to disable the channel */
2170 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
2171 /* respond with CHAN REL ACK */
2172 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
2173
2174 /* expect Clear Complete from BSC */
2175 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
2176
2177 /* MSC disconnects as instructed. */
2178 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2179 }
2180
2181 /* In the buggy behavior, a timeout of 2 seconds happens between above
2182 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
2183 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
2184 f_sleep(4.0);
2185
2186 deactivate(d);
2187 f_shutdown_helper();
2188}
2189
Harald Welte94e0c342018-04-07 11:33:23 +02002190/***********************************************************************
2191 * IPA style dynamic PDCH
2192 ***********************************************************************/
2193
2194private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
2195 template (omit) RSL_Cause nack := omit)
2196runs on test_CT {
2197 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
2198 var RSL_Message rsl_unused;
2199 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2200 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
2201 /* expect the BSC to issue the related RSL command */
2202 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2203 if (istemplatekind(nack, "omit")) {
2204 /* respond with a related acknowledgement */
2205 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2206 } else {
2207 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
2208 }
2209}
2210
2211private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
2212 template (omit) RSL_Cause nack := omit)
2213runs on test_CT {
2214 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
2215 var RSL_Message rsl_unused;
2216 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2217 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
2218 /* expect the BSC to issue the related RSL command */
2219 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
2220 if (istemplatekind(nack, "omit")) {
2221 /* respond with a related acknowledgement */
2222 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
2223 } else {
2224 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
2225 }
2226}
2227
2228private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
2229runs on test_CT return charstring {
2230 var charstring cmd, resp;
2231 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
2232 resp := f_vty_transceive_ret(BSCVTY, cmd);
2233 return regexp(resp, "*\((*)\)*", 0);
2234}
2235
2236private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
2237 template charstring exp)
2238runs on test_CT {
2239 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
2240 if (not match(mode, exp)) {
2241 setverdict(fail, "Unexpected TS Mode: ", mode);
2242 self.stop;
2243 }
2244}
2245
2246private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
2247runs on test_CT {
2248 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
2249 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
2250 f_vty_transceive(BSCVTY, "end");
2251}
2252
2253private const charstring TCHF_MODE := "TCH/F mode";
2254private const charstring TCHH_MODE := "TCH/H mode";
2255private const charstring PDCH_MODE := "PDCH mode";
2256private const charstring NONE_MODE := "NONE mode";
2257
2258/* Test IPA PDCH activation / deactivation triggered by VTY */
2259testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
2260 var RSL_Message rsl_unused;
2261
2262 /* change Timeslot 6 before f_init() starts RSL */
2263 f_init_vty();
2264 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
2265 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2266
2267 f_init(1, false);
2268 f_sleep(1.0);
2269
2270 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2271
2272 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2273 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2274 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2275 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2276 f_sleep(1.0);
2277 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2278
2279 /* De-activate it via VTY */
2280 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2281 f_sleep(1.0);
2282 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2283
2284 /* re-activate it via VTY */
2285 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
2286 f_sleep(1.0);
2287 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2288
2289 /* and finally de-activate it again */
2290 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2291 f_sleep(1.0);
2292 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2293
2294 setverdict(pass);
2295}
2296
2297/* Test IPA PDCH activation NACK */
2298testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
2299 var RSL_Message rsl_unused;
2300
2301 /* change Timeslot 6 before f_init() starts RSL */
2302 f_init_vty();
2303 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
2304 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2305
2306 f_init(1, false);
2307 f_sleep(1.0);
2308
2309 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2310
2311 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2312 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2313 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
2314 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
2315 f_sleep(1.0);
2316 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2317
2318 /* De-activate it via VTY */
2319 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
2320 f_sleep(1.0);
2321 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2322
2323 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
2324 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
2325 f_sleep(1.0);
2326 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
2327
2328 setverdict(pass);
2329}
2330
2331
2332/***********************************************************************
2333 * Osmocom style dynamic PDCH
2334 ***********************************************************************/
2335
2336private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
2337 template (omit) RSL_Cause nack := omit)
2338runs on test_CT {
2339 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
2340 var RSL_Message rsl_unused;
2341 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2342 /* FIXME: no VTY command to activate Osmocom PDCH !! */
2343 /* expect the BSC to issue the related RSL command */
2344 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
2345 if (istemplatekind(nack, "omit")) {
2346 /* respond with a related acknowledgement */
2347 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
2348 } else {
2349 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
2350 }
2351}
2352
2353private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
2354 template (omit) RSL_Cause nack := omit)
2355runs on test_CT {
2356 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
2357 var RSL_Message rsl_unused;
2358 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
2359 /* FIXME: no VTY command to activate Osmocom PDCH !! */
2360 /* expect the BSC to issue the related RSL command */
2361 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
2362 if (istemplatekind(nack, "omit")) {
2363 /* respond with a related acknowledgement */
2364 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
2365 } else {
2366 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
2367 }
2368}
2369
2370/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
2371testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
2372 var RSL_Message rsl_unused;
2373
2374 /* change Timeslot 6 before f_init() starts RSL */
2375 f_init_vty();
2376 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
2377 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2378
2379 f_init(1, false);
2380 f_sleep(1.0);
2381
2382 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
2383
2384 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2385 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2386 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
2387
2388 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
2389 f_sleep(1.0);
2390 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
2391
2392 setverdict(pass);
2393}
2394
2395/* Test Osmocom dyn PDCH activation NACK behavior */
2396testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
2397 var RSL_Message rsl_unused;
2398
2399 /* change Timeslot 6 before f_init() starts RSL */
2400 f_init_vty();
2401 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
2402 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2403
2404 f_init(1, false);
2405 f_sleep(1.0);
2406
2407 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
2408
2409 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2410 /* The BSC will activate the dynamic PDCH by default, so confirm that */
2411 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
2412
2413 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
2414 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
2415 f_sleep(1.0);
2416 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
2417
2418 setverdict(pass);
2419}
2420
Harald Welte0ea2d5e2018-04-07 21:40:29 +02002421/* Dyn PDCH todo:
2422 * activate OSMO as TCH/F
2423 * activate OSMO as TCH/H
2424 * does the BSC-located PCU socket get the updated INFO?
2425 * what if no PCU is connected at the time?
2426 * is the info correct on delayed PCU (re)connect?
2427 */
Harald Welte94e0c342018-04-07 11:33:23 +02002428
Harald Welte28d943e2017-11-25 15:00:50 +01002429control {
Harald Welte898113b2018-01-31 18:32:21 +01002430 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01002431 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002432 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01002433 execute( TC_ctrl() );
Harald Welte898113b2018-01-31 18:32:21 +01002434
2435 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01002436 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01002437 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01002438 execute( TC_chan_act_ack_noest() );
2439 execute( TC_chan_act_ack_est_ind_noreply() );
2440 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01002441 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01002442 execute( TC_chan_exhaustion() );
Harald Welte4003d112017-12-09 22:35:39 +01002443 execute( TC_chan_rel_rll_rel_ind() );
2444 execute( TC_chan_rel_conn_fail() );
2445 execute( TC_chan_rel_hard_clear() );
Harald Welted8c36cd2017-12-09 23:05:31 +01002446 execute( TC_chan_rel_hard_rlsd() );
Harald Welte85804d42017-12-10 14:11:58 +01002447 execute( TC_chan_rel_a_reset() );
Harald Welte6f521d82017-12-11 19:52:02 +01002448
Harald Weltecfe2c962017-12-15 12:09:32 +01002449 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01002450
2451 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01002452 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01002453 execute( TC_assignment_csd() );
2454 execute( TC_assignment_ctm() );
2455 execute( TC_assignment_sign() );
2456 execute( TC_assignment_fr_a5_0() );
2457 execute( TC_assignment_fr_a5_1() );
Harald Welte8f67d1d2018-05-25 20:38:42 +02002458 if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) {
2459 execute( TC_assignment_fr_a5_1_codec_missing() );
2460 }
Harald Welte235ebf12017-12-15 14:18:16 +01002461 execute( TC_assignment_fr_a5_3() );
2462 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02002463 execute( TC_ciph_mode_a5_0() );
2464 execute( TC_ciph_mode_a5_1() );
2465 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01002466
Harald Welte60aa5762018-03-21 19:33:13 +01002467 execute( TC_assignment_codec_fr() );
2468 execute( TC_assignment_codec_hr() );
2469 execute( TC_assignment_codec_efr() );
2470 execute( TC_assignment_codec_amr_f() );
2471 execute( TC_assignment_codec_amr_h() );
2472
Harald Welte898113b2018-01-31 18:32:21 +01002473 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01002474 execute( TC_rll_est_ind_inact_lchan() );
2475 execute( TC_rll_est_ind_inval_sapi1() );
2476 execute( TC_rll_est_ind_inval_sapi3() );
2477 execute( TC_rll_est_ind_inval_sacch() );
2478
Harald Welte898113b2018-01-31 18:32:21 +01002479 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01002480 execute( TC_paging_imsi_nochan() );
2481 execute( TC_paging_tmsi_nochan() );
2482 execute( TC_paging_tmsi_any() );
2483 execute( TC_paging_tmsi_sdcch() );
2484 execute( TC_paging_tmsi_tch_f() );
2485 execute( TC_paging_tmsi_tch_hf() );
2486 execute( TC_paging_imsi_nochan_cgi() );
2487 execute( TC_paging_imsi_nochan_lac_ci() );
2488 execute( TC_paging_imsi_nochan_ci() );
2489 execute( TC_paging_imsi_nochan_lai() );
2490 execute( TC_paging_imsi_nochan_lac() );
2491 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01002492 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
2493 execute( TC_paging_imsi_nochan_rnc() );
2494 execute( TC_paging_imsi_nochan_lac_rnc() );
2495 execute( TC_paging_imsi_nochan_lacs() );
2496 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01002497 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01002498 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01002499 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01002500 execute( TC_paging_counter() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002501
2502 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002503 execute( TC_rsl_unknown_unit_id() );
2504
2505 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01002506
2507 execute( TC_classmark() );
2508 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01002509 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01002510 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01002511 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01002512 execute( TC_err_84_unknown_msg() );
Harald Welte261af4b2018-02-12 21:20:39 +01002513 execute( TC_ho_int() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01002514
2515 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01002516 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01002517 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02002518
2519 execute( TC_dyn_pdch_ipa_act_deact() );
2520 execute( TC_dyn_pdch_ipa_act_nack() );
2521 execute( TC_dyn_pdch_osmo_act_deact() );
2522 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte28d943e2017-11-25 15:00:50 +01002523}
2524
2525}