1from gi.repository
import Gtk
4 from ns3.visualizer.base
import InformationWindow
5except ModuleNotFoundError:
29 @param self this object
30 @param visualizer visualizer object
31 @param node_index the node index
33 InformationWindow.__init__(self)
34 self.win = Gtk.Dialog(parent=visualizer.window,
35 flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
36 buttons=("_Close", Gtk.ResponseType.CLOSE))
38 self.
win.set_title(
"IPv4 routing table for node %i" % node_index)
46 sw = Gtk.ScrolledWindow()
47 sw.set_properties(hscrollbar_policy=Gtk.PolicyType.AUTOMATIC,
48 vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
52 self.
win.set_default_size(600, 300)
55 column = Gtk.TreeViewColumn(
'Destination', Gtk.CellRendererText(),
56 text=self.COLUMN_DESTINATION)
57 treeview.append_column(column)
60 column = Gtk.TreeViewColumn(
'Next hop', Gtk.CellRendererText(),
61 text=self.COLUMN_NEXT_HOP)
62 treeview.append_column(column)
65 column = Gtk.TreeViewColumn(
'Interface', Gtk.CellRendererText(),
66 text=self.COLUMN_INTERFACE)
67 treeview.append_column(column)
70 column = Gtk.TreeViewColumn(
'Type', Gtk.CellRendererText(),
71 text=self.COLUMN_TYPE)
72 treeview.append_column(column)
75 column = Gtk.TreeViewColumn(
'Prio', Gtk.CellRendererText(),
76 text=self.COLUMN_PRIO)
77 treeview.append_column(column)
84 Response callback function
85 @param self this object
87 @param response the response
91 self.visualizer.remove_information_window(self)
96 @param self this object
100 ipv4 = ns.cppyy.gbl.getNodeIpv4(node)
101 routing = ipv4.GetRoutingProtocol()
105 routing_protocols = []
107 if isinstance(routing, ns.Ipv4StaticRouting):
108 ipv4_routing = routing_protocols.append((routing,
"static", 0))
109 elif isinstance(routing, ns.Ipv4ListRouting):
110 list_routing = routing
111 for rI
in range(list_routing.GetNRoutingProtocols()):
112 routing, prio = list_routing.GetRoutingProtocol(rI)
113 if isinstance(routing, ns.Ipv4StaticRouting):
114 routing_protocols.append((routing,
"static", prio))
115 elif isinstance(routing, ns.Ipv4GlobalRouting):
116 routing_protocols.append((routing,
"global", prio))
117 if not routing_protocols:
121 for route_proto, type_string, prio
in routing_protocols:
122 for routeI
in range(route_proto.GetNRoutes()):
123 route = route_proto.GetRoute(routeI)
125 netdevice = ipv4.GetNetDevice(route.GetInterface())
126 if netdevice
is None:
127 interface_name =
'lo'
129 interface_name = ns.Names.FindName(netdevice)
130 if not interface_name:
131 interface_name =
"(interface %i)" % route.GetInterface()
133 self.COLUMN_DESTINATION, str(route.GetDest()),
134 self.COLUMN_NEXT_HOP, str(route.GetGateway()),
135 self.COLUMN_INTERFACE, interface_name,
136 self.COLUMN_TYPE, type_string,
137 self.COLUMN_PRIO, prio)
141 menu_item = Gtk.MenuItem(
"Show IPv4 Routing Table")
144 def _show_ipv4_routing_table(dummy_menu_item):
147 menu_item.connect(
"activate", _show_ipv4_routing_table)
151 viz.connect(
"populate-node-menu", populate_node_menu)
ShowIpv4RoutingTable class.
def _response_cb(self, win, response)
Response callback function.
def __init__(self, visualizer, node_index)
Initializer.
def update(self)
Update function.
def populate_node_menu(viz, node, menu)