1 from __future__
import division
5 from xml.etree
import cElementTree
as ElementTree
7 from xml.etree
import ElementTree
31 __slots_ = [
'sourceAddress',
'destinationAddress',
'protocol',
'sourcePort',
'destinationPort']
34 @param self The object pointer.
35 @param el The element.
41 self.
protocolprotocol = int(el.get(
'protocol'))
54 __slots_ =
'bins',
'nbins',
'number_of_flows'
57 @param self The object pointer.
58 @param el The element.
63 for bin
in el.findall(
'bin'):
64 self.
binsbins.append( (float(bin.get(
"start")), float(bin.get(
"width")), int(bin.get(
"count"))) )
93 __slots_ = [
'flowId',
'delayMean',
'packetLossRatio',
'rxBitrate',
'txBitrate',
94 'fiveTuple',
'packetSizeMean',
'probe_stats_unsorted',
95 'hopCount',
'flowInterruptionsHistogram',
'rx_duration']
98 @param self The object pointer.
99 @param flow_el The element.
101 self.
flowIdflowId = int(flow_el.get(
'flowId'))
102 rxPackets = float(flow_el.get(
'rxPackets'))
103 txPackets = float(flow_el.get(
'txPackets'))
105 tx_duration = (parse_time_ns (flow_el.get(
'timeLastTxPacket')) -
parse_time_ns(flow_el.get(
'timeFirstTxPacket')))*1e-9
106 rx_duration = (parse_time_ns (flow_el.get(
'timeLastRxPacket')) -
parse_time_ns(flow_el.get(
'timeFirstRxPacket')))*1e-9
110 self.
hopCounthopCount = float(flow_el.get(
'timesForwarded')) / rxPackets + 1
114 self.
delayMeandelayMean = float(flow_el.get(
'delaySum')[:-2]) / rxPackets * 1e-9
120 self.
rxBitraterxBitrate = float(flow_el.get(
'rxBytes'))*8 / rx_duration
124 self.
txBitratetxBitrate = float(flow_el.get(
'txBytes'))*8 / tx_duration
127 lost = float(flow_el.get(
'lostPackets'))
134 interrupt_hist_elem = flow_el.find(
"flowInterruptionsHistogram")
135 if interrupt_hist_elem
is None:
153 __slots_ = [
'probeId',
'packets',
'bytes',
'delayFromFirstProbe']
161 '''! The initializer.
162 @param self The object pointer.
163 @param simulation_el The element.
166 FlowClassifier_el, = simulation_el.findall(
"Ipv4FlowClassifier")
168 for flow_el
in simulation_el.findall(
"FlowStats/Flow"):
170 flow_map[flow.flowId] = flow
171 self.
flowsflows.append(flow)
172 for flow_cls
in FlowClassifier_el.findall(
"Flow"):
173 flowId = int(flow_cls.get(
'flowId'))
174 flow_map[flowId].fiveTuple =
FiveTuple(flow_cls)
176 for probe_elem
in simulation_el.findall(
"FlowProbes/FlowProbe"):
177 probeId = int(probe_elem.get(
'index'))
178 for stats
in probe_elem.findall(
"FlowStats"):
179 flowId = int(stats.get(
'flowId'))
181 s.packets = int(stats.get(
'packets'))
182 s.bytes = float(stats.get(
'bytes'))
185 s.delayFromFirstProbe =
parse_time_ns(stats.get(
'delayFromFirstProbeSum')) / float(s.packets)
187 s.delayFromFirstProbe = 0
188 flow_map[flowId].probe_stats_unsorted.append(s)
192 file_obj = open(argv[1])
193 print(
"Reading XML file ", end=
" ")
198 for event, elem
in ElementTree.iterparse(file_obj, events=(
"start",
"end")):
203 if level == 0
and elem.tag ==
'FlowMonitor':
207 sys.stdout.write(
".")
213 for flow
in sim.flows:
215 proto = {6:
'TCP', 17:
'UDP'} [t.protocol]
216 print(
"FlowID: %i (%s %s/%s --> %s/%i)" % \
217 (flow.flowId, proto, t.sourceAddress, t.sourcePort, t.destinationAddress, t.destinationPort))
218 if flow.txBitrate
is None:
219 print(
"\tTX bitrate: None")
221 print(
"\tTX bitrate: %.2f kbit/s" % (flow.txBitrate*1e-3,))
222 if flow.rxBitrate
is None:
223 print(
"\tRX bitrate: None")
225 print(
"\tRX bitrate: %.2f kbit/s" % (flow.rxBitrate*1e-3,))
226 if flow.delayMean
is None:
227 print(
"\tMean Delay: None")
229 print(
"\tMean Delay: %.2f ms" % (flow.delayMean*1e3,))
230 if flow.packetLossRatio
is None:
231 print(
"\tPacket Loss Ratio: None")
233 print(
"\tPacket Loss Ratio: %.2f %%" % (flow.packetLossRatio*100))
236 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.