Archive

Posts Tagged ‘Configure Waf’

Installing NS-3 in Ubuntu 12.04

September 11, 2012 47 comments

I like to write things down for myself. I am not working with NS-3 these days but if you have more questions, please  refer to the detailed installation guide from the NS website.

If you are reading this post, then I presume you already know what NS-3 is. I have followed the following steps to install and configure NS3 in Ubuntu 12.04.

Open a terminal and run the following commands to install the list of required packages (you may not need all the packages):

sudo apt-get install gcc g++ python              
sudo apt-get install gcc g++ python python-dev
sudo apt-get install mercurial
sudo apt-get install bzr
sudo apt-get install gdb valgrind
sudo apt-get install gsl-bin libgsl0-dev libgsl0ldbl
sudo apt-get install flex bison libfl-dev
sudo apt-get install g++-3.4 gcc-3.4
sudo apt-get install tcpdump
sudo apt-get install sqlite sqlite3 libsqlite3-dev
sudo apt-get install libxml2 libxml2-dev
sudo apt-get install libgtk2.0-0 libgtk2.0-dev
sudo apt-get install vtun lxc
sudo apt-get install uncrustify
sudo apt-get install doxygen graphviz imagemagick sudo apt-get install texlive texlive-extra-utils texlive-latex-extra
sudo apt-get install python-sphinx dia
sudo apt-get install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev
sudo apt-get install libboost-signals-dev libboost-filesystem-dev
sudo apt-get install openmpi*
 

You can either download and build development version or get a tarball directly and untar it.  I would recommend you to choose the second option initially.

Option 1: Using Mercurial

cd
mkdir repos
cd repos
hg clone http://code.nsnam.org/ns-3-allinone

Option 2: Downloading NS-3 using a tarball

cd
mkdir tarballs
cd tarballs wget
http://www.nsnam.org/release/ns-allinone-3.13.tar.bz2
tar xjf ns-allinone-3.13.tar.bz2
 

To build your NS-3, run the following command:

./build.py

Configuration with Waf:

./waf distclean
./waf configure    // (or use this > ./waf configure –enable-examples –enable-tests)
./waf build

Now, test your installation using:

./test.py   // or use this ( if you want to test core modules only) > ./test.py -c core
 

Get ready to run your  program. You need waf (a python based framework designed for configuring, compiling and installing applications). Use the following command to run your program:

./waf – -run filename

Your program must be in /scratch directory, because when you run waf they are build at the same time. For example, I am copying a myfirst.cc from a example directory to scratch directory to run the program. Go to your ns directory and run the command to copy, configure and run:

 
cp examples/tutorial/first.cc scratch/myfirst.cc
./waf
./waf –run scratch/myfirst

If you do everything correctly, you should be able to see the following in your command line.

Waf: Entering directory ‘/home/user/repos/ns-3-allinone/ns-3-dev/build’
Waf: Leaving directory ‘/home/userrepos/ns-3-allinone/ns-3-dev/build’
’build’ finished successfully (1.175s)
Sent 1024 bytes to 10.1.1.2
Received 1024 bytes from 10.1.1.1
Received 1024 bytes from 10.1.1.2

If you have something to visualize run the command : ./waf –run scratch/your_program –visualize, and to plot your output use: ./waf –run scratch/your_program | gnuplot

Cheers 🙂

 
 
 
Advertisements