Network Simulator-3 (NS-3) Practical Lab Manual
ISBN 9788119221820

Highlights

Notes

  

Practical 4:: Configure NetAnim Simulator

Prerequests: NS3 Installation on Ubuntu 1804

Related folders and files in this document

Configure NetAnim

# Go to NS3 All-in-one folder and go further into NetAnim folder

cd ns-allinone-3.30.1/netanim-3.108/

#

sudo apt-get install make -y

# clean the source code, qmake and then make

make clean

qmake NetAnim.pro make

Now, NetAnim is ready to use.

Run Tutorial Examples

Pay attention to the name of the file

# go to ns3-30.1 examples

cd .. # now we are at ns-allinone-3.30.1/

cd ns-3.30.1/examples/tutorial

# instead of ruining the example, we copy it to scratch/ Note that, you cannot change the folder unless you have configured the path

# Also, you should not reuse the name "first", because NS3 will find out first.cc or first.py instead of your file.

# here we use tutorial1.cc

cp first.cc ../../scratch/tutorial1.cc cd ../../scratch/

# use your favourite code editor to edit the first.cc file.# I use vscode.

Add Code for NetAnim

    1 Add the header file

#include “ns3/netanim-module.h”

    2 Add the following statement before Simulation::Run()

AnimationInterface anim (“animation.xml”);

    3 Set give positions to your nodes.

anim.SetConstantPosition (node, double x, double y);

2.2.3.6. Build and Run

# go back to ns-3.30.1

cd ../

# use waf to compile and run the code

./waf --run tutorial1

You should see

Use NetAnim to Show The Animation

# go to netanim-3.108

cd ../netanim-3.108/

# run NetAnim

./NetAnim