blob: 680f1e2ad4644a50b163264c1ce389a3b85651f7 [file] [log] [blame]
Harald Welte5a1d7272023-05-10 19:49:44 +02001module BTS_Tests_ASCI {
2
3/* ASCI Integration Tests for OsmoBTS
4 *
5 * (C) 2023 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
6 * All Rights Reserved
7 *
8 * SPDX-License-Identifier: AGPL-3.0+
9 *
10 * Authors: Harald Welte; Andreas Eversberg
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Affero General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
21 *
22 * You should have received a copy of the GNU Affero General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26import from Misc_Helpers all;
27import from General_Types all;
28import from Osmocom_Types all;
29import from GSM_Types all;
30import from L1CTL_PortType all;
31import from L1CTL_Types all;
32import from LAPDm_Types all;
33import from IPA_Emulation all;
34import from GSM_RR_Types all;
35import from L3_Templates all;
36
37import from MobileL3_CommonIE_Types all;
38
39import from RSL_Emulation all;
40import from RSL_Types all;
41
42import from BTS_Tests all;
43
44
45
46/* convert from boolean value to BIT1 */
47private function bool2bit1(boolean inp) return BIT1 {
48 if (inp) {
49 return '1'B;
50 } else {
51 return '0'B;
52 }
53}
54
55/* encode a VBS/VGCS call reference into it's OCT5 representation */
56private function f_enc_gcr(integer call_ref, boolean is_group_call, boolean ack_required := false)
57return OCT5
58{
59 var DescriptiveGroupOrBroadcastCallReference_V v := {
60 binaryCodingOfGroupOrBroadcastCallReference := int2bit(call_ref, 27),
61 sF := bool2bit1(is_group_call),
62 aF := bool2bit1(ack_required),
63 callPriority := '000'B,
64 cipheringInformation := '0000'B,
65 spare := '0000'B
66 }
67 return bit2oct(encvalue(v));
68}
69
70/* Send Notification command to start and stop notifying an ASCI call.
71 * When it starts, it is expected that NCH is received by MS. Also it is expected that NCH is received again.
72 * When it stops, it is expected that NCH is not received anymore. */
73testcase TC_vbs_notification() runs on test_CT
74{
75 timer T;
76
77 f_init();
78 f_init_l1ctl();
79 f_l1_tune(L1CTL);
80
81 var OCT5 gcr := f_enc_gcr(hex2int('2342'H), false, false);
82 var OCT3 chan_desc := '234266'O;
83 var octetstring notif_nch := '090620B42230000091A1330B2B2B2B2B2B2B2B2B2B2B2B'O;
84 var integer recv_count := 0;
85
86 log("Sending RSL NOTIF_CMD (start)");
87 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_NOTIF_CMD_START(gcr, chan_desc)));
88
89 /* NCH must be received twice. */
90 T.start(2.0);
91 alt {
92 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, notif_nch)) {
93 log("Received matching NOTIFICATION/NCH.");
94 recv_count := recv_count + 1;
95 if (recv_count != 2) {
96 repeat;
97 }
98 T.stop;
99 }
100 [] L1CTL.receive { repeat; }
101 [] T.timeout {
102 setverdict(fail, "Timeout waiting for NCH message");
103 }
104 }
105
106 log("Sending RSL NOTIF_CMD (stop)");
107 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_NOTIF_CMD_STOP(gcr)));
108
109 /* Flush pending messages and be sure that the sending of notifications has stopped. */
110 f_sleep(1.0);
111 L1CTL.clear;
112
113 /* NCH must not be received. */
114 T.start(2.0);
115 alt {
116 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, notif_nch)) {
117 T.stop;
118 setverdict(fail, "Received unexpected NOTIFICATION/NCH.");
119 }
120 [] L1CTL.receive { repeat; }
121 [] T.timeout {
122 log("Not received NOTIFICATION/NCH. (as expected)");
123 setverdict(pass);
124 }
125 }
126
127 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
128}
129
Andreas Eversberg4801baa2023-07-17 11:45:38 +0200130/* Sub function to clean up MS and BTS. */
131private function f_vgcs_cleanup() runs on ConnHdlr
132{
133 /* Cleanup L1CTL. */
134 f_L1CTL_RESET(L1CTL);
135 f_l1_tune(L1CTL);
136
137 /* Cleanup VGCS Channel. */
138 f_rsl_chan_deact();
139}
140
141/* A VGCS channel is activated. The BSC sends UPLINK FREE message and UPLINK BUSY message.
142 * When the UPLINK FREE message is sent, the MS is expected to receive several UPLINK FREE messages.
143 * Then the UPLINK BUSY message is sent, the MS is expected to receive one UPLINK BUSY message.
144 */
145private function f_TC_vgcs_uplink_free_and_busy(charstring id) runs on ConnHdlr
146{
147 var octetstring uplink_free := '082B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
148 var octetstring uplink_busy := '062A'O;
149
150 f_l1_tune(L1CTL);
151 RSL.clear;
152
153 /* Activate channel on the BTS side */
154 log("Activating VGCS channel.");
155 f_rsl_chan_act(g_pars.chan_mode);
156
157 /* enable dedicated mode */
158 f_l1ctl_est_dchan(L1CTL, g_pars);
159
160 /* Send one UPLINK FREE message and expect them to be repeated. */
161 log("Send UPLINK FREE.");
162 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), uplink_free));
163 for (var integer i := 0; i < 20; i := i + 1) {
164 f_l1_exp_lapdm(tr_LAPDm_Bter_UI(uplink_free));
165 log("Received UPLINK FREE.");
166 }
167
168 /* Send one UPLINK BUSY message and expect it to be received. */
169 log("Send UPLINK BUSY.");
170 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), uplink_busy));
171 f_l1_exp_lapdm(tr_LAPDm_UI(0, cr_MT_CMD, uplink_busy));
172 log("Received UPLINK BUSY.");
173
174 /* Deactivate and cleanup. */
175 f_vgcs_cleanup();
176}
177testcase TC_vgcs_uplink_free_and_busy() runs on test_CT
178{
179 var template RSL_IE_ChannelMode ch_mode;
180 var ConnHdlrPars pars;
181 var ConnHdlr vc_conn;
182
183 f_init();
184
185 ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F_GROUP, RSL_CMOD_SP_GSM1);
186 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ch_mode));
187 vc_conn := f_start_handler(refers(f_TC_vgcs_uplink_free_and_busy), pars);
188 vc_conn.done;
189
190 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
191}
192
Harald Welte5a1d7272023-05-10 19:49:44 +0200193control {
194 execute( TC_vbs_notification() );
Andreas Eversberg4801baa2023-07-17 11:45:38 +0200195 execute( TC_vgcs_uplink_free_and_busy() );
Harald Welte5a1d7272023-05-10 19:49:44 +0200196
197}
198
199}