Pre-ci test passed git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4000 818b1a75-f10b-46b9-bf7c-635c3b92a50f
234 lines
5.3 KiB
Bash
Executable File
234 lines
5.3 KiB
Bash
Executable File
#!/bin/bash
|
|
#set -x
|
|
###########################################################
|
|
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
|
|
###########################################################
|
|
|
|
black='\E[30m'
|
|
red='\E[31m'
|
|
green='\E[32m'
|
|
yellow='\E[33m'
|
|
blue='\E[34m'
|
|
magenta='\E[35m'
|
|
cyan='\E[36m'
|
|
white='\E[37m'
|
|
|
|
ROOT_UID=0
|
|
E_NOTROOT=67
|
|
|
|
trim ()
|
|
{
|
|
echo "$1" | sed -n '1h;1!H;${;g;s/^[ \t]*//g;s/[ \t]*$//g;p;}'
|
|
}
|
|
|
|
|
|
cecho() # Color-echo
|
|
# arg1 = message
|
|
# arg2 = color
|
|
{
|
|
local default_msg="No Message."
|
|
message=${1:-$default_msg}
|
|
color=${2:-$black}
|
|
echo -e "$color"
|
|
echo -n "$message"
|
|
tput sgr0
|
|
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
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
wait_process_ended () {
|
|
if [ -z "$1" ]
|
|
then
|
|
echo_error "WAITING FOR PROCESS START: NO PROCESS"
|
|
return 1
|
|
fi
|
|
pkill $1
|
|
ps -C $1 > /dev/null 2>&1
|
|
while [ $? -eq 0 ]; do
|
|
echo_warning "WAITING FOR $1 END"
|
|
pkill $1
|
|
sleep 2
|
|
ps -C $1 > /dev/null 2>&1
|
|
done
|
|
echo_success "PROCESS $1 ENDED"
|
|
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
|
|
}
|
|
|
|
control_c()
|
|
# run if user hits control-c
|
|
{
|
|
echo -en "\n*** Exiting ***\n"
|
|
pkill LTE_RAL_UE
|
|
wait_process_ended LTE_RAL_UE
|
|
pkill oaisim_UE
|
|
wait_process_ended oaisim_UE
|
|
sleep 1
|
|
cp /tmp/log_oaiUE ./log_oaiUE.txt
|
|
cp /tmp/log_lteralue ./log_lteralue.txt
|
|
sleep 1
|
|
ip link set oai0 down
|
|
/sbin/rmmod -w nascellmt
|
|
exit $?
|
|
}
|
|
|
|
|
|
set_openair() {
|
|
path=`pwd`
|
|
declare -i length_path
|
|
declare -i index
|
|
length_path=${#path}
|
|
|
|
index=`echo $path | grep -b -o 'targets' | 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 OPENAIR1_DIR=$openair_path/openair1
|
|
export OPENAIR2_DIR=$openair_path/openair2
|
|
export OPENAIR3_DIR=$openair_path/openair3
|
|
export OPENAIR_TARGETS=$openair_path/targets
|
|
return 0
|
|
fi
|
|
return -1
|
|
}
|
|
|
|
|
|
trap control_c SIGINT
|
|
#set_openair
|
|
echo "OPENAIR1_DIR="$OPENAIR1_DIR
|
|
echo "OPENAIR2_DIR="$OPENAIR2_DIR
|
|
echo "OPENAIR3_DIR="$OPENAIR3_DIR
|
|
echo "OPENAIR_TARGETS="$OPENAIR_TARGETS
|
|
|
|
echo "Bring up UE interface"
|
|
pkill oaisim_UE
|
|
/sbin/rmmod -w nascellmt
|
|
ip route del 239.0.0.160/28 dev eth1
|
|
|
|
#make oaisim rrc_cellular=1 UE_flag=1
|
|
/sbin/insmod $OPENAIR2_DIR/NAS/DRIVER/CELLULAR/NASMT/nascellmt.ko nas_IMEI=3,5,6,0,1,4,9,1,5,0,0,0,0,0
|
|
#sudo $OPENAIR2_DIR/NAS/DRIVER/CELLULAR/start_mt_cellular
|
|
echo "UE interface network driver started"
|
|
|
|
#avoid conflict with reserved multicast addresses (224.0.0.11,224.0.0.13, 224.0.0.16)
|
|
## ip link set oai0 broadcast ff:ff:ff:ff:ff:ff
|
|
ip route add 239.0.0.160/28 dev eth1
|
|
ip link set oai0 up
|
|
echo "UE interface network driver up"
|
|
sleep 1
|
|
ifconfig oai0 10.0.1.2 netmask 255.255.255.0 broadcast 10.0.1.255
|
|
echo "UE interface network driver IPv4 address configured"
|
|
sleep 1
|
|
## ip addr add dev oai0 2001:660:382:14:235:60ff:fe14:9150/64
|
|
ip addr add dev oai0 2001:660:382:14:235:60ff:fe14:9150/64
|
|
|
|
##
|
|
|
|
#echo " Enabling ping broadcast"
|
|
#sudo bash_exec "sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=0"
|
|
#assert "`sudo sysctl -n net.ipv4.icmp_echo_ignore_broadcasts` -eq 0" $LINENO
|
|
|
|
# ** Next lines start the Access Stratum
|
|
#nice --adjustment=-10 $OPENAIR_TARGETS/SIMU/USER/oaisim_UE -E 1234 -u1 -b0 -M1 -p2 -l6 > /dev/null 2>&1
|
|
echo "Starting OAI Access Stratum ..."
|
|
nice --adjustment=-10 $OPENAIR_TARGETS/SIMU/USER/oaisim_UE -E 1 -u1 -b0 -M1 -p2 -g2 -l6 > /tmp/log_oaiUE 2>&1 &
|
|
#$OPENAIR_TARGETS/SIMU/USER/oaisim_UE -E 1 -u1 -b0 -M1 -p2 -g1 -l6
|
|
#nice --adjustment=-10 $OPENAIR_TARGETS/SIMU/USER/oaisim_UE -E 1 -u1 -b0 -M1 -p2 -g1 -l6
|
|
|
|
#gdb --args $OPENAIR_TARGETS/SIMU/USER/oaisim -E 1234 -b0 -M1 -p2 -g1 -l3
|
|
|
|
# ** Next lines start the RAL
|
|
#wait_process_started oaisim_UE
|
|
#sleep 4
|
|
#$OPENAIR3_DIR/RAL-LTE/LTE_RAL_UE/LTE_RAL_UE > /tmp/log_lteralue 2>&1 &
|
|
#wait_process_started LTE_RAL_UE
|
|
|
|
# ** Next lines start the gioctl
|
|
wait_process_started oaisim_UE
|
|
sleep 7
|
|
$OPENAIR2_DIR/NAS/DRIVER/CELLULAR/CTL_TOOL/gioctl cx add 0 5
|
|
|
|
echo "End"
|
|
|