1from gi.repository 
import Gtk
 
    4    from ns3.visualizer.base 
import InformationWindow
 
    5except ModuleNotFoundError:
 
   42        @param self this object
 
   43        @param visualizer visualizer object
 
   44        @param node_index the node index
 
   46        InformationWindow.__init__(self) 
   47        self.win = Gtk.Dialog( 
   48            parent=visualizer.window, 
   49            flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, 
   50            buttons=("_Close", Gtk.ResponseType.CLOSE),
 
   53        self.
win.set_title(
"IPv4 routing table for node %i" % node_index)
 
   61        sw = Gtk.ScrolledWindow()
 
   63            hscrollbar_policy=Gtk.PolicyType.AUTOMATIC, vscrollbar_policy=Gtk.PolicyType.AUTOMATIC
 
   68        self.
win.set_default_size(600, 300)
 
   71        column = Gtk.TreeViewColumn(
 
   72            "Destination", Gtk.CellRendererText(), text=self.COLUMN_DESTINATION
 
   74        treeview.append_column(column)
 
   77        column = Gtk.TreeViewColumn(
"Next hop", Gtk.CellRendererText(), text=self.COLUMN_NEXT_HOP)
 
   78        treeview.append_column(column)
 
   81        column = Gtk.TreeViewColumn(
"Interface", Gtk.CellRendererText(), text=self.COLUMN_INTERFACE)
 
   82        treeview.append_column(column)
 
   85        column = Gtk.TreeViewColumn(
"Type", Gtk.CellRendererText(), text=self.COLUMN_TYPE)
 
   86        treeview.append_column(column)
 
   89        column = Gtk.TreeViewColumn(
"Prio", Gtk.CellRendererText(), text=self.COLUMN_PRIO)
 
   90        treeview.append_column(column)
 
   97        Response callback function 
   98        @param self this object
 
  100        @param response the response
 
  104        self.visualizer.remove_information_window(self) 
  109        @param self this object
 
  113        ipv4 = node.GetObject[ns.Ipv4]().__deref__() 
  114        routing = ipv4.GetRoutingProtocol() 
  118        routing_protocols = []  
 
  120        if isinstance(routing, ns.Ipv4StaticRouting):
 
  121            ipv4_routing = routing_protocols.append((routing, 
"static", 0))
 
  122        elif isinstance(routing, ns.Ipv4ListRouting):
 
  123            list_routing = routing
 
  124            for rI 
in range(list_routing.GetNRoutingProtocols()):
 
  125                routing, prio = list_routing.GetRoutingProtocol(rI)
 
  126                if isinstance(routing, ns.Ipv4StaticRouting):
 
  127                    routing_protocols.append((routing, 
"static", prio))
 
  128                elif isinstance(routing, ns.Ipv4GlobalRouting):
 
  129                    routing_protocols.append((routing, 
"global", prio))
 
  130        if not routing_protocols:
 
  134        for route_proto, type_string, prio 
in routing_protocols:
 
  135            for routeI 
in range(route_proto.GetNRoutes()):
 
  136                route = route_proto.GetRoute(routeI)
 
  138                netdevice = ipv4.GetNetDevice(route.GetInterface())
 
  139                if netdevice 
is None:
 
  140                    interface_name = 
"lo" 
  142                    interface_name = ns.Names.FindName(netdevice)
 
  143                    if not interface_name:
 
  144                        interface_name = 
"(interface %i)" % route.GetInterface()
 
  147                    self.COLUMN_DESTINATION,
 
  148                    str(route.GetDest()),
 
  149                    self.COLUMN_NEXT_HOP,
 
  150                    str(route.GetGateway()),
 
  151                    self.COLUMN_INTERFACE,
 
  161    menu_item = Gtk.MenuItem(
"Show IPv4 Routing Table")
 
  164    def _show_ipv4_routing_table(dummy_menu_item):
 
  167    menu_item.connect(
"activate", _show_ipv4_routing_table)
 
  172    viz.connect(
"populate-node-menu", populate_node_menu)
 
ShowIpv4RoutingTable class.
 
def __init__(self, visualizer, node_index)
Initializer.
 
def _response_cb(self, win, response)
Response callback function.
 
def update(self)
Update function.
 
def populate_node_menu(viz, node, menu)