Commit 5b0b4e74 authored by Lionel Gauthier's avatar Lionel Gauthier

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5402 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 7e43b944
......@@ -35,55 +35,6 @@
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
cidr2mask() {
local i mask=""
local full_octets=$(($1/8))
local partial_octet=$(($1%8))
for ((i=0;i<4;i+=1)); do
if [ $i -lt $full_octets ]; then
mask+=255
elif [ $i -eq $full_octets ]; then
mask+=$((256 - 2**(8-$partial_octet)))
else
mask+=0
fi
test $i -lt 3 && mask+=.
done
echo $mask
}
# example: netcalc 192.168.12.100 255.255.255.0
netcalc(){
local IFS='.' ip i
local -a oct msk
read -ra oct <<<"$1"
read -ra msk <<<"$2"
for i in ${!oct[@]}; do
ip+=( "$(( oct[i] & msk[i] ))" )
done
echo "${ip[*]}"
}
# example: s
bcastcalc(){
local IFS='.' ip i
local -a oct msk
read -ra oct <<<"$1"
read -ra msk <<<"$2"
for i in ${!oct[@]}; do
ip+=( "$(( oct[i] + ( 255 - ( oct[i] | msk[i] ) ) ))" )
done
echo "${ip[*]}"
}
black='\E[30m'
red='\E[31m'
......@@ -355,546 +306,44 @@ check_for_root_rights() {
}
is_real_interface() {
my_bool=1
for var in "$@"
do
if [ "a$var" == "a" ]; then
return 0
fi
if [ "a$var" == "anone" ]; then
return 0
fi
IF=`cat /etc/udev/rules.d/70-persistent-net.rules | grep $var | sed 's/^.*NAME=//' | tr -d '"'`
if [ "$IF" == "$var" ]; then
if [ "a${var:0:3}" != "aeth" ]; then
if [ "a${var:0:4}" != "awlan" ]; then
if [ "a${var:0:4}" != "awifi" ]; then
my_bool=0;
fi
fi
fi
fi
done
return $my_bool
}
is_vlan_interface() {
my_bool=1
for var in "$@"
do
if [ "a$var" == "a" ]; then
return 0
fi
if [[ $var == *.* ]]
then
interface_name=`echo $var | cut -f1 -d '.'`
vlan=`echo $var | cut -f2 -d '.'`
IF=`cat /etc/udev/rules.d/70-persistent-net.rules | grep $interface_name | sed 's/^.*NAME=//' | tr -d '"'`
if [ "$IF" == "$interface_name" ]; then
if [ "a${interface_name:0:3}" != "aeth" ]; then
if [ "a${interface_name:0:4}" != "awlan" ]; then
if [ "a${interface_name:0:4}" != "awifi" ]; then
return 0;
fi
fi
fi
fi
else
return 0;
fi
done
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_tun_interface() {
is_tun_interface $1
if [ $? -eq 1 ]; then
ip link set $1 down > /dev/null 2>&1
openvpn --mktun --dev $1 > /dev/null 2>&1
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_error "/lib/modules/`uname -r`/extra/openvswitch.ko not found"
bash $OPENAIRCN_DIR/SCRIPTS/install_openvswitch1.9.0.bash
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
}
create_tun_interface() {
openvpn --mktun --dev $1
#ip link set $1 up
}
# arg1 = interface name
# arg2 = ipv4 addr cidr
# arg3 = netmask cidr
set_interface_up() {
interface=$1
address=$2
cidr_netmask=$3
bash_exec "ifconfig $interface up"
sync
netmask=`cidr2mask $cidr_netmask`
broadcast=`bcastcalc $address $netmask`
bash_exec "ip -4 addr add $address/$cidr_netmask broadcast $broadcast dev $interface"
stop_openswitch_daemon() {
pkill ovs-vswitchd
pkill ovsdb-server
sync
}
build_enb_vlan_network() {
# create vlan interface
is_vlan_interface $ENB_INTERFACE_NAME_FOR_S1_MME
if [ $? -eq 1 ]; then
interface_name=`echo $ENB_INTERFACE_NAME_FOR_S1_MME | cut -f1 -d '.'`
vlan=`echo $ENB_INTERFACE_NAME_FOR_S1_MME | cut -f2 -d '.'`
ifconfig $ENB_INTERFACE_NAME_FOR_S1_MME down > /dev/null 2>&1
vconfig rem $ENB_INTERFACE_NAME_FOR_S1_MME > /dev/null 2>&1
sync
bash_exec "vconfig add $interface_name $vlan"
sync
#bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1_MME up"
#sync
#bash_exec "ip -4 addr add $ENB_IPV4_ADDRESS_FOR_S1_MME/$ENB_IPV4_NETMASK_FOR_S1_MME dev $ENB_INTERFACE_NAME_FOR_S1_MME"
set_interface_up $ENB_INTERFACE_NAME_FOR_S1_MME $ENB_IPV4_ADDRESS_FOR_S1_MME $ENB_IPV4_NETMASK_FOR_S1_MME
else
echo_fatal "BAD INTERFACE NAME FOR ENB S1-MME $ENB_INTERFACE_NAME_FOR_S1_MME"' (waiting for ethx.y, wlanx.y or wifix.y)'
fi;
is_vlan_interface $ENB_INTERFACE_NAME_FOR_S1U
if [ $? -eq 1 ]; then
interface_name=`echo $ENB_INTERFACE_NAME_FOR_S1U | cut -f1 -d '.'`
vlan=`echo $ENB_INTERFACE_NAME_FOR_S1U | cut -f2 -d '.'`
ifconfig $ENB_INTERFACE_NAME_FOR_S1U down > /dev/null 2>&1
vconfig rem $ENB_INTERFACE_NAME_FOR_S1U > /dev/null 2>&1
sync
bash_exec "vconfig add $interface_name $vlan"
sync
#bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1U up"
#sync
#bash_exec "ip -4 addr add $ENB_IPV4_ADDRESS_FOR_S1U/$ENB_IPV4_NETMASK_FOR_S1U dev $ENB_INTERFACE_NAME_FOR_S1U"
set_interface_up $ENB_INTERFACE_NAME_FOR_S1U $ENB_IPV4_ADDRESS_FOR_S1U $ENB_IPV4_NETMASK_FOR_S1U
sync
else
echo_fatal "BAD INTERFACE NAME FOR ENB S1U $ENB_INTERFACE_NAME_FOR_S1U"' (waiting for ethx.y, wlanx.y or wifix.y)'
fi;
}
clean_enb_vlan_network() {
is_vlan_interface $ENB_INTERFACE_NAME_FOR_S1_MME
if [ $? -eq 1 ]; then
echo_success "Found VLAN interface $ENB_INTERFACE_NAME_FOR_S1_MME ... deleting"
ifconfig $ENB_INTERFACE_NAME_FOR_S1_MME down > /dev/null 2>&1
vconfig rem $ENB_INTERFACE_NAME_FOR_S1_MME > /dev/null 2>&1
fi;
is_vlan_interface $ENB_INTERFACE_NAME_FOR_S1U
if [ $? -eq 1 ]; then
echo_success "Found VLAN interface $ENB_INTERFACE_NAME_FOR_S1U ... deleting"
ifconfig $ENB_INTERFACE_NAME_FOR_S1U down > /dev/null 2>&1
vconfig rem $ENB_INTERFACE_NAME_FOR_S1U > /dev/null 2>&1
fi;
sync;
clean_network
}
test_enb_vlan_network() {
# TEST INTERFACES
#ping -q -c 1 $MME_IPV4_ADDRESS_FOR_S1_MME > /dev/null 2>&1
#if [ $? -ne 0 ]; then echo_fatal "PING MME S1_MME ERROR, ADDRESS IS $MME_IPV4_ADDRESS_FOR_S1_MME"; fi;
#ping -q -c 1 $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP > /dev/null 2>&1
#if [ $? -ne 0 ]; then echo_fatal "PING SGW S1U ERROR, ADDRESS IS $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP"; fi;
return 0
}
build_mme_spgw_vlan_network() {
# hss.eur
# |
# +-----------+ +-----------+ v +----------+
# | eNB +------+ VLAN 1+------+ MME +----+ +---+ HSS |
# | |ethx.1+------------------+ethy.1| | +------+ | |
# | +------+ +------+ +----+ +---+ |
# | |ethx.2+-------+ | | +----------+
# | +------+ | +-+-------+-+
# | | | | s11mme|
# | | | +---+---+
# | | | (optional)| VLAN 3
# +-----------+ | +---+---+
# | | s11sgw| router.eur
# | +-+-------+-+ | +--------------+
# | | S+P-GW | v | ROUTER |
# | VLAN2 +------+ +-------+ +----+ +----+
# +----------+ethy.2| |sgi +-...-+ | | +---...Internet
# +------+ +-------+ +----+ +----+
# | | 11 VLANS | |
# +-----------+ ids=[5..15] +--------------+
bash_exec "modprobe 8021q"
# create vlan interface
is_vlan_interface $MME_INTERFACE_NAME_FOR_S1_MME
if [ $? -eq 1 ]; then
interface_name=`echo $MME_INTERFACE_NAME_FOR_S1_MME | cut -f1 -d '.'`
vlan=`echo $MME_INTERFACE_NAME_FOR_S1_MME | cut -f2 -d '.'`
ifconfig $MME_INTERFACE_NAME_FOR_S1_MME down > /dev/null 2>&1
vconfig rem $MME_INTERFACE_NAME_FOR_S1_MME > /dev/null 2>&1
sync
bash_exec "vconfig add $interface_name $vlan"
sync
#bash_exec "ifconfig $MME_INTERFACE_NAME_FOR_S1_MME up"
#sync
#"bash_exec "ip -4 addr add $MME_IPV4_ADDRESS_FOR_S1_MME/$MME_IPV4_NETMASK_FOR_S1_MME dev $MME_INTERFACE_NAME_FOR_S1_MME"
set_interface_up $MME_INTERFACE_NAME_FOR_S1_MME $MME_IPV4_ADDRESS_FOR_S1_MME $MME_IPV4_NETMASK_FOR_S1_MME
else
echo_fatal "BAD INTERFACE NAME FOR SGW S1-MME $MME_INTERFACE_NAME_FOR_S1_MME"' (waiting for ethx.y, wlanx.y or wifix.y)'
fi;
is_vlan_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
if [ $? -eq 1 ]; then
interface_name=`echo $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP | cut -f1 -d '.'`
vlan=`echo $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP | cut -f2 -d '.'`
ifconfig $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP down > /dev/null 2>&1
vconfig rem $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP > /dev/null 2>&1
sync
bash_exec "vconfig add $interface_name $vlan"
sync
#bash_exec "ifconfig $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP up"
#sync
#bash_exec "ip -4 addr add $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP/$SGW_IPV4_NETMASK_FOR_S1U_S12_S4_UP dev $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP"
#sync
set_interface_up $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP $SGW_IPV4_NETMASK_FOR_S1U_S12_S4_UP
else
echo_fatal "BAD INTERFACE NAME FOR SGW S1U $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP"' (waiting for ethx.y, wlanx.y or wifix.y)'
fi;
#
is_real_interface $PGW_INTERFACE_NAME_FOR_SGI
if [ $? -eq 1 ]; then
ping -c 1 router.eur > /dev/null || { echo_fatal "router.eur does not respond to ping" >&2 ; }
IP_ROUTER=`python -c 'import socket; print socket.gethostbyname("router.eur")'`
export MAC_ROUTER=`ip neigh show | grep $IP_ROUTER | cut -d ' ' -f5 | tr -d ':'`
echo_success "ROUTER MAC ADDRESS= $MAC_ROUTER"
# # 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
echo_warning "SGI interface disabled by config file"
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
}
clean_epc_vlan_network() {
bash_exec "modprobe tun"
bash_exec "modprobe ip_tables"
bash_exec "modprobe iptable_nat"
bash_exec "modprobe x_tables"
bash_exec "$IPTABLES -P INPUT ACCEPT"
bash_exec "$IPTABLES -F INPUT"
bash_exec "$IPTABLES -P OUTPUT ACCEPT"
bash_exec "$IPTABLES -F OUTPUT"
bash_exec "$IPTABLES -P FORWARD ACCEPT"
bash_exec "$IPTABLES -F FORWARD"
bash_exec "$IPTABLES -t raw -F"
bash_exec "$IPTABLES -t nat -F"
bash_exec "$IPTABLES -t mangle -F"
bash_exec "$IPTABLES -t filter -F"
bash_exec "ip route flush cache"
echo " Disabling forwarding"
bash_exec "sysctl -w net.ipv4.ip_forward=0"
assert " `sysctl -n net.ipv4.ip_forward` -eq 0" $LINENO
echo " Enabling DynamicAddr.."
bash_exec "sysctl -w net.ipv4.ip_dynaddr=1"
assert " `sysctl -n net.ipv4.ip_dynaddr` -eq 1" $LINENO
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 "modprobe 8021q"
ifconfig $MME_INTERFACE_NAME_FOR_S1_MME down > /dev/null 2>&1
vconfig rem $MME_INTERFACE_NAME_FOR_S1_MME > /dev/null 2>&1
ifconfig $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP down > /dev/null 2>&1
vconfig rem $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP > /dev/null 2>&1
for i in 5 6 7 8 9 10 11 12 13 14 15
do
# delete 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
done
#ip link set $PGW_INTERFACE_NAME_FOR_SGI down > /dev/null 2>&1
clean_network
}
build_tun_network() {
# REMINDER:
# hss.eur
# |
# +-----------+ +-----------+ v +----------+
# | eNB +------+ +------+ MME +----+ +---+ HSS |
# | |cpenb0+------------------+cpmme0| |s6am+------+s6a| |
# | +------+ +------+ +----+ +---+ |
# | |upenb0+-------+ | | +----------+
# | +------+ | +-+-------+-+
# | | | | s11mme|
# | | | +---+---+
# | | | (optional)|
# +-----------+ | +---+---+
# | | s11sgw| router.eur
# | +-+-------+-+ | +--------------+
# | | S+P-GW | v | ROUTER |
# | +------+ +-------+ +----+ +----+
# +----------+upsgw0| |sgi +-...-+ | | +---...Internet
# +------+ +-------+ +----+ +----+
# | | 11 VLANS | |
# +-----------+ ids=[5..15] +--------------+
#
bash_exec "modprobe tun"
##################################################
# build network between eNB and MME/SPGW and HSS
##################################################
echo_success "ENB_INTERFACE_NAME_FOR_S1_MME is "$ENB_INTERFACE_NAME_FOR_S1_MME" addr is "$ENB_IPV4_ADDRESS_FOR_S1_MME
echo_success "ENB_INTERFACE_NAME_FOR_S1U is "$ENB_INTERFACE_NAME_FOR_S1U" addr is "$ENB_IPV4_ADDRESS_FOR_S1U
echo_success "MME_INTERFACE_NAME_FOR_S1_MME is "$MME_INTERFACE_NAME_FOR_S1_MME" addr is "$MME_IPV4_ADDRESS_FOR_S1_MME
echo_success "SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP is "$SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP" addr is "$SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP
echo_success "MME_INTERFACE_NAME_FOR_S11_MME is "$MME_INTERFACE_NAME_FOR_S11_MME" addr is "$MME_IPV4_ADDRESS_FOR_S11_MME
echo_success "SGW_INTERFACE_NAME_FOR_S11 is "$SGW_INTERFACE_NAME_FOR_S11" addr is "$SGW_IPV4_ADDRESS_FOR_S11
echo_success "MME_INTERFACE_NAME_FOR_S6A is "$MME_INTERFACE_NAME_FOR_S6A" addr is "$MME_IPV4_ADDRESS_FOR_S6A
echo_success "HSS_INTERFACE_NAME_FOR_S6A is "$HSS_INTERFACE_NAME_FOR_S6A" addr is "$HSS_IPV4_ADDRESS_FOR_S6A
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
set_interface_up $MME_INTERFACE_NAME_FOR_S1_MME $MME_IPV4_ADDRESS_FOR_S1_MME $MME_IPV4_NETMASK_FOR_S1_MME
set_interface_up $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP $SGW_IPV4_NETMASK_FOR_S1U_S12_S4_UP
set_interface_up $ENB_INTERFACE_NAME_FOR_S1_MME $ENB_IPV4_ADDRESS_FOR_S1_MME $ENB_IPV4_NETMASK_FOR_S1_MME
set_interface_up $ENB_INTERFACE_NAME_FOR_S1U $ENB_IPV4_ADDRESS_FOR_S1U $ENB_IPV4_NETMASK_FOR_S1U
set_interface_up $MME_INTERFACE_NAME_FOR_S11_MME $MME_IPV4_ADDRESS_FOR_S11_MME $MME_IPV4_NETMASK_FOR_S11_MME
set_interface_up $SGW_INTERFACE_NAME_FOR_S11 $SGW_IPV4_ADDRESS_FOR_S11 $SGW_IPV4_NETMASK_FOR_S11
set_interface_up $MME_INTERFACE_NAME_FOR_S6A $MME_IPV4_ADDRESS_FOR_S6A $MME_IPV4_NETMASK_FOR_S6A
set_interface_up $HSS_INTERFACE_NAME_FOR_S6A $HSS_IPV4_ADDRESS_FOR_S6A $HSS_IPV4_NETMASK_FOR_S6A
}
# arg1 is IF1 IP addr
# arg2 is IF2 IP addr
test_local_iperf() {
TRY_NO=3
until [ $TRY_NO -lt 1 ]; do
iperf --bind $1 -u -s 2>&1 > /dev/null &
iperf --bind $2 -u --num 1K -c $1 2>&1 | grep -i WARNING > /dev/null
if [ $? -eq 0 ]; then
pkill iperf 2>&1 > /dev/null
echo_warning "NETWORK TEST FAILED between $1 and $2"
else
echo_success "NETWORK TEST SUCCESS between $1 and $2"
pkill iperf 2>&1 > /dev/null
return
fi
let TRY_NO-=1
pkill iperf 2>&1 > /dev/null
done
echo_fatal "FATAL: NETWORK TEST FAILED between $1 and $2"
}
test_tun_network() {
# TEST INTERFACES
ping -q -c 1 $MME_IPV4_ADDRESS_FOR_S1_MME > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $MME_INTERFACE_NAME_FOR_S1_MME ERROR, ADDRESS IS $MME_IPV4_ADDRESS_FOR_S1_MME"; fi;
ping -q -c 1 $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP ERROR, ADDRESS IS $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP"; fi;
ping -q -c 1 $ENB_IPV4_ADDRESS_FOR_S1_MME > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $ENB_INTERFACE_NAME_FOR_S1_MME ADDR ERROR, ADDRESS IS $ENB_IPV4_ADDRESS_FOR_S1_MME"; fi;
ping -q -c 1 $ENB_IPV4_ADDRESS_FOR_S1U > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $ENB_INTERFACE_NAME_FOR_S1U ERROR, ADDRESS IS $ENB_IPV4_ADDRESS_FOR_S1U"; fi;
ping -q -c 1 $MME_IPV4_ADDRESS_FOR_S11_MME > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $MME_INTERFACE_NAME_FOR_S11_MME ERROR, ADDRESS IS $MME_IPV4_ADDRESS_FOR_S11_MME"; fi;
ping -q -c 1 $SGW_IPV4_ADDRESS_FOR_S11 > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $SGW_INTERFACE_NAME_FOR_S11 ERROR, ADDRESS IS $SGW_IPV4_ADDRESS_FOR_S11"; fi;
ping -q -c 1 $MME_IPV4_ADDRESS_FOR_S6A > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $MME_INTERFACE_NAME_FOR_S6A ERROR, ADDRESS IS $MME_IPV4_ADDRESS_FOR_S6A"; fi;
ping -q -c 1 $HSS_IPV4_ADDRESS_FOR_S6A > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $HSS_INTERFACE_NAME_FOR_S6A ERROR, ADDRESS IS $HSS_IPV4_ADDRESS_FOR_S6A"; fi;
## TEST NETWORK BETWEEN ENB-MME-SP-GW
test_local_iperf $ENB_IPV4_ADDRESS_FOR_S1_MME $MME_IPV4_ADDRESS_FOR_S1_MME
test_local_iperf $ENB_IPV4_ADDRESS_FOR_S1U $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP
test_local_iperf $MME_IPV4_ADDRESS_FOR_S11_MME $SGW_IPV4_ADDRESS_FOR_S11
test_local_iperf $MME_IPV4_ADDRESS_FOR_S6A $HSS_IPV4_ADDRESS_FOR_S6A
# Get MAC address of router.eur
ping -c 1 hss.eur > /dev/null || { echo_fatal "hss.eur does not respond to ping" >&2 ; }
ping -c 1 router.eur > /dev/null || { echo_fatal "router.eur does not respond to ping" >&2 ; }
return 0
}
clean_tun_network() {
bash_exec "modprobe tun"
##################################################
# del interfaces eNB and MME/SPGW and HSS
##################################################
delete_tun_interface $ENB_INTERFACE_NAME_FOR_S1_MME
delete_tun_interface $ENB_INTERFACE_NAME_FOR_S1U
delete_tun_interface $MME_INTERFACE_NAME_FOR_S1_MME
delete_tun_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
delete_tun_interface $MME_INTERFACE_NAME_FOR_S11_MME
delete_tun_interface $SGW_INTERFACE_NAME_FOR_S11
delete_tun_interface $MME_INTERFACE_NAME_FOR_S6A
delete_tun_interface $HSS_INTERFACE_NAME_FOR_S6A
}
build_epc_tun_network() {
build_tun_network
ping -c 1 router.eur > /dev/null || { echo_fatal "router.eur does not respond to ping" >&2 ; }
IP_ROUTER=`python -c 'import socket; print socket.gethostbyname("router.eur")'`
export MAC_ROUTER=`ip neigh show | grep $IP_ROUTER | cut -d ' ' -f5 | tr -d ':'`
echo_success "ROUTER MAC ADDRESS= $MAC_ROUTER"
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"
}
clean_epc_ovs_network() {
bash_exec "modprobe tun"
bash_exec "modprobe ip_tables"
bash_exec "modprobe iptable_nat"
bash_exec "modprobe x_tables"
bash_exec "$IPTABLES -P INPUT ACCEPT"
bash_exec "$IPTABLES -F INPUT"
bash_exec "$IPTABLES -P OUTPUT ACCEPT"
bash_exec "$IPTABLES -F OUTPUT"
bash_exec "$IPTABLES -P FORWARD ACCEPT"
bash_exec "$IPTABLES -F FORWARD"
bash_exec "$IPTABLES -t raw -F"
bash_exec "$IPTABLES -t nat -F"
bash_exec "$IPTABLES -t mangle -F"
bash_exec "$IPTABLES -t filter -F"
bash_exec "ip route flush cache"
echo " Disabling forwarding"
bash_exec "sysctl -w net.ipv4.ip_forward=0"
assert " `sysctl -n net.ipv4.ip_forward` -eq 0" $LINENO
echo " Enabling DynamicAddr.."
bash_exec "sysctl -w net.ipv4.ip_dynaddr=1"
assert " `sysctl -n net.ipv4.ip_dynaddr` -eq 1" $LINENO
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
for i in 5 6 7 8 9 10 11 12 13 14 15
do
ifconfig $PGW_INTERFACE_NAME_FOR_SGI.$i down > /dev/null 2>&1
vconfig rem $PGW_INTERFACE_NAME_FOR_SGI.$i > /dev/null 2>&1
done
clean_network
clean_tun_network
}
clean_network() {
interfaces=`ifconfig | grep HWaddr | cut -d " " -f1-2 | tr -d '\n'`
for interface in $interfaces
do
is_vlan_interface $interface
if [ $? -eq 1 ]; then
echo_success "Found VLAN interface $interface ... deleting"
ifconfig $interface down > /dev/null 2>&1
vconfig rem $interface > /dev/null 2>&1
fi
done
}
check_s6a_certificate() {
if [ -d /usr/local/etc/freeDiameter ]
......@@ -917,6 +366,106 @@ check_s6a_certificate() {
return 1
}
generate_ssh_keys() {
ssh-keygen -t dsa
}
# arg 1 is dest machine
copy_ssh_keys() {
ssh-copy-id -i ~/.ssh/id_dsa.pub $LOGNAME@$1
}
# arg 1 is mysql user (root)
# arg 2 is mysql password (linux)
create_hss_database(){
EXPECTED_ARGS=2
E_BADARGS=65
MYSQL=`which mysql`
if [ $# -ne $EXPECTED_ARGS ]
then
echo_fatal "Usage: $0 dbuser dbpass"
fi
set_openair
Q1="CREATE DATABASE IF NOT EXISTS ${BTICK}oai_db${BTICK};"
SQL="${Q1}"
$MYSQL -u $1 --password=$2 -e "$SQL"
if [ $? -ne 0 ]; then
echo_error "oai_db creation failed"
else
echo_success "oai_db creation succeeded"
fi
$MYSQL -u $1 --password=$2 oai_db < $OPENAIRCN_DIR/OPENAIRHSS/db/oai_db.sql
if [ $? -ne 0 ]; then
echo_error "oai_db tables creation failed"
else
echo_success "oai_db tables creation succeeded"
fi
Q1="GRANT ALL PRIVILEGES ON *.* TO 'hssadmin'@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;"
Q2="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}"
$MYSQL -u $1 --password=$2 -e "$SQL"
if [ $? -ne 0 ]; then
echo_error "hssadmin permissions failed"
else
echo_success "hssadmin permissions succeeded"
fi
}
check_install_hss_software() {
test_install_package autoconf
test_install_package automake
test_install_package bison
test_install_package build-essential
test_install_package cmake
test_install_package cmake-curses-gui
test_install_package dkms
test_install_package flex
test_install_package gawk
test_install_package gcc
test_install_package gdb
test_install_package guile-2.0-dev
test_install_package g++
test_install_package libgmp-dev
test_install_package libgcrypt11-dev
test_install_package libidn11-dev
test_install_package libidn2-0-dev
test_install_package libmysqlclient-dev
test_install_package libtasn1-3-dev
test_install_package libsctp1
test_install_package libsctp-dev
test_install_package libxml2-dev
test_install_package linux-headers-`uname -r`
test_install_package make
test_install_package mysql-client-core-5.5
test_install_package mysql-server-core-5.5
test_install_package mysql-server-5.5
test_install_package openssh-client
test_install_package openssh-server
test_install_package phpmyadmin
test_install_package python-dev
test_install_package sshfs
test_install_package swig
test_install_package unzip
test_install_package valgrind
}
check_install_vbox_software() {
test_install_package dkms
test_install_package openssh-client
test_install_package openssh-server
test_install_package sshfs
test_install_package virtualbox
test_install_package virtualbox-dkms
test_install_package virtualbox-guest-additions-iso
test_install_package virtualbox-qt
test_install_package virtualbox-guest-utils
}
check_install_epc_software() {
test_install_package autoconf
test_install_package automake
......@@ -960,9 +509,12 @@ check_install_epc_software() {
test_install_package libxml2-dev
test_install_package linux-headers-`uname -r`
test_install_package make
test_install_package openssh-client
test_install_package openssh-server
test_install_package openssl
test_install_package openvpn
test_install_package python-dev
test_install_package sshfs
test_install_package subversion
test_install_package swig
test_install_package tshark
......@@ -1001,6 +553,45 @@ check_install_epc_software() {
fi
}
function cgrp()
{
OPTIND=1
local case=""
local usage="cgrp: find string in files.
Usage: cgrp \"pattern\" "
set_openair
find $OPENAIR2_DIR -name *.c -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR1_DIR -name *.c -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR3_DIR -name *.c -exec grep --color=auto -Hni $1 {} \;
find $OPENAIRCN_DIR -name *.c -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR_TARGETS -name *.c -exec grep --color=auto -Hni $1 {} \;
}
function hgrp()
{
OPTIND=1
local case=""
local usage="hgrp: find string in files.
Usage: hgrp \"pattern\" "
set_openair
find $OPENAIR2_DIR -name *.h -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR1_DIR -name *.h -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR3_DIR -name *.h -exec grep --color=auto -Hni $1 {} \;
find $OPENAIRCN_DIR -name *.h -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR_TARGETS -name *.h -exec grep --color=auto -Hni $1 {} \;
}
function svn_find_str_in_file_history()
{
for REV in `svn log $1 | grep ^r[0-9] | awk '{print $1}'`; do
svn cat $1 -r $REV | grep $2
if [ $? -eq 0 ]; then
echo "$REV"
fi
done
}
compile_epc() {
cd $OPENAIRCN_DIR
OBJ_DIR=`find . -maxdepth 1 -type d -iname obj*`
......@@ -1043,7 +634,10 @@ compile_epc() {
exit 1
fi
}
###########################################################
THIS_UTILS_SCRIPT_PATH=$(dirname $(readlink -f $0))
source $THIS_UTILS_SCRIPT_PATH/networks.bash
###########################################################
###########################################################
IPTABLES=/sbin/iptables
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
......
......@@ -7,16 +7,41 @@ export OS_TYPE="Ubuntu"
export HOST_BRIDGED_IF_NAME="eth1"
export DEFAULT_VIRTUAL_BOX_VM_PATH='/root/VirtualBox VMs'
export TRUNK_SHARED_FOLDER_NAME="shared_trunk"
###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
source $THIS_SCRIPT_PATH/utils.bash
###########################################################
# NETWORK SETTING AT EURECOM IN EXPERIMENTAL NETWORK (192.168.12.X)
#
# +-----------+----------------+------+---------------------------------------+
# | COMPUTER 1| | eth1 | Physical |
# +-----------+ (nic1) +-+--+-+ Interface |
#
# INTERNET GW 192.168.12.100
# |
# |
# 192.168.12.X/24 |
# +-----------+----------------+---+--+---------------------------------------+
# | COMPUTER 1| | eth0 | |
# +-----------+ +---+--+ |
# | | |
# | | |
# | +-----+------+ |
# | |MASQUERADING| |
# | +-----+------+ |
# | | |
# | | |
# | | |
# | | |
# | | |
# | +---+--+ |
# | | eth1 | |
# +----------------------------+---+--+---------------------------------------+
# |
# | INTERNET GW 192.168.12.100
# | |
# 192.168.13.X/24 | |
# +-----------+----------------+---+--+---------------------+---+--+----------+
# | COMPUTER 2| | eth1 | Physical | eth0 | |
# +-----------+ +-+--+-+ Interface +------+ |
# | | | 'HOST_BRIDGED_IF_NAME' |
# | | | |
# | | | +-----------+ |
......@@ -91,6 +116,8 @@ build_vbox_vm_enb() {
--nic1 bridged --nic2 hostonly --nic3 hostonly --nic4 hostonly \
--nictype1 82545EM --nictype2 82545EM --nictype3 82545EM --nictype4 82545EM \
--cableconnected1 on --cableconnected2 on --cableconnected3 off --cableconnected4 off \
--macaddress1 c8d3a3020301 --macaddress2 c8d3a3020302 \
--macaddress3 c8d3a3020303 --macaddress4 c8d3a3020304 \
--bridgeadapter1 $HOST_BRIDGED_IF_NAME \
--hostonlyadapter2 vboxnet0 \
--audio none \
......@@ -121,11 +148,11 @@ build_vbox_vm_enb() {
build_vbox_vm_hss() {
UUID=`VBoxManage clonevm --mode all --name $HSS_VM_NAME --register
UUID=`VBoxManage clonevm $ENB_VM_NAME --mode all --name $HSS_VM_NAME --register
`
HSS_UUID=`VBoxManage showvminfo $HSS_VM_NAME | grep Hardware\ UUID | cut -d: -f2 | tr -d ' '`
echo HSS_UUID=$HSS_UUID
......@@ -136,6 +163,8 @@ build_vbox_vm_hss() {
--nic1 bridged --nic2 hostonly --nic3 none --nic4 none \
--nictype1 82545EM --nictype2 virtio --nictype3 82545EM --nictype4 82545EM \
--cableconnected1 on --cableconnected2 on --cableconnected3 off --cableconnected4 off \
--macaddress1 c8d3a3020101 --macaddress2 c8d3a3020102 \
--macaddress3 c8d3a3020103 --macaddress4 c8d3a3020104 \
--bridgeadapter1 $HOST_BRIDGED_IF_NAME \
--hostonlyadapter2 vboxnet1 \
--audio none \
......@@ -145,14 +174,21 @@ build_vbox_vm_hss() {
build_vms() {
build_vbox_vm_enb
build_vbox_vm_hss
echo_warning "!!!!!!! once VM are created, you have to harmonize IP addresses and MAC addresses !!!!!!!"
echo_warning "!!!!!!! /etc/network/interfaces and /etc/udev/rules.d/70-persistent-net.rules !!!!!!!"
echo_warning "!!!!!!! !!!!!!!"
echo_warning "!!!!!!! to share open air source code: use sshfs (you can use vbox shared folders,!!!!!!!"
echo_warning "!!!!!!! in this case, help yourself...) !!!!!!!"
echo_warning "!!!!!!! exchange ssh keys between host and guests !!!!!!!"
echo_warning "!!!!!!! in /etc/fstab on guests: add following line: !!!!!!!"
echo_warning "!!!!!!! sshfs#root@192.168.13.175:/root/trunk /mnt/sshfs/trunk fuse comment=sshfs!!!!!!!"
echo_warning "!!!!!!! ,noauto,users,exec,uid=0,gid=0,allow_other,reconnect,transform_symlinks, !!!!!!!"
echo_warning "!!!!!!! BatchMode=yes 0 0 !!!!!!!"
echo_warning "!!!!!!! on guest: create a mount point: /mnt/sshfs/trunk for example, then mount: !!!!!!!"
echo_warning "!!!!!!! mount /mnt/sshfs/trunk !!!!!!!"
}
create_shared_folder_openair_trunk() {
VBoxManage sharedfolder add "$ENB_VM_NAME" --transient --name "$TRUNK_SHARED_FOLDER_NAME" --hostpath "$OPENAIR_HOME"
#bash_exec "mount -t vboxsf $TRUNK_SHARED_FOLDER_NAME $OPENAIR_HOME"
}
build_vbox_vm_enb
create_shared_folder_openair_trunk
build_vms
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment