19 InformationWindow.__init__(self)
20 self.
win = gtk.Dialog(parent=visualizer.window,
21 flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,
22 buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
24 self.win.set_title(
"IPv4 routing table for node %i" % node_index)
32 sw = gtk.ScrolledWindow()
33 sw.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
34 vscrollbar_policy=gtk.POLICY_AUTOMATIC)
38 self.win.set_default_size(600, 300)
41 column = gtk.TreeViewColumn(
'Destination', gtk.CellRendererText(),
42 text=self.COLUMN_DESTINATION)
43 treeview.append_column(column)
46 column = gtk.TreeViewColumn(
'Next hop', gtk.CellRendererText(),
47 text=self.COLUMN_NEXT_HOP)
48 treeview.append_column(column)
51 column = gtk.TreeViewColumn(
'Interface', gtk.CellRendererText(),
52 text=self.COLUMN_INTERFACE)
53 treeview.append_column(column)
56 column = gtk.TreeViewColumn(
'Type', gtk.CellRendererText(),
57 text=self.COLUMN_TYPE)
58 treeview.append_column(column)
61 column = gtk.TreeViewColumn(
'Prio', gtk.CellRendererText(),
62 text=self.COLUMN_PRIO)
63 treeview.append_column(column)
65 self.visualizer.add_information_window(self)
70 self.visualizer.remove_information_window(self)
73 node = ns.network.NodeList.GetNode(self.
node_index)
74 ipv4 = node.GetObject(ns.internet.Ipv4.GetTypeId())
75 routing = ipv4.GetRoutingProtocol()
79 routing_protocols = []
81 if isinstance(routing, ns.internet.Ipv4StaticRouting):
82 ipv4_routing = routing_protocols.append((routing,
"static", 0))
83 elif isinstance(routing, ns.internet.Ipv4ListRouting):
84 list_routing = routing
85 for rI
in range(list_routing.GetNRoutingProtocols()):
86 routing, prio = list_routing.GetRoutingProtocol(rI)
87 if isinstance(routing, ns.internet.Ipv4StaticRouting):
88 routing_protocols.append((routing,
"static", prio))
89 elif isinstance(routing, ns.internet.Ipv4GlobalRouting):
90 routing_protocols.append((routing,
"global", prio))
91 if not routing_protocols:
94 self.table_model.clear()
95 for route_proto, type_string, prio
in routing_protocols:
96 for routeI
in range(route_proto.GetNRoutes()):
97 route = route_proto.GetRoute(routeI)
98 tree_iter = self.table_model.append()
99 netdevice = ipv4.GetNetDevice(route.GetInterface())
100 if netdevice
is None:
101 interface_name =
'lo'
103 interface_name = ns.core.Names.FindName(netdevice)
104 if not interface_name:
105 interface_name =
"(interface %i)" % route.GetInterface()
106 self.table_model.set(tree_iter,
107 self.COLUMN_DESTINATION, str(route.GetDest()),
108 self.COLUMN_NEXT_HOP, str(route.GetGateway()),
109 self.COLUMN_INTERFACE, interface_name,
110 self.COLUMN_TYPE, type_string,
111 self.COLUMN_PRIO, prio)
115 menu_item = gtk.MenuItem(
"Show IPv4 Routing Table")
118 def _show_ipv4_routing_table(dummy_menu_item):
121 menu_item.connect(
"activate", _show_ipv4_routing_table)
125 viz.connect(
"populate-node-menu", populate_node_menu)