[Ns-developers] Visualization library

Tom Henderson tomh at tomh.org
Sat Mar 1 09:09:16 PST 2008


Gustavo Carneiro wrote:
> Some of you may remember the "mobility visualizer" program I submitted a
> long time ago.  That was a standalone program used to view an animation of
> nodes moving according to one of the ns-3 builtin mobility models.
> 
> Lately I have felt the need to apply the same visualization method to normal
> simulation scripts, for debugging purposes.  I had an idea: to adapt the
> same code into "library" format, so that you can visualize any simulation
> program you want.  The prototype for this is available at:
> http://code.nsnam.org/gjc/ns-3-viz/
> 
> Usage is pretty simple, and I demonstrate it with a wifi sample:
> 
> --- a/samples/main-ap-wifi.cc	Tue Feb 26 01:39:59 2008 +0100
> +++ b/samples/main-ap-wifi.cc	Thu Feb 28 16:16:07 2008 +0000
> @@ -33,6 +33,7 @@
>  #include "ns3/packet.h"
>  #include "ns3/node-list.h"
> 
> +#include "ns3/visualizer.h"
> 
>  #include <iostream>
> 
> @@ -182,7 +183,7 @@ int main (int argc, char *argv[])
>    //NodeList::Connect ("/nodes/*/devices/*/*", MakeCallback
> (&WifiNetDeviceTrace));
>    //NodeList::Connect ("/nodes/*/devices/*/phy/state", MakeCallback
> (&WifiPhyStateTrace));
> 
> -  Simulator::Run ();
> +  VisualizerRun ();
> 
>    Simulator::Destroy ();
> 
> --- a/samples/wscript	Tue Feb 26 01:39:59 2008 +0100
> +++ b/samples/wscript	Thu Feb 28 16:16:07 2008 +0000
> @@ -45,6 +45,7 @@ def build(bld):
>      obj = bld.create_ns3_program('main-ap-wifi',
>                                   ['core', 'simulator', 'mobility', 'wifi'])
>      obj.source = 'main-ap-wifi.cc'
> +    obj.uselib_local += ' visualizer'
> 
>      obj = bld.create_ns3_program('main-random-walk',
>                                   ['core', 'simulator', 'mobility'])
> 
> 
> 
> As you can see, the program just needs to link with an additional
> 'visualizer' library, and replace the call to Simulator::Run () with
> VisualizerRun ().  It is safe to always do so, as VisualizerRun () simply
> calls Simulator::Run () if the system does not have the necessary GUI
> libraries (gtk+ and goocanvas).
> 
> The "visualizer" is pretty simple now, but in the future it would be
> interesting to additonal graphical representations, such as point-to-point
> links, or wifi range.
> 
> Personally I see this more of a debugging/demo tool.  It does not, and never
> will¹, help anyone write simulation scripts graphically.
> 
> Any comments?  Is there any interest in integrating this functionality (or
> similar) in the main tree?

Gustavo, what are all of the third party dependencies?  I recall trying 
to unsuccessfully get the previous one to work on a Fedora Core 5 system 
(seems like something like FC7 or 8 is needed, and I don't know whether 
it works outside of Linux).

The Toilers group has also been working on an ns-3 visualizer and I 
think it would be nice if we could look at that work and discuss which 
direction we want to go for integrating visualization into the main tree.

- Tom



More information about the Ns-developers mailing list