NetAnim Advanced mode

From Nsnam
Jump to: navigation, search

WARNING: This is an experimental feature. Use it only if you have free time.


  1. mercurial
  2. QT4 development packages (recommended version 4.7)
  3. xerces-c++ development packages (minimum version 3.1.1)

Debian/Ubuntu Linux distribution:

  1. apt-get install mercurial
  2. apt-get install qt4-dev-tools
  3. apt-get install libxerces-c-dev

Red Hat/Fedora based distribution:

  1. yum install mercurial
  2. yum install qt4
  3. yum install qt4-devel
  4. yum install xerces-c
  5. yum install xerces-c-devel


  1. mercurial
  2. Qt4 : Install Qt4 (including Qt Creator if possible) from
  3. Xerces-c++: (minimum version 3.1.1)

Advanced-mode feature summary [Experimental]

Advanced-mode Animation

Press the "Offline" button to move to "Online" mode. Hit play as usual. In this mode, the animation happens as the simulation proceeds. This usually gives a better animation. This provides some useful features such as pause and resume for your simulation


Advanced-mode Logging

Here you can log components separately. More than one component can be added using the "+" and "-" button


Advanced-mode L3/Routing stats

This tab records commonly used stats such as "Routing-table", Tx,Rx,Drop Counters, list of IP addresses of a node. It also has the logtofile button, which can be used to log the stats to the disk under the "logs" folder We have the option of polling the stats per Simulation Time or Real time. ( Make sure you click the "Stopped" button to begin polling for stats )

As shown below before simulation begins, NetAnim will provide a scrollable list of buttons for each node Id. Toggling each of these buttons monitors the l3 stats for a node selectively.


This tab also provides elementary packet filtering at layer 3 as shown by the video

Advanced-mode Application stats

This tab tracks stats such as the number of applications on a node,Rx,Tx counters available on an application


Advanced-mode NetDevice/Queue stats

This tab tracks stats such as the list of NetDevices on a node, Mac Address to IP address mappings, Tx,Rx,Drop counters. This tab also tracks Drop-tail queue statistics, and provides a simple-way to enable Pcaps at a NetDevice level


Building NetAnim (Advanced-mode) Experimental

Please note: This feature is experimental and is undergoing a lot of revisions.

To enable NetAnim's advanced-mode features, the ns-3 libraries need to be integrated with NetAnim. See this youtube-video for a glance at the new features

Summary of steps

  • build ns-3 and install it
  • ensure that PKG_CONFIG_PATH and LD_LIBRARY_PATH are properly set
  • Edit to enable ns-3 features
  • Add your test to ns3test.cpp
  • Rebuild NetAnim

Detailed steps follow

Build ns-3 and install it

Use the following steps to build ns-3 modular libraries for Linux

hg clone
cd ns-3-dev
./waf -d debug configure
sudo ./waf install

This usually installs the ".pc" for ns-3 at "/usr/local/lib/pkgconfig" This also installs the "libns3-*.so" or "libns3-*.dylib" libraries at "/usr/local/lib"

For instance here is the "ls" output I get:

ns-3-dev john$ ls /usr/local/lib/pkgconfig/libns3*
/usr/local/lib/pkgconfig/libns3-aodv.pc				/usr/local/lib/pkgconfig/libns3-mesh.pc				/usr/local/lib/pkgconfig/libns3-spectrum.pc
/usr/local/lib/pkgconfig/libns3-applications.pc			/usr/local/lib/pkgconfig/libns3-mobility.pc			/usr/local/lib/pkgconfig/libns3-stats.pc
/usr/local/lib/pkgconfig/libns3-bridge.pc			/usr/local/lib/pkgconfig/libns3-mpi.pc				/usr/local/lib/pkgconfig/libns3-template.pc
/usr/local/lib/pkgconfig/libns3-config-store.pc			/usr/local/lib/pkgconfig/libns3-netanim.pc			/usr/local/lib/pkgconfig/libns3-test.pc
/usr/local/lib/pkgconfig/libns3-core.pc				/usr/local/lib/pkgconfig/libns3-network.pc			/usr/local/lib/pkgconfig/libns3-tools.pc
/usr/local/lib/pkgconfig/libns3-csma-layout.pc			/usr/local/lib/pkgconfig/libns3-nix-vector-routing.pc		/usr/local/lib/pkgconfig/libns3-topology-read.pc
/usr/local/lib/pkgconfig/libns3-csma.pc				/usr/local/lib/pkgconfig/libns3-ns3tcp.pc			/usr/local/lib/pkgconfig/libns3-uan.pc
/usr/local/lib/pkgconfig/libns3-dsdv.pc				/usr/local/lib/pkgconfig/libns3-ns3wifi.pc			/usr/local/lib/pkgconfig/libns3-virtual-net-device.pc
/usr/local/lib/pkgconfig/libns3-energy.pc			/usr/local/lib/pkgconfig/libns3-olsr.pc				/usr/local/lib/pkgconfig/libns3-visualizer.pc
/usr/local/lib/pkgconfig/libns3-flow-monitor.pc			/usr/local/lib/pkgconfig/libns3-point-to-point-layout.pc	/usr/local/lib/pkgconfig/libns3-wifi.pc
/usr/local/lib/pkgconfig/libns3-internet.pc			/usr/local/lib/pkgconfig/libns3-point-to-point.pc		/usr/local/lib/pkgconfig/libns3-wimax.pc
/usr/local/lib/pkgconfig/libns3-lte.pc				/usr/local/lib/pkgconfig/libns3-propagation.pc

[root@localhost ns-3-dev]# ls /usr/local/lib                                                           perl5            pkgconfig               python2.7 


Set the PKG_CONFIG_PATH variable to the location containing the "*.pc" files mentioned above like so

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

On some systems it may be required to set LD_LIBRARY_PATH to the location of the "libns3-*.so" files (libns3-*dylib for Mac OSX) like so

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

Edit to enable Advanced-mode

Download NetAnim2 or NetAnim (version 3) Edit the file "" in NetAnim2 like below

######### NS-3 related
# include(

Uncomment the above line to look something like

######### NS-3 related

Note: only the default modules of ns-3 are included in If you need to include optional modules such as click, openflow, emu etc, please edit suitably

A Test Run

Assuming all of the above steps were done correctly , go to the netanim folder and build NetAnim like so

make clean
qmake   (or qmake-qt4 in some systems)

If the above went well, the NetAnim advanced-mode should be presented like the below image , with "Logging" and "Routing" tabs etc


Adding your own tests

NetAnim comes with a default example in the "ns3test" folder in the file "ns3test.cpp". To run an ns-3 example within NetAnim the following must be considered

Special rules
  1. NetAnim uses the namespace "netanim".
  2. Your program must not include "Simulator::Run" and "Simulator::Destroy" (NetAnim will do that for you)
  3. Your program must not include any "ns3::AnimationInterface" objects (NetAnim will take care of setting up the Animation Interface)
  4. Your program must replace the "main" function with "Simulation::ConfigureSimulation" as shown in the example "ns3test.cpp"
  5. Your program must include the Simulator::Stop(Time_t) function to indicate when the Simulation should stop. Without this, the simulation may run indefinitely.
  6. Optionally: If your example has some statements that come after Simulator::Run, they must be moved to the function "Simulation::PostSimulation" as shown in ns3test.cpp

IMPORTANT: NetAnim has its own definition of "Node" and "Packet" so if you use Node and Packet in your program make sure you have the proper name resolution such as

netanim::Node n
ns3::Node n

Passing command-line arguments to your program , can be done by passing the arguments to NetAnim itself like so

./NetAnim --animFile=a.xml --numNodes=5

Your example code must use the statement

using namespace netanim

as shown in the example in "ns3test.cpp"