[Ns-developers] Visualization library
Gustavo Carneiro
gjcarneiro at gmail.com
Thu Feb 28 10:04:36 PST 2008
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?
¹ Not that don't think it can't / shouldn't be done, just not on top of
this simple code base.
--
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