1 from __future__
import print_function
2 from gi.repository
import Gtk
3 from gi.repository
import Gdk
32 @param self this object
33 @param visualizer visualizer object
34 @param node_index the node index
36 InformationWindow.__init__(self)
37 self.
winwin = 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.
winwin.set_default_size(Gdk.Screen.width()/2, Gdk.Screen.height()/2)
42 self.
winwin.set_title(
"OLSR routing table for node %i" % node_index)
46 self.
table_modeltable_model = Gtk.ListStore(str, str, str, int)
48 treeview = Gtk.TreeView(self.
table_modeltable_model)
50 sw = Gtk.ScrolledWindow()
51 sw.set_properties(hscrollbar_policy=Gtk.PolicyType.AUTOMATIC,
52 vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
55 self.
winwin.vbox.add(sw)
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)
77 self.
visualizervisualizer.add_information_window(self)
83 @param self this object
85 @param response the response
89 self.
visualizervisualizer.remove_information_window(self)
94 @param self this object
97 node = ns.network.NodeList.GetNode(self.
node_indexnode_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)
ShowOlsrRoutingTable class.
def __init__(self, visualizer, node_index)
Initializer.
def update(self)
Update function.
def _response_cb(self, win, response)
Initializer.
def populate_node_menu(viz, node, menu)