1 from gi.repository
import GObject
2 from gi.repository
import Gtk
9 from kiwi.ui.objectlist
import ObjectList, Column
53 @param self this object 56 self.set_properties(hscrollbar_policy=Gtk.PolicyType.AUTOMATIC,
57 vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
63 def add_column(descr, colid):
64 column = Gtk.TreeViewColumn(descr, Gtk.CellRendererText(), text=colid)
65 treeview.append_column(column)
67 add_column(
"Time", self.COLUMN_TIME)
68 add_column(
"Interface", self.COLUMN_INTERFACE)
69 add_column(
"Size", self.COLUMN_SIZE)
70 add_column(
"Contents", self.COLUMN_CONTENTS)
75 @param self this object 77 @param packet_list packet list 81 for sample
in packet_list:
83 if sample.device
is None:
84 interface_name =
"(unknown)" 86 interface_name = ns.core.Names.FindName(sample.device)
87 if not interface_name:
88 interface_name =
"(interface %i)" % sample.device.GetIfIndex()
90 self.COLUMN_TIME, str(sample.time.GetSeconds()),
91 self.COLUMN_INTERFACE, interface_name,
92 self.COLUMN_SIZE, str(sample.packet.GetSize ()),
93 self.COLUMN_CONTENTS, str(sample.packet)
100 @param self this object 101 @param visualizer the visualizer object 102 @param node_index the node index 104 InformationWindow.__init__(self)
105 self.
win = Gtk.Dialog(parent=visualizer.window,
106 flags=Gtk.DialogFlags.DESTROY_WITH_PARENT|Gtk.DialogFlags.NO_SEPARATOR,
107 buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
109 self.
win.set_title(
"Last packets for node %i" % node_index)
112 self.
node = ns.network.NodeList.GetNode(node_index)
114 def smart_expand(expander, vbox):
115 if expander.get_expanded():
116 vbox.set_child_packing(expander, expand=
True, fill=
True, padding=0, pack_type=Gtk.PACK_START)
118 vbox.set_child_packing(expander, expand=
False, fill=
False, padding=0, pack_type=Gtk.PACK_START)
120 main_hbox = Gtk.HBox(
False, 4)
122 main_vbox = Gtk.VBox(
False, 4)
124 self.
win.vbox.add(main_hbox)
125 main_hbox.add(main_vbox)
129 group = Gtk.Expander(
"Last transmitted packets")
132 main_vbox.pack_start(group, expand=
False, fill=
False)
133 group.connect_after(
"activate", smart_expand, main_vbox)
137 group = Gtk.Expander(
"Last received packets")
140 main_vbox.pack_start(group, expand=
False, fill=
False)
141 group.connect_after(
"activate", smart_expand, main_vbox)
145 group = Gtk.Expander(
"Last dropped packets")
148 main_vbox.pack_start(group, expand=
False, fill=
False)
149 group.connect_after(
"activate", smart_expand, main_vbox)
158 packet_filter_vbox = Gtk.VBox(
False, 4)
159 packet_filter_vbox.show()
160 main_hbox.add(packet_filter_vbox)
162 sel_buttons_box = Gtk.HButtonBox()
163 sel_buttons_box.show()
164 packet_filter_vbox.pack_start(sel_buttons_box,
False,
False, 4)
165 select_all_button = GObject.new(Gtk.Button, label=
"Sel. All", visible=
True)
166 select_none_button = GObject.new(Gtk.Button, label=
"Sel. None", visible=
True)
167 sel_buttons_box.add(select_all_button)
168 sel_buttons_box.add(select_none_button)
171 Column(
'selected', title=
"Sel.", data_type=bool, editable=
True),
172 Column(
'name', title=
"Header"),
177 class TypeIdConfig(object):
178 __slots__ = [
'name',
'selected',
'typeid']
182 Header = ns.core.TypeId.LookupByName(
"ns3::Header")
183 Trailer = ns.core.TypeId.LookupByName(
"ns3::Trailer")
184 for typeid_i
in range(ns.core.TypeId.GetRegisteredN()):
185 typeid = ns.core.TypeId.GetRegistered(typeid_i)
190 if typeid_tmp == Header
or typeid_tmp == Trailer:
193 if typeid_tmp.HasParent():
194 typeid_tmp = typeid_tmp.GetParent()
199 if typeid
in [Header, Trailer]:
203 c.name = typeid.GetName()
208 def update_capture_options():
217 self.
visualizer.simulation.sim_helper.SetPacketCaptureOptions(
226 update_capture_options()
232 update_capture_options()
234 select_all_button.connect(
"clicked", sel_all_cb)
235 select_none_button.connect(
"clicked", sel_none_cb)
237 op_buttons_box = Gtk.HButtonBox()
238 op_buttons_box.show()
239 packet_filter_vbox.pack_start(op_buttons_box,
False,
False, 4)
240 self.
op_AND_button = GObject.new(Gtk.RadioButton, label=
"AND", visible=
True)
246 self.
op_AND_button.connect(
"toggled",
lambda b: update_capture_options())
248 def cell_edited(l, obj, attribute):
249 update_capture_options()
252 update_capture_options()
255 self.
win.set_default_size(600, 300)
260 Response callback function 261 @param self this object 262 @param win the window 263 @param response the response 267 self.
visualizer.remove_information_window(self)
272 @param self this object 275 last_packets = self.
visualizer.simulation.sim_helper.GetLastPackets(self.
node.GetId())
283 menu_item = Gtk.MenuItem(
"Show Last Packets")
286 def _show_it(dummy_menu_item):
289 menu_item.connect(
"activate", _show_it)
293 viz.connect(
"populate-node-menu", populate_node_menu)
tx_list
packet transmit list
def update(self, node, packet_list)
Update function.
packet_filter_widget
packet filter widget
drop_list
packet drop list
packet_capture_options
packet capture options
def _response_cb(self, win, response)
Response callback function.
def update(self)
Update function.
def __init__(self, visualizer, node_index)
packet_filter_list
list of TypeIdConfig instances
rx_list
packet receive list
def populate_node_menu(viz, node, menu)