1 from __future__
import division
7 from xml.etree
import cElementTree
as ElementTree
9 from xml.etree
import ElementTree
33 __slots_ = [
"sourceAddress",
"destinationAddress",
"protocol",
"sourcePort",
"destinationPort"]
37 @param self The object pointer.
38 @param el The element.
44 self.
protocolprotocol = int(el.get(
"protocol"))
54 __slots_ =
"bins",
"nbins",
"number_of_flows"
58 @param self The object pointer.
59 @param el The element.
64 for bin
in el.findall(
"bin"):
66 (float(bin.get(
"start")), float(bin.get(
"width")), int(bin.get(
"count")))
103 "probe_stats_unsorted",
105 "flowInterruptionsHistogram",
110 """! The initializer.
111 @param self The object pointer.
112 @param flow_el The element.
114 self.
flowIdflowId = int(flow_el.get(
"flowId"))
115 rxPackets = float(flow_el.get(
"rxPackets"))
116 txPackets = float(flow_el.get(
"txPackets"))
129 self.
hopCounthopCount = float(flow_el.get(
"timesForwarded")) / rxPackets + 1
133 self.
delayMeandelayMean = float(flow_el.get(
"delaySum")[:-2]) / rxPackets * 1e-9
139 self.
rxBitraterxBitrate = float(flow_el.get(
"rxBytes")) * 8 / rx_duration
143 self.
txBitratetxBitrate = float(flow_el.get(
"txBytes")) * 8 / tx_duration
146 lost = float(flow_el.get(
"lostPackets"))
153 interrupt_hist_elem = flow_el.find(
"flowInterruptionsHistogram")
154 if interrupt_hist_elem
is None:
169 __slots_ = [
"probeId",
"packets",
"bytes",
"delayFromFirstProbe"]
178 """! The initializer.
179 @param self The object pointer.
180 @param simulation_el The element.
183 (FlowClassifier_el,) = simulation_el.findall(
"Ipv4FlowClassifier")
185 for flow_el
in simulation_el.findall(
"FlowStats/Flow"):
187 flow_map[flow.flowId] = flow
188 self.
flowsflows.append(flow)
189 for flow_cls
in FlowClassifier_el.findall(
"Flow"):
190 flowId = int(flow_cls.get(
"flowId"))
191 flow_map[flowId].fiveTuple =
FiveTuple(flow_cls)
193 for probe_elem
in simulation_el.findall(
"FlowProbes/FlowProbe"):
194 probeId = int(probe_elem.get(
"index"))
195 for stats
in probe_elem.findall(
"FlowStats"):
196 flowId = int(stats.get(
"flowId"))
198 s.packets = int(stats.get(
"packets"))
199 s.bytes = float(stats.get(
"bytes"))
203 stats.get(
"delayFromFirstProbeSum")
206 s.delayFromFirstProbe = 0
207 flow_map[flowId].probe_stats_unsorted.append(s)
211 with open(argv[1], encoding=
"utf-8")
as file_obj:
212 print(
"Reading XML file ", end=
" ")
217 for event, elem
in ElementTree.iterparse(file_obj, events=(
"start",
"end")):
222 if level == 0
and elem.tag ==
"FlowMonitor":
226 sys.stdout.write(
".")
231 for flow
in sim.flows:
233 proto = {6:
"TCP", 17:
"UDP"}[t.protocol]
235 "FlowID: %i (%s %s/%s --> %s/%i)"
241 t.destinationAddress,
245 if flow.txBitrate
is None:
246 print(
"\tTX bitrate: None")
248 print(
"\tTX bitrate: %.2f kbit/s" % (flow.txBitrate * 1e-3,))
249 if flow.rxBitrate
is None:
250 print(
"\tRX bitrate: None")
252 print(
"\tRX bitrate: %.2f kbit/s" % (flow.rxBitrate * 1e-3,))
253 if flow.delayMean
is None:
254 print(
"\tMean Delay: None")
256 print(
"\tMean Delay: %.2f ms" % (flow.delayMean * 1e3,))
257 if flow.packetLossRatio
is None:
258 print(
"\tPacket Loss Ratio: None")
260 print(
"\tPacket Loss Ratio: %.2f %%" % (flow.packetLossRatio * 100))
263 if __name__ ==
"__main__":
def __init__(self, el)
The initializer.
sourceAddress
class variablessource address
destinationPort
destination port
destinationAddress
destination address
flowInterruptionsHistogram
flow histogram
txBitrate
transmit bit rate
packetSizeMean
packet size mean
rxBitrate
receive bit rate
packetLossRatio
packet loss ratio
def __init__(self, flow_el)
The initializer.
rx_duration
receive duration
flowId
class variablesdelay ID
probe_stats_unsorted
unsirted probe stats
def __init__(self, el=None)
The initializer.
bins
class variableshistogram bins
flows
class variableslist of flows
def __init__(self, simulation_el)
The initializer.