1 from gi.repository
import Gtk
30 @param self this object 31 @param visualizer visualizer object 32 @param node_index the node index 33 @return the statistics 35 InformationWindow.__init__(self)
36 self.
win = Gtk.Dialog(parent=visualizer.window,
37 flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
38 buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
40 self.
win.set_title(
"IPv4 routing table for node %i" % node_index)
48 sw = Gtk.ScrolledWindow()
49 sw.set_properties(hscrollbar_policy=Gtk.PolicyType.AUTOMATIC,
50 vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
54 self.
win.set_default_size(600, 300)
57 column = Gtk.TreeViewColumn(
'Destination', Gtk.CellRendererText(),
58 text=self.COLUMN_DESTINATION)
59 treeview.append_column(column)
62 column = Gtk.TreeViewColumn(
'Next hop', Gtk.CellRendererText(),
63 text=self.COLUMN_NEXT_HOP)
64 treeview.append_column(column)
67 column = Gtk.TreeViewColumn(
'Interface', Gtk.CellRendererText(),
68 text=self.COLUMN_INTERFACE)
69 treeview.append_column(column)
72 column = Gtk.TreeViewColumn(
'Type', Gtk.CellRendererText(),
73 text=self.COLUMN_TYPE)
74 treeview.append_column(column)
77 column = Gtk.TreeViewColumn(
'Prio', Gtk.CellRendererText(),
78 text=self.COLUMN_PRIO)
79 treeview.append_column(column)
86 Response callback function 87 @param self this object 89 @param response the response 93 self.
visualizer.remove_information_window(self)
98 @param self this object 101 node = ns.network.NodeList.GetNode(self.
node_index)
102 ipv4 = node.GetObject(ns.internet.Ipv4.GetTypeId())
103 routing = ipv4.GetRoutingProtocol()
107 routing_protocols = []
109 if isinstance(routing, ns.internet.Ipv4StaticRouting):
110 ipv4_routing = routing_protocols.append((routing,
"static", 0))
111 elif isinstance(routing, ns.internet.Ipv4ListRouting):
112 list_routing = routing
113 for rI
in range(list_routing.GetNRoutingProtocols()):
114 routing, prio = list_routing.GetRoutingProtocol(rI)
115 if isinstance(routing, ns.internet.Ipv4StaticRouting):
116 routing_protocols.append((routing,
"static", prio))
117 elif isinstance(routing, ns.internet.Ipv4GlobalRouting):
118 routing_protocols.append((routing,
"global", prio))
119 if not routing_protocols:
123 for route_proto, type_string, prio
in routing_protocols:
124 for routeI
in range(route_proto.GetNRoutes()):
125 route = route_proto.GetRoute(routeI)
127 netdevice = ipv4.GetNetDevice(route.GetInterface())
128 if netdevice
is None:
129 interface_name =
'lo' 131 interface_name = ns.core.Names.FindName(netdevice)
132 if not interface_name:
133 interface_name =
"(interface %i)" % route.GetInterface()
135 self.COLUMN_DESTINATION, str(route.GetDest()),
136 self.COLUMN_NEXT_HOP, str(route.GetGateway()),
137 self.COLUMN_INTERFACE, interface_name,
138 self.COLUMN_TYPE, type_string,
139 self.COLUMN_PRIO, prio)
143 menu_item = Gtk.MenuItem(
"Show IPv4 Routing Table")
146 def _show_ipv4_routing_table(dummy_menu_item):
149 menu_item.connect(
"activate", _show_ipv4_routing_table)
153 viz.connect(
"populate-node-menu", populate_node_menu)
def update(self)
Update function.
def _response_cb(self, win, response)
Response callback function.
def populate_node_menu(viz, node, menu)
ShowIpv4RoutingTable class.
def __init__(self, visualizer, node_index)