项目作者: coaka

项目描述 :
Previous-Hop Routing for VANETs
高级语言: Tcl
项目地址: git://github.com/coaka/phr.git
创建时间: 2017-10-02T10:37:15Z
项目社区:https://github.com/coaka/phr

开源协议:

下载


Previous Hop Routing:
A new routing protocol for VANETs.

A tutorial on how to install ns-2.35 on Ubuntu 18.04 then add the PHR code to it is provided as follows:

The new version of Ubuntu 18.04 does not support the direct installation of ns-2.35, due to the latest C/C++ compiler (7.x), however, the C/C++ compiler version 4.8 is supported by ns2. Here, we’re going to install ns2.35 on Ubuntu version 18.04:

  1. Download ns2.35 package.
    https://sourceforge.net/projects/nsnam/files/latest/download/
  1. tar zxvf ns-allinone-2.35.tar.gz

  2. sudo apt install gcc-4.8 g++-4.8

  3. sudo apt update

  4. sudo apt install build-essential autoconf automake libxmu-dev

  5. gedit ns-allinone-2.35/ns-2.35/linkstate/ls.h
    in line number 137, change erase to this->erase

  6. cd ns-allinone-2.35/

  7. export CC=gcc-4.8 CXX=g++-4.8 && ./install

  8. sudo gedit ~/.bashrc

add the following lines and change “yourname” accordingly.

  1. #LD_LIBRARY_PATH
  2. OTCL_LIB=/home/yourname/ns-allinone-2.35/otcl-1.14
  3. NS2_LIB=/home/yourname/ns-allinone-2.35/lib
  4. X11_LIB=/usr/X11R6/lib
  5. USR_LOCAL_LIB=/usr/local/lib
  6. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB
  7. #TCL_LIBRARY
  8. TCL_LIB=/home/yourname/ns-allinone-2.35/tcl8.5.10/library
  9. USR_LIB=/usr/lib
  10. export TCL_LIBRARY=$TCL_LIB:$USR_LIB
  11. #PATH
  12. XGRAPH=/home/yourname/ns-allinone-2.35/bin:/home/yourname/ns-allinone-2.35/tcl8.5.10/unix:/home/yourname/ns-allinone-2.35/tk8.5.10/unix
  13. #the above two lines beginning from xgraph and ending with unix should come on the same line
  14. NS=/home/yourname/ns-allinone-2.35/ns-2.35/
  15. NAM=/home/yourname/ns-allinone-2.35/nam-1.15/
  16. PATH=$PATH:$XGRAPH:$NS:$NAM

Then

  1. source ~/.bashrc
  1. patch the PHR protocol by to place phr.patch in the same directory of ns-allinone-2.35
    then

type in terminal:

  1. cd ..
  2. patch -p0 < phr.patch
  1. Now you just need to recompile ns2,
    type in terminal the following commands:
  1. cd ns-allinone-2.35/ns-2.35
  2. ./configure --with-tcl-ver=8.5
  3. export CC=gcc-4.8 CXX=g++-4.8 && make

NOW ns2 with PHR is ready to run .tcl files.

You can find a simple scienaro with PHR in the git, to run it, type in terminal:

  1. ns phr_scenario.tcl

In order to get results out from .tr simulation file, python scripts are provided.

Note: .tr files need to be in new trace format as can be seen in phr_scenario.tcl configurations

  • To get Packet Delivery Ratio (PDR), all you need is to run pdr.py as follows:
    1. python pdr.py ns2_tracefilename.tr
    ns2_tracefilename.tr is trace filename that you’ve got after run simulation
  • To calculate CDF delay, all you need is to pass four different .tr files as parameters to delaypdf.py script to be ploated.

    1. python delaypdf.py aodv.tr olsr.tr gpsr.tr phr.tr

    Note: do not change the .tr files order. if you need to plot two or more CDF delay protocols, please, change the script accordingly.

  • To calculate Probability of Drop Burst Length(DBL), (A new metric proposed by Awos Kh. Ali & Iain Phillips in This paper), you need to run the following two python scripts as follow:

    1. python pre_dbl.py ns2_tracefilename.tr > new_file.txt

    Then the pass the new_file.txt to the second script as follows:

  1. python calc_dbl.py new_file.txt > ready_to_plot.txt

Now ready_to_plot.txt contains probability of DBL for a certain simulation, all you need now is to plot it.

To plot probability of dbl you need to run the following python script and pass 3 dbl files for 3 different protocols as follows:

  1. python plot_dbl.py ready_to_plot_aodv.txt ready_to_plot_olsr.txt ready_to_plot_phr.txt

You can change plot_dbl.py to plot more or less dbl files. Change generated graph title accordingly.