Go to NetAnim Advanced mode

From Nsnam
Revision as of 11:05, 26 October 2011 by Jabraham3 (Talk | contribs) (Created page with "== Advanced-mode feature summary == === Advanced-mode Animation === Press the "Offline" button to move to "Online" mode. Hit play as usual. Don't forget to remove "Track" for Wi...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Advanced-mode feature summary

Advanced-mode Animation

Press the "Offline" button to move to "Online" mode. Hit play as usual. Don't forget to remove "Track" for Wired animation. 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 NetAnim.pro 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 http://code.nsnam.org/ns-3-dev
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
libns3-aodv.so          libns3-mobility.so               libns3-template.so
libns3-applications.so  libns3-mpi.so                    libns3-test.so
libns3-bridge.so        libns3-netanim.so                libns3-tools.so
libns3-config-store.so  libns3-network.so                libns3-topology-read.so
libns3-core.so          libns3-nix-vector-routing.so     libns3-uan.so
libns3-csma-layout.so   libns3-ns3tcp.so                 libns3-virtual-net-device.so
libns3-csma.so          libns3-ns3wifi.so                libns3-visualizer.so
libns3-dsdv.so          libns3-olsr.so                   libns3-wifi.so
libns3-emu.so           libns3-point-to-point-layout.so  libns3-wimax.so
libns3-energy.so        libns3-point-to-point.so         perl5
libns3-flow-monitor.so  libns3-propagation.so            pkgconfig
libns3-internet.so      libns3-spectrum.so               python2.7
libns3-lte.so           libns3-stats.so
libns3-mesh.so          libns3-tap-bridge.so


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 NetAnim.pro to enable Advanced-mode

######### NS-3 related
# include(ns3.pro)

Uncomment the above line to look something like

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

Note: only the default modules of ns-3 are included in ns3.pro If you need to include optional modules such as click, openflow, emu etc, please edit ns3.pro 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 NetAnim.pro   (or qmake-qt4 NetAnim.pro 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"