start_enb.bash 9.79 KB
Newer Older
1
#!/bin/bash
Lionel Gauthier's avatar
Lionel Gauthier committed
2
################################################################################
Lionel Gauthier's avatar
Lionel Gauthier committed
3 4
#   OpenAirInterface
#   Copyright(c) 1999 - 2014 Eurecom
Lionel Gauthier's avatar
Lionel Gauthier committed
5
#
Lionel Gauthier's avatar
Lionel Gauthier committed
6 7 8 9
#    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.
Lionel Gauthier's avatar
Lionel Gauthier committed
10 11
#
#
Lionel Gauthier's avatar
Lionel Gauthier committed
12 13 14 15
#    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.
Lionel Gauthier's avatar
Lionel Gauthier committed
16
#
Lionel Gauthier's avatar
Lionel Gauthier committed
17 18 19 20 21 22 23 24 25 26
#    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
Lionel Gauthier's avatar
Lionel Gauthier committed
28 29 30 31 32 33 34 35
#
################################################################################
# file start_enb.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
###########################################
36 37 38
# INPUT OF THIS SCRIPT:
# THE DIRECTORY WHERE ARE LOCATED THE CONFIGURATION FILES
#########################################
Lionel Gauthier's avatar
 
Lionel Gauthier committed
39
# This script start  ENB  
40
# Depending on configuration files, it can be instanciated a virtual switch 
Lionel Gauthier's avatar
 
Lionel Gauthier committed
41
# setting or a VLAN setting for the networking between eNB and MME.
42
# MME+SP-GW executable have to be launched on the same host by your own (start_epc.bash) before this script is invoked.
Lionel Gauthier's avatar
 
Lionel Gauthier committed
43
# UE executable have to be launched on another host by your own (start_ue.bash) after this script is invoked.
44 45 46 47 48
#

###########################################################
# Parameters
###########################################################
Lionel Gauthier's avatar
 
Lionel Gauthier committed
49 50
declare EMULATION_DEV_INTERFACE="eth1"
declare EMULATION_MULTICAST_GROUP=1
Lionel Gauthier's avatar
 
Lionel Gauthier committed
51

52
declare MAKE_LTE_ACCESS_STRATUM_TARGET="oaisim DEBUG=1 ENABLE_ITTI=1 USE_MME=R10 LINK_PDCP_TO_GTPV1U=1 NAS=1 SECU=1 RRC_MSG_PRINT=1"
Lionel Gauthier's avatar
Lionel Gauthier committed
53 54
declare MAKE_LTE_ACCESS_STRATUM_TARGET_RTAI="lte-softmodem DEBUG=1  RTAI=1 HARD_RT=1 EXMIMO=1  ENABLE_ITTI=1 USE_MME=R10 LINK_PDCP_TO_GTPV1U=1 DISABLE_XER_PRINT=1 SECU=1 RRC_MSG_PRINT=1 "
declare MAKE_LTE_ACCESS_STRATUM_TARGET_LINUX_KERNEL="lte-softmodem DEBUG=1 RTAI=0 EXMIMO=1 ENABLE_ITTI=1 USE_MME=R10 LINK_PDCP_TO_GTPV1U=1 DISABLE_XER_PRINT=1 SECU=1 RRC_MSG_PRINT=1 "
Lionel Gauthier's avatar
 
Lionel Gauthier committed
55

56 57 58

###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
Lionel Gauthier's avatar
 
Lionel Gauthier committed
59 60 61
. $THIS_SCRIPT_PATH/utils.bash
. $THIS_SCRIPT_PATH/interfaces.bash
. $THIS_SCRIPT_PATH/networks.bash
62 63 64 65 66 67 68 69
###########################################################
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
Lionel Gauthier's avatar
 
Lionel Gauthier committed
70
    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"
71 72 73 74
    exit 1
fi


Lionel Gauthier's avatar
 
Lionel Gauthier committed
75
#check_install_epc_software
Lionel Gauthier's avatar
 
Lionel Gauthier committed
76 77 78



79
cd $THIS_SCRIPT_PATH
Lionel Gauthier's avatar
 
Lionel Gauthier committed
80 81 82

EMULATION_DEV_ADDRESS=`ifconfig $EMULATION_DEV_INTERFACE | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`

83 84 85 86
#######################################################
# FIND CONFIG FILE
#######################################################
SEARCHED_CONFIG_FILE_ENB="enb*.conf"
Lionel Gauthier's avatar
 
Lionel Gauthier committed
87
CONFIG_FILE_ENB=$THIS_SCRIPT_PATH/`find $CONFIG_FILE_DIR -iname $SEARCHED_CONFIG_FILE_ENB`
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
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

#######################################################
# SOURCE CONFIG FILE
#######################################################
rm -f /tmp/source.txt
VARIABLES="
           ENB_INTERFACE_NAME_FOR_S1_MME\|\
           ENB_IPV4_ADDRESS_FOR_S1_MME\|\
           ENB_INTERFACE_NAME_FOR_S1U\|\
Lionel Gauthier's avatar
 
Lionel Gauthier committed
103
           ENB_IPV4_ADDRESS_FOR_S1U\|\
Lionel Gauthier's avatar
 
Lionel Gauthier committed
104
           real_time"
105 106 107 108 109 110 111 112 113 114 115 116 117 118

VARIABLES=$(echo $VARIABLES | sed -e 's/\\r//g')
VARIABLES=$(echo $VARIABLES | tr -d ' ')
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 '/')

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 '/')


##################################################
Lionel Gauthier's avatar
 
Lionel Gauthier committed
119
# LAUNCH eNB executable
120 121
##################################################
pkill oaisim
Lionel Gauthier's avatar
 
Lionel Gauthier committed
122
pkill tshark
123

Lionel Gauthier's avatar
 
Lionel Gauthier committed
124 125 126
if [ ! -d $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME ]; then 
    mkdir -m 777 -p $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME
fi
Lionel Gauthier's avatar
Lionel Gauthier committed
127

128
if [ x$real_time == "xemulation" ]; then
Lionel Gauthier's avatar
 
Lionel Gauthier committed
129 130
    ITTI_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/itti_enb_ue.$HOSTNAME.log
    #rotate_log_file $ITTI_LOG_FILE
Lionel Gauthier's avatar
 
Lionel Gauthier committed
131
    
Lionel Gauthier's avatar
 
Lionel Gauthier committed
132 133 134
    STDOUT_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/stdout_enb_ue.$HOSTNAME.log
    #rotate_log_file $STDOUT_LOG_FILE
    #rotate_log_file $STDOUT_LOG_FILE.filtered
Lionel Gauthier's avatar
 
Lionel Gauthier committed
135
    
Lionel Gauthier's avatar
 
Lionel Gauthier committed
136 137
    PCAP_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/tshark_enb_ue.$HOSTNAME.pcap
    #rotate_log_file $PCAP_LOG_FILE
Lionel Gauthier's avatar
 
Lionel Gauthier committed
138
else 
Lionel Gauthier's avatar
 
Lionel Gauthier committed
139 140
    ITTI_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/itti_enb_rf.$HOSTNAME.log
    #rotate_log_file $ITTI_LOG_FILE
Lionel Gauthier's avatar
 
Lionel Gauthier committed
141
    
Lionel Gauthier's avatar
 
Lionel Gauthier committed
142 143 144
    STDOUT_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/stdout_enb_rf.$HOSTNAME.log
    #rotate_log_file $STDOUT_LOG_FILE
    #rotate_log_file $STDOUT_LOG_FILE.filtered
Lionel Gauthier's avatar
 
Lionel Gauthier committed
145
    
Lionel Gauthier's avatar
 
Lionel Gauthier committed
146 147
    PCAP_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/tshark_enb_rf.$HOSTNAME.pcap
    #rotate_log_file $PCAP_LOG_FILE
Lionel Gauthier's avatar
 
Lionel Gauthier committed
148
fi
Lionel Gauthier's avatar
 
Lionel Gauthier committed
149

150

Lionel Gauthier's avatar
Lionel Gauthier committed
151
cd $THIS_SCRIPT_PATH
Lionel Gauthier's avatar
 
Lionel Gauthier committed
152

Lionel Gauthier's avatar
 
Lionel Gauthier committed
153 154 155 156 157 158
if [ x$ENB_INTERFACE_NAME_FOR_S1_MME == x$ENB_INTERFACE_NAME_FOR_S1U ]; then 
    nohup tshark -i $ENB_INTERFACE_NAME_FOR_S1_MME -w $PCAP_LOG_FILE &
else
    nohup tshark -i $ENB_INTERFACE_NAME_FOR_S1_MME -i $ENB_INTERFACE_NAME_FOR_S1U -w $PCAP_LOG_FILE &
fi

Lionel Gauthier's avatar
 
Lionel Gauthier committed
159

160
if [ x$real_time == "xemulation" ]; then
Lionel Gauthier's avatar
 
Lionel Gauthier committed
161 162 163
    echo_warning "USER MODE"
    make --directory=$OPENAIR_TARGETS/SIMU/USER $MAKE_LTE_ACCESS_STRATUM_TARGET -j`grep -c ^processor /proc/cpuinfo ` || exit 1
    bash_exec "ip route add 239.0.0.160/28 dev $EMULATION_DEV_INTERFACE"
Lionel Gauthier's avatar
 
Lionel Gauthier committed
164
    gdb --args $OPENAIR_TARGETS/SIMU/USER/oaisim -a  -l9 -u0 -b1 -M0 -p2  -g$EMULATION_MULTICAST_GROUP -D $EMULATION_DEV_ADDRESS -K $ITTI_LOG_FILE --enb-conf $CONFIG_FILE_ENB 2>&1 | tee $STDOUT_LOG_FILE 
Lionel Gauthier's avatar
 
Lionel Gauthier committed
165
else
166
    if [ x$real_time == "xrtai" ]; then
Lionel Gauthier's avatar
 
Lionel Gauthier committed
167 168 169 170 171 172 173 174 175
        echo_warning "HARD REAL TIME MODE"
        PATH=$PATH:/usr/realtime/bin

        #make --directory=$OPENAIR_TARGETS/RT/USER drivers  || exit 1
        # 2 lines below replace the line above
        cd $OPENAIR_TARGETS/ARCH/EXMIMO/DRIVER/eurecom && make clean && make   || exit 1
        cd $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT && make clean && make   || exit 1
        cd $THIS_SCRIPT_PATH

176
        make --directory=$OPENAIR_TARGETS/RT/USER $MAKE_LTE_ACCESS_STRATUM_TARGET_RTAI -j`grep -c ^processor /proc/cpuinfo ` || exit 1
Lionel Gauthier's avatar
 
Lionel Gauthier committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196

        if [ ! -f /tmp/init_rt_done.tmp ]; then
            echo_warning "STARTING REAL TIME (RTAI)"
            insmod /usr/realtime/modules/rtai_hal.ko     > /dev/null 2>&1
            insmod /usr/realtime/modules/rtai_sched.ko   > /dev/null 2>&1
            insmod /usr/realtime/modules/rtai_sem.ko     > /dev/null 2>&1
            insmod /usr/realtime/modules/rtai_fifos.ko   > /dev/null 2>&1
            insmod /usr/realtime/modules/rtai_mbx.ko     > /dev/null 2>&1
            touch /tmp/init_rt_done.tmp
            chmod 666 /tmp/init_rt_done.tmp
        else
            echo_warning "REAL TIME FOUND STARTED (RTAI)"
        fi

        cd $OPENAIR_TARGETS/RT/USER
        bash ./init_exmimo2.sh
        echo_warning "STARTING SOFTMODEM..."
        #cat /dev/rtf62 > $STDOUT_LOG_FILE &
        gdb --args ./lte-softmodem -K $ITTI_LOG_FILE -V  -O $CONFIG_FILE_ENB  2>&1
        cd $THIS_SCRIPT_PATH
Lionel Gauthier's avatar
 
Lionel Gauthier committed
197
    else
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
        if [ x$real_time == "xlinux-kernel" ]; then
            echo_warning "LINUX_KERNEL MODE"

            #make --directory=$OPENAIR_TARGETS/RT/USER drivers  || exit 1
            # 2 lines below replace the line above
            cd $OPENAIR_TARGETS/ARCH/EXMIMO/DRIVER/eurecom && make clean && make   || exit 1
            cd $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT && make clean && make   || exit 1
            cd $THIS_SCRIPT_PATH

            make --directory=$OPENAIR_TARGETS/RT/USER $MAKE_LTE_ACCESS_STRATUM_TARGET_LINUX_KERNEL -j`grep -c ^processor /proc/cpuinfo ` || exit 1

            cd $OPENAIR_TARGETS/RT/USER
            bash ./init_exmimo2.sh
            echo_warning "STARTING SOFTMODEM..."
            touch .gdbinit_enb
            echo "file $OPENAIR_TARGETS/RT/USER/lte-softmodem" > ~/.gdbinit_enb
            echo "set args -K $ITTI_LOG_FILE -V  -O $CONFIG_FILE_ENB" >> ~/.gdbinit_enb
            echo "run" >> ~/.gdbinit_enb
            gdb -nh -x ~/.gdbinit_enb 2>&1 
            #> $STDOUT_LOG_FILE
            
            cd $THIS_SCRIPT_PATH
Lionel Gauthier's avatar
 
Lionel Gauthier committed
220
        fi
Lionel Gauthier's avatar
 
Lionel Gauthier committed
221 222
    fi
fi
223

Lionel Gauthier's avatar
 
Lionel Gauthier committed
224
pkill tshark
225

226 227 228 229
#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