1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
#!/bin/bash
################################################################################
# OpenAirInterface
# Copyright(c) 1999 - 2014 Eurecom
#
# OpenAirInterface is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# OpenAirInterface is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenAirInterface.The full GNU General Public License is
# included in this distribution in the file called "COPYING". If not,
# see <http://www.gnu.org/licenses/>.
#
# Contact Information
# OpenAirInterface Admin: openair_admin@eurecom.fr
# OpenAirInterface Tech : openair_tech@eurecom.fr
# OpenAirInterface Dev : openair4g-devel@eurecom.fr
#
# Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
#
################################################################################
# file start_epc.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
#########################################
# INPUT OF THIS SCRIPT:
# THE DIRECTORY WHERE ARE LOCATED THE CONFIGURATION FILES
#########################################
# This script start MME+S/P-GW (all in one executable, on one host)
# Depending on configuration files, it can be instanciated a virtual switch
# setting or a VLAN setting.
#
###########################################################################################################################
# VIRTUAL BOX SETTING
###########################################################################################################################
# NETWORK SETTING AT EURECOM IN EXPERIMENTAL NETWORK (192.168.12.X)
#
#
# INTERNET GW 192.168.12.100
# |
# |
# 192.168.12.X/24 |
# +-----------+----------------+---+--+---------------------------------------+
# | COMPUTER 1| | eth0 | |
# +-----------+ +---+--+ |
# | | |
# | | |
# | ROUTER +-----+------+ |
# | |MASQUERADING| |
# | |FORWARDING | |
# | +-----+------+ |
# | | |
# | | |
# | | |
# | | |
# | | |
# | +---+--+ |
# | | eth1 | |
# +----------------------------+---+--+---------------------------------------+
# |router.eur
# 11 VLANS | INTERNET GW 192.168.12.100
# ids=[5..15] | |
# 192.168.13.X/24 | |
# +-----------+----------------+---+--+---------------------+---+--+----------+
# | COMPUTER 2| SGI | eth1 | Physical | eth0 | |
# +-----------+ +-+--+-+ Interface +------+ |
# | | | 'HOST_BRIDGED_IF_NAME' |
# | | | |
# | | | +-----------+ |
# | | | +------+ HSS | |
# | | +----------+ eth0 | (VM) | |
# | | +------+ | |
# | | | | |
# | | +-+------+--+ |
# | | |eth1 | hss.eur |
# | virtual box | +--+---+ |
# | +------------------+ | virtual box |
# | | bridged network | host-only |
# | | | network |
# | | | 192.168.57/24 |
# | | | |
# | +--+---+ +--+-----+ |
# | |eth0 | |vboxnet1| |
# | +-+------+--+192.168.56.101 192.168.56.1+-+--------++ |
# | | eNB 0 +------+ virtual box +--------+ MME | |
# | | (VM) |eth1 +----------------+vboxnet0| S+P/GW | |
# | | +------+ host-only +--------+(execu. on | |
# | | | network |COMPUTER2) | |
# | | | 192.168.56/24 | | |
# | | LTE eNB 1 | | | |
# | | LTE UEs | | | |
# | +-----------+ +-----------+ |
# | |
# | |
# +---------------------------------------------------------------------------+
#
###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
. $THIS_SCRIPT_PATH/utils.bash
. $THIS_SCRIPT_PATH/interfaces.bash
. $THIS_SCRIPT_PATH/networks.bash
###########################################################
control_c()
# run if user hits control-c
{
echo -en "\n*** Exiting... ***\n"
pkill -9 tshark
pkill -9 oai_epc
echo -en "\n*** Exit ***\n"
exit $?
}
if [ $# -eq 1 ]; then
declare -x CONFIG_FILE_DIR=$1
if [ ! -d $CONFIG_FILE_DIR ]; then
echo_error "ERROR while invoking this script, as first argument to this script you have to provide the path to a directory (./CONF/VLAN.VIRTUAL.$HOSTNAME for example) containing valid epc and enb config files"
exit 1
fi
else
echo_error "ERROR while invoking this script, as first argument to this script you have to provide the path to a directory (./CONF/VLAN.VIRTUAL.$HOSTNAME for example) containing valid epc and enb config files"
exit 1
fi
#check_install_epc_software
##################################
# Get or set OBJ DIR and compile #
##################################
# TEST IF EXIST
cd $OPENAIRCN_DIR
OBJ_DIR=`find . -maxdepth 1 -type d -iname obj*`
if [ ! -n "$OBJ_DIR" ]
then
OBJ_DIR="objs"
bash_exec "mkdir -m 777 ./$OBJ_DIR"
echo_success "Created $OBJ_DIR directory"
else
OBJ_DIR=`basename $OBJ_DIR`
fi
if [ ! -n "m4" ]
then
mkdir -m 777 m4
fi
if [ ! -f $OBJ_DIR/Makefile ]
then
autoreconf -i
echo_success "Invoking autogen"
bash_exec "./autogen.sh"
cd ./$OBJ_DIR
echo_success "Invoking configure"
../configure HAVE_CHECK=true --enable-standalone-epc --enable-raw-socket-for-sgi LDFLAGS=-L/usr/local/lib
else
cd ./$OBJ_DIR
fi
pkill oai_epc
pkill tshark
if [ -f Makefile ]
then
echo_success "Compiling..."
make -j `cat /proc/cpuinfo | grep processor | wc -l`
if [ $? -ne 0 ]; then
echo_error "Build failed, exiting"
exit 1
fi
else
echo_error "Configure failed, exiting"
exit 1
fi
cd $THIS_SCRIPT_PATH
#######################################################
# FIND CONFIG FILE
#######################################################
SEARCHED_CONFIG_FILE_EPC="epc*.conf"
CONFIG_FILE_EPC=`find $CONFIG_FILE_DIR -iname $SEARCHED_CONFIG_FILE_EPC`
if [ -f $CONFIG_FILE_EPC ]; then
echo_warning "EPC config file found is now $CONFIG_FILE_EPC"
else
echo_error "EPC config file not found, exiting (searched for $SEARCHED_CONFIG_FILE_EPC)"
exit 1
fi
SEARCHED_CONFIG_FILE_ENB="enb*.conf"
CONFIG_FILE_ENB=`find $CONFIG_FILE_DIR -iname $SEARCHED_CONFIG_FILE_ENB`
if [ -f $CONFIG_FILE_ENB ]; then
echo_warning "eNB config file found is now $CONFIG_FILE_ENB"
else
echo_error "eNB config file not found, exiting"
exit 1
fi
#######################################################
# SOURCE CONFIG FILE
#######################################################
rm -f /tmp/source.txt
VARIABLES="
GNU_DEBUGGER\|\
ENB_INTERFACE_NAME_FOR_S1_MME\|\
ENB_IPV4_ADDRESS_FOR_S1_MME\|\
ENB_INTERFACE_NAME_FOR_S1U\|\
ENB_IPV4_ADDRESS_FOR_S1U\|\
MME_INTERFACE_NAME_FOR_S6A\|\
MME_IPV4_ADDRESS_FOR_S6A\|\
MME_INTERFACE_NAME_FOR_S1_MME\|\
MME_IPV4_ADDRESS_FOR_S1_MME\|\
MME_INTERFACE_NAME_FOR_S11_MME\|\
MME_IPV4_ADDRESS_FOR_S11_MME\|\
HSS_INTERFACE_NAME_FOR_S6A\|\
HSS_IPV4_ADDRESS_FOR_S6A\|\
SGW_INTERFACE_NAME_FOR_S11\|\
SGW_IPV4_ADDRESS_FOR_S11\|\
SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP\|\
SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP\|\
SGW_INTERFACE_NAME_FOR_S5_S8_UP\|\
SGW_IPV4_ADDRESS_FOR_S5_S8_UP\|\
PGW_INTERFACE_NAME_FOR_S5_S8\|\
PGW_IPV4_ADDRESS_FOR_S5_S8\|\
PGW_INTERFACE_NAME_FOR_SGI\|\
PGW_IPV4_ADDR_FOR_SGI"
VARIABLES=$(echo $VARIABLES | sed -e 's/\\r//g')
VARIABLES=$(echo $VARIABLES | tr -d ' ')
cat $CONFIG_FILE_EPC | grep -w "$VARIABLES"| tr -d " " | tr -d ";" > /tmp/source.txt
cat $CONFIG_FILE_ENB | grep -w "$VARIABLES"| tr -d " " | tr -d ";" >> /tmp/source.txt
source /tmp/source.txt
declare ENB_IPV4_NETMASK_FOR_S1_MME=$( echo $ENB_IPV4_ADDRESS_FOR_S1_MME | cut -f2 -d '/')
declare ENB_IPV4_NETMASK_FOR_S1U=$( echo $ENB_IPV4_ADDRESS_FOR_S1U | cut -f2 -d '/')
declare MME_IPV4_NETMASK_FOR_S1_MME=$( echo $MME_IPV4_ADDRESS_FOR_S1_MME | cut -f2 -d '/')
declare MME_IPV4_NETMASK_FOR_S11_MME=$( echo $MME_IPV4_ADDRESS_FOR_S11_MME | cut -f2 -d '/')
declare MME_IPV4_NETMASK_FOR_S6A=$( echo $MME_IPV4_ADDRESS_FOR_S6A | cut -f2 -d '/')
declare SGW_IPV4_NETMASK_FOR_S11=$( echo $SGW_IPV4_ADDRESS_FOR_S11 | cut -f2 -d '/')
declare SGW_IPV4_NETMASK_FOR_S1U_S12_S4_UP=$(echo $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP | cut -f2 -d '/')
declare SGW_IPV4_NETMASK_FOR_S5_S8_UP=$( echo $SGW_IPV4_ADDRESS_FOR_S5_S8_UP | cut -f2 -d '/')
declare PGW_IPV4_NETMASK_FOR_S5_S8=$( echo $PGW_IPV4_ADDRESS_FOR_S5_S8 | cut -f2 -d '/')
declare PGW_IPV4_NETMASK_FOR_SGI=$( echo $PGW_IPV4_ADDR_FOR_SGI | cut -f2 -d '/')
ENB_IPV4_ADDRESS_FOR_S1_MME=$( echo $ENB_IPV4_ADDRESS_FOR_S1_MME | cut -f1 -d '/')
ENB_IPV4_ADDRESS_FOR_S1U=$( echo $ENB_IPV4_ADDRESS_FOR_S1U | cut -f1 -d '/')
MME_IPV4_ADDRESS_FOR_S1_MME=$( echo $MME_IPV4_ADDRESS_FOR_S1_MME | cut -f1 -d '/')
MME_IPV4_ADDRESS_FOR_S11_MME=$( echo $MME_IPV4_ADDRESS_FOR_S11_MME | cut -f1 -d '/')
SGW_IPV4_ADDRESS_FOR_S11=$( echo $SGW_IPV4_ADDRESS_FOR_S11 | cut -f1 -d '/')
SGW_IPV4_ADDRESS_FOR_S6A=$( echo $SGW_IPV4_ADDRESS_FOR_S6A | cut -f1 -d '/')
SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP=$( echo $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP | cut -f1 -d '/')
SGW_IPV4_ADDRESS_FOR_S5_S8_UP=$( echo $SGW_IPV4_ADDRESS_FOR_S5_S8_UP | cut -f1 -d '/')
PGW_IPV4_ADDRESS_FOR_S5_S8=$( echo $PGW_IPV4_ADDRESS_FOR_S5_S8 | cut -f1 -d '/')
PGW_IPV4_ADDR_FOR_SGI=$( echo $PGW_IPV4_ADDR_FOR_SGI | cut -f1 -d '/')
#is_vlan_interface $MME_INTERFACE_NAME_FOR_S1_MME \
# $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
#if [ $? -eq 1 ]; then
# echo_success "Found open VLAN network configuration"
# clean_epc_vlan_network
# build_mme_spgw_vlan_network
#else
# clean_epc_vlan_network
#create_sgi_vlans
delete_sgi_vlans
#fi
get_mac_router
##################################################
# LAUNCH MME + S+P-GW executable
##################################################
cd $THIS_SCRIPT_PATH
if [ ! -d "OUTPUT/"$HOSTNAME ]
then
bash_exec "mkdir -p -m 777 ./OUTPUT/$HOSTNAME"
echo_success "Created OUTPUT/$HOSTNAME directory"
fi
ITTI_LOG_FILE=itti_mme.$HOSTNAME.log
#rotate_log_file $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$ITTI_LOG_FILE
STDOUT_LOG_FILE=stdout_mme.$HOSTNAME.log
#rotate_log_file $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$STDOUT_LOG_FILE
PCAP_S1C_LOG_FILE=tshark_mme_s1c.$HOSTNAME.pcap
#rotate_log_file $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$PCAP_S1C_LOG_FILE
PCAP_S6A_LOG_FILE=tshark_mme_s6a.$HOSTNAME.pcap
#rotate_log_file $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$PCAP_S6A_LOG_FILE
PCAP_S6A_S1C_LOG_FILE=tshark_mme_s6a_s1c.$HOSTNAME.pcap
touch $THIS_SCRIPT_PATH/kill_epc.bash
echo '#!/bin/bash' > $THIS_SCRIPT_PATH/kill_epc.bash
echo "pkill -P $$" >> $THIS_SCRIPT_PATH/kill_epc.bash
chmod 777 $THIS_SCRIPT_PATH/kill_epc.bash
trap control_c SIGINT
echo_success "Resolving hss.eur"
HSS_IP=$(get_ip hss.eur)
echo_success "HSS_IP: $HSS_IP"
HSS_ROUTE=$(ip route get $HSS_IP | grep $HSS_IP )
HSS_ROUTE_IS_LOCAL=`echo $HSS_ROUTE | cut -d ' ' -f 1`
if [ "x$HSS_ROUTE_IS_LOCAL" == "xlocal" ]; then
MME_INTERFACE_NAME_FOR_S6A=`ip route get $HSS_IP | grep $HSS_IP | cut -d ' ' -f 4`
else
MME_INTERFACE_NAME_FOR_S6A=`ip route get $HSS_IP | grep $HSS_IP | cut -d ' ' -f 3`
fi
echo_success "MME_INTERFACE_NAME_FOR_S1_MME : $MME_INTERFACE_NAME_FOR_S1_MME"
echo_success "MME_INTERFACE_NAME_FOR_S6A : $MME_INTERFACE_NAME_FOR_S6A"
# see http://www.coverfire.com/articles/queueing-in-the-linux-network-stack/
ethtool –A $MME_INTERFACE_NAME_FOR_S1_MME autoneg off rx off tx off
ethtool –G $MME_INTERFACE_NAME_FOR_S1_MME rx 4096 tx 4096
ethtool –C $MME_INTERFACE_NAME_FOR_S1_MME rx-usecs 3
ifconfig $MME_INTERFACE_NAME_FOR_S1_MME txqueuelen 1000
if [ x$MME_INTERFACE_NAME_FOR_S1_MME != x$SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP ]; then
ethtool –A $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP autoneg off rx off tx off
ethtool –G $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP rx 4096 tx 4096
ethtool –C $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP rx-usecs 3
ifconfig $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP txqueuelen 1000
fi
if [ x$MME_INTERFACE_NAME_FOR_S1_MME == x$MME_INTERFACE_NAME_FOR_S6A ]; then
nohup tshark -i $MME_INTERFACE_NAME_FOR_S1_MME -f "not port 22" -w $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$PCAP_S6A_S1C_LOG_FILE &
else
nohup tshark -i $MME_INTERFACE_NAME_FOR_S1_MME -f "not port 22" -w $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$PCAP_S1C_LOG_FILE &
nohup tshark -i $MME_INTERFACE_NAME_FOR_S6A -f "not port 22" -w $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$PCAP_S6A_LOG_FILE &
fi
wait_process_started tshark
cd $OPENAIRCN_DIR/$OBJ_DIR
echo "GNU_DEBUGGER:"$GNU_DEBUGGER
if [ "x$GNU_DEBUGGER" == "xyes" ]; then
echo_success "Running with GDB"
touch .gdbinit
echo "file $OPENAIRCN_DIR/$OBJ_DIR/OAI_EPC/oai_epc" > ~/.gdbinit
echo "set args -K $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$ITTI_LOG_FILE -c $THIS_SCRIPT_PATH/$CONFIG_FILE_EPC" >> ~/.gdbinit
# echo "b encode_eps_mobile_identity" >> ~/.gdbinit
echo "run" >> ~/.gdbinit
gdb 2>&1 | tee $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$STDOUT_LOG_FILE
else
echo_success "Running without GDB"
$OPENAIRCN_DIR/$OBJ_DIR/OAI_EPC/oai_epc -K $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$ITTI_LOG_FILE -c $THIS_SCRIPT_PATH/$CONFIG_FILE_EPC 2>&1 | tee $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$STDOUT_LOG_FILE
fi