Commit 0547353c authored by gauthier's avatar gauthier

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5367 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent f11e0059
#!/bin/bash
################################################################################
# Eurecom OpenAirInterface core network
# Copyright(c) 1999 - 2014 Eurecom
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope 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
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
#
# Contact Information
# Openair Admin: openair_admin@eurecom.fr
# Openair Tech : openair_tech@eurecom.fr
# Forums : http://forums.eurecom.fsr/openairinterface
# Address : EURECOM,
# Campus SophiaTech,
# 450 Route des Chappes,
# CS 50193
# 06904 Biot Sophia Antipolis cedex,
# FRANCE
################################################################################
# file start_mme_and_enb_and_ue.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+ENB+UE (ENB+UE in one executable, MME in one executable, all on one host)
#
###########################################################################################################################
# TUN SETTING
###########################################################################################################################
# hss.eur
# |
# +-----------+ +-----------+ v +----------+
# | UE +------+ +------+ MME +-----+ +-----+ HSS |
# | + | tun10+------------------+tun11 | |tun61+-----+tun60| |
# | eNB +------+ +------+ +-----+ +-----+ |
# | | tun20+-------+ | | +----------+
# | +------+ | +-+-------+-+
# | | | | | tun111| |
# | | | | +---+---+ |
# | | | (optional)| |
# +-----------+ | | +---+---+ |
# | | | tun110| | router.eur
# | +-+-------+-+ | +--------------+
# | | S+P-GW | v | ROUTER |
# | +------+ +-------+ +----+ +----+
# +----------+tun21 | |sgi +-...-+ | | +---...Internet
# +------+ +-------+ +----+ +----+
# | | 11 VLANS | |
# +-----------+ ids=[5..15] +--------------+
###########################################################
# Parameters
###########################################################
declare MAKE_LTE_ACCESS_STRATUM_TARGET="oaisim DEBUG=1 ENABLE_ITTI=1 USE_MME=R10 LINK_PDCP_TO_GTPV1U=1 NAS=1 SECU=1 Rel10=1"
declare MAKE_IP_DRIVER_TARGET="ue_ip.ko"
declare IP_DRIVER_NAME="ue_ip"
declare LTEIF="oip1"
declare UE_IPv4="10.0.0.8"
declare UE_IPv6="2001:1::8"
declare UE_IPv6_CIDR=$UE_IPv6"/64"
declare UE_IPv4_CIDR=$UE_IPv4"/24"
declare MME_ITTI_LOG_FILE=./itti_mme.$HOSTNAME.log
declare MME_STDOUT_LOG_FILE=./stdout_mme.$HOSTNAME.log
declare MME_PCAP_LOG_FILE=./tshark_s1_mme.$HOSTNAME.pcap
declare ITTI_LOG_FILE=./OUTPUT/itti_enb_ue.$HOSTNAME.log
declare STDOUT_LOG_FILE=./OUTPUT/stdout_enb_ue.$HOSTNAME.log
declare PCAP_LOG_FILE=./tshark_enb.$HOSTNAME.pcap
###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
source $THIS_SCRIPT_PATH/utils.bash
###########################################################
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 MISC SOFTWARES AND LIBS
#######################################################
check_install_epc_software
######################################
# compile EPC #
######################################
compile_epc
######################################
# compile UE + eNB #
######################################
#------------------------------------
# USIM, NVRAM files
#------------------------------------
export NVRAM_DIR=$THIS_SCRIPT_PATH
if [ ! -f $OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/ue_data ]; then
make --directory=$OPENAIRCN_DIR/NAS/EURECOM-NAS veryveryclean
make --directory=$OPENAIRCN_DIR/NAS/EURECOM-NAS PROCESS=UE
rm .ue.nvram
fi
if [ ! -f $OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/usim_data ]; then
make --directory=$OPENAIRCN_DIR/NAS/EURECOM-NAS veryveryclean
make --directory=$OPENAIRCN_DIR/NAS/EURECOM-NAS PROCESS=UE
rm .usim.nvram
fi
if [ ! -f .ue.nvram ]; then
# generate .ue_emm.nvram .ue.nvram
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/ue_data --gen
fi
if [ ! -f .usim.nvram ]; then
# generate .usim.nvram
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/usim_data --gen
fi
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/ue_data --print
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/usim_data --print
cecho "make $MAKE_IP_DRIVER_TARGET $MAKE_LTE_ACCESS_STRATUM_TARGET ....." $green
make --directory=$OPENAIR2_DIR $MAKE_IP_DRIVER_TARGET || exit 1
#make --directory=$OPENAIR_TARGETS/SIMU/USER $MAKE_LTE_ACCESS_STRATUM_TARGET -j`grep -c ^processor /proc/cpuinfo ` || exit 1
make --debug=b --directory=$OPENAIR_TARGETS/SIMU/USER $MAKE_LTE_ACCESS_STRATUM_TARGET || exit 1
cd $THIS_SCRIPT_PATH
#######################################################
# FIND CONFIG FILES
#######################################################
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
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
#######################################################
# SOURCE CONFIG FILES for MME AND eNB
#######################################################
rm -f /tmp/source.txt
VARIABLES="
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_S1_MME\|\
MME_IPV4_ADDRESS_FOR_S1_MME\|\
MME_INTERFACE_NAME_FOR_S11_MME\|\
MME_IPV4_ADDRESS_FOR_S11_MME\|\
MME_INTERFACE_NAME_FOR_S6A\|\
MME_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\|\
HSS_INTERFACE_NAME_FOR_S6A\|\
HSS_IPV4_ADDR_FOR_S6A"
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 '/')
declare HSS_IPV4_NETMASK_FOR_S6A=$( echo $HSS_IPV4_ADDR_FOR_S6A | 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 '/')
MME_IPV4_ADDRESS_FOR_S6A=$( echo $MME_IPV4_ADDRESS_FOR_S6A | cut -f1 -d '/')
SGW_IPV4_ADDRESS_FOR_S11=$( echo $SGW_IPV4_ADDRESS_FOR_S11 | 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 '/')
HSS_IPV4_ADDR_FOR_S6A=$( echo $HSS_IPV4_ADDR_FOR_S6A | cut -f1 -d '/')
#######################################################
# BUILD NETWORK
#######################################################
clean_tun_network
build_tun_network
test_tun_network
##################################################
# LAUNCH HSS
##################################################
# TO DO
##################################################
# LAUNCH MME executable
##################################################
cd $THIS_SCRIPT_PATH
if [ ! -d "OUTPUT/"$HOSTNAME ]
then
bash_exec "mkdir -m 777 ./OUTPUT/$HOSTNAME"
echo_success "Created OUTPUT/$HOSTNAME directory"
fi
rotate_log_file $MME_ITTI_LOG_FILE
rotate_log_file $MME_STDOUT_LOG_FILE
rotate_log_file $MME_PCAP_LOG_FILE
cd $OPENAIRCN_DIR/$OBJ_DIR
nohup tshark -i MME_INTERFACE_NAME_FOR_S1_MME -w $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$MME_PCAP_LOG_FILE &
nohup xterm -e $OPENAIRCN_DIR/$OBJ_DIR/OAI_EPC/oai_epc -K $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$MME_ITTI_LOG_FILE -c $THIS_SCRIPT_PATH/$CONFIG_FILE_EPC 2>&1 | tee $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/$MME_STDOUT_LOG_FILE &
##################################################
# LAUNCH eNB + UE executable
##################################################
echo "Bringup UE interface"
pkill oaisim
bash_exec "rmmod $IP_DRIVER_NAME" > /dev/null 2>&1
bash_exec "insmod $OPENAIR2_DIR/NETWORK_DRIVER/UE_IP/$IP_DRIVER_NAME.ko"
bash_exec "ip route flush cache"
#bash_exec "ip link set $LTEIF up"
sleep 1
#bash_exec "ip addr add dev $LTEIF $UE_IPv4_CIDR"
#bash_exec "ip addr add dev $LTEIF $UE_IPv6_CIDR"
sleep 1
bash_exec "sysctl -w net.ipv4.conf.all.log_martians=1"
assert " `sysctl -n net.ipv4.conf.all.log_martians` -eq 1" $LINENO
echo " Disabling reverse path filtering"
bash_exec "sysctl -w net.ipv4.conf.all.rp_filter=0"
assert " `sysctl -n net.ipv4.conf.all.rp_filter` -eq 0" $LINENO
bash_exec "ip route flush cache"
# Check table 200 lte in /etc/iproute2/rt_tables
fgrep lte /etc/iproute2/rt_tables > /dev/null
if [ $? -ne 0 ]; then
echo "200 lte " >> /etc/iproute2/rt_tables
fi
ip rule add fwmark 5 table lte
ip route add default dev $LTEIF table lte
rotate_log_file $ITTI_LOG_FILE
rotate_log_file $STDOUT_LOG_FILE
rotate_log_file $STDOUT_LOG_FILE.filtered
rotate_log_file $PCAP_LOG_FILE
cd $THIS_SCRIPT_PATH
nohup tshark -i $ENB_INTERFACE_NAME_FOR_S1_MME -i $ENB_INTERFACE_NAME_FOR_S1U -w $PCAP_LOG_FILE &
nohup xterm -e $OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/UserProcess &
gdb --args $OPENAIR_TARGETS/SIMU/USER/oaisim -a -u1 -l9 -K $ITTI_LOG_FILE --enb-conf $CONFIG_FILE_ENB 2>&1 | tee $STDOUT_LOG_FILE
pkill tshark
cat $STDOUT_LOG_FILE | grep -v '[PHY]' | grep -v '[MAC]' | grep -v '[EMU]' | \
grep -v '[OCM]' | grep -v '[OMG]' | \
grep -v 'RLC not configured' | grep -v 'check if serving becomes' | \
grep -v 'mac_rrc_data_req' | grep -v 'BCCH request =>' > $STDOUT_LOG_FILE.filtered
......@@ -321,41 +321,8 @@ test_command_install_script() {
echo_success "$1 available"
}
start_openswitch_daemon() {
rmmod -s bridge
if [[ -e "/lib/modules/`uname -r`/extra/openvswitch.ko" ]] ; then
bash_exec "insmod /lib/modules/`uname -r`/extra/openvswitch.ko" > /dev/null 2>&1
else
echo_fatal "/lib/modules/`uname -r`/extra/openvswitch.ko not found, exiting"
fi
is_process_started "ovsdb-server"
if [ $? -ne 0 ]
then
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,manager_options --pidfile --detach
wait_process_started "ovsdb-server"
fi
# To be done after installation
# ovs-vsctl --no-wait init
is_process_started "ovs-vswitchd"
if [ $? -ne 0 ]
then
ovs-vswitchd --pidfile --detach
wait_process_started "ovs-vswitchd"
fi
}
stop_openswitch_daemon() {
pkill ovs-vswitchd
pkill ovsdb-server
sync
if ! is_process_started ovs-vswitchd ; then
pkill -9 ovs-vswitchd
fi
if ! is_process_started ovsdb-server ; then
pkill -9 ovsdb-server
fi
rmmod -f openvswitch
}
check_for_epc_executable() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAI_EPC/oai_epc ]
......@@ -387,30 +354,6 @@ check_for_root_rights() {
fi
}
is_openvswitch_interface() {
for var in "$@"
do
if [ "a$var" == "a" ]; then
return 0
fi
if [ "a${var:0:3}" == "aeth" ]; then
return 0;
else
if [ "a${var:0:4}" == "awlan" ]; then
return 0;
else
if [ "a${var:0:4}" == "awifi" ]; then
return 0;
else
if [ "a${var:0:4}" == "anone" ]; then
return 0;
fi
fi
fi
fi
done
return 1;
}
is_real_interface() {
my_bool=1
......@@ -464,22 +407,37 @@ is_vlan_interface() {
return $my_bool
}
is_tun_interface() {
my_bool=1
for var in "$@"
do
if [ "a$var" == "a" ]; then
return 0
fi
bus_info=`ethtool -i $var`
if [[ "$IF" != *tun* ]]; then
return 0;
fi
done
return $my_bool
}
delete_openvswitch_interface() {
is_openvswitch_interface $1
delete_tun_interface() {
is_tun_interface $1
if [ $? -eq 1 ]; then
ifconfig $1 down > /dev/null 2>&1
tunctl -d $1 > /dev/null 2>&1
ip link set $1 down > /dev/null 2>&1
openvpn --mktun --dev $1 > /dev/null 2>&1
fi
}
create_openvswitch_interface() {
is_openvswitch_interface $1
if [ $? -eq 1 ]; then
bash_exec "tunctl -t $1"
fi
create_tun_interface() {
openvpn --mktun --dev $1
#ip link set $1 up
}
# arg1 = interface name
# arg2 = ipv4 addr cidr
# arg3 = netmask cidr
......@@ -645,106 +603,31 @@ build_mme_spgw_vlan_network() {
export MAC_ROUTER=`ip neigh show | grep $IP_ROUTER | cut -d ' ' -f5 | tr -d ':'`
echo_success "ROUTER MAC ADDRESS= $MAC_ROUTER"
if [ $ENABLE_USE_NETFILTER_FOR_SGI -eq 1 ]; then
bash_exec "modprobe nf_conntrack"
bash_exec "modprobe nf_conntrack_ftp"
######################################################
# PREROUTING
######################################################
# We restore the mark following the CONNMARK mark. In fact, it does a simple MARK=CONNMARK
# where MARK is the standard mark (usable by tc)
# In French: Cette option de cible restaure le paquet marqué dans la marque de connexion
# comme défini par CONNMARK. Un masque peut aussi être défini par l'option --mask.
# Si une option mask est placée, seules les options masquées seront placées.
# Notez que cette option de cible n'est valide que dans la table mangle.
bash_exec "$IPTABLES -t mangle -A PREROUTING -j CONNMARK --restore-mark"
# TEST bash_exec "$IPTABLES -t mangle -A PREROUTING -m mark --mark 0 -i $PGW_INTERFACE_NAME_FOR_SGI -j MARK --set-mark 15"
# We set the mark of the initial packet as value of the conntrack mark for all the packets of the connection.
# This mark will be restore for the other packets by the first rule of POSTROUTING --restore-mark).
bash_exec "$IPTABLES -t mangle -A PREROUTING -j CONNMARK --save-mark"
######################################################
# POSTROUTING
######################################################
# MARK=CONNMARK
bash_exec "iptables -A POSTROUTING -t mangle -o tap0 -j CONNMARK --restore-mark"
# If we’ve got a mark no need to get further[
bash_exec "iptables -A POSTROUTING -t mangle -o tap0 -m mark ! --mark 0 -j ACCEPT"
#bash_exec "iptables -A POSTROUTING -p tcp --dport 21 -t mangle -j MARK --set-mark 1"
#bash_exec "iptables -A POSTROUTING -p tcp --dport 80 -t mangle -j MARK --set-mark 2"
# We set the mark of the initial packet as value of the conntrack mark for all the packets
# of the connection. This mark will be restore for the other packets by the first rule
# of POSTROUTING (–restore-mark).
bash_exec "iptables -A POSTROUTING -t mangle -j CONNMARK --save-mark"
bash_exec "iptables -A PREROUTING -t mangle -j CONNMARK --restore-mark"
# We restore the mark following the CONNMARK mark.
# In fact, it does a simple MARK=CONNMARK where MARK is the standard mark (usable by tc)
#bash_exec "$IPTABLES -A OUTPUT -t mangle -m mark ! --mark 0 -j CONNMARK --restore-mark"
# If we’ve got a mark no need to get further[1]
#TEST bash_exec "$IPTABLES -A OUTPUT -t mangle -p icmp -j MARK --set-mark 14"
#bash_exec "$IPTABLES -A OUTPUT -t mangle -m mark ! --mark 0 -j ACCEPT"
# We set the mark of the initial packet as value of the conntrack mark for all the packets of the connection.
# This mark will be restore for the other packets by the first rule of OUTPUT (–restore-mark).
#bash_exec "$IPTABLES -A OUTPUT -t mangle -j CONNMARK --save-mark"
######################################################
# NETFILTER QUEUE
######################################################
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 5 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 6 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 7 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 8 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 9 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 10 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 11 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 12 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 13 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 14 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 15 -j NFQUEUE --queue-num 1"
#echo 0 > /proc/sys/net/bridge/bridge-nf-call-iptables #To disable Iptables in the bridge.
#Raw table: Some years ago appeared a new tables in Iptables.
#This table can be used to avoid packets (connection really) to enter the NAT table:
# iptables -t raw -I PREROUTING -i BRIDGE -s x.x.x.x -j NOTRACK.
#bash_exec "$IPTABLES -t nat -A POSTROUTING -o $PGW_INTERFACE_NAME_FOR_SGI -j SNAT --to-source $PGW_IP_ADDR_FOR_SGI"
else
# # get ipv4 address from PGW_INTERFACE_NAME_FOR_SGI
#IP_ADDR=`ifconfig $PGW_INTERFACE_NAME_FOR_SGI | awk '/inet addr/ {split ($2,A,":"); print A[2]}' | tr '\n' ' ' | sed -n '1h;1!H;${;g;s/^[ \t]*//g;s/[ \t]*$//g;p;}'`
#NETWORK=`echo $IP_ADDR | cut -d . -f 1,2,3`
bash_exec "modprobe 8021q"
for i in 5 6 7 8 9 10 11 12 13 14 15
do
# create vlan interface
ifconfig $PGW_INTERFACE_NAME_FOR_SGI.$i down > /dev/null 2>&1
vconfig rem $PGW_INTERFACE_NAME_FOR_SGI.$i > /dev/null 2>&1
sync
bash_exec "vconfig add $PGW_INTERFACE_NAME_FOR_SGI $i"
sync
bash_exec "ifconfig $PGW_INTERFACE_NAME_FOR_SGI.$i up"
sync
# configure vlan interface
#CIDR=$NETWORK'.'$i'/24'
base=200
NET=$(( $i + $base ))
CIDR='10.0.'$NET'.2/8'
bash_exec "ip -4 addr add $CIDR dev $PGW_INTERFACE_NAME_FOR_SGI.$i"
done
fi
# # get ipv4 address from PGW_INTERFACE_NAME_FOR_SGI
#IP_ADDR=`ifconfig $PGW_INTERFACE_NAME_FOR_SGI | awk '/inet addr/ {split ($2,A,":"); print A[2]}' | tr '\n' ' ' | sed -n '1h;1!H;${;g;s/^[ \t]*//g;s/[ \t]*$//g;p;}'`
#NETWORK=`echo $IP_ADDR | cut -d . -f 1,2,3`
bash_exec "modprobe 8021q"
for i in 5 6 7 8 9 10 11 12 13 14 15
do
# create vlan interface
ifconfig $PGW_INTERFACE_NAME_FOR_SGI.$i down > /dev/null 2>&1
vconfig rem $PGW_INTERFACE_NAME_FOR_SGI.$i > /dev/null 2>&1
sync
bash_exec "vconfig add $PGW_INTERFACE_NAME_FOR_SGI $i"
sync
bash_exec "ifconfig $PGW_INTERFACE_NAME_FOR_SGI.$i up"
sync
# configure vlan interface
#CIDR=$NETWORK'.'$i'/24'
base=200
NET=$(( $i + $base ))
CIDR='10.0.'$NET'.2/8'
bash_exec "ip -4 addr add $CIDR dev $PGW_INTERFACE_NAME_FOR_SGI.$i"
done
bash_exec "ip link set $PGW_INTERFACE_NAME_FOR_SGI promisc on"
else
......@@ -806,65 +689,59 @@ clean_epc_vlan_network() {
clean_network
}
build_openvswitch_network() {
start_openswitch_daemon
build_tun_network() {
# REMINDER:
# hss.eur
# |
# +-----------+ +------+ +-----------+ v +----------+
# | eNB +------+ | ovs | VLAN 1+------+ MME +----+ +---+ HSS |
# | |cpenb0+------------------+cpmme0| | +------+ | |
# | +------+ |bridge| +------+ +----+ +---+ |
# | |upenb0+-------+ | | | +----------+
# | +------+ | | | +-+-------+-+
# | | | | +----------------| s11mme|---+
# | | | | +---+---+ |
# | | | | (optional)| |ovs bridge is optional
# +-----------+ | | +---+---+ |
# +---|------------------ | s11sgw|---+ router.eur
# +-----------+ +-----------+ v +----------+
# | eNB +------+ +------+ MME +----+ +---+ HSS |
# | |cpenb0+------------------+cpmme0| |s6am+------+s6a| |
# | +------+ +------+ +----+ +---+ |
# | |upenb0+-------+ | | +----------+
# | +------+ | +-+-------+-+
# | | | | s11mme|
# | | | +---+---+
# | | | (optional)|
# +-----------+ | +---+---+
# | | s11sgw| router.eur
# | +-+-------+-+ | +--------------+
# | | S+P-GW | v | ROUTER |
# | VLAN2 +------+ +-------+ +----+ +----+
# | +------+ +-------+ +----+ +----+
# +----------+upsgw0| |sgi +-...-+ | | +---...Internet
# +------+ +-------+ +----+ +----+
# | | 11 VLANS | |
# +-----------+ ids=[5..15] +--------------+
#
bash_exec "modprobe tun"
##################################################
# build bridge between eNB and MME/SPGW
# build network between eNB and MME/SPGW and HSS
##################################################
create_openvswitch_interface $ENB_INTERFACE_NAME_FOR_S1_MME
create_openvswitch_interface $ENB_INTERFACE_NAME_FOR_S1U
create_openvswitch_interface $MME_INTERFACE_NAME_FOR_S1_MME
create_openvswitch_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
create_openvswitch_interface $MME_INTERFACE_NAME_FOR_S11_MME
create_openvswitch_interface $SGW_INTERFACE_NAME_FOR_S11
create_tun_interface $ENB_INTERFACE_NAME_FOR_S1_MME
create_tun_interface $ENB_INTERFACE_NAME_FOR_S1U
create_tun_interface $MME_INTERFACE_NAME_FOR_S1_MME
create_tun_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
create_tun_interface $MME_INTERFACE_NAME_FOR_S11_MME
create_tun_interface $SGW_INTERFACE_NAME_FOR_S11
create_tun_interface $MME_INTERFACE_NAME_FOR_S6A
create_tun_interface $HSS_INTERFACE_NAME_FOR_S6A
bash_exec "ovs-vsctl add-br $BRIDGE"
bash_exec "ovs-vsctl add-port $BRIDGE $ENB_INTERFACE_NAME_FOR_S1_MME tag=1"
bash_exec "ovs-vsctl add-port $BRIDGE $MME_INTERFACE_NAME_FOR_S1_MME tag=1"
bash_exec "ovs-vsctl add-port $BRIDGE $ENB_INTERFACE_NAME_FOR_S1U tag=2"
bash_exec "ovs-vsctl add-port $BRIDGE $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP tag=2"
bash_exec "ovs-vsctl add-port $BRIDGE $MME_INTERFACE_NAME_FOR_S11_MME tag=3"
bash_exec "ovs-vsctl add-port $BRIDGE $SGW_INTERFACE_NAME_FOR_S11 tag=3"