1 from gi.repository
import Gtk
2 from gi.repository
import Gdk
31 @param self this object 32 @param visualizer visualizer object 33 @param node_index the node index 36 InformationWindow.__init__(self)
37 self.
win = Gtk.Dialog(parent=visualizer.window,
38 flags=Gtk.DialogFlags.DESTROY_WITH_PARENT|Gtk.DialogFlags.NO_SEPARATOR,
39 buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
40 self.
win.set_default_size(Gdk.Screen.width()/2, Gdk.Screen.height()/2)
42 self.
win.set_title(
"OLSR routing table for node %i" % node_index)
50 sw = Gtk.ScrolledWindow()
51 sw.set_properties(hscrollbar_policy=Gtk.PolicyType.AUTOMATIC,
52 vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
58 column = Gtk.TreeViewColumn(
'Destination', Gtk.CellRendererText(),
59 text=self.COLUMN_DESTINATION)
60 treeview.append_column(column)
63 column = Gtk.TreeViewColumn(
'Next hop', Gtk.CellRendererText(),
64 text=self.COLUMN_NEXT_HOP)
65 treeview.append_column(column)
68 column = Gtk.TreeViewColumn(
'Interface', Gtk.CellRendererText(),
69 text=self.COLUMN_INTERFACE)
70 treeview.append_column(column)
73 column = Gtk.TreeViewColumn(
'Num. Hops', Gtk.CellRendererText(),
74 text=self.COLUMN_NUM_HOPS)
75 treeview.append_column(column)
83 @param self this object 85 @param response the response 89 self.
visualizer.remove_information_window(self)
94 @param self this object 97 node = ns.network.NodeList.GetNode(self.
node_index)
98 olsr = node.GetObject(ns.olsr.olsr.RoutingProtocol.GetTypeId())
99 ipv4 = node.GetObject(ns.internet.Ipv4.GetTypeId())
103 for route
in olsr.GetRoutingTableEntries():
105 netdevice = ipv4.GetNetDevice(route.interface)
106 if netdevice
is None:
107 interface_name =
'lo' 109 interface_name = ns.core.Names.FindName(netdevice)
110 if not interface_name:
111 interface_name =
"(interface %i)" % route.interface
113 self.COLUMN_DESTINATION, str(route.destAddr),
114 self.COLUMN_NEXT_HOP, str(route.nextAddr),
115 self.COLUMN_INTERFACE, interface_name,
116 self.COLUMN_NUM_HOPS, route.distance)
120 ns3_node = ns.network.NodeList.GetNode(node.node_index)
121 olsr = ns3_node.GetObject(ns.olsr.olsr.RoutingProtocol.GetTypeId())
126 menu_item = Gtk.MenuItem(
"Show OLSR Routing Table")
129 def _show_ipv4_routing_table(dummy_menu_item):
132 menu_item.connect(
"activate", _show_ipv4_routing_table)
136 viz.connect(
"populate-node-menu", populate_node_menu)
def update(self)
Update function.
def __init__(self, visualizer, node_index)
Initializer.
def _response_cb(self, win, response)
Initializer.
ShowOlsrRoutingTable class.
def populate_node_menu(viz, node, menu)