Installation of NS3
NS3 installation steps:
1) sudo apt-get update
2) sudo apt-get upgrade
3) sudo apt-get install gcc g++ python python-dev qt4-dev-tools libgtk-3-dev python-pygoocanvas python-pygraphviz wireshark gnuplot openjdk-7-jdk
4) sudo apt-get -y install vtun lxc bridge-utils uml-utilities
5) sudo apt-get -y install doxygen graphviz imagemagick texlive texlive-extra-utils texlive-latex-extra python-sphinx dia
6) sudo apt-get -y install wireshark
7) sudo apt-get -y install gnuplot plotdrop
8) cd
wget http://www.nsnam.org/release/ns-allinone-3.26.tar.bz2
tar xvjf ns-allinone-3.26.tar.bz2
cd ns-allinone-3.26
ls
/* you should now see the following files
bake constants.py netanim-3.106 pybindgen-0.17.0.886 util.py
build.py constants.pyc ns-3.23 README util.py */
9) ./build.py --enable-examples --enable-tests
10) cd
mkdir ns3
cd ns3
hg clone http://code.nsnam.org/bake
cd bake
11) sudo apt-get -y install unrar-free autoconf cvs git unzip p7zip-full
12) export BAKE_HOME=`pwd`
export PATH=$PATH:$BAKE_HOME:$BAKE_HOME/build/bin
export PYTHONPATH=$PYTHONPATH:$BAKE_HOME:$BAKE_HOME/build/lib
./bake.py check
13) ./bake.py configure -e ns-3-dev
14) ./bake.py download -vvv
15) ./bake.py build -vvv
16) cd ns-allinone-3.26/ns-3.26
./waf --run scratch/scratch-simulator
17) cd source/ns-3-dev
./waf --run scratch/scratch-simulator
18) cp examples/tutorial/third.cc scratch/first.cc
./waf --run scratch/first
Structure of C++ program in NS3
- Include header files
- Add namespace
- Enable logging for different modules
- Create nodes
- Create network devices with MAC and PHY
- Attach network devices to node and set the interconnection
- Install protocol stack in node
- Set network address for interface
- Install application in nodes
- Run the Simulation
- Release resources at the end of the simulation
Log Level Information
- Type the following command just before creating nodes in first.cc NS_LOG_INFO(“CREATING TOPOLOGY”);
- Type on the terminal
export NS_LOG=FirstScriptExample=info - Now if you run first.cc it displays CREATING TOPOLOGY along with the output.
- export NS_LOG=UdpEchoClientApplication=level-all
- Run first.cc file
- Displays the log level information of UdpEchoClientApplication.
- export NS_LOG=*=level-all
- Run first.cc file
- Displays the log level information of all the application
- export NS_LOG=
- Clears the log level information. confirm the output by executing first.cc