Commit a4ac7ea7 authored by nguyennd's avatar nguyennd
Browse files

For e MBMS

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5115 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent e17afedf
#! /bin/bash
# Author Lionel GAUTHIER
###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
###########################################################
echo_success "\n###############################"
echo_success "# Check installed utils and libs"
echo_success "###############################"
test_command_install_package "gccxml" "gccxml" "--force-yes"
test_command_install_package "iptables" "iptables"
#test_command_install_package "ebtables" "ebtables" "--force-yes"
test_command_install_package "ip" "iproute"
test_install_package "openssl"
test_install_package "libblas-dev"
# for itti analyser
test_install_package "libgtk-3-dev"
test_install_package "libxml2"
test_install_package "libxml2-dev"
test_install_package "libforms-bin" "--force-yes"
test_install_package "libforms-dev"
test_install_package "libatlas-dev"
test_install_package "libatlas-base-dev"
test_install_package "libpgm-5.1-0" "--force-yes"
test_install_package "libpgm-dev" "--force-yes"
test_install_package linux-headers-`uname -r`
test_install_package "tshark" "--force-yes"
# for ODTONE git clone
test_install_package "git"
test_install_asn1c_4_rrc_cellular
echo_success "\n###############################"
echo_success "# COMPILE oaisim"
echo_success "###############################"
cd $OPENAIR_TARGETS/SIMU/USER
echo_success "Executing: make oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 Rel10=1 -j`grep -c ^processor /proc/cpuinfo `"
make oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 Rel10=1 -j`grep -c ^processor /proc/cpuinfo `
if [[ $? -eq 2 ]] ; then
exit 1
fi
echo_success "\n###############################"
echo_success "# COMPILE IP kernel drivers"
echo_success "###############################"
echo_success "Compiling IP Drivers"
cd $OPENAIR2_DIR
make naslite_netlink_ether.ko
cd $OPENAIR2_DIR/NAS/DRIVER/LITE/RB_TOOL/
make
echo_success "\n###############################"
echo_success "# COMPILE ITTI ANALYSER"
echo_success "###############################"
#cd $OPENAIR_HOME/common/utils/itti_analyzer
#if [ ! -f $OPENAIR_HOME/common/utils/itti_analyzer/Makefile ]
# then
# ./autogen.sh
# ./configure
# fi
#make install
Active_eNBs = ( "eNB_Eurecom_0");
eNBs =
(
{
////////// Identification parameters:
eNB_ID = 347472;
cell_type = "CELL_MACRO_ENB";
eNB_name = "eNB_Eurecom_0";
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
mobile_country_code = 208;
mobile_network_code = 10;
////////// Channel parameters:
// Default Paging DRX of the eNB as defined in TS 36.304
default_paging_drx = "PAGING_DRX_256";
////////// Physical parameters:
frame_type = "TDD";
prefix_type = "NORMAL";
eutra_band = 33;
downlink_frequency = 1907.6e6;
uplink_frequency_offset = 0.0;
////////// MME parameters:
mme_ip_address = ( { ipv4 = "192.168.12.31";
ipv6 = "2192:168:30::17";
active = "yes";
preference = "ipv4";
},
{ ipv4 = "192.168.12.86";
ipv6 = "2192:168:30::18";
active = "yes";
preference = "ipv4";
}
);
}
);
#!/bin/bash
# Author Lionel GAUTHIER
# OAI NETWORKING--------------------------------
declare -x EMULATION_DEV_INTERFACE="eth0"
declare -x IP_DRIVER_NAME="oai_nw_drv"
declare -x LTEIF="oai0"
declare -x ENB_IPv4="10.0.1.1"
declare -x ENB_IPv6="9998::1"
declare -x ENB_IPv6_CIDR=$ENB_IPv6"/64"
declare -x ENB_IPv4_CIDR=$ENB_IPv4"/24"
declare -a NAS_IMEI=( 3 9 1 8 3 6 6 2 0 0 0 0 0 0 )
#------------------------------------------------
LOG_FILE="/tmp/oai_sim_enb.log"
###########################################################
IPTABLES=/sbin/iptables
declare -x OPENAIR_DIR=""
declare -x OPENAIR1_DIR=""
declare -x OPENAIR2_DIR=""
declare -x OPENAIR3_DIR=""
declare -x OPENAIR_TARGETS=""
#######################################
#######################################
###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
source $THIS_SCRIPT_PATH/utils.bash
###########################################################
set_openair
cecho "OPENAIR_DIR = $OPENAIR_DIR" $green
cecho "OPENAIR1_DIR = $OPENAIR1_DIR" $green
cecho "OPENAIR2_DIR = $OPENAIR2_DIR" $green
cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green
cecho "OPENAIR_TARGETS = $OPENAIR_TARGETS" $green
bash_exec "/sbin/iptables -t mangle -F"
bash_exec "/sbin/iptables -t nat -F"
bash_exec "/sbin/iptables -t raw -F"
bash_exec "/sbin/iptables -t filter -F"
bash_exec "/sbin/ip6tables -t mangle -F"
bash_exec "/sbin/ip6tables -t filter -F"
bash_exec "/sbin/ip6tables -t raw -F"
##################################################
# LAUNCH eNB executable
##################################################
source $THIS_SCRIPT_PATH/build_all.bash
echo "Bringup eNB interface"
pkill oaisim > /dev/null 2>&1
pkill oaisim > /dev/null 2>&1
rmmod -f $IP_DRIVER_NAME > /dev/null 2>&1
bash_exec "insmod $OPENAIR2_DIR/NAS/DRIVER/LITE/$IP_DRIVER_NAME.ko oai_nw_drv_IMEI=${NAS_IMEI[0]},${NAS_IMEI[1]},${NAS_IMEI[2]},${NAS_IMEI[3]},${NAS_IMEI[4]},${NAS_IMEI[5]},${NAS_IMEI[6]},${NAS_IMEI[7]},${NAS_IMEI[8]},${NAS_IMEI[9]},${NAS_IMEI[10]},${NAS_IMEI[11]},${NAS_IMEI[12]},${NAS_IMEI[13]}"
bash_exec "ip route flush cache"
bash_exec "ip link set $LTEIF up"
sleep 1
bash_exec "ip addr add dev $LTEIF $ENB_IPv4_CIDR"
bash_exec "ip addr add dev $LTEIF $ENB_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
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"
# please add table 200 lte in /etc/iproute2/rt_tables
fgrep lte /etc/iproute2/rt_tables > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "200 lte " >> /etc/iproute2/rt_tables
fi
ip rule add fwmark 3 table lte
ip route add default dev $LTEIF table lte
ip route add 239.0.0.160/28 dev $EMULATION_DEV_INTERFACE
/sbin/ebtables -t nat -A POSTROUTING -p arp -j mark --mark-set 3
/sbin/ip6tables -A OUTPUT -t mangle -o oai0 -m pkttype --pkt-type multicast -j MARK --set-mark 3
/sbin/iptables -A OUTPUT -t mangle -o oai0 -m pkttype --pkt-type broadcast -j MARK --set-mark 3
/sbin/iptables -A OUTPUT -t mangle -o oai0 -m pkttype --pkt-type multicast -j MARK --set-mark 3
/sbin/ip6tables -A POSTROUTING -t mangle -o oai0 -m pkttype --pkt-type multicast -j MARK --set-mark 3
/sbin/iptables -A POSTROUTING -t mangle -o oai0 -m pkttype --pkt-type broadcast -j MARK --set-mark 3
/sbin/iptables -A POSTROUTING -t mangle -o oai0 -m pkttype --pkt-type multicast -j MARK --set-mark 3
#All other traffic is sent on the RAB you want (mark = RAB ID)
/sbin/ip6tables -A POSTROUTING -t mangle -o oai0 -m pkttype --pkt-type unicast -j MARK --set-mark 3
/sbin/ip6tables -A OUTPUT -t mangle -o oai0 -m pkttype --pkt-type unicast -j MARK --set-mark 3
/sbin/iptables -A POSTROUTING -t mangle -o oai0 -m pkttype --pkt-type unicast -j MARK --set-mark 3
/sbin/iptables -A OUTPUT -t mangle -o oai0 -m pkttype --pkt-type unicast -j MARK --set-mark 3
NOW=$(date +"%Y-%m-%d.%Hh_%Mm_%Ss")
rotate_log_file $LOG_FILE
#xterm -hold -e gdb --args
#$OPENAIR_TARGETS/SIMU/USER/oaisim -a -Q3 -s15 -K $LOG_FILE -l9 -u0 -b1 -M0 -p2 -g1 -D $EMULATION_DEV_INTERFACE -O $THIS_SCRIPT_PATH/enb.conf &
#$OPENAIR_TARGETS/SIMU/USER/oaisim -a -l3 -u0 -b1 -M0 -p2 -g1 -D $EMULATION_DEV_INTERFACE -O $THIS_SCRIPT_PATH/enb.conf &
$OPENAIR_TARGETS/SIMU/USER/oaisim -a -l3 -u0 -b1 -M0 -p2 -g1 -D 192.168.55.51 -O $THIS_SCRIPT_PATH/enb.conf &
wait_process_started oaisim
sleep 100000
#!/bin/bash
# Author Lionel GAUTHIER
# OAI NETWORKING--------------------------------
declare -x EMULATION_DEV_INTERFACE="eth4"
declare -x IP_DRIVER_NAME="oai_nw_drv"
declare -x LTEIF="oai0"
declare -x UE_IPv4="10.0.0.11"
declare -x UE_IPv6="9998::11"
declare -x UE_IPv6_CIDR=$UE_IPv6"/64"
declare -x UE_IPv4_CIDR=$UE_IPv4"/24"
declare -a NAS_IMEI=( 3 9 1 8 3 6 7 3 0 2 0 0 0 0 )
#------------------------------------------------
LOG_FILE="/tmp/oai_sim_ue.log"
###########################################################
IPTABLES=/sbin/iptables
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
declare -x OPENAIR_DIR=""
declare -x OPENAIR1_DIR=""
declare -x OPENAIR2_DIR=""
declare -x OPENAIR3_DIR=""
declare -x OPENAIR_TARGETS=""
###########################################################
###########################################################
source $THIS_SCRIPT_PATH/utils.bash
source $THIS_SCRIPT_PATH/build_all.bash
###########################################################
##################################################
# LAUNCH UE
##################################################
echo "Bringup UE interface"
pkill oaisim > /dev/null 2>&1
pkill oaisim > /dev/null 2>&1
rmmod -f $IP_DRIVER_NAME > /dev/null 2>&1
bash_exec "insmod $OPENAIR2_DIR/NAS/DRIVER/LITE/$IP_DRIVER_NAME.ko oai_nw_drv_IMEI=${NAS_IMEI[0]},${NAS_IMEI[1]},${NAS_IMEI[2]},${NAS_IMEI[3]},${NAS_IMEI[4]},${NAS_IMEI[5]},${NAS_IMEI[6]},${NAS_IMEI[7]},${NAS_IMEI[8]},${NAS_IMEI[9]},${NAS_IMEI[10]},${NAS_IMEI[11]},${NAS_IMEI[12]},${NAS_IMEI[13]}"
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
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"
# please add table 200 lte in file /etc/iproute2/rt_tables
fgrep lte /etc/iproute2/rt_tables > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "200 lte " >> /etc/iproute2/rt_tables
fi
ip rule add fwmark 5 table lte
ip -4 route add default dev $LTEIF table lte
ip -6 route add default dev $LTEIF table lte
ip route add 239.0.0.160/28 dev $EMULATION_DEV_INTERFACE
NOW=$(date +"%Y-%m-%d.%Hh_%Mm_%Ss")
rotate_log_file $LOG_FILE
#xterm -hold -e gdb --args
$OPENAIR_TARGETS/SIMU/USER/oaisim -a -Q3 -s15 -K $LOG_FILE -l9 -u1 -b0 -M1 -p2 -g1 -D $EMULATION_DEV_INTERFACE
wait_process_started oaisim
# start MIH-USER
sleep 100000
#!/bin/bash
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
}
black='\E[30m'
red='\E[31m'
green='\E[32m'
yellow='\E[33m'
blue='\E[34m'
magenta='\E[35m'
cyan='\E[36m'
white='\E[37m'
reset_color='\E[00m'
ROOT_UID=0
E_NOTROOT=67
HOSTNAME=$(hostname -f)
trim ()
{
echo "$1" | sed -n '1h;1!H;${;g;s/^[ \t]*//g;s/[ \t]*$//g;p;}'
}
trim2()
{
local var=$@
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
cecho() # Color-echo
# arg1 = message
# arg2 = color
{
local default_msg="No Message."
message=${1:-$default_msg}
color=${2:-$green}
echo -e -n "$color$message$reset_color"
echo
return
}
echo_error() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
cecho "$my_string" $red
}
echo_warning() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
cecho "$my_string" $yellow
}
echo_success() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
cecho "$my_string" $green
}
bash_exec() {
output=$($1 2>&1)
result=$?
if [ $result -eq 0 ]
then
echo_success "$1"
else
echo_error "$1: $output"
fi
}
rotate_log_file () {
if [ -f $1 ]; then
TIMESTAMP=`date +%Y-%m-%d.%Hh_%Mm_%Ss`
NEWLOGFILE=$1.$TIMESTAMP
mv $1 $NEWLOGFILE
cat /dev/null > $1
nohup gzip -f -9 $NEWLOGFILE &
fi
}
extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo_error "'$1' cannot be extracted via >extract<" ; return 1;;
esac
else
echo_error "'$1' is not a valid file"
return 1
fi
return 0
}
set_openair() {
path=`pwd`
declare -i length_path
declare -i index
length_path=${#path}
for i in 'openair1' 'openair2' 'openair3' 'openair-cn' 'targets'
do
index=`echo $path | grep -b -o $i | cut -d: -f1`
#echo ${path%$token*}
if [[ $index -lt $length_path && index -gt 0 ]]
then
declare -x OPENAIR_DIR
index=`expr $index - 1`
openair_path=`echo $path | cut -c1-$index`
#openair_path=`echo ${path:0:$index}`
export OPENAIR_DIR=$openair_path
export OPENAIR_HOME=$openair_path
export OPENAIR1_DIR=$openair_path/openair1
export OPENAIR2_DIR=$openair_path/openair2
export OPENAIR3_DIR=$openair_path/openair3
export OPENAIRCN_DIR=$openair_path/openair-cn
export OPENAIR_TARGETS=$openair_path/targets
return 0
fi
done
return -1
}
test_install_asn1c_4_rrc_cellular() {
if [ -d $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/asn1c ]; then
if [ -x $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/asn1c/asn1c/asn1c ]; then
if [ -x /usr/local/bin/asn1c ]; then
diff /usr/local/bin/asn1c $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/asn1c/asn1c/asn1c >/dev/null 2>&1;
if [ $? -eq 0 ]; then
echo_success "asn1c for RRC cellular installed"
return 0
fi
fi
echo_warning "Installing asn1c for RRC cellular..."
cd $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/asn1c
make install
return 0
fi
else
echo_warning "asn1c for RRC cellular is not installed in $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/. Installing it"
cd $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c
svn co https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk asn1c
fi
echo_warning "Configuring and building and installing asn1c for RRC cellular..."
cd $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/asn1c
./configure
make
make install
}
wait_process_started () {
if [ -z "$1" ]
then
echo_error "WAITING FOR PROCESS START: NO PROCESS"
return 1
fi
ps -C $1 > /dev/null 2>&1
while [ $? -ne 0 ]; do
echo_warning "WAITING FOR $1 START"
sleep 2
ps -C $1 > /dev/null 2>&1
done
echo_success "PROCESS $1 STARTED"
return 0
}
is_process_started () {
if [ -z "$1" ]
then
echo_error "WAITING FOR PROCESS START: ERROR NO PROCESS NAME IN ARGUMENT"
return 1
fi
ps -C $1 > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo_success "PROCESS $1 NOT STARTED"
return 1
fi
echo_success "PROCESS $1 STARTED"
return 0
}
assert() {
# If condition false
# exit from script with error message
E_PARAM_ERR=98
E_PARAM_FAILED=99
if [ -z "$2" ] # Not enought parameters passed.
then
return $E_PARAM_ERR
fi
lineno=$2
if [ ! $1 ]
then
echo "Assertion failed: \"$1\""
echo "File \"$0\", line $lineno"
exit $E_ASSERT_FAILED
fi
}
test_install_package() {
# usage: test_install_package package_name_to_be_installed optional_option_to_apt_get_install
dpkg --get-selections $1 | grep -i install > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo_warning "Package $1 is not installed. Installing it." >&2
apt-get install $2 $1 -y
dpkg --get-selections $1 | grep -i install > /dev/null 2>&1
if [ $? -ne 0 ]; then
exit 1
fi
else
echo_success "$1 is installed"
fi
return 0
}
test_command_install_package() {
# usage: test_command_install_package searched_binary package_to_be_installed_if_binary_not_found optional_option_to_apt_get_install
if [ $# -eq 2 ]; then
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; apt-get install $2 -y; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };}
else
if [ $# -eq 3 ]; then
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it (apt-get install $3 $2)." >&2; apt-get install $3 $2 -y; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };}
else
echo_success "test_command_install_package: BAD PARAMETER"
exit 1
fi
fi
echo_success "$1 available"
}
test_command_install_script() {
# usage: test_command_install_script searched_binary script_to_be_invoked_if_binary_not_found
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; bash $2; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };}
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"
else
echo_error "/lib/modules/`uname -r`/extra/openvswitch.ko not found, exiting"
exit -1
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
}
check_enb_config() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/enb_$HOSTNAME.conf ]
then
echo "Cannot find file $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/enb_$HOSTNAME.conf"
e