1 from gi.repository
import GObject
2 from gi.repository
import Gtk
7 from kiwi.ui.objectlist
import ObjectList, Column
51 @param self this object
54 self.set_properties(hscrollbar_policy=Gtk.PolicyType.AUTOMATIC,
55 vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
57 treeview = Gtk.TreeView(self.
table_modeltable_model)
61 def add_column(descr, colid):
62 column = Gtk.TreeViewColumn(descr, Gtk.CellRendererText(), text=colid)
63 treeview.append_column(column)
65 add_column(
"Time", self.COLUMN_TIME)
66 add_column(
"Interface", self.COLUMN_INTERFACE)
67 add_column(
"Size", self.COLUMN_SIZE)
68 add_column(
"Contents", self.COLUMN_CONTENTS)
73 @param self this object
75 @param packet_list packet list
79 for sample
in packet_list:
81 if sample.device
is None:
82 interface_name =
"(unknown)"
84 interface_name = ns.core.Names.FindName(sample.device)
85 if not interface_name:
86 interface_name =
"(interface %i)" % sample.device.GetIfIndex()
88 self.COLUMN_TIME, str(sample.time.GetSeconds()),
89 self.COLUMN_INTERFACE, interface_name,
90 self.COLUMN_SIZE, str(sample.packet.GetSize ()),
91 self.COLUMN_CONTENTS, str(sample.packet)
98 @param self this object
99 @param visualizer the visualizer object
100 @param node_index the node index
102 InformationWindow.__init__(self)
103 self.
winwin = Gtk.Dialog(parent=visualizer.window,
104 flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
105 buttons=(
"_Close", Gtk.ResponseType.CLOSE))
107 self.
winwin.set_title(
"Last packets for node %i" % node_index)
109 self.
viz_nodeviz_node = visualizer.get_node(node_index)
110 self.
nodenode = ns.network.NodeList.GetNode(node_index)
112 def smart_expand(expander, vbox):
113 if expander.get_expanded():
114 vbox.set_child_packing(expander, expand=
True, fill=
True, padding=0, pack_type=Gtk.PACK_START)
116 vbox.set_child_packing(expander, expand=
False, fill=
False, padding=0, pack_type=Gtk.PACK_START)
118 main_hbox = Gtk.HBox(
False, 4)
120 main_vbox = Gtk.VBox(
False, 4)
122 self.
winwin.vbox.add(main_hbox)
123 main_hbox.add(main_vbox)
127 group = Gtk.Expander(
"Last transmitted packets")
130 main_vbox.pack_start(group, expand=
False, fill=
False)
131 group.connect_after(
"activate", smart_expand, main_vbox)
135 group = Gtk.Expander(
"Last received packets")
138 main_vbox.pack_start(group, expand=
False, fill=
False)
139 group.connect_after(
"activate", smart_expand, main_vbox)
143 group = Gtk.Expander(
"Last dropped packets")
146 main_vbox.pack_start(group, expand=
False, fill=
False)
147 group.connect_after(
"activate", smart_expand, main_vbox)
156 packet_filter_vbox = Gtk.VBox(
False, 4)
157 packet_filter_vbox.show()
158 main_hbox.add(packet_filter_vbox)
160 sel_buttons_box = Gtk.HButtonBox()
161 sel_buttons_box.show()
162 packet_filter_vbox.pack_start(sel_buttons_box,
False,
False, 4)
163 select_all_button = GObject.new(Gtk.Button, label=
"Sel. All", visible=
True)
164 select_none_button = GObject.new(Gtk.Button, label=
"Sel. None", visible=
True)
165 sel_buttons_box.add(select_all_button)
166 sel_buttons_box.add(select_none_button)
169 Column(
'selected', title=
"Sel.", data_type=bool, editable=
True),
170 Column(
'name', title=
"Header"),
175 class TypeIdConfig(
object):
176 __slots__ = [
'name',
'selected',
'typeid']
180 Header = ns.core.TypeId.LookupByName(
"ns3::Header")
181 Trailer = ns.core.TypeId.LookupByName(
"ns3::Trailer")
182 for typeid_i
in range(ns.core.TypeId.GetRegisteredN()):
183 typeid = ns.core.TypeId.GetRegistered(typeid_i)
188 if typeid_tmp == Header
or typeid_tmp == Trailer:
191 if typeid_tmp.HasParent():
192 typeid_tmp = typeid_tmp.GetParent()
197 if typeid
in [Header, Trailer]:
201 c.name = typeid.GetName()
206 def update_capture_options():
208 self.
packet_capture_optionspacket_capture_options.mode = ns.visualizer.PyViz.PACKET_CAPTURE_FILTER_HEADERS_AND
210 self.
packet_capture_optionspacket_capture_options.mode = ns.visualizer.PyViz.PACKET_CAPTURE_FILTER_HEADERS_OR
213 self.
visualizervisualizer.simulation.lock.acquire()
215 self.
visualizervisualizer.simulation.sim_helper.SetPacketCaptureOptions(
218 self.
visualizervisualizer.simulation.lock.release()
224 update_capture_options()
230 update_capture_options()
232 select_all_button.connect(
"clicked", sel_all_cb)
233 select_none_button.connect(
"clicked", sel_none_cb)
235 op_buttons_box = Gtk.HButtonBox()
236 op_buttons_box.show()
237 packet_filter_vbox.pack_start(op_buttons_box,
False,
False, 4)
238 self.
op_AND_buttonop_AND_button = GObject.new(Gtk.RadioButton, label=
"AND", visible=
True)
244 self.
op_AND_buttonop_AND_button.connect(
"toggled",
lambda b: update_capture_options())
246 def cell_edited(l, obj, attribute):
247 update_capture_options()
250 update_capture_options()
252 self.
visualizervisualizer.add_information_window(self)
253 self.
winwin.set_default_size(600, 300)
258 Response callback function
259 @param self this object
260 @param win the window
261 @param response the response
264 self.
winwin.destroy()
265 self.
visualizervisualizer.remove_information_window(self)
270 @param self this object
273 last_packets = self.
visualizervisualizer.simulation.sim_helper.GetLastPackets(self.
nodenode.GetId())
281 menu_item = Gtk.MenuItem(
"Show Last Packets")
284 def _show_it(dummy_menu_item):
287 menu_item.connect(
"activate", _show_it)
291 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)