A simple animator is presented here, called NetAnim. Written by George Riley, and based on the multi-platform QT4 GUI toolkit, it is capable of animating simulations with PointToPoint links in ns-3. It depicts frames on the links as they travel from node to node. It uses a custom trace output format for animation, so there is some additional code which has to be included in ns-3 to enable these traces.
The animator requires the QT4 development packages. If you are using a Debian or Ubuntu Linux distribution, you can get the following package: qt4-dev-tools
This should install everything you need to compile and build NetAnim. If you are using an Red Hat based distribution, look for similar qt4 packages (or libqt4*) and install these using yum. Mac users should install the binaries: http://www.qtsoftware.com/downloads/mac-os-cpp
Make sure to download the binary package; look for a link to something without the word "src" or "debug" in the download filename. These will be the library binaries you need.
Also, you will require mercurial. See your distribution's packages or the mercurial website for more info.
The tarball of the source code is available here. Download it, then untar it:
tar -xzvf NetAnim.tar.gz
NetAnim uses a QT4 build tool called qmake; this is similar to the configure script from autotools in that it generates the Makefile, which make then uses to build the project. qmake is different on different versions of Qt, so we'll provide some additional information that is system dependent. You can check your default version of qmake:
qmake --version Qmake version: 1.07a (Qt 3.3.8b) Qmake is free software from Trolltech ASA.
If you see something like the above, where it says Qt 3.x.x, find the qt4 version of qmake on your system and explicitly call it instead.
cd NetAnim qmake make
On Mac OS X
cd NetAnim /usr/local/Trolltech/Qt-4.x.y/bin/qmake make
Note that above, the x.y is the specific version of Qt4 you are running. As of April 1st 2009, the latest version is 4.5.0, although you might have an older version already installed.
On Ubuntu/Debian with Qt3 AND Qt4
cd NetAnim qmake-qt4 make
Adding the Animation Interface for ns-3
This is a layer which allows ns-3 instances to talk to NetAnim. This is presently implemented by an "AnimationInterface" class in ns-3. The ns-3 animation interface can be installed in two ways. First, a new repository can be downloaded, extracted, and built. This is easier if you are unfamiliar with mercurial or applying patches. Second, a patch can be used against an existing mercurial repository.
Using a new repository
The netanim repository can be downloaded here. To use this repository, download and extract it:
tar -xzvf ns-3-netanim.tar.gz
Then enter the ns-3-netanim directory, and build:
./waf -d debug configure
Using a patch
This patch was created against the ns-3-dev repository, specifically changeset 4e068296f09f [Aug. 17, 2009]. Care should be taken to ensure that a relavent version of ns-3 is used for updating. If you are unsure, using a new repository [above] is recommended. You can download the patch here. Copy this patch into the ns-3 root directory which you will update, and execute:
hg patch ns-3-netanim.patch
Running an Example File
An example of how to use the animation functionality can be found here. You can drop this file into your scratch directory of ns-3-netanim to compile it and try it out:
./waf --run "scratch/testdb --nLeftLeaf=10 --nRightLeaf=3 --animFile=out.tr"
Then take the output file we generated, and feed it into NetAnim. Copy the out.tr file from ns-3-netanim directory to the NetAnim directory. From the NetAnim directory:
This should produce an animation of the packets in the simulation. The sliders control the behavior of the speed of animation.