1from gi.repository
import GObject
2from gi.repository
import Gtk
7 from nsnam.visualizer.base
import InformationWindow
8except ModuleNotFoundError:
11from kiwi.ui.objectlist
import ObjectList, Column
55 @param self this object
58 self.set_properties(hscrollbar_policy=Gtk.PolicyType.AUTOMATIC,
59 vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
65 def add_column(descr, colid):
66 column = Gtk.TreeViewColumn(descr, Gtk.CellRendererText(), text=colid)
67 treeview.append_column(column)
69 add_column(
"Time", self.COLUMN_TIME)
70 add_column(
"Interface", self.COLUMN_INTERFACE)
71 add_column(
"Size", self.COLUMN_SIZE)
72 add_column(
"Contents", self.COLUMN_CONTENTS)
77 @param self this object
79 @param packet_list packet list
83 for sample
in packet_list:
85 if sample.device
is None:
86 interface_name =
"(unknown)"
88 interface_name = ns.core.Names.FindName(sample.device)
89 if not interface_name:
90 interface_name =
"(interface %i)" % sample.device.GetIfIndex()
92 self.COLUMN_TIME, str(sample.time.GetSeconds()),
93 self.COLUMN_INTERFACE, interface_name,
94 self.COLUMN_SIZE, str(sample.packet.GetSize ()),
95 self.COLUMN_CONTENTS, str(sample.packet)
102 @param self this object
103 @param visualizer the visualizer object
104 @param node_index the node index
106 InformationWindow.__init__(self)
107 self.win = Gtk.Dialog(parent=visualizer.window,
108 flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
109 buttons=("_Close", Gtk.ResponseType.CLOSE))
111 self.
win.set_title(
"Last packets for node %i" % node_index)
114 self.
node = ns.network.NodeList.GetNode(node_index)
116 def smart_expand(expander, vbox):
117 if expander.get_expanded():
118 vbox.set_child_packing(expander, expand=
True, fill=
True, padding=0, pack_type=Gtk.PACK_START)
120 vbox.set_child_packing(expander, expand=
False, fill=
False, padding=0, pack_type=Gtk.PACK_START)
122 main_hbox = Gtk.HBox(
False, 4)
124 main_vbox = Gtk.VBox(
False, 4)
126 self.
win.vbox.add(main_hbox)
127 main_hbox.add(main_vbox)
131 group = Gtk.Expander(
"Last transmitted packets")
134 main_vbox.pack_start(group, expand=
False, fill=
False)
135 group.connect_after(
"activate", smart_expand, main_vbox)
139 group = Gtk.Expander(
"Last received packets")
142 main_vbox.pack_start(group, expand=
False, fill=
False)
143 group.connect_after(
"activate", smart_expand, main_vbox)
147 group = Gtk.Expander(
"Last dropped packets")
150 main_vbox.pack_start(group, expand=
False, fill=
False)
151 group.connect_after(
"activate", smart_expand, main_vbox)
160 packet_filter_vbox = Gtk.VBox(
False, 4)
161 packet_filter_vbox.show()
162 main_hbox.add(packet_filter_vbox)
164 sel_buttons_box = Gtk.HButtonBox()
165 sel_buttons_box.show()
166 packet_filter_vbox.pack_start(sel_buttons_box,
False,
False, 4)
167 select_all_button = GObject.new(Gtk.Button, label=
"Sel. All", visible=
True)
168 select_none_button = GObject.new(Gtk.Button, label=
"Sel. None", visible=
True)
169 sel_buttons_box.add(select_all_button)
170 sel_buttons_box.add(select_none_button)
173 Column(
'selected', title=
"Sel.", data_type=bool, editable=
True),
174 Column(
'name', title=
"Header"),
179 class TypeIdConfig(
object):
180 __slots__ = [
'name',
'selected',
'typeid']
184 Header = ns.core.TypeId.LookupByName(
"ns3::Header")
185 Trailer = ns.core.TypeId.LookupByName(
"ns3::Trailer")
186 for typeid_i
in range(ns.core.TypeId.GetRegisteredN()):
187 typeid = ns.core.TypeId.GetRegistered(typeid_i)
192 if typeid_tmp == Header
or typeid_tmp == Trailer:
195 if typeid_tmp.HasParent():
196 typeid_tmp = typeid_tmp.GetParent()
201 if typeid
in [Header, Trailer]:
205 c.name = typeid.GetName()
210 def update_capture_options():
219 self.
visualizer.simulation.sim_helper.SetPacketCaptureOptions(
228 update_capture_options()
234 update_capture_options()
236 select_all_button.connect(
"clicked", sel_all_cb)
237 select_none_button.connect(
"clicked", sel_none_cb)
239 op_buttons_box = Gtk.HButtonBox()
240 op_buttons_box.show()
241 packet_filter_vbox.pack_start(op_buttons_box,
False,
False, 4)
242 self.
op_AND_button = GObject.new(Gtk.RadioButton, label=
"AND", visible=
True)
248 self.
op_AND_button.connect(
"toggled",
lambda b: update_capture_options())
250 def cell_edited(l, obj, attribute):
251 update_capture_options()
254 update_capture_options()
257 self.
win.set_default_size(600, 300)
262 Response callback function
263 @param self this object
264 @param win the window
265 @param response the response
269 self.visualizer.remove_information_window(self)
274 @param self this object
277 last_packets = self.visualizer.simulation.sim_helper.GetLastPackets(self.node.GetId())
285 menu_item = Gtk.MenuItem(
"Show Last Packets")
288 def _show_it(dummy_menu_item):
291 menu_item.connect(
"activate", _show_it)
295 viz.connect(
"populate-node-menu", populate_node_menu)
def update(self, node, packet_list)
Update function.
def _response_cb(self, win, response)
Response callback function.
tx_list
packet transmit list
packet_capture_options
packet capture options
drop_list
packet drop list
rx_list
packet receive list
packet_filter_widget
packet filter widget
def update(self)
Update function.
def __init__(self, visualizer, node_index)
Initializer.
packet_filter_list
list of TypeIdConfig instances
def populate_node_menu(viz, node, menu)