blob: b65d8999c3c38122500c7f2ae39758c8836d5702 [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
4 * (C) 2017 by Harald Welte <laforge@gnumonks.org>
5 * 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;
Harald Welteae026692017-12-09 01:03:01 +010031import from IPA_Types all;
32import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010033import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010034import from MGCP_Emulation all;
Harald Welte28d943e2017-11-25 15:00:50 +010035
Harald Welte96c94412017-12-09 03:12:45 +010036import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010037import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010038import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010039
Harald Welte6f521d82017-12-11 19:52:02 +010040import from MobileL3_CommonIE_Types all;
41import from L3_Templates all;
42import from GSM_RR_Types all;
43
Harald Welte5d1a2202017-12-13 19:51:29 +010044const integer NUM_BTS := 3;
Harald Welteae026692017-12-09 01:03:01 +010045const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010046
Harald Welte799c97b2017-12-14 17:50:30 +010047/* make sure to sync this with the osmo-bts.cfg you're using */
48const integer NUM_TCHF_PER_BTS := 5;
Harald Weltedd8cbf32018-01-28 12:07:52 +010049const integer NUM_SDCCH_PER_BTS := 4;
Harald Welte799c97b2017-12-14 17:50:30 +010050
Harald Welte4003d112017-12-09 22:35:39 +010051
Harald Welte21b46bd2017-12-17 19:46:32 +010052/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010053type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010054 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010055 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010056}
57
Harald Welteffe55fc2018-01-17 22:39:54 +010058type component test_CT extends BSSAP_Adapter_CT, CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +010059 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +010060 var BTS_State bts[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +010061 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +010062 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Harald Weltea5d2ab22017-12-09 14:21:42 +010063
Daniel Willmann191e0d92018-01-17 12:44:35 +010064 var MGCP_Emulation_CT vc_MGCP;
65
Harald Welte21b46bd2017-12-17 19:46:32 +010066 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +010067 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +010068
69 /* global test case guard timer */
Harald Welteae026692017-12-09 01:03:01 +010070 timer T_guard := 30.0;
71
Harald Welte28d943e2017-11-25 15:00:50 +010072}
73
74modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +010075 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +010076 charstring mp_bsc_ip := "127.0.0.1";
Harald Welte21b46bd2017-12-17 19:46:32 +010077 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +010078 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +010079 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +010080 integer mp_bsc_ctrl_port := 4249;
Daniel Willmann191e0d92018-01-17 12:44:35 +010081 /* IP address at which the test binds */
82 charstring mp_test_ip := "127.0.0.1";
Harald Welte28d943e2017-11-25 15:00:50 +010083}
84
Harald Welteae026692017-12-09 01:03:01 +010085type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +010086 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +010087 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +010088 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +010089 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +010090 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +010091 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +010092 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +010093 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +010094}
95
Harald Welte21b46bd2017-12-17 19:46:32 +010096/*! Start the IPA/RSL related bits for one IPA_Client.
97 * \param clnt IPA_Client for which to establish
98 * \param bsc_host IP address / hostname of the BSC
99 * \param bsc_port TCP port number of the BSC
100 * \param i number identifying this BTS
101 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100102function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
103 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100104runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100105 timer T := 10.0;
106
Harald Welte96c94412017-12-09 03:12:45 +0100107 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100108 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
109 clnt.ccm_pars := c_IPA_default_ccm_pars;
110 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
111 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100112 if (handler_mode) {
113 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
114 }
Harald Welteae026692017-12-09 01:03:01 +0100115
116 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100117 if (handler_mode) {
118 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
119 } else {
120 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
121 }
Harald Welteae026692017-12-09 01:03:01 +0100122
Harald Welte5d1a2202017-12-13 19:51:29 +0100123 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100124 if (handler_mode) {
125 clnt.vc_RSL.start(RSL_Emulation.main());
126 return;
127 }
Harald Welteae026692017-12-09 01:03:01 +0100128
129 /* wait for IPA RSL link to connect and send ID ACK */
130 T.start;
131 alt {
132 [] IPA_RSL[i].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_ID_ACK}) {
133 T.stop;
134 IPA_RSL[i].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23)));
135 }
Harald Welte60e823a2017-12-10 14:10:59 +0100136 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100137 [] IPA_RSL[i].receive { repeat }
138 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100139 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Harald Welteae026692017-12-09 01:03:01 +0100140 self.stop;
141 }
142 }
143}
144
Harald Welte21b46bd2017-12-17 19:46:32 +0100145/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100146function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
147 timer T := secs_max;
148 T.start;
149 while (true) {
150 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
151 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100152 /* the 'degraded' state exists from OML connection time, and we have to wait
153 * until all MO's are initialized */
154 T.start(1.0);
155 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100156 return;
157 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100158 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100159 if (not T.running) {
160 setverdict(fail, "Timeout waiting for oml-connection-state ", status);
161 self.stop;
162 }
163 }
164}
165
Harald Welte21b46bd2017-12-17 19:46:32 +0100166/* sleep for given number of (fractional) seconds */
Harald Welteae026692017-12-09 01:03:01 +0100167function f_sleep(float seconds) {
168 timer T := seconds;
169 T.start;
170 T.timeout;
171}
172
Harald Welte21b46bd2017-12-17 19:46:32 +0100173/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100174altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100175 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welteae026692017-12-09 01:03:01 +0100176 [] T_guard.timeout { setverdict(fail, "Timeout of T_guard"); }
Harald Welte60e823a2017-12-10 14:10:59 +0100177 /* always respond with RESET ACK to RESET */
178 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind {
179 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
180 ts_BSSMAP_ResetAck));
Harald Welte69c1c262017-12-13 21:02:08 +0100181 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100182 }
Harald Welte28d943e2017-11-25 15:00:50 +0100183}
184
Daniel Willmann191e0d92018-01-17 12:44:35 +0100185function f_init_mgcp(charstring id) runs on test_CT {
186 id := id & "-MGCP";
187
188 var MGCPOps ops := {
189 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
190 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
191 };
192 var MGCP_conn_parameters mgcp_pars := {
193 callagent_ip := mp_bsc_ip,
194 callagent_udp_port := 2727,
195 mgw_ip := mp_test_ip,
196 mgw_udp_port := 2427
197 };
198
199 vc_MGCP := MGCP_Emulation_CT.create(id);
200 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
201}
202
Harald Welte21b46bd2017-12-17 19:46:32 +0100203/* global initialization function
204 * \param nr_bts Number of BTSs we should start/bring up
205 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte89d42e82017-12-17 16:42:41 +0100206function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false) runs on test_CT {
Harald Welte28d943e2017-11-25 15:00:50 +0100207 var integer i;
Harald Welte28d943e2017-11-25 15:00:50 +0100208
Harald Welteae026692017-12-09 01:03:01 +0100209 if (g_initialized) {
210 return;
Harald Welte28d943e2017-11-25 15:00:50 +0100211 }
Harald Welteae026692017-12-09 01:03:01 +0100212 g_initialized := true;
213
214 /* Call a function of our 'parent component' BSSAP_Adapter_CT to start the
215 * MSC-side BSSAP emulation */
Harald Welte67089ee2018-01-17 22:19:03 +0100216 if (handler_mode) {
217 f_bssap_init("VirtMSC", MSC_BssmapOps);
218 } else {
219 f_bssap_init("VirtMSC", omit);
220 }
Harald Welteffe55fc2018-01-17 22:39:54 +0100221 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +0100222
Daniel Willmann191e0d92018-01-17 12:44:35 +0100223 f_init_mgcp("VirtMSC");
224
Harald Welte89d42e82017-12-17 16:42:41 +0100225 for (i := 0; i < nr_bts; i := i+1) {
Harald Weltea5d2ab22017-12-09 14:21:42 +0100226 /* wait until osmo-bts-omldummy has respawned */
227 f_wait_oml(i, "degraded", 5.0);
228 /* start RSL connection */
Harald Welte624f9632017-12-16 19:26:04 +0100229 f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i, handler_mode);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100230 /* wait until BSC tells us "connected" */
231 f_wait_oml(i, "connected", 5.0);
Harald Welte696ddb62017-12-08 14:01:43 +0100232 }
233
Harald Welteae026692017-12-09 01:03:01 +0100234 T_guard.start;
235 activate(as_Tguard());
Harald Welte28d943e2017-11-25 15:00:50 +0100236}
237
Harald Welte21b46bd2017-12-17 19:46:32 +0100238/* expect to receive a RSL message matching a specified templaten on a given BTS / stream */
Harald Welteae026692017-12-09 01:03:01 +0100239function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
240runs on test_CT return RSL_Message {
241 var ASP_RSL_Unitdata rx_rsl_ud;
242 timer T := t_secs;
243
244 T.start;
245 alt {
246 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud {
247 T.stop;
248 }
249 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +0100250 [] T.timeout {
251 setverdict(fail, "Timeout expecting ", t_rx);
252 self.stop;
253 }
Harald Welteae026692017-12-09 01:03:01 +0100254 }
255 return rx_rsl_ud.rsl;
256}
257
Harald Welte21b46bd2017-12-17 19:46:32 +0100258/* helper function to transmit RSL on a given BTS/stream */
Harald Welteae026692017-12-09 01:03:01 +0100259function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
260runs on test_CT {
261 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx));
262}
263
264
Harald Welte4003d112017-12-09 22:35:39 +0100265/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +0100266testcase TC_chan_act_noreply() runs on test_CT {
267 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte28d943e2017-11-25 15:00:50 +0100268
Harald Welte89d42e82017-12-17 16:42:41 +0100269 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100270 f_bssap_reset();
Harald Welte28d943e2017-11-25 15:00:50 +0100271
Harald Welteae026692017-12-09 01:03:01 +0100272 IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23)));
273 f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
274 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +0100275}
276
Harald Welte4003d112017-12-09 22:35:39 +0100277/* verify if the "chreq:total" counter increments as expected */
278testcase TC_chan_act_counter() runs on test_CT {
279 var BSSAP_N_UNITDATA_ind ud_ind;
280 var integer chreq_total;
281
Harald Welte89d42e82017-12-17 16:42:41 +0100282 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100283 f_bssap_reset();
284
285 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
286 IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23)));
287 f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
288 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
289
290 setverdict(pass);
291}
292
Harald Welteae026692017-12-09 01:03:01 +0100293/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
294testcase TC_chan_act_ack_noest() runs on test_CT {
295 var RSL_Message rx_rsl;
296
Harald Welte89d42e82017-12-17 16:42:41 +0100297 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100298 f_bssap_reset();
299
300 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100301 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100302
303 /* expect BSC to disable the channel again if there's no RLL EST IND */
304 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
305
306 setverdict(pass);
307}
308
309/* Test behavior if MSC never answers to CR */
310testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +0100311 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
312 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +0100313 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +0100314 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +0100315
Harald Welte89d42e82017-12-17 16:42:41 +0100316 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100317 f_bssap_reset();
318
319 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100320 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100321
322 var octetstring l3 := '00010203040506'O
323 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
324
325 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
326
327 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +0100328 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
329 IPA_RSL[0].clear;
330 alt {
331 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) -> value rx_rsl_ud { }
332 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_REL_REQ(chan_nr, ?))) -> value rx_rsl_ud {
333 f_ipa_tx(0, ts_RSL_REL_CONF(chan_nr, main_dcch));
334 repeat;
335 }
336 }
Harald Welteae026692017-12-09 01:03:01 +0100337
338 setverdict(pass);
339}
340
341/* Test behavior if MSC answers with CREF to CR */
342testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
343 var BSSAP_N_CONNECT_ind rx_c_ind;
344 var RSL_Message rx_rsl;
345
Harald Welte89d42e82017-12-17 16:42:41 +0100346 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100347 f_bssap_reset();
348
349 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100350 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100351
352 var octetstring l3 := '00010203040506'O
353 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
354
355 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
356 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
357
358 /* expect BSC to disable the channel */
359 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
360
361 setverdict(pass);
362}
363
Harald Welte618ef642017-12-14 14:58:20 +0100364/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
365testcase TC_chan_act_nack() runs on test_CT {
366 var RSL_Message rx_rsl;
367 var integer chact_nack;
368
Harald Welte89d42e82017-12-17 16:42:41 +0100369 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +0100370 f_bssap_reset();
371
372 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
373
374 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
375 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
376 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
377
378 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
379
380 /* wait for some time to hope the NACK arrives before the CTRL GET below */
381 f_sleep(0.5);
382
383 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
384
385 setverdict(pass);
386}
387
Harald Welte799c97b2017-12-14 17:50:30 +0100388/* Test for channel exhaustion due to RACH overload */
389testcase TC_chan_exhaustion() runs on test_CT {
390 var ASP_RSL_Unitdata rsl_ud;
391 var integer i;
392 var integer chreq_total, chreq_nochan;
393
Harald Welte89d42e82017-12-17 16:42:41 +0100394 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +0100395 f_bssap_reset();
396
397 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
398 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
399
400 /* expect 5xTCH/F to succeed */
Harald Weltedd8cbf32018-01-28 12:07:52 +0100401 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
Harald Welte799c97b2017-12-14 17:50:30 +0100402 f_chreq_act_ack('23'O, i);
403 }
404
405 IPA_RSL[0].clear;
406
Harald Weltedd8cbf32018-01-28 12:07:52 +0100407 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
408 chreq_total+NUM_TCHF_PER_BTS+NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +0100409
410 /* now expect additional channel activations to fail */
411 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
412
413 alt {
414 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
415 tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
416 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
417 }
418 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
419 var GsmRrMessage rr;
420 /* match on IMM ASS REJ */
421 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
422 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
423 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Harald Weltedd8cbf32018-01-28 12:07:52 +0100424 chreq_total+NUM_TCHF_PER_BTS+NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +0100425 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
426 chreq_nochan+1);
427 setverdict(pass);
428 } else {
429 repeat;
430 }
431 }
432 [] IPA_RSL[0].receive { repeat; }
433 }
434}
435
Harald Weltecfe2c962017-12-15 12:09:32 +0100436/***********************************************************************
437 * Assignment Testing
438 ***********************************************************************/
439
440/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction) */
441testcase TC_outbound_connect() runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +0100442 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +0100443 f_bssap_reset();
444
445 BSSAP.send(ts_BSSAP_CONNECT_req(g_sccp_addr_peer, g_sccp_addr_own, 2342, ts_BSSMAP_AssignmentReq));
446 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
447 setverdict(pass);
448}
449
Harald Welte16a4adf2017-12-14 18:54:01 +0100450/* Test behavior if MSC answers with CREF to CR */
451testcase TC_assignment_cic_only() runs on test_CT {
452 var BSSAP_N_CONNECT_ind rx_c_ind;
453 var RSL_Message rx_rsl;
454 var DchanTuple dt;
455
Harald Welte89d42e82017-12-17 16:42:41 +0100456 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +0100457 f_bssap_reset();
458
459 dt := f_est_dchan('23'O, 23, '00000000'O);
460 /* send assignment without AoIP IEs */
Harald Weltecc7e4dc2017-12-14 21:55:10 +0100461 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
Harald Welte16a4adf2017-12-14 18:54:01 +0100462 alt {
463 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
464 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
465 }
Harald Welte235ebf12017-12-15 14:18:16 +0100466 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +0100467 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
468 setverdict(pass);
469 }
470 [] BSSAP.receive { repeat; }
471 }
472}
473
Harald Welte235ebf12017-12-15 14:18:16 +0100474/* Run everything required up to sending a caller-specified assignment command and expect response */
475function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
476runs on test_CT {
477 var BSSAP_N_CONNECT_ind rx_c_ind;
478 var RSL_Message rx_rsl;
479 var DchanTuple dt;
480
Harald Welte89d42e82017-12-17 16:42:41 +0100481 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +0100482 f_bssap_reset();
483
484 dt := f_est_dchan('23'O, 23, '00000000'O);
485 /* send assignment without AoIP IEs */
486 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
487 alt {
488 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
489 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
490 setverdict(pass);
491 } else {
492 setverdict(fail, fail_text);
493 }
494 }
495 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
496 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
497 setverdict(pass);
498 } else {
499 setverdict(fail, fail_text);
500 }
501 }
502 [] BSSAP.receive { repeat; }
503 }
504}
505testcase TC_assignment_csd() runs on test_CT {
506 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
507 var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
508 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
509 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
510 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
511 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
512}
513
514testcase TC_assignment_ctm() runs on test_CT {
515 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
516 var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
517 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
518 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
519 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
520 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
521}
522
Harald Welte4003d112017-12-09 22:35:39 +0100523type record DchanTuple {
524 integer sccp_conn_id,
525 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +0100526}
527
Harald Welted6939652017-12-13 21:02:46 +0100528/* Send CHAN RQD and wait for allocation; acknowledge it */
529private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
530runs on test_CT return RslChannelNr {
531 var RSL_Message rx_rsl;
532 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
533 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
534 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
535 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
536 return chan_nr;
537}
538
Harald Welte4003d112017-12-09 22:35:39 +0100539/* helper function to establish a dedicated channel via BTS and MSC */
540function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
541runs on test_CT return DchanTuple {
542 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +0100543 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100544
Harald Welte4003d112017-12-09 22:35:39 +0100545 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100546 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +0100547
548 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
549
550 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
551 dt.sccp_conn_id := rx_c_ind.connectionId;
552 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
553
554 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100555}
556
Harald Welte4003d112017-12-09 22:35:39 +0100557/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
558testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
559 var RSL_Message rx_rsl;
560 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +0100561
Harald Welte89d42e82017-12-17 16:42:41 +0100562 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +0100563 f_bssap_reset();
564
Harald Welte4003d112017-12-09 22:35:39 +0100565 dt := f_est_dchan('23'O, 23, '00010203040506'O);
566
567 /* simulate RLL REL IND */
568 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
569
570 /* expect BSC to disable the channel */
571 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
572 /* respond with CHAN REL ACK */
573 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
574
575 /* expect DISC_IND on MSC side */
576 BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?));
577
578 setverdict(pass);
579}
580
581/* Test behavior of channel release after CONN FAIL IND from BTS */
582testcase TC_chan_rel_conn_fail() runs on test_CT {
583 var BSSAP_N_DATA_ind rx_di;
584 var RSL_Message rx_rsl;
585 var DchanTuple dt;
586
Harald Welte89d42e82017-12-17 16:42:41 +0100587 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100588 f_bssap_reset();
589
590 dt := f_est_dchan('23'O, 23, '00010203040506'O);
591
592 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +0100593 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 +0100594 /* TODO: different cause values? */
595
Harald Welte4003d112017-12-09 22:35:39 +0100596 /* expect Clear Request from BSC */
597 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
598
599 /* Instruct BSC to clear channel */
600 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
601 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
602
Harald Welte6ff76ea2018-01-28 13:08:01 +0100603 /* expect BSC to disable the channel */
604 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
605 /* respond with CHAN REL ACK */
606 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
607
Harald Welte4003d112017-12-09 22:35:39 +0100608 /* expect Clear Complete from BSC */
609 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
610
611 /* release the SCCP connection */
612 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
613
614 /* wait for SCCP emulation to do its job */
615 f_sleep(1.0);
616
617 setverdict(pass);
618}
619
Harald Welte91d54a52018-01-28 15:35:07 +0100620function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr, boolean flush := true,
621 boolean handle_rll_rel := true) runs on test_CT {
622
623 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
624 if (flush) {
625 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
626 IPA_RSL[bts_nr].clear;
627 }
628 alt {
629 /* ignore DEACTIVATE SACCH (if any) */
630 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
631 tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
632 repeat;
633 }
634 /* acknowledge RLL release (if any)*/
635 [handle_rll_rel] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
636 tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
637 /* FIXME: Why are we getting this for LinkID SACCH? */
638 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
639 repeat;
640 }
641 /* Expect RF channel release from BSC on Abis */
642 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,
643 tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
644 /* respond with CHAN REL ACK */
645 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
646 }
647 /* ignore any user data */
648 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) {
649 repeat;
650 }
651 }
652}
653
Harald Welte4003d112017-12-09 22:35:39 +0100654/* Test behavior of channel release after hard Clear Command from MSC */
655testcase TC_chan_rel_hard_clear() runs on test_CT {
656 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +0100657 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +0100658
Harald Welte89d42e82017-12-17 16:42:41 +0100659 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100660 f_bssap_reset();
661
662 dt := f_est_dchan('23'O, 23, '00010203040506'O);
663
664 /* Instruct BSC to clear channel */
665 var BssmapCause cause := 0;
666 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
667
668 /* expect Clear Complete from BSC on A */
669 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
670 /* release the SCCP connection */
671 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
672 }
673
Harald Welte91d54a52018-01-28 15:35:07 +0100674 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welte4003d112017-12-09 22:35:39 +0100675 setverdict(pass);
676}
677
Harald Welted8c36cd2017-12-09 23:05:31 +0100678/* Test behavior of channel release after hard RLSD from MSC */
679testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +0100680 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +0100681
Harald Welte89d42e82017-12-17 16:42:41 +0100682 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +0100683 f_bssap_reset();
684
685 dt := f_est_dchan('23'O, 23, '00010203040506'O);
686
687 /* release the SCCP connection */
688 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
689
Harald Welte91d54a52018-01-28 15:35:07 +0100690 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welted8c36cd2017-12-09 23:05:31 +0100691 setverdict(pass);
692}
693
Harald Welte85804d42017-12-10 14:11:58 +0100694/* Test behavior of channel release after BSSMAP RESET from MSC */
695testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +0100696 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +0100697
Harald Welte89d42e82017-12-17 16:42:41 +0100698 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +0100699 f_bssap_reset();
700
701 dt := f_est_dchan('23'O, 23, '00010203040506'O);
702
703 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
704 IPA_RSL[0].clear;
705
706 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
707 BSSAP.send(ts_BSSAP_UNITDATA_req(g_sccp_addr_peer, g_sccp_addr_own, ts_BSSMAP_Reset(0)));
708 interleave {
709 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_sccp_addr_own, g_sccp_addr_peer, tr_BSSMAP_ResetAck)) { }
710 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
711 }
712
Harald Welte91d54a52018-01-28 15:35:07 +0100713 f_expect_chan_rel(0, dt.rsl_chan_nr);
Harald Welte85804d42017-12-10 14:11:58 +0100714 setverdict(pass);
715}
716
Harald Welte5cd20ed2017-12-13 21:03:20 +0100717/* Test behavior if RSL EST IND for non-active channel */
718testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
719 timer T := 2.0;
720
Harald Welte89d42e82017-12-17 16:42:41 +0100721 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100722 f_bssap_reset();
723
724 var octetstring l3 := '00010203040506'O;
725 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
726 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
727
728 T.start;
729 alt {
730 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
731 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
732 }
733 [] BSSAP.receive {}
734 [] IPA_RSL[0].receive {}
735 [] T.timeout {}
736 }
737
738 setverdict(pass);
739}
740
741/* Test behavior if RSL EST IND for invalid SAPI */
742testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
743 var RslChannelNr chan_nr;
744
Harald Welte89d42e82017-12-17 16:42:41 +0100745 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100746 f_bssap_reset();
747
748 chan_nr := f_chreq_act_ack()
749
750 var octetstring l3 := '00010203040506'O;
751 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
752
753 timer T := 2.0;
754 T.start;
755 alt {
756 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
757 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
758 }
759 [] BSSAP.receive { repeat; }
760 [] IPA_RSL[0].receive { repeat; }
761 [] T.timeout {}
762 }
763
764 setverdict(pass);
765}
766
767/* Test behavior if RSL EST IND for invalid SAPI */
768testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
769 timer T := 2.0;
770
Harald Welte89d42e82017-12-17 16:42:41 +0100771 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100772 f_bssap_reset();
773
774 var RslChannelNr chan_nr := f_chreq_act_ack();
775
776 var octetstring l3 := '00010203040506'O;
777 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
778
779 T.start;
780 alt {
781 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
782 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
783 }
784 [] BSSAP.receive { repeat; }
785 [] IPA_RSL[0].receive { repeat; }
786 [] T.timeout {}
787 }
788
789 setverdict(pass);
790}
791
792/* Test behavior if RSL EST IND for invalid SACCH */
793testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
794 timer T := 2.0;
795
Harald Welte89d42e82017-12-17 16:42:41 +0100796 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +0100797 f_bssap_reset();
798
799 var RslChannelNr chan_nr := f_chreq_act_ack();
800
801 var octetstring l3 := '00010203040506'O;
802 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
803
804 T.start;
805 alt {
806 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
807 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
808 }
809 [] BSSAP.receive { repeat; }
810 [] IPA_RSL[0].receive { repeat; }
811 [] T.timeout {}
812 }
813
814 setverdict(pass);
815}
816
817
818
Harald Welte4003d112017-12-09 22:35:39 +0100819
820testcase TC_ctrl_msc_connection_status() runs on test_CT {
821 var charstring ctrl_resp;
822
Harald Welte89d42e82017-12-17 16:42:41 +0100823 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100824 f_bssap_reset();
825
826 /* See https://osmocom.org/issues/2729 */
827 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
828 setverdict(pass);
829}
830
Stefan Sperlingb041b3d2018-01-03 17:14:55 +0100831testcase TC_ctrl_msc0_connection_status() runs on test_CT {
832 var charstring ctrl_resp;
833
834 f_init(1);
835 f_bssap_reset();
836
837 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
838 setverdict(pass);
839}
840
Harald Welte4003d112017-12-09 22:35:39 +0100841testcase TC_ctrl() runs on test_CT {
842 var charstring ctrl_resp;
843
Harald Welte89d42e82017-12-17 16:42:41 +0100844 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100845 f_bssap_reset();
846
847 /* all below values must match the osmo-bsc.cfg config file used */
848
849 f_ctrl_get_exp(IPA_CTRL, "mcc", "1");
850 f_ctrl_get_exp(IPA_CTRL, "mnc", "1");
Harald Welte44bdaa52017-12-17 17:01:47 +0100851 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "3");
Harald Welte4003d112017-12-09 22:35:39 +0100852
853 var integer bts_nr := 0;
854 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
855 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
856 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
857 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
858 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
859 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
860 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
861
862 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
863 f_sleep(2.0);
864 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
865 setverdict(fail, "oml-uptime not incrementing as expected");
866 }
867 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
868
869 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
870
871 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +0100872}
873
Harald Welte6f521d82017-12-11 19:52:02 +0100874function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT {
875 BSSAP.send(ts_BSSAP_UNITDATA_req(g_sccp_addr_peer, g_sccp_addr_own, bssap));
876}
877
878
879/***********************************************************************
880 * Paging Testing
881 ***********************************************************************/
882
883type record Cell_Identity {
884 GsmMcc mcc,
885 GsmMnc mnc,
886 GsmLac lac,
887 GsmCellId ci
888};
889private const Cell_Identity cid := { '001'H, '001'H, 1, 0 };
890
Harald Welte5d1a2202017-12-13 19:51:29 +0100891type set of integer BtsIdList;
892
893private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
894 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
895 if (bts_id == bts_ids[j]) {
896 return true;
897 }
898 }
899 return false;
900}
Harald Welte6f521d82017-12-11 19:52:02 +0100901
902/* core paging test helper function; used by most paging test cases */
903private function f_pageing_helper(hexstring imsi,
904 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +0100905 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +0100906 template RSL_ChanNeeded rsl_chneed := omit,
907 template OCT4 tmsi := omit) runs on test_CT
908{
909 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
910 var MobileIdentity mi;
911 var template octetstring id_enc; /* FIXME */
912 var RSL_Message rx_rsl;
913 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +0100914 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +0100915
916 f_init();
917 f_bssap_reset();
918
919 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Welte5d1a2202017-12-13 19:51:29 +0100920 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
921 IPA_RSL[bts_ids[i]].clear;
922 }
Harald Welte6f521d82017-12-11 19:52:02 +0100923
924 if (isvalue(rsl_chneed)) {
925 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
926 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
927 } else {
928 bssmap_chneed := omit;
929 }
930
931 f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed));
932
933/* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder
934 if (isvalue(tmsi)) {
935 mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi))));
936 } else {
937 mi := valueof(ts_Osmo_MI_IMSI(imsi));
938 }
939 id_enc := enc_MobileIdentity(mi);
940*/
941 id_enc := ?;
Harald Welte5d1a2202017-12-13 19:51:29 +0100942 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
943 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc));
944 /* check channel type, paging group */
945 if (rx_rsl.ies[1].body.paging_group != paging_group) {
946 setverdict(fail, "Paging for wrong paging group");
947 }
948 if (ispresent(rsl_chneed) and
949 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
950 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
951 }
Harald Welte6f521d82017-12-11 19:52:02 +0100952 }
Harald Welte5d1a2202017-12-13 19:51:29 +0100953 /* do a quick check on all not-included BTSs if they received paging */
954 for (i := 0; i < NUM_BTS; i := i + 1) {
955 timer T := 0.1;
956 if (f_bts_in_list(i, bts_ids)) {
957 continue;
958 }
959 T.start;
960 alt {
961 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) {
962 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
963 }
964 [] IPA_RSL[i].receive { repeat; }
965 [] T.timeout { }
966 }
Harald Welte6f521d82017-12-11 19:52:02 +0100967 }
968
969 setverdict(pass);
970}
971
Harald Welte5d1a2202017-12-13 19:51:29 +0100972const BtsIdList c_BtsId_all := { 0, 1, 2 };
973const BtsIdList c_BtsId_LAC1 := { 0, 1 };
974const BtsIdList c_BtsId_LAC2 := { 2 };
975
Harald Welte6f521d82017-12-11 19:52:02 +0100976/* PAGING by IMSI + TMSI */
977testcase TC_paging_imsi_nochan() runs on test_CT {
978 var BSSMAP_FIELD_CellIdentificationList cid_list;
979 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +0100980 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte6f521d82017-12-11 19:52:02 +0100981}
982
983/* PAGING by IMSI + TMSI */
984testcase TC_paging_tmsi_nochan() runs on test_CT {
985 var BSSMAP_FIELD_CellIdentificationList cid_list;
986 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +0100987 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Harald Welte6f521d82017-12-11 19:52:02 +0100988}
989
990/* Paging with different "channel needed' values */
991testcase TC_paging_tmsi_any() runs on test_CT {
992 var BSSMAP_FIELD_CellIdentificationList cid_list;
993 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +0100994 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Harald Welte6f521d82017-12-11 19:52:02 +0100995}
996testcase TC_paging_tmsi_sdcch() runs on test_CT {
997 var BSSMAP_FIELD_CellIdentificationList cid_list;
998 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +0100999 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Harald Welte6f521d82017-12-11 19:52:02 +01001000}
1001testcase TC_paging_tmsi_tch_f() runs on test_CT {
1002 var BSSMAP_FIELD_CellIdentificationList cid_list;
1003 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001004 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Harald Welte6f521d82017-12-11 19:52:02 +01001005}
1006testcase TC_paging_tmsi_tch_hf() runs on test_CT {
1007 var BSSMAP_FIELD_CellIdentificationList cid_list;
1008 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001009 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Harald Welte6f521d82017-12-11 19:52:02 +01001010}
1011
1012/* Paging by CGI */
1013testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
1014 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1015 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001016 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Harald Welte6f521d82017-12-11 19:52:02 +01001017}
1018
1019/* Paging by LAC+CI */
1020testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
1021 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1022 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001023 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Harald Welte6f521d82017-12-11 19:52:02 +01001024}
1025
1026/* Paging by CI */
1027testcase TC_paging_imsi_nochan_ci() runs on test_CT {
1028 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1029 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001030 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Harald Welte6f521d82017-12-11 19:52:02 +01001031}
1032
1033/* Paging by LAI */
1034testcase TC_paging_imsi_nochan_lai() runs on test_CT {
1035 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1036 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001037 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Harald Welte6f521d82017-12-11 19:52:02 +01001038}
1039
1040/* Paging by LAC */
1041testcase TC_paging_imsi_nochan_lac() runs on test_CT {
1042 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1043 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01001044 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Harald Welte6f521d82017-12-11 19:52:02 +01001045}
1046
1047/* Paging by "all in BSS" */
1048testcase TC_paging_imsi_nochan_all() runs on test_CT {
1049 var template BSSMAP_FIELD_CellIdentificationList cid_list;
1050 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01001051 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Harald Welte6f521d82017-12-11 19:52:02 +01001052}
1053
1054/* Paging by PLMN+LAC+RNC */
1055/* Paging by RNC */
1056/* Paging by LAC+RNC */
1057
1058/* Paging on multiple cells (multiple in one LAC): Verify all of them page */
1059/* Paging on multiple cells (multiple entries in list): Verify all of them page */
1060/* Verify paging retransmission interval + count */
1061/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01001062/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01001063
Harald Weltee65d40e2017-12-13 00:09:06 +01001064/* Verify PCH load */
1065testcase TC_paging_imsi_load() runs on test_CT {
1066 var BSSMAP_FIELD_CellIdentificationList cid_list;
1067 timer T := 4.0;
1068 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001069 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01001070
1071 /* tell BSC there is no paging space anymore */
1072 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
1073
1074 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
1075 * there would be 8 retransmissions during 4 seconds */
1076 T.start;
1077 alt {
1078 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1079 setverdict(fail, "Received PAGING after LOAD_IND(0)");
1080 self.stop;
1081 }
1082 [] T.timeout {
1083 setverdict(pass);
1084 }
1085 }
1086}
1087
Harald Welte235ebf12017-12-15 14:18:16 +01001088/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01001089testcase TC_paging_counter() runs on test_CT {
1090 var BSSMAP_FIELD_CellIdentificationList cid_list;
1091 timer T := 4.0;
1092 var integer i;
1093 var integer paging_attempted_bsc;
1094 var integer paging_attempted_bts[NUM_BTS];
1095 var integer paging_expired_bts[NUM_BTS];
1096 cid_list := valueof(ts_BSSMAP_CIL_noCell);
1097
1098 f_init();
1099
1100 /* read counters before paging */
1101 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
1102 for (i := 0; i < NUM_BTS; i := i+1) {
1103 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
1104 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
1105 }
1106
1107 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
1108
1109 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
1110 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
1111 for (i := 0; i < NUM_BTS; i := i+1) {
1112 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
1113 paging_attempted_bts[i]+1);
1114 }
1115
1116 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
1117 f_sleep(12.0);
1118 for (i := 0; i < NUM_BTS; i := i+1) {
1119 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
1120 paging_expired_bts[i]+1);
1121 }
1122 setverdict(pass);
1123
1124}
1125
1126
Harald Welte10985002017-12-12 09:29:15 +01001127/* Verify paging stops after A-RESET */
1128testcase TC_paging_imsi_a_reset() runs on test_CT {
1129 var BSSMAP_FIELD_CellIdentificationList cid_list;
1130 timer T := 3.0;
1131 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01001132 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01001133
1134 /* Perform a BSSMAP Reset and wait for ACK */
1135 BSSAP.send(ts_BSSAP_UNITDATA_req(g_sccp_addr_peer, g_sccp_addr_own, ts_BSSMAP_Reset(0)));
1136 alt {
1137 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_sccp_addr_own, g_sccp_addr_peer, tr_BSSMAP_ResetAck)) { }
1138 [] BSSAP.receive { repeat; }
1139 }
1140
1141 /* Clear the queue, it might still contain stuff like BCCH FILLING */
1142 IPA_RSL[0].clear;
1143
1144 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
1145 T.start;
1146 alt {
1147 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1148 setverdict(fail, "Received PAGING after A-RESET");
1149 self.stop;
1150 }
Harald Welte5d1a2202017-12-13 19:51:29 +01001151 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1152 setverdict(fail, "Received PAGING after A-RESET");
1153 self.stop;
1154 }
1155 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) {
1156 setverdict(fail, "Received PAGING after A-RESET");
1157 self.stop;
1158 }
Harald Welte10985002017-12-12 09:29:15 +01001159 [] T.timeout {
1160 setverdict(pass);
1161 }
1162 }
1163}
Harald Welteae026692017-12-09 01:03:01 +01001164
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001165/* Test RSL link drop causes counter increment */
1166testcase TC_rsl_drop_counter() runs on test_CT {
1167 var integer rsl_fail;
1168
Harald Welte89d42e82017-12-17 16:42:41 +01001169 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001170 f_bssap_reset();
1171
1172 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
1173
1174 bts[0].rsl.vc_IPA.stop;
1175
1176 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
1177
1178 setverdict(pass);
1179}
1180
1181/* TODO: Test OML link drop causes counter increment */
1182
Harald Weltec1a2fff2017-12-17 11:06:19 +01001183/***********************************************************************
1184 * "New world" test cases using RSL_Emulation + BSSMAP_Emulation
1185 ***********************************************************************/
1186
1187import from BSSMAP_Emulation all;
1188import from RSL_Emulation all;
1189import from MSC_ConnectionHandler all;
1190
1191type function void_fn(charstring id) runs on MSC_ConnHdlr;
1192
1193/* helper function to create, connect and start a MSC_ConnHdlr component */
1194function f_start_handler(void_fn fn, charstring id) runs on test_CT return MSC_ConnHdlr {
1195 var MSC_ConnHdlr vc_conn;
1196
1197 vc_conn := MSC_ConnHdlr.create(id);
1198 connect(vc_conn:BSSMAPEM, vc_BSSMAP:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001199 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001200 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
1201 connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01001202 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001203 vc_conn.start(derefers(fn)(id));
1204 return vc_conn;
1205}
1206
Harald Welte552620d2017-12-16 23:21:36 +01001207private function f_tc_assignment_fr_a5_0(charstring id) runs on MSC_ConnHdlr {
1208 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1209 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
1210 var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1211 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1212 const OCT8 kc := '0001020304050607'O;
Harald Weltec1a2fff2017-12-17 11:06:19 +01001213
Harald Welte552620d2017-12-16 23:21:36 +01001214 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1215 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001216
Harald Welte552620d2017-12-16 23:21:36 +01001217 f_establish_fully(pars, ass_cmd, exp_compl);
Harald Welte73cd2712017-12-17 00:44:52 +01001218 f_cipher_mode('01'O, kc);
Harald Welte552620d2017-12-16 23:21:36 +01001219}
1220
1221testcase TC_assignment_fr_a5_0() runs on test_CT {
1222 var MSC_ConnHdlr vc_conn;
1223
Harald Welte89d42e82017-12-17 16:42:41 +01001224 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001225 f_sleep(1.0);
1226
1227 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_0), testcasename());
1228 vc_conn.done;
1229}
1230
1231
1232
1233private function f_tc_assignment_fr_a5_1(charstring id) runs on MSC_ConnHdlr {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001234 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1235
1236 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
1237 var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1238 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1239 const OCT8 kc := '0001020304050607'O;
1240
1241 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1242 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltec1a2fff2017-12-17 11:06:19 +01001243
1244 f_establish_fully(pars, ass_cmd, exp_compl);
Harald Welte73cd2712017-12-17 00:44:52 +01001245 f_cipher_mode('02'O, kc);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001246}
1247
Harald Welte552620d2017-12-16 23:21:36 +01001248testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01001249 var MSC_ConnHdlr vc_conn;
1250
Harald Welte89d42e82017-12-17 16:42:41 +01001251 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01001252 f_sleep(1.0);
1253
Harald Welte552620d2017-12-16 23:21:36 +01001254 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1), testcasename());
Harald Weltec1a2fff2017-12-17 11:06:19 +01001255 vc_conn.done;
1256}
1257
Harald Welte552620d2017-12-16 23:21:36 +01001258/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
1259private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
1260 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1261 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
1262 var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1263 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1264 const OCT8 kc := '0001020304050607'O;
1265
1266 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Harald Welte552620d2017-12-16 23:21:36 +01001267 f_establish_fully(pars, ass_cmd, exp_fail);
1268}
1269
1270testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
1271 var MSC_ConnHdlr vc_conn;
1272
Harald Welte89d42e82017-12-17 16:42:41 +01001273 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001274 f_sleep(1.0);
1275
1276 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing), testcasename());
1277 vc_conn.done;
1278}
1279
1280
1281private function f_tc_assignment_fr_a5_3(charstring id ) runs on MSC_ConnHdlr {
1282 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1283 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
1284 var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1285 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1286 const OCT8 kc := '0001020304050607'O;
1287
1288 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1289 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01001290
Harald Welte552620d2017-12-16 23:21:36 +01001291 f_establish_fully(pars, ass_cmd, exp_compl);
Harald Welte73cd2712017-12-17 00:44:52 +01001292 f_cipher_mode('08'O, kc);
Harald Welte552620d2017-12-16 23:21:36 +01001293}
1294
1295testcase TC_assignment_fr_a5_3() runs on test_CT {
1296 var MSC_ConnHdlr vc_conn;
1297
Harald Welte89d42e82017-12-17 16:42:41 +01001298 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001299 f_sleep(1.0);
1300
1301 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_3), testcasename());
1302 vc_conn.done;
1303}
1304
1305
1306private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
1307 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Harald Welte38b2a102017-12-23 02:42:58 +01001308 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
Harald Welte552620d2017-12-16 23:21:36 +01001309 var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1310 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1311 const OCT8 kc := '0001020304050607'O;
1312 const OCT16 kc128 := kc & kc;
1313
1314 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
1315 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte38b2a102017-12-23 02:42:58 +01001316 f_establish_fully(pars, ass_cmd, exp_compl);
1317 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01001318 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01001319}
1320
1321testcase TC_assignment_fr_a5_4() runs on test_CT {
1322 var MSC_ConnHdlr vc_conn;
1323
Harald Welte89d42e82017-12-17 16:42:41 +01001324 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01001325 f_sleep(1.0);
1326
1327 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4), testcasename());
1328 vc_conn.done;
1329}
1330
1331
Harald Welte4532e0a2017-12-23 02:05:44 +01001332private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
1333 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
1334 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
1335 var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, omit));
1336
1337 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
1338 f_establish_fully(pars, ass_cmd, exp_compl);
1339}
1340
1341testcase TC_assignment_sign() runs on test_CT {
1342 var MSC_ConnHdlr vc_conn;
1343
1344 f_init(1, true);
1345 f_sleep(1.0);
1346
1347 vc_conn := f_start_handler(refers(f_tc_assignment_sign), testcasename());
1348 vc_conn.done;
1349}
1350
Harald Welte552620d2017-12-16 23:21:36 +01001351
1352
Harald Welte28d943e2017-11-25 15:00:50 +01001353control {
Harald Welte4003d112017-12-09 22:35:39 +01001354 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001355 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01001356 execute( TC_ctrl() );
Harald Welteae026692017-12-09 01:03:01 +01001357 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01001358 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01001359 execute( TC_chan_act_ack_noest() );
1360 execute( TC_chan_act_ack_est_ind_noreply() );
1361 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01001362 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01001363 execute( TC_chan_exhaustion() );
Harald Welte4003d112017-12-09 22:35:39 +01001364 execute( TC_chan_rel_rll_rel_ind() );
1365 execute( TC_chan_rel_conn_fail() );
1366 execute( TC_chan_rel_hard_clear() );
Harald Welted8c36cd2017-12-09 23:05:31 +01001367 execute( TC_chan_rel_hard_rlsd() );
Harald Welte85804d42017-12-10 14:11:58 +01001368 execute( TC_chan_rel_a_reset() );
Harald Welte6f521d82017-12-11 19:52:02 +01001369
Harald Weltecfe2c962017-12-15 12:09:32 +01001370 execute( TC_outbound_connect() );
Harald Welte16a4adf2017-12-14 18:54:01 +01001371 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01001372 execute( TC_assignment_csd() );
1373 execute( TC_assignment_ctm() );
1374 execute( TC_assignment_sign() );
1375 execute( TC_assignment_fr_a5_0() );
1376 execute( TC_assignment_fr_a5_1() );
Harald Weltef1b64e22017-12-15 14:55:14 +01001377 execute( TC_assignment_fr_a5_1_codec_missing() );
Harald Welte235ebf12017-12-15 14:18:16 +01001378 execute( TC_assignment_fr_a5_3() );
1379 execute( TC_assignment_fr_a5_4() );
Harald Welte16a4adf2017-12-14 18:54:01 +01001380
Harald Welte5cd20ed2017-12-13 21:03:20 +01001381 execute( TC_rll_est_ind_inact_lchan() );
1382 execute( TC_rll_est_ind_inval_sapi1() );
1383 execute( TC_rll_est_ind_inval_sapi3() );
1384 execute( TC_rll_est_ind_inval_sacch() );
1385
Harald Welte6f521d82017-12-11 19:52:02 +01001386 execute( TC_paging_imsi_nochan() );
1387 execute( TC_paging_tmsi_nochan() );
1388 execute( TC_paging_tmsi_any() );
1389 execute( TC_paging_tmsi_sdcch() );
1390 execute( TC_paging_tmsi_tch_f() );
1391 execute( TC_paging_tmsi_tch_hf() );
1392 execute( TC_paging_imsi_nochan_cgi() );
1393 execute( TC_paging_imsi_nochan_lac_ci() );
1394 execute( TC_paging_imsi_nochan_ci() );
1395 execute( TC_paging_imsi_nochan_lai() );
1396 execute( TC_paging_imsi_nochan_lac() );
1397 execute( TC_paging_imsi_nochan_all() );
Harald Welte10985002017-12-12 09:29:15 +01001398 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01001399 execute( TC_paging_imsi_load() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01001400
1401 execute( TC_rsl_drop_counter() );
Harald Welte28d943e2017-11-25 15:00:50 +01001402}
1403
1404}