From 5e112ceba303a4054ab2a48009e1c827f0d0e90b Mon Sep 17 00:00:00 2001 From: Alexander Afanasyev Date: Sat, 3 Jan 2015 02:22:13 -0800 Subject: [PATCH] bindings: Version update and ndnSIM-related updates - Now requiring a customized version of pybindgen (necessary for ndnSIM bindings) - Fixed ndnSIM FIB/CS/PIT visualizer plugins to work with ndnSIM-v2 codebase --- bindings/python/wscript | 4 ++-- .../visualizer/plugins/ndnsim_cs.py | 14 ++++-------- .../visualizer/plugins/ndnsim_fib.py | 16 ++++++-------- .../visualizer/plugins/ndnsim_pit.py | 22 +++++++++---------- 4 files changed, 23 insertions(+), 33 deletions(-) diff --git a/bindings/python/wscript b/bindings/python/wscript index b57c5d951..f247debb2 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -12,8 +12,8 @@ from waflib.Errors import WafError # feature = TaskGen.feature # after = TaskGen.after -# https://github.com/gjcarneiro/pybindgen -REQUIRED_PYBINDGEN_VERSION = '0.17.0.post41+ngd10fa60' +# https://github.com/named-data-ndnSIM/pybindgen +REQUIRED_PYBINDGEN_VERSION = '0.17.0.post45+ng4806e4f' REQUIRED_PYGCCXML_VERSION = (0, 9, 5) RUN_ME=-3 diff --git a/src/visualizer/visualizer/plugins/ndnsim_cs.py b/src/visualizer/visualizer/plugins/ndnsim_cs.py index da6e42434..12c9fc4c9 100644 --- a/src/visualizer/visualizer/plugins/ndnsim_cs.py +++ b/src/visualizer/visualizer/plugins/ndnsim_cs.py @@ -3,7 +3,7 @@ import gtk import ns.core import ns.network import ns.internet -import ns.ndnSIM +from ns.ndnSIM import ndn from visualizer.base import InformationWindow @@ -53,23 +53,17 @@ class ShowNdnCs(InformationWindow): self.visualizer.remove_information_window(self) def update(self): - ndnCs = ns.ndnSIM.ndn.ContentStore.GetContentStore (self.node) + ndnCs = ndn.L3Protocol.getL3Protocol(self.node).getForwarder().getCs() if ndnCs is None: return self.table_model.clear() - values = [] - item = ndnCs.Begin () - while (item != ndnCs.End ()): - values.append (str(item.GetName ())) - item = ndnCs.Next (item) - - for value in sorted(values): + for item in ndnCs: tree_iter = self.table_model.append() self.table_model.set(tree_iter, - self.COLUMN_PREFIX, value) + self.COLUMN_PREFIX, item.getName()) def populate_node_menu(viz, node, menu): menu_item = gtk.MenuItem("Show NDN CS") diff --git a/src/visualizer/visualizer/plugins/ndnsim_fib.py b/src/visualizer/visualizer/plugins/ndnsim_fib.py index c8ef0916d..b0eb33fb2 100644 --- a/src/visualizer/visualizer/plugins/ndnsim_fib.py +++ b/src/visualizer/visualizer/plugins/ndnsim_fib.py @@ -3,7 +3,7 @@ import gtk import ns.core import ns.network import ns.internet -import ns.ndnSIM +from ns.ndnSIM import ndn from visualizer.base import InformationWindow @@ -61,20 +61,18 @@ class ShowNdnFib(InformationWindow): self.visualizer.remove_information_window(self) def update(self): - ndnFib = ns.ndnSIM.ndn.Fib.GetFib (self.node) - + ndnFib = ndn.L3Protocol.getL3Protocol(self.node).getForwarder().getFib() + if ndnFib is None: return self.table_model.clear() - - item = ndnFib.Begin () - while (item != ndnFib.End ()): + + for item in ndnFib: tree_iter = self.table_model.append() self.table_model.set(tree_iter, - self.COLUMN_PREFIX, str(item.GetPrefix()), - self.COLUMN_FACE, str(item)) - item = ndnFib.Next (item) + self.COLUMN_PREFIX, str(item.getPrefix()), + self.COLUMN_FACE, ", ".join(["%s%d (%d)" % (str(nh.getFace()), nh.getFace().getId(), nh.getCost()) for nh in item.getNextHops()])) def populate_node_menu(viz, node, menu): menu_item = gtk.MenuItem("Show NDN FIB") diff --git a/src/visualizer/visualizer/plugins/ndnsim_pit.py b/src/visualizer/visualizer/plugins/ndnsim_pit.py index 2304ac187..14525c77d 100644 --- a/src/visualizer/visualizer/plugins/ndnsim_pit.py +++ b/src/visualizer/visualizer/plugins/ndnsim_pit.py @@ -3,7 +3,7 @@ import gtk import ns.core import ns.network import ns.internet -import ns.ndnSIM +from ns.ndnSIM import ndn from visualizer.base import InformationWindow @@ -27,7 +27,7 @@ class ShowNdnPit(InformationWindow): if len(node_name) != 0: title += " (" + str(node_name) + ")" - self.win.set_title (title) + self.win.set_title (title) self.visualizer = visualizer self.node_index = node_index @@ -42,7 +42,7 @@ class ShowNdnPit(InformationWindow): sw.add(treeview) self.win.vbox.add(sw) self.win.set_default_size(600, 300) - + # Dest. column = gtk.TreeViewColumn('Prefix', gtk.CellRendererText(), text=self.COLUMN_PREFIX) @@ -59,22 +59,20 @@ class ShowNdnPit(InformationWindow): def _response_cb(self, win, response): self.win.destroy() self.visualizer.remove_information_window(self) - + def update(self): - ndnPit = ns.ndnSIM.ndn.Pit.GetPit (self.node) - + ndnPit = ndn.L3Protocol.getL3Protocol(self.node).getForwarder().getPit() + if ndnPit is None: return self.table_model.clear() - - item = ndnPit.Begin () - while (item != ndnPit.End ()): + + for item in ndnPit: tree_iter = self.table_model.append() self.table_model.set(tree_iter, - self.COLUMN_PREFIX, str(item.GetPrefix()), - self.COLUMN_FACE, str(item)) - item = ndnPit.Next (item) + self.COLUMN_PREFIX, str(item.getName()), + self.COLUMN_FACE, str(item.getInterest())) def populate_node_menu(viz, node, menu): menu_item = gtk.MenuItem("Show NDN PIT")