How to Install ns-3 Network Simulation tool

Hello researchers, I have drafted a document for you how to install ns-3 simulation tool. ns-3 is next version of ns-2 and this document is helpful for those who are currently looking for prerequisites and installation step by step. Installation Guide for ns3.

Installation Guide for ns-3 simulation tool.

 

In this Document we have provided the installation steps for ns-3.

It includes three main steps.

 

  1. Pre-Requisites:
  2. Manual Downloading:
  3. Configuration with Waf:
  • Pre-Requisites:

DUuntu/Debian

The following list of packages should be accurate for Ubuntu 14.10 release; other releases or other Debian-based systems may slightly vary.

  • Minimal requirements for C++ (release):This is the minimal set of packages needed to run ns-3 from a released tarball.

 apt-get install gcc g++ python

  • minimal requirements for Python (release):This is the minimal set of packages needed to work with Python bindings from a released tarball.

 apt-get install gcc g++ python python-dev

  • qt4 development tools (Note:qt4, not qt5) needed for NetAnim animator

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

  • Mercurial is needed to work with ns-3 development repositories.

 apt-get install mercurial

  • Running python bindings from the ns-3 development tree (ns-3-dev) requires bazaar

 apt-get install bzr

  • Support for generating modified python bindings

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

and you will want to install gccxml and pygccxml as per the instructions for python bindings (or through the bake build tool as described in the tutorial).

  • Debugging:

 apt-get install gdb valgrind

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

 apt-get install gsl-bin libgsl0-dev libgsl0ldbl

  • The Network Simulation Cradle (nsc) requires the 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

  • Xml-based version of the config store (requires libxml2 >= version 2.7)

apt-get install libxml2 libxml2-dev

  • A GTK-based configuration system

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

  • To experiment with virtual machines and ns-3

 apt-get install vtun lxc

  • Support for utils/check-style.py code style check program

apt-get install uncrustify

  • Doxygen and related inline documentation:

 apt-get install doxygen graphviz imagemagick

apt-get install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils texlive-lang-portuguese dvipng

  • The ns-3 manual and tutorial are written in reStructuredText for Sphinx (doc/tutorial, doc/manual, doc/models), and figures typically in dia (also needs the texlive packages above):

 apt-get install python-sphinx dia

Note: Sphinx version >= 1.12 required for ns-3.15. To check your version, type “sphinx-build”. To fetch this package alone, outside of the Ubuntu package system, try “sudo easy_install -U Sphinx”.

  • Support for Gustavo Carneiro’s ns-3-pyviz visualizer

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

  • Support for openflow module (requires some boost libraries)

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

  • Support for MPI-based distributed emulation

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

 

 

 

 

 

 

Manual Downloading:

Create any working directory in any location for example respos.

 

 mkdir repos

cd repos

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

 

Go to the ns-3-allin one directory and you will find below files.

 

build.py  constants.py  dist.py  download.py*  README  util.py

 

To download the most common options type the following into your shell (remember you can substitute the name of your chosen release number instead of ns-3-dev)

 

Run this command to download ns-3:

./download.py -n ns-3-dev

 

At the end it will show you this output.

After download process completes, you should have several new directories under ~/repos/ns-3-allinone:

build.py     constants.pyc  download.py  nsc/        README      util.pyc

constants.py  dist.py*       ns-3-dev/     pybindgen/  util.py

Go ahead and change into ns-3-dev under your ~/repos/ns-3-allinone directory. You should see something like the following there:

 

AUTHORS       examples/  RELEASE_NOTES  utils/   wscript

bindings/     LICENSE    samples/       VERSION  wutils.py

CHANGES.html  ns3/       scratch/       waf*

doc/          README     src/           waf.bat*

You are now ready to build the ns-3 distribution

 

Configuration with Waf:

 

Run the following commands in sequence to complete configuration of ns-3 successfully.

Go to the ns-3-dev directory and run commands one by one, mostly commands will take several minutes.

CXXFLAGS=”-O3″ ./waf configure

or, alternately, the gcc compiler

CXX=g++-3.4 ./waf configure

Note: Unlike some other build tools, to change the build target, the option must be supplied during the configure stage rather than the build stage (i.e., “./waf -d optimized” will not work; instead, do

./waf -d optimized configure; ./waf./waf –shell

In order to forcibly disable python bindings, you can provide the following option:

./waf –disable-python configure

In order to tell the build system to use the sudo program to set the suid bit if required, you can provide the following option:

./waf –enable-sudo configure

To start over a configuration from scratch, type:

./waf distclean

Or if you get stuck and all else fails:

rm -rf build

Followed by changing back directory into ns-3-allinone and doing:

./build.py

It will basically reset your build state.

Run this command.

./waf configure –enable-sudo –enable-examples –enable-tests

 

Now again switch to ns-3-dev directory, to see all waf options:

./waf –help

Validating

ns-3 has unit tests that can be run to verify the installation:

./test.py

which should produce output like:

PASS: TestSuite histogramPASS: TestSuite ns3-wifi-interferencePASS: TestSuite ns3-tcp-cwndPASS: TestSuite ns3-tcp-interoperabilityPASS: TestSuite sample…

Reference: https://www.nsnam.org/wiki/Installation

 

 

 

Running a Script

We typically run scripts under the control of Waf. This allows the build system to ensure that the shared library paths are set correctly and that the libraries are available at run time. To run a program, simply use the –run option in Waf. Let’s run the ns-3 equivalent of the ubiquitous hello world program by typing the following:

$ ./waf –run hello-simulator

Waf first checks to make sure that the program is built correctly and executes a build if required. Waf then executes the program, which produces the following output.

Hello Simulator

Congratulations! You are now an ns-3 user!

 

Example below:

Now find your script in example directory and copy it in Scratch folder and then run this command with below syntax.

I have one Test script in scratch folder and I’m running it under the ns3-dev directory.

./waf –run filename

 

All LTE related examples are placed in /ns-3-allinone/ns-3-dev/build/src/lte/examples$

 

 

 

 

 

 

 

 

 

Leave a Reply.

This site uses Akismet to reduce spam. Learn how your comment data is processed.