Professional Documents
Culture Documents
Vanetrbc ns2
Vanetrbc ns2
Vanetrbc ns2
Daniel Jungels
Laboratory for computer Communications and Applications (LCA)
EPFL
December 23, 2005
This document quickly describes how to install ns2, and how to implement a VANET protocol
(using a broadcast example protocol as basis).
1 NS2
First, you have to install the network simulator in your home directory. The simplest way to get
started is to use the ns-allinone package. At the moment of this writing, version 2.29 was the
most recent one. Because of this, all line-numbers later in this document (given to help you find
the mentioned code parts faster) refer to this version. However, there is always an explanation
in what enum, class or function the changes have to be made.
In the explanations, I use /home/myuser as home directory, and the simulator will be installed
in /home/myuser/ns-allinone-2.29. You can find ns-allinone at http://www.isi.edu/nsnam/ns/.
The downloaded archive files ns-allinone-2.29.tar.gz (from the ns website) and vanetrbc-ns229.tgz
(from http://ivc.epfl.ch/) are now supposed to be in /home/myuser. I also suppose that you are
using Linux (for example the LCA project PCs at EPFL, you can also connect via ssh from a
Windows PC to those machines).
So, we start by extracting and installing the ns-allinone package:
cd /home/myuser
tar -xvzf ns-allinone-2.29.tar.gz
cd ns-allinone-2.29
./install
This takes a while (both the extraction of the files and the installation). After the installation
script has finished successfully, you must edit your shell configuration files (this is also explained
at the end of the installation script): I give here the examples for bash and tcsh. For tcsh, add
the following lines to /home/myuser/.cshrc:
set path = ( ${path} /home/myuser/ns-allinone-2.29/bin \
/home/myuser/ns-allinone-2.29/tcl8.4.11/unix \
/home/myuser/ns-allinone-2.29/tk8.4.11/unix )
1
For bash, add the following lines to /home/myuser/.bashrc:
PATH=${PATH}:/home/myuser/ns-allinone-2.29/bin
PATH=${PATH}:/home/myuser/ns-allinone-2.29/tcl8.4.11/unix
PATH=${PATH}:/home/myuser/ns-allinone-2.29/tk8.4.11/unix
export PATH
LD_LIBRARY_PATH=/home/myuser/ns-allinone-2.29/otcl-1.11:${LD_LIBRARY_PATH}
LD_LIBRARY_PATH=/home/myuser/ns-allinone-2.29/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
TCL_LIBRARY=/home/myuser/ns-allinone-2.29/tcl8.4.11/library:${TCL_LIBRARY}
export TCL_LIBRARY
Reload your shell-configuration: for tcsh execute in your terminal
source /home/myuser/.cshrc
or for bash
source /home/myuser/.bashrc
or simply logout and login again. Now ns should be installed and ready to use.
PT_VANETRBC,
• and in the same file in the class p info (line 266), insert
name_[PT_VANETRBC]="VanetRBC";
2
• In ns-allinone-2.29/ns-2.29/tcl/lib/ns-default.tcl, for example at the end of the file, insert
these lines (these are example values used to initialize the parameters, but they can always
be overriden in your TCL-scripts):
vanetrbc/vanetrbc.o vanetrbc/vanetrbc_rxdatadb.o \
The following changes are not strictly necessary, but probably you want to make them to
prevent lots of messages cluttering up your screen (forcing you to search for the messages you
actually want to see):
• In ns-allinone-2.29/ns-2.29/mobile/dumb-agent.cc (line 96), you may comment out the line
For the beginning, this “printf” may be useful because you can see where your simulation
is right now (time), and what distances are used in your scenario (i.e., if your transmission
range is defined correctly). However, after some time they become annoying. So maybe
leave them for now, but you may comment out this “printf” later.
Finally, you can recompile ns, with the new protocol:
cd /home/myuser/ns-allinone-2.29/ns-2.29/
make clean
make
The “make clean” is necessary because you have changed some header-files, but not the .cc files
(therefore, make does not notice that you changed the .h). The example RBC protocol should
be ready to run. You can execute a test script (containing also the necessary parameters for
802.11a) with
cd /home/myuser/ns-allinone-2.29/ns-2.29/vanetrbc
ns vntest.tcl
If at the end of the simulation you get an error message saying that nam could not be executed,
please read Section 4.4.
3
3 Adding your protocol
You can now take the RBC-protocol as a basis for your VANET protocol. There are lots of
comments in the source files, have a look at them! You may also want to rename the entire stuff,
simply check for “RBC” (or “rbc”) and change them to your own protocol name (in the .cc and
.h files in the vanetrbc directory, and in all places that you changed in the previous section).
Please note that if you make a copy of the VanetRBC protocol in a different directory, and want
both to co-exist (your protocol and VanetRBC ), you must rename the structures of the packet
headers in your new protocol, so that no packet headers of the two protocols share the same
name.
While developing (debugging) your protocol, it is not necessary to redo the “make clean” every
time you recompile the code. If you change a header file of your protocol (but not a general file of
the rest of the ns-core), a “touch *.cc” in the directory containing your protocol is sufficient. To
recompile ns with your updated protocol, simply execute “make” in the ns-allinone-2.29/ns-2.29/
directory.
4
a good idea to generate some more relevant scenarios. For your information, this example has
been generated with the Rice Mobility generator, using the West university place data file as
input.