1 from gi.repository
import Gdk, Gtk
4 from ns3.visualizer.base
import InformationWindow
5 except ModuleNotFoundError:
39 @param self this object
40 @param visualizer visualizer object
41 @param node_index the node index
43 InformationWindow.__init__(self)
44 self.
winwin = Gtk.Dialog(
45 parent=visualizer.window,
46 flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
47 buttons=(
"_Close", Gtk.ResponseType.CLOSE),
49 self.
winwin.set_default_size(Gdk.Screen.width() / 2, Gdk.Screen.height() / 2)
51 self.
winwin.set_title(
"OLSR routing table for node %i" % node_index)
55 self.
table_modeltable_model = Gtk.ListStore(str, str, str, int)
57 treeview = Gtk.TreeView(self.
table_modeltable_model)
59 sw = Gtk.ScrolledWindow()
61 hscrollbar_policy=Gtk.PolicyType.AUTOMATIC, vscrollbar_policy=Gtk.PolicyType.AUTOMATIC
65 self.
winwin.vbox.add(sw)
68 column = Gtk.TreeViewColumn(
69 "Destination", Gtk.CellRendererText(), text=self.COLUMN_DESTINATION
71 treeview.append_column(column)
74 column = Gtk.TreeViewColumn(
"Next hop", Gtk.CellRendererText(), text=self.COLUMN_NEXT_HOP)
75 treeview.append_column(column)
78 column = Gtk.TreeViewColumn(
"Interface", Gtk.CellRendererText(), text=self.COLUMN_INTERFACE)
79 treeview.append_column(column)
82 column = Gtk.TreeViewColumn(
"Num. Hops", Gtk.CellRendererText(), text=self.COLUMN_NUM_HOPS)
83 treeview.append_column(column)
85 self.
visualizervisualizer.add_information_window(self)
91 @param self this object
93 @param response the response
97 self.
visualizervisualizer.remove_information_window(self)
102 @param self this object
105 node = ns.NodeList.GetNode(self.
node_indexnode_index)
106 ipv4 = node.GetObject(ns.Ipv4.GetTypeId())
107 if not ns.cppyy.gbl.hasOlsr(ns3_node):
109 olsr = ns.cppyy.gbl.getNodeOlsr(node)
112 for route
in olsr.GetRoutingTableEntries():
114 netdevice = ipv4.GetNetDevice(route.interface)
115 if netdevice
is None:
116 interface_name =
"lo"
118 interface_name = ns.Names.FindName(netdevice)
119 if not interface_name:
120 interface_name =
"(interface %i)" % route.interface
123 self.COLUMN_DESTINATION,
125 self.COLUMN_NEXT_HOP,
127 self.COLUMN_INTERFACE,
129 self.COLUMN_NUM_HOPS,
135 ns3_node = ns.NodeList.GetNode(node.node_index)
136 if not ns.cppyy.gbl.hasOlsr(ns3_node):
140 menu_item = Gtk.MenuItem(
"Show OLSR Routing Table")
143 def _show_ipv4_routing_table(dummy_menu_item):
146 menu_item.connect(
"activate", _show_ipv4_routing_table)
151 viz.connect(
"populate-node-menu", populate_node_menu)
ShowOlsrRoutingTable class.
def __init__(self, visualizer, node_index)
Initializer.
def _response_cb(self, win, response)
Initializer.
def update(self)
Update function.
def populate_node_menu(viz, node, menu)