How to install ns3 Linux Ubuntu 16.04

Posted by

In this tutorial , You can get simple steps to install ns3 on linux ubuntu 16.04. This ns3 is written using the C++ & Python programming language. The ns3 library is wrapped by Python. C++ headers to gccxml and pygccxml  which automatically generate the corresponding C++ binding files which are finally compiled into the ns3 Python module. It allows users to interact with the C++.

Let’s started, First we need to Install prerequisite packages and libraries which need to run ns3 on linux ubuntu. Press Ctrl + Alt + T to open terminal. login as Sudo su. Just copy following commands one by one on your terminal.

Install required compilers & additional packages

apt-get install gcc g++ python
apt-get install gcc g++ python python-dev
apt-get install mercurial python-setuptools git

qt4 development tools are needed for Netanim animator

apt-get install qt4-dev-tools libqt4-dev

Compilation packages

apt-get install cmake libc6-dev libc6-dev-i386 g++-multilib

Debugging tools, valgrind for memory debugging

apt-get install gdb valgrind

GNU Scientific Library (GSL) support for more accurate WiFi error models

apt-get install gsl-bin libgsl2 libgsl-dev

for flex lexical analyzer and bison parser generator

apt-get install flex bison libfl-dev

To read pcap packet traces

apt-get install tcpdump

Database support for statistics framework

apt-get install sqlite sqlite3 libsqlite3-dev

for Xml library support

apt-get install libxml2 libxml2-dev

for creating graphical user interface

sudo apt-get install libgtk2.0-0 libgtk2.0-dev

for virtual machines and ns-3

apt-get install vtun lxc

for source code modification

apt-get install uncrustify

for editing image and texlive for documentation

apt-get install doxygen graphviz imagemagick
apt-get install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils texlive-lang-portuguese dvipng
sudo apt-get install python-sphinx dia

for pyviz visualizer

apt-get install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev ipython

for openflow module

apt-get install libboost-signals-dev libboost-filesystem-dev

for MPI-based distributed emulation

apt-get install openmpi-bin openmpi-common openmpi-doc libopenmpi-dev

Create a directory NS3 under opt directory for downloading ns3 files.

cd /opt
mkdir NS3
cd NS3
hg clone

As the hg (Mercurial) command executes, you should see something like the following displayed

 destination directory: ns-3-allinone
 requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 26 changesets with 40 changes to 7 files
 7 files updated, 0 files merged, 0 files removed, 0 files unresolved

After the clone command completes, you can find directory ns-3-allinone under your /opt/NS3 directory. run the python file to download and build the ns-3 distribution

 cd ns-3-allinone
 ./ -n ns-3-dev

After download process completes, you can find several new directories under /opt/NS3/ns-3-allinone as below.*     constants.pyc*  nsc/        README      util.pyc*       ns-3-dev/     pybindgen/

Now compile and build the package. run build python file


Configuration with Waf

cd ns-3-dev
CXXFLAGS="-O3" ./waf configure
./waf -d optimized configure; ./waf
./waf --enable-examples configure
./waf --enable-tests configure

Now verify installation


u will get output as below

PASS: TestSuite histogram
PASS: TestSuite ns3-wifi-interference
PASS: TestSuite ns3-tcp-cwnd
PASS: TestSuite ns3-tcp-interoperability
PASS: TestSuite sample

It means your installation is successful !

In my next post, I will show how to run first program in ns-3.

Thanks !

You can ask any query by mail  at [email protected]

It's only fair to share...Share on FacebookShare on Google+Tweet about this on Twitter