NetAnim2

From Nsnam
Revision as of 11:41, 21 August 2011 by Jabraham3 (Talk | contribs) (The Animation Interface for ns-3)

Jump to: navigation, search

A simple animator is presented here, called NetAnim , based on the multi-platform QT4 GUI toolkit. NetAnim requires a custom trace file for animation. This trace file is generated by an animation interface and is included in the current version of ns-3.

The NetAnim GUI


Prerequisites

  1. mercurial
  2. QT4 development packages
  3. xerces-c++ development packages

Debian/Ubuntu Linux distribution:

  1. apt-get install mercurial
  2. apt-get install qt4-dev-tools

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

Mac/OSX

  1. Qt4 : Install the binaries (including Qt Creator) from http://qt.nokia.com/downloads/
  2. Xerces-c++: http://xerces.apache.org/xerces-c/download.cgi

Downloading NetAnim

NetAnim 2.0:

hg clone http://code.nsnam.org/jabraham3/netanim

NetAnim 1.0:

click here. Untar it using:tar -xzvf NetAnim.tar.gz

Building NetAnim

NetAnim uses a QT4 build tool called qmake.

In General

cd netAnim
qmake NetAnim.pro
make

DO NOT build NetAnim as a root-user or you might encounter the following error

GLib-GIO:ERROR:gdbusconnection.c:2279:initable_init: assertion failed: (connection->initialization_error == NULL) Aborted (core dumped)

On Mac OS X

The preferred Qt 4 version is Qt 4.7. Using "Qt Creator" to build NetAnim is usually fool-proof

cd NetAnim
/usr/local/Trolltech/Qt-4.x.y/bin/qmake NetAnim.pro
make

Note that above, the x.y is the specific version of Qt4 you are running.

If the above steps do not work , please see the suggestion below from a user

1. Download Qt libraries for Mac from the page
   [http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x]
    for example: [http://get.qt.nokia.com/qt/source/qt-mac-opensource-4.7.2-debug-libs.dmg]
2. Download NetAnim from [http://www.nsnam.org/~jpelkey3/NetAnim.tar.gz]
3. $tar -xzvf NetAnim.tar.gz
4. $cd NetAnim
5. $/usr/bin/qmake-4.7 NetAnim.pro
    This will create xcode project NetAnim.xcodeproj
6. Open NetAnim.xcodeproj with xcode and build.You will get NetAnim executable.

Special note to Mac OS X Lion users as of July 30, 2011: In the latest build of Qt libraries, namely, http://get.qt.nokia.com/qt/source/qt-mac-opensource-4.7.3.dmg, qmake generates Xcode .pbproj file instead of Makefile by default. The Xcode file, however, is incompatible to the Xcode tools (version 4.1) for Lion. To get the Makefile output from qmake, one can try the following after installed qt-mac-opensource-4.7.3.dmg:

 $ cd /usr/local/Qt4.7/mkspecs/
 $ sudo rm default
 $ sudo ln -s macx-g++ default

Then, qmake will use the GCC template instead of Xcode template for building Qt projects. You can then build NetAnim as usual, namely,

 $ tar -zxvf NetAnim.tar.gz
 $ cd NetAnim
 $ qmake
 $ make

On Ubuntu/Debian

cd netAnim
qmake-qt4 NetAnim.pro
make


Feature-set in NetAnim 2.0

  1. Basic
    1. Read offline XML trace file generated by ns-3's [ http://www.nsnam.org/doxygen/classns3_1_1_animation_interface.html AnimationInterface ]
    2. Ability to track Wired & Wireless transmission
    3. Track mobility of nodes
    4. Record button to take periodic snapshots of the Animation
    5. Display Node Id on the Animation canvas, with zoom-in, zoom-out etc
  2. Advanced (Requires integration with ns-3 libraries.Not yet completely implemented)
    1. Plotting the animation while the simulation is running
    2. Logging statistics to select Logging Components individually and display them while the simulation is running
    3. Routing statistics to print Routing Tables and other Ipv4 statistics such as Tx,Rx,Drop counters while the simulation is running
  3. Feature removed
    1. Socket based communication between the Animator and ns-3

Feature-set in NetAnim 1.0

  1. Animate only Wired topology
  2. Read non-XML trace file generated by ns-3

The Animation Interface for ns-3

The NetAnim application requires a custom trace file for animation. This trace file is created by [ http://www.nsnam.org/doxygen/classns3_1_1_animation_interface.html AnimationInterface ] in ns-3.

  1. Model is at: src/netanim/model
  2. Examples are at src/netanim/examples

NetAnim 2.0 supports only reading XML trace files. NetAnim 1.0 can read only Non-XML traces. AnimationInterface as of ns-3.12 generates only non-XML trace files by default. To generate XML trace files, use void ns3::AnimationInterface::SetXMLOutput() prior to StartAnimation. See the examples under "src/netanim/examples"

Running an Example File

Two example scripts exist in ns-3 for NetAnim, dumbbell-animation and grid-animation. They are located under examples/animation. The examples can be executed with the following commmands:

./waf --run 'examples/animation/dumbbell-animation --nLeftLeaf=5 --nRightLeaf=5 --animFile=dumbbell.tr'
./waf --run 'examples/animation/grid-animation --xSize=5 --ySize=5 --animFile=grid.tr'

This command generates the custom trace output for the NetAnim GUI. Take the output file we generated, and feed it into NetAnim. Copy the dumbbell.tr file from ns-3 directory to the NetAnim directory. From the NetAnim directory:

./NetAnim dumbbell.tr

This should produce an animation of the packets in the simulation. The sliders control the behavior of the speed of animation.

Creating Custom Scripts for Animation

If you would like to create custom scripts for animation because you need more than a simple dumbbell or grid topology, please keep in mind that nodes must be assigned locations for your animation to show up. Some example code for assigning node locations exists in point-to-point-grid-helper and point-to-point-dumbbell helper, specifically in the BoundingBox functions.