[Ns-developers] Visualization library
Gustavo Carneiro
gjcarneiro at gmail.com
Sat Mar 1 13:12:17 PST 2008
On 01/03/2008, Tom Henderson <tomh at tomh.org> wrote:
>
> 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).
It might not work outside Linux.
It does require a fairly recent Linux distribution.
But, I am afraid I am not willing not make it work with ancient linux
distribution, because that would mean I would have to only use standard
libraries and would have to reinvent the wheel. I have no time for
reinventing wheels, sorry! :P
In defence of the viz. library I can only say that it uses waf configuration
code to detect the needed libraries in the system. If not found, the same
library is still built, but with downgraded functionality (doesn't show a
window, just runs the simulator).
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.
I don't know what the Toilers group is, and I am announcing this ns-3-viz
branch of mine precisely to avoid duplication of efforts. NS-3 being an
Open Source project, I am of the opinion that even experimental code should
be shared and announced. Had I known of any other good and working
visualization code, I would try to use it if possible.
Regarding Mathieu's comment about official vs contrib., I honestly don't
grasp the difference very well. As far as I know, even "official" code can
change completely or disappear, as NS-3 is not yet API frozen, right?
Having said that, I think it would be perfectly fine to move the code to
src/contrib. In fact the code is mostly a quick hack to get some nodes
moving graphically. Until a better thing is written, I think it helps a
lot.
Best regards,
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
More information about the Ns-developers
mailing list