run_enb_ue_virt_noS1 8.67 KB
Newer Older
gauthier's avatar
gauthier committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
################################################################################
#   OpenAirInterface
#   Copyright(c) 1999 - 2014 Eurecom
#
#    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.
#
#
#    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.
#
#    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
25
#  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
gauthier's avatar
gauthier committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#
#  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
#
################################################################################
# file start_enb_ue_virt_noS1
# 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  ENB+UE (all in one executable, on one host)
# eNB is in standalone mode, it does not require a MME.



###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
. $THIS_SCRIPT_PATH/build_helper
###########################################################




function help()
{
  echo_error " "
  echo_error "Usage: start_enb_ue_virt_noS1 [OPTION]..."
  echo_error "Run the eNB and/or UE executable with no hardware."
  echo_error " "
  echo_error "Options:"
  echo_error "Mandatory arguments to long options are mandatory for short options too."
60
  echo_error "  -a, --abstraction                       enable phy abstraction mode"
gauthier's avatar
gauthier committed
61
62
63
  echo_error "  -c, -C, --config-file  eNB_config_file  eNB config file, (see $OPENAIR_DIR/targets/PROJECTS/GENERIC-LTE-EPC/CONF)"
  echo_error "                                          Default eNB config file if not set is $1"
  echo_error "  -g, --gdb                               Run with GDB."
64
  echo_error "  -l, --log-level                         set the global log level (8:trace, 7:debug, 6:info, 4:warn, 3:error). Note that the log configuration is eNB config file is ignored for oaisim."
gauthier's avatar
gauthier committed
65
66
67
68
  echo_error "  -h, --help                              Print this help."
  echo_error "  -K, --itti-dump-file   filename         ITTI dump file containing all ITTI events occuring during EPC runtime.(can omit file name if last argument)"
  echo_error "  -m, --mscgen           directory        Generate mscgen output files in a directory"
  echo_error "  -V, --vcd                               Dump timings of processing in a GTKWave compliant file format."
gauthier's avatar
gauthier committed
69
70
71
72
  echo_error "  -W, --wireshark-l2                      Dump MAC frames for visualization with wireshark."
  echo_error "                                          You need to open Wireshark, open the preferences, and check try heuristics for the UDP protocol, MAC-LTE, RLC-LTE,"
  echo_error "                                          and PDCP-LTE. Then capture for all the interfaces with the following filters: s1ap or lte_rrc or mac-lte or rlc-lte"
  echo_error "                                          or pdcp-lte. Note the L2 pdus are transmitted to the local interface."
gauthier's avatar
gauthier committed
73
  echo_error "  -x, --xforms                            Run XFORMS scope windows."
74
  echo_error "  -n, --num-frames                        Set number of frames for simulation"
gauthier's avatar
gauthier committed
75
76
77
78
79
80
81
82
83
84
85
86
}



function main()
{
  set_openair_env
  cecho "OPENAIR_DIR    = $OPENAIR_DIR" $green

  local -i run_gdb=0
  local -i run_mscgen=0
  local    exe_arguments=""
gauthier's avatar
gauthier committed
87
  local    DEFAULT_CONFIG_FILE_ENB=$OPENAIR_DIR/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.generic.oaisim.local_no_mme.conf
gauthier's avatar
gauthier committed
88
89
  local    CONFIG_FILE_ENB=$DEFAULT_CONFIG_FILE_ENB
  local    MSC_DIR="/tmp"
90
91
  local abstraction_flag=0

gauthier's avatar
gauthier committed
92
93
94
  until [ -z "$1" ]
    do
    case "$1" in
95
96
97
98
99
100
101
	-a | --abstraction )
	abstraction_flag=1
	echo "enabling abstraction mode"
	exe_arguments="$exe_arguments -a"
        shift;
	;;      
	-c | -C | --config-file)
gauthier's avatar
gauthier committed
102
103
104
105
106
        CONFIG_FILE_ENB=$2
        # may be relative path 
        if [ -f $(dirname $(readlink -f $0))/$CONFIG_FILE ]; then
          CONFIG_FILE_ENB=$(dirname $(readlink -f $0))/$CONFIG_FILE
          echo "setting config file to: $CONFIG_FILE"
107
          config_FILE_ACCESS_OK=1
gauthier's avatar
gauthier committed
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
        else
          # may be absolute path 
          if [ -f $CONFIG_FILE_ENB ]; then
            echo "setting config file to: $CONFIG_FILE_ENB"
          else
            echo_fatal "config file $CONFIG_FILE_ENB not found"
          fi
        fi
        shift 2;
        ;;
      -g | --gdb)
        run_gdb=1
        echo "setting GDB flag to: $GDB"
        shift;
        ;;
123
124
125
126
127
      -l | --log-level)
	echo "setting the log level to $2"
	exe_arguments="$exe_arguments -l $2"
        shift 2;
	;;          
gauthier's avatar
gauthier committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
      -h | --help)
        help $DEFAULT_CONFIG_FILE_ENB
        shift;
        exit 0
        ;;
      -K | --itti-dump-file)
        ITTI_DUMP_FILE=$2
        # can omit file name if last arg on the line
        if [ "x$ITTI_DUMP_FILE" = "x" ]; then
          ITTI_DUMP_FILE="/tmp/itti_enb_ue_s1.log"
          shift 1;
        else
          shift 2;
        fi
        echo "setting ITTI dump file to: $ITTI_DUMP_FILE"
        exe_arguments="$exe_arguments -K $ITTI_DUMP_FILE"
        ;;      

      -m | --mscgen)
        MSC_DIR=$2
        if [ -d  "$MSC_DIR" ]; then
          echo "setting mscgen log files to dir: $MSC_DIR"
          run_mscgen=1
          shift 2;
        else
          echo_error "Mscgen log dir does not exist"
          exit -1
        fi
        ;;      
157
158
#      -u | --num-ue )
	    
gauthier's avatar
gauthier committed
159
160
161
162
163
      -V | --vcd)
        "setting gtk-wave output"
        exe_arguments="$exe_arguments -V /tmp/oai_gtk_wave.vcd"
        shift ;
        ;;
164
      -W | --wireshark-l2)
gauthier's avatar
gauthier committed
165
166
        echo "setting l2 pcap dump output"
        exe_arguments="$exe_arguments -P wireshark"
167
        shift 1;
gauthier's avatar
gauthier committed
168
        ;;
169
170
171
172
173
      -n | --num-frames)
	echo "setting the number of frames in simulation to $2"
	exe_arguments="$exe_arguments -n $2"
        shift 2;
	;; 
gauthier's avatar
gauthier committed
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
      *)   
        echo "Unknown option $1"
        help
        exit 0
        ;;
    esac
  done

  # may use default config file
  exe_arguments="$exe_arguments --enb-conf $CONFIG_FILE_ENB"


  ##################################################
  # LAUNCH eNB + UE executable
  ##################################################
  $SUDO pkill oaisim
  $SUDO rmmod nasmesh > /dev/null 2>&1

  echo_success "Bringup UE interface..."
  $SUDO insmod  $OPENAIR_DIR/targets/bin/nasmesh.ko
  sync

  echo "bring up oai0 interface for enb"
  $SUDO ifconfig oai0 10.0.1.1 netmask 255.255.255.0 broadcast 10.0.1.255
  sync
  echo "bring up oai1 interface for ue 1"
  $SUDO ifconfig oai1 10.0.2.2 netmask 255.255.255.0 broadcast 10.0.2.255
  sync

  # enb -> ue1
  $OPENAIR_DIR/targets/bin/rb_tool -a -c0 -i0 -z0 -s 10.0.1.1 -t 10.0.1.2 -r 1
  # ue1 -> enb
  $OPENAIR_DIR/targets/bin/rb_tool -a -c0 -i1 -z0 -s 10.0.2.2 -t 10.0.2.1 -r 1

guptar's avatar
guptar committed
208
  if [ "$abstraction_flag" -eq "0" ] ; then 
209
210
211
212
      exe_arguments="$exe_arguments -s15 -AAWGN -b1 -u1"
  else 
      exe_arguments="$exe_arguments -b1 -u1" 
  fi 
gauthier's avatar
gauthier committed
213
214
215
216
217
218
219
    
  cd  $OPENAIR_DIR/targets/bin
   
   
  if [ $run_mscgen -eq 1 ]; then 
    $SUDO rm -f /tmp/openair.msc.*
  fi
guptar's avatar
guptar committed
220
  
gauthier's avatar
gauthier committed
221
  if [ $run_gdb -eq 0 ]; then 
222
    exec $SUDO $OPENAIR_DIR/targets/bin/oaisim_nos1.Rel10 $exe_arguments | tee /tmp/enb_ue_nos1.log.txt
gauthier's avatar
gauthier committed
223
224
225
  else
    touch      ~/.gdb_enb_ue_nos1
    chmod 777  ~/.gdb_enb_ue_nos1
226
    echo "file $OPENAIR_DIR/targets/bin/oaisim_nos1.Rel10" > ~/.gdb_enb_ue_nos1
gauthier's avatar
gauthier committed
227
228
229
230
231
232
233
234
235
    echo "set args $exe_arguments" >> ~/.gdb_enb_ue_nos1
    echo "run"                        >> ~/.gdb_enb_ue_nos1
    cat ~/.gdb_enb_ue_nos1
    $SUDO gdb -n -x ~/.gdb_enb_ue_nos1 
  fi
  
  if [ $run_mscgen -eq 1 ]; then 
    cd $MSC_DIR
    last_created_file=`ls -t mscgen* | head -1 | tr -d ':'`
236
    $OPENAIR_DIR/targets/SCRIPTS/msc_gen.py  --profile E_UTRAN
gauthier's avatar
gauthier committed
237
238
239
240
241
242
243
244
245
246
247
248
    sync
    last_created_file2=`ls -t mscgen* | head -1 | tr -d ':'`
        
    if [ x"$last_created_file" != x"$last_created_file2" ]; then
      if [ -f ./$last_created_file2/oai_mscgen_page_0.png ]; then 
        command -v eog 2>/dev/null &&  eog ./$last_created_file2/oai_mscgen_page_0.png
      fi
    fi 
  fi
}

main "$@"