10 from kiwi.ui.objectlist
import ObjectList, Column
54 @param self this object
57 self.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
58 vscrollbar_policy=gtk.POLICY_AUTOMATIC)
64 def add_column(descr, colid):
65 column = gtk.TreeViewColumn(descr, gtk.CellRendererText(), text=colid)
66 treeview.append_column(column)
68 add_column(
"Time", self.COLUMN_TIME)
69 add_column(
"Interface", self.COLUMN_INTERFACE)
70 add_column(
"Size", self.COLUMN_SIZE)
71 add_column(
"Contents", self.COLUMN_CONTENTS)
76 @param self this object
78 @param packet_list packet list
81 self.table_model.clear()
82 for sample
in packet_list:
83 tree_iter = self.table_model.append()
84 if sample.device
is None:
85 interface_name =
"(unknown)"
87 interface_name = ns.core.Names.FindName(sample.device)
88 if not interface_name:
89 interface_name =
"(interface %i)" % sample.device.GetIfIndex()
90 self.table_model.set(tree_iter,
91 self.COLUMN_TIME, str(sample.time.GetSeconds()),
92 self.COLUMN_INTERFACE, interface_name,
93 self.COLUMN_SIZE, str(sample.packet.GetSize ()),
94 self.COLUMN_CONTENTS, str(sample.packet)
101 @param self this object
102 @param visualizer the visualizer object
103 @param node_index the node index
105 InformationWindow.__init__(self)
106 self.
win = gtk.Dialog(parent=visualizer.window,
107 flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,
108 buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
110 self.win.set_title(
"Last packets for node %i" % node_index)
113 self.
node = ns.network.NodeList.GetNode(node_index)
115 def smart_expand(expander, vbox):
116 if expander.get_expanded():
117 vbox.set_child_packing(expander, expand=
True, fill=
True, padding=0, pack_type=gtk.PACK_START)
119 vbox.set_child_packing(expander, expand=
False, fill=
False, padding=0, pack_type=gtk.PACK_START)
121 main_hbox = gtk.HBox(
False, 4)
123 main_vbox = gtk.VBox(
False, 4)
125 self.win.vbox.add(main_hbox)
126 main_hbox.add(main_vbox)
130 group = gtk.Expander(
"Last transmitted packets")
133 main_vbox.pack_start(group, expand=
False, fill=
False)
134 group.connect_after(
"activate", smart_expand, main_vbox)
138 group = gtk.Expander(
"Last received packets")
141 main_vbox.pack_start(group, expand=
False, fill=
False)
142 group.connect_after(
"activate", smart_expand, main_vbox)
145 self.drop_list.show()
146 group = gtk.Expander(
"Last dropped packets")
149 main_vbox.pack_start(group, expand=
False, fill=
False)
150 group.connect_after(
"activate", smart_expand, main_vbox)
157 self.packet_capture_options.numLastPackets = 100
159 packet_filter_vbox = gtk.VBox(
False, 4)
160 packet_filter_vbox.show()
161 main_hbox.add(packet_filter_vbox)
163 sel_buttons_box = gtk.HButtonBox()
164 sel_buttons_box.show()
165 packet_filter_vbox.pack_start(sel_buttons_box,
False,
False, 4)
166 select_all_button = gobject.new(gtk.Button, label=
"Sel. All", visible=
True)
167 select_none_button = gobject.new(gtk.Button, label=
"Sel. None", visible=
True)
168 sel_buttons_box.add(select_all_button)
169 sel_buttons_box.add(select_none_button)
172 Column(
'selected', title=
"Sel.", data_type=bool, editable=
True),
173 Column(
'name', title=
"Header"),
175 self.packet_filter_widget.show()
178 class TypeIdConfig(object):
179 __slots__ = [
'name',
'selected',
'typeid']
183 Header = ns.core.TypeId.LookupByName(
"ns3::Header")
184 Trailer = ns.core.TypeId.LookupByName(
"ns3::Trailer")
185 for typeid_i
in range(ns.core.TypeId.GetRegisteredN()):
186 typeid = ns.core.TypeId.GetRegistered(typeid_i)
191 if typeid_tmp == Header
or typeid_tmp == Trailer:
194 if typeid_tmp.HasParent():
195 typeid_tmp = typeid_tmp.GetParent()
200 if typeid
in [Header, Trailer]:
204 c.name = typeid.GetName()
206 self.packet_filter_list.append(c)
209 def update_capture_options():
210 if self.op_AND_button.props.active:
211 self.packet_capture_options.mode = ns.visualizer.PyViz.PACKET_CAPTURE_FILTER_HEADERS_AND
213 self.packet_capture_options.mode = ns.visualizer.PyViz.PACKET_CAPTURE_FILTER_HEADERS_OR
214 self.packet_capture_options.numLastPackets = 100
215 self.packet_capture_options.headers = [c.typeid
for c
in self.
packet_filter_list if c.selected]
216 self.visualizer.simulation.lock.acquire()
218 self.visualizer.simulation.sim_helper.SetPacketCaptureOptions(
221 self.visualizer.simulation.lock.release()
226 self.packet_filter_widget.refresh()
227 update_capture_options()
232 self.packet_filter_widget.refresh()
233 update_capture_options()
235 select_all_button.connect(
"clicked", sel_all_cb)
236 select_none_button.connect(
"clicked", sel_none_cb)
238 op_buttons_box = gtk.HButtonBox()
239 op_buttons_box.show()
240 packet_filter_vbox.pack_start(op_buttons_box,
False,
False, 4)
241 self.
op_AND_button = gobject.new(gtk.RadioButton, label=
"AND", visible=
True)
245 self.op_OR_button.props.active =
True
247 self.op_AND_button.connect(
"toggled",
lambda b: update_capture_options())
249 def cell_edited(l, obj, attribute):
250 update_capture_options()
251 self.packet_filter_widget.connect(
"cell-edited", cell_edited)
253 update_capture_options()
255 self.visualizer.add_information_window(self)
256 self.win.set_default_size(600, 300)
261 Response callback function
262 @param self this object
263 @param win the window
264 @param response the response
268 self.visualizer.remove_information_window(self)
273 @param self this object
276 last_packets = self.visualizer.simulation.sim_helper.GetLastPackets(self.node.GetId())
278 self.tx_list.update(self.
node, last_packets.lastTransmittedPackets)
279 self.rx_list.update(self.
node, last_packets.lastReceivedPackets)
280 self.drop_list.update(self.
node, last_packets.lastDroppedPackets)
284 menu_item = gtk.MenuItem(
"Show Last Packets")
287 def _show_it(dummy_menu_item):
290 menu_item.connect(
"activate", _show_it)
294 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)