NS-3
About
The ns-3 simulator is a discrete-event network simulator targeted primarily for research and educational use. The ns-3 project, started in 2006, is an open-source project developing ns-3 .
A few key points are worth noting at the onset:
ns-3 is open-source, and the project strives to maintain an open environment for researchers to contribute and share their software.
ns-3 is not a backwards-compatible extension of ns-2; it is a new simulator. The two simulators are both written in C++ but ns-3 is a new simulator that does not support the ns-2 APIs
Needed Platform
Linux
Ubuntu
Mint
Debian
CentOs
Linux
Fedora/Redhat
Gentoo
FreeBSD
MacOS
Linux - Ubuntu/Mint/Debian Installation Guide Step by Step
Before Install Ns3 in your PC. Run some commands for basic setup:
$] sudo apt update
$] sudo apt upgrade
ns3 needs so many developmental libraires which needs to be installed on ns3 .
For Most Used Version 3.27/3.29, Run the Complete command package that can help you to install ns3 completely in your PC. 3.27 Version is recommended.
$] sudo apt install build-essential autoconf automake libxmu-dev python-pygoocanvas python-pygraphviz cvs mercurial bzr git cmake p7zip-full python-matplotlib python-tk python-dev python-kiwi python-gnome2 python-gnome2-desktop-dev python-rsvg qt4-dev-tools qt4-qmake qt4-qmake qt4-default gnuplot-x11 wireshark
$] echo $HOME
$]./build.py --enable-examples --enable-tests
ns3 builds so many packages which will be built using the above command...
to run a .cc file here is the command
$] ./waf --run scratch/first (No need to specify the extension)
To run a python file
$] ./waf --pyrun scratch/first.py (we need to specify the extn)
Ubuntu/Debian/Mint Step by Step For Latest version
The following list of packages should be accurate for Ubuntu 19.04 release; other releases or other Debian-based systems may slightly vary. Ubuntu 16.04 LTS release is probably the oldest release that is known to work as of recent ns-3 releases.
Note: As of ns-3.30 release (August 2019), ns-3 uses Python 3 by default, but earlier releases depend on Python 2 packages, and at least a Python 2 interpreter is recommended. If working with an earlier release, one may in general substitute 'python' for 'python3' in the below (e.g. install 'python-dev' instead of 'python3-dev').
minimal requirements for C++ users (release): This is the minimal set of packages needed to run ns-3 from a released tarball.
apt-get install gcc g++ python python3
minimal requirements for Python users (release 3.30 and ns-3-dev): This is the minimal set of packages needed to work with Python bindings from a released tarball.
apt-get install gcc g++ python python3 python3-dev
minimal requirements for Python (development): For use of ns-3-allinone repository (cloned from Git), additional packages are needed to fetch and successfully install pybindgen and netanim.
apt-get install python3-setuptools git mercurial
Netanim animator: qt5 development tools are needed for Netanim animator; qt4 will also work but we have migrated to qt5.
apt-get install qt5-default mercurial
Support for ns-3-pyviz visualizer
For ns-3.28 and earlier releases, PyViz is based on GTK+ 2, GooCanvas, and GraphViz:
apt-get install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev ipython
For Ubuntu 18.04, python-pygoocanvas is no longer provided. The ns-3.29 release and later upgrades the support to GTK+ version 3, and requires these packages:
apt-get install gir1.2-goocanvas-2.0 python-gi python-gi-cairo python-pygraphviz python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython ipython3
Support for MPI-based distributed emulation
apt-get install openmpi-bin openmpi-common openmpi-doc libopenmpi-dev
Support for bake build tool:
apt-get install autoconf cvs bzr unrar
Debugging:
apt-get install gdb valgrind
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 latexmk
If you get an error such as 'convert ... not authorized source-temp/figures/lena-dual-stripe.eps', see this post about editing Imagick's security policy configuration: https://alexvanderbist.com/posts/2018/fixing-imagick-error-unauthorized
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 python3-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".
GNU Scientific Library (GSL) support for more accurate 802.11b WiFi error models (not needed for OFDM):
apt-get install gsl-bin libgsl-dev libgsl23 libgslcblas0
If the above doesn't work (doesn't detect GSL on the system), consult: https://coral.ise.lehigh.edu/jild13/2016/07/11/hello/. But don't worry if you are not using 802.11b models.
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
Support for generating modified python bindings
apt-get install cmake libc6-dev libc6-dev-i386 libclang-6.0-dev llvm-6.0-dev automake pip
python3 -m pip install --user cxxfilt
and you will want to install castxml and pygccxml as per the instructions for python bindings (or through the bake build tool as described in the tutorial). The 'castxml' package provided by Ubuntu 18.04 and earlier is not recommended; a source build (coordinated via bake) is recommended.
Note: Ubuntu versions (through 19.04) and systems based on it (e.g. Linux Mint 18) default to an old version of clang and llvm (3.8), when simply 'libclang-dev' and 'llvm-dev' are specified. The packaging on these 3.8 versions is broken. Users of Ubuntu will want to explicitly install a newer version by specifying 'libclang-6.0-dev' and 'llvm-6.0-dev'. Other versions newer than 6.0 may work (not tested).
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 uml-utilities
Support for openflow module (requires some boost libraries)
apt-get install libboost-signals-dev libboost-filesystem-dev
For more Details : https://www.nsnam.org/wiki/Installation
NetAnim Installation
Debian/Ubuntu Linux distribution:
apt-get install mercurial
apt-get install qt5-default
Red Hat/Fedora based distribution:
yum install mercurial
yum install qt5
yum install qt5-devel
Shortcut Way to Install in Any Version
desktop/ns-allinone-3.27/netanim-3.108$ sudo apt install qt4-default qt4-qmake
desktop/ns-allinone-3.27/netanim-3.108$ qmake NetAnim.pro
desktop/ns-allinone-3.27/netanim-3.108$ make
Flow Monitor Plot
Use of Flow Monitor With Manet Routing Example
GnuPlot
set terminal pngcairo size 600,400
set output "Average SINR(dB).png"
set title "SINR V/s Time"
set xrange [0:25]
set xlabel "Time(s)"
set ylabel "Average SINR (dB)"
plot "RxPacketTrace.txt" using 2:13 with lines title "SINR Output"
To Create PNG file with 600*400 size
For a data with text file in which you want to use column number with another column number
set terminal pdf
set output "Average SINR(dB).pdf"
set title "SINR V/s Time"
set xrange [0:25]
set xlabel "Time(s)"
set ylabel "Average SINR (dB)"
plot "RxPacketTrace.txt" using 2:13 with lines title "SINR Output"
For a data with text file in which you want to use column number with another column number