Skip to main content

Installing NS-3 in Ubuntu

Installing testing it and running NS-3 in Ubuntu 10.04

NS-3 is a discrete-event network simulator basically for simulating Internet systems.
#The list of Dependency for ns 3.12(sorry if something is missing):

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
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 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-pdf texlive-latex-extra texlive-generic-extra texlive-generic-recommended
sudo apt-get install python-sphinx dia texlive texlive-pdf texlive-latex-extra texlive-extra-utils texlive-generic-recommended
sudo apt-get install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev
sudo apt-get install libboost-signals-dev libboost-filesystem-dev

#Download and build development version:

hg clone http://code.nsnam.org/ns-3-allinone
cd ns-3-allinone
./download.py

instead of using the above method, you can directly get the ns-3 tarball and untar it and follow the following:

./build.py
cd ns-3-dev
./waf distclean
./waf configure OR ./waf configure --enable-examples --enable-tests
./waf build

Now test the installation of NS-3 (we expect all the tests to run successfully):

./test.py OR ./test.py -c core (test core modules only)

other useful options:

./waf -d optimized configure
./waf --help shows you other options

# To run the first program on NS-3, waf is required. Waf is a Python-based
framework for configuring, compiling and installing applications. It is already
included in the ubuntu repository. The syntax to run any NS-3 script is:

./waf - -run filename

Now, we can run a very basic program on NS-3 without using any extra files and extra codes:

./waf - -run hello-simulator

# Writing your own NS-3 programs:
The scratch/ directory is supposed to contain the user written programs and they are automatically build while running the waf.
For example, let us copy wifi-adhoc.cc from the example/ directory to the scratch/ directory.

cp ns-3.12.1/examples/wireless/wifi-adhoc.cc ns-3.12.1/scratch/wifi-adhoc.cc
./waf
./waf --run scratch/wifi-adhoc

To visualize the program :

./waf --run scratch/wifi-adhoc --visualize

To plot the output :

./waf --run scratch/wifi-adhoc | gnuplot

Comments

Khan said…
Thank you very much..it was very helpful.
Unknown said…
hey, please. Help

program 'hello-simulator.cc' not found; available programs are: []
Unknown said…
Hi, please. Help me with:

./waf --run hello-simulator.cc
Waf: Entering directory `/home/repos/ns-3-allinone/ns-3-dev/build'
program 'hello-simulator.cc' not found; available programs are: []
Sєтнυ said…
This comment has been removed by the author.
Sєтнυ said…
When I try to run ./build.py I was getting this error "Build failed
-> task failed (exit status 1): "
Do you know how to solve this problem
?
ace-cse2011 said…
Installing testing it and running NS-3 in Ubuntu 14.10.1
guys please help me my guide is killing me to use latest os.