start_epc.bash 7.05 KB
Newer Older
1
#!/bin/bash
gauthier's avatar
Licence    
gauthier committed
2
################################################################################
gauthier's avatar
gauthier committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#   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
#
ghaddab's avatar
ghaddab committed
27
#  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
gauthier's avatar
gauthier committed
28
#
gauthier's avatar
Licence    
gauthier committed
29
30
31
32
33
34
35
################################################################################
# file start_epc.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
36
37
38

#########################################
# INPUT OF THIS SCRIPT:
gauthier's avatar
realm    
gauthier committed
39
# THE EPC CONFIGURATION FILE
40
41
42
43
44
#########################################
# This script start MME+S/P-GW (all in one executable, on one host) 

###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
gauthier's avatar
   
gauthier committed
45
46
47
. $THIS_SCRIPT_PATH/utils.bash
. $THIS_SCRIPT_PATH/interfaces.bash
. $THIS_SCRIPT_PATH/networks.bash
48
49
###########################################################

gauthier's avatar
   
gauthier committed
50
#check_install_epc_software
51
52
53
54
55
56
57

##################################
# Get or set OBJ DIR and compile #
##################################
# TEST IF EXIST
cd $OPENAIRCN_DIR
OBJ_DIR=`find . -maxdepth 1 -type d -iname obj*`
gauthier's avatar
Licence    
gauthier committed
58
if [ ! -n "$OBJ_DIR" ]
59
60
61
62
then
    OBJ_DIR="objs"
    bash_exec "mkdir -m 777 ./$OBJ_DIR"
    echo_success "Created $OBJ_DIR directory"
gauthier's avatar
Licence    
gauthier committed
63
64
65
else
    OBJ_DIR=`basename $OBJ_DIR`
fi
gauthier's avatar
gauthier committed
66
67
68
69
if [ ! -n "m4" ]
then
    mkdir -m 777 m4
fi
gauthier's avatar
Licence    
gauthier committed
70
71
if [ ! -f $OBJ_DIR/Makefile ]
then
gauthier's avatar
gauthier committed
72
    autoreconf -i -f
gauthier's avatar
gauthier committed
73
74
75
    echo_success "Invoking autogen"
    bash_exec "./autogen.sh"
    cd ./$OBJ_DIR
76
    echo_success "Invoking configure"
gauthier's avatar
   
gauthier committed
77
78
    #../configure HAVE_CHECK=true --enable-debug --enable-standalone-epc --enable-raw-socket-for-sgi  LDFLAGS=-L/usr/local/lib
    ../configure HAVE_CHECK=true --enable-debug --enable-standalone-epc --enable-gtp1u-in-kernel LDFLAGS=-L/usr/local/lib
gauthier's avatar
Licence    
gauthier committed
79
80
else
    cd ./$OBJ_DIR
81
82
fi

gauthier's avatar
Licence    
gauthier committed
83

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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
gauthier's avatar
realm    
gauthier committed
99
100
101
102
103
104
105

#######################################################
# COMPILE GTP kernel modules
#######################################################
(cd $OPENAIRCN_DIR/GTPV1-U/GTPUAH;make;cp -f ./Bin/libxt_*.so /lib/xtables;)
(cd $OPENAIRCN_DIR/GTPV1-U/GTPURH;make;cp -f ./Bin/libxt_*.so /lib/xtables;)

106
107
108
#######################################################
# FIND CONFIG FILE
#######################################################
gauthier's avatar
realm    
gauthier committed
109
110
111
DEFAULT_CONFIG_FILE="epc.`hostname -s`.conf"
CONFIG_FILE_EPC=${1:-DEFAULT_CONFIG_FILE}

gauthier's avatar
   
gauthier committed
112
echo "CONFIG_FILE_EPC=$CONFIG_FILE_EPC"
113
114
115
if [ -f $CONFIG_FILE_EPC ]; then
    echo_warning "EPC config file found is now $CONFIG_FILE_EPC"
else
gauthier's avatar
realm    
gauthier committed
116
    echo_error "EPC config file not found, exiting (searched for $CONFIG_FILE_EPC)"
117
118
119
120
121
122
123
124
125
    exit 1
fi


#######################################################
# SOURCE CONFIG FILE
#######################################################
rm -f /tmp/source.txt
VARIABLES="
gauthier's avatar
gauthier committed
126
           GNU_DEBUGGER\|\
gauthier's avatar
realm    
gauthier committed
127
           REALM"
128
129
130
131
132
133

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
source /tmp/source.txt

gauthier's avatar
   
gauthier committed
134

gauthier's avatar
realm    
gauthier committed
135
check_epc_s6a_certificate $REALM
gauthier's avatar
   
gauthier committed
136

gauthier's avatar
   
gauthier committed
137
iptables -F FORWARD
gauthier's avatar
realm    
gauthier committed
138
iptables -A FORWARD -m state --state INVALID -j LOG --log-prefix "FW: INVALID STATE:"
gauthier's avatar
   
gauthier committed
139
#iptables -I PREROUTING  -t raw  -i $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP  -j LOG --log-level crit --log-ip-options --log-prefix "PREROUTING raw:"
gauthier's avatar
   
gauthier committed
140

gauthier's avatar
gauthier committed
141
142

touch $THIS_SCRIPT_PATH/kill_epc.bash
gauthier's avatar
   
gauthier committed
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
echo '#!/bin/bash' >                 $THIS_SCRIPT_PATH/kill_epc.bash
echo "pkill -P $$" >>                $THIS_SCRIPT_PATH/kill_epc.bash
echo "iptables -P INPUT ACCEPT" >>   $THIS_SCRIPT_PATH/kill_epc.bash
echo "iptables -F INPUT" >>          $THIS_SCRIPT_PATH/kill_epc.bash
echo "iptables -P OUTPUT ACCEPT" >>  $THIS_SCRIPT_PATH/kill_epc.bash
echo "iptables -F OUTPUT" >>         $THIS_SCRIPT_PATH/kill_epc.bash
echo "iptables -P FORWARD ACCEPT" >> $THIS_SCRIPT_PATH/kill_epc.bash
echo "iptables -F FORWARD" >>        $THIS_SCRIPT_PATH/kill_epc.bash
echo "iptables -t nat -F" >>         $THIS_SCRIPT_PATH/kill_epc.bash
echo "iptables -t mangle -F" >>      $THIS_SCRIPT_PATH/kill_epc.bash
echo "iptables -t filter -F" >>      $THIS_SCRIPT_PATH/kill_epc.bash
echo "iptables -t raw -F" >>         $THIS_SCRIPT_PATH/kill_epc.bash
echo "ip route flush cache" >>       $THIS_SCRIPT_PATH/kill_epc.bash
echo "rmmod iptable_raw" >>          $THIS_SCRIPT_PATH/kill_epc.bash
echo "rmmod iptable_mangle" >>       $THIS_SCRIPT_PATH/kill_epc.bash
echo "rmmod iptable_nat" >>          $THIS_SCRIPT_PATH/kill_epc.bash
echo "rmmod iptable_filter" >>       $THIS_SCRIPT_PATH/kill_epc.bash
echo "rmmod ip_tables" >>            $THIS_SCRIPT_PATH/kill_epc.bash
echo "rmmod xt_state xt_mark xt_GTPUAH xt_GTPURH  xt_tcpudp xt_connmark ipt_LOG ipt_MASQUERADE" >>            $THIS_SCRIPT_PATH/kill_epc.bash
echo "rmmod x_tables" >>             $THIS_SCRIPT_PATH/kill_epc.bash
echo "rmmod nf_conntrack_netlink nfnetlink nf_nat nf_conntrack_ipv4 nf_conntrack" >>             $THIS_SCRIPT_PATH/kill_epc.bash
gauthier's avatar
gauthier committed
164
165
166
chmod 777 $THIS_SCRIPT_PATH/kill_epc.bash


gauthier's avatar
   
gauthier committed
167
168

# see http://www.coverfire.com/articles/queueing-in-the-linux-network-stack/
gauthier's avatar
realm    
gauthier committed
169
170
171
172
#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"
gauthier's avatar
   
gauthier committed
173

gauthier's avatar
   
gauthier committed
174

gauthier's avatar
   
gauthier committed
175

gauthier's avatar
   
gauthier committed
176
cd $OPENAIRCN_DIR/$OBJ_DIR
gauthier's avatar
gauthier committed
177
178
179
180
181
echo "GNU_DEBUGGER:"$GNU_DEBUGGER

if [ "x$GNU_DEBUGGER" == "xyes" ]; then
    echo_success "Running with GDB"
    touch .gdbinit
gauthier's avatar
gauthier committed
182
    echo "file $OPENAIRCN_DIR/$OBJ_DIR/OAI_EPC/oai_epc" > ~/.gdbinit
gauthier's avatar
realm    
gauthier committed
183
    echo "set args -K /tmp/itti_epc.log -c $THIS_SCRIPT_PATH/$CONFIG_FILE_EPC" >> ~/.gdbinit
gauthier's avatar
gauthier committed
184
185
#    echo "b encode_eps_mobile_identity" >> ~/.gdbinit
    echo "run" >> ~/.gdbinit
gauthier's avatar
realm    
gauthier committed
186
    gdb 2>&1 | tee /tmp/stdout_epc.log
gauthier's avatar
gauthier committed
187
188
else 
    echo_success "Running without GDB"
gauthier's avatar
   
gauthier committed
189
    valgrind --tool=memcheck --track-origins=yes $OPENAIRCN_DIR/$OBJ_DIR/OAI_EPC/oai_epc -K /tmp/itti_epc.log -c $THIS_SCRIPT_PATH/$CONFIG_FILE_EPC  2>&1 | tee /tmp/stdout_epc.log
gauthier's avatar
gauthier committed
190
fi     
gauthier's avatar
   
gauthier committed
191