Monday, December 4, 2017

NS3: What i learned

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

  1. Include header files
  2. Add namespace
  3. Enable logging for different modules
  4. Create nodes
  5. Create network devices with MAC and PHY
  6. Attach network devices to node and set the interconnection
  7. Install protocol stack in node
  8. Set network address for interface
  9. Install application in nodes
  10. Run the Simulation
  11. Release resources at the end of the simulation


Log Level Information

  1. Type the following command just before creating nodes in first.cc     NS_LOG_INFO(“CREATING TOPOLOGY”);
  2. Type on the terminal
          export NS_LOG=FirstScriptExample=info
  3. Now if you run first.cc it displays CREATING TOPOLOGY along with the output.

  4. export NS_LOG=UdpEchoClientApplication=level-all
  5.  Run first.cc file
  6. Displays the log level information of UdpEchoClientApplication.
  7. export NS_LOG=*=level-all
  8. Run first.cc file
  9. Displays the log level information of all the application
  10. export NS_LOG=
  11. Clears the log level information. confirm the output by executing first.cc

No comments:

Post a Comment