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.
50 __slots_ =
'bins',
'nbins',
'number_of_flows'
53 @param self The object pointer.
54 @param el The element.
59 for bin
in el.findall(
'bin'):
60 self.
binsbins.append( (float(bin.get(
"start")), float(bin.get(
"width")),
int(bin.get(
"count"))) )
87 __slots_ = [
'flowId',
'delayMean',
'packetLossRatio',
'rxBitrate',
'txBitrate',
88 'fiveTuple',
'packetSizeMean',
'probe_stats_unsorted',
89 'hopCount',
'flowInterruptionsHistogram',
'rx_duration']
92 @param self The object pointer.
93 @param flow_el The element.
96 rxPackets = float(flow_el.get(
'rxPackets'))
97 txPackets = float(flow_el.get(
'txPackets'))
99 tx_duration = (parse_time_ns (flow_el.get(
'timeLastTxPacket')) -
parse_time_ns(flow_el.get(
'timeFirstTxPacket')))*1e-9
100 rx_duration = (parse_time_ns (flow_el.get(
'timeLastRxPacket')) -
parse_time_ns(flow_el.get(
'timeFirstRxPacket')))*1e-9
104 self.
hopCounthopCount = float(flow_el.get(
'timesForwarded')) / rxPackets + 1
108 self.
delayMeandelayMean = float(flow_el.get(
'delaySum')[:-2]) / rxPackets * 1e-9
114 self.
rxBitraterxBitrate = float(flow_el.get(
'rxBytes'))*8 / rx_duration
118 self.
txBitratetxBitrate = float(flow_el.get(
'txBytes'))*8 / tx_duration
121 lost = float(flow_el.get(
'lostPackets'))
128 interrupt_hist_elem = flow_el.find(
"flowInterruptionsHistogram")
129 if interrupt_hist_elem
is None:
143 __slots_ = [
'probeId',
'packets',
'bytes',
'delayFromFirstProbe']
151 '''! The initializer.
152 @param self The object pointer.
153 @param simulation_el The element.
156 FlowClassifier_el, = simulation_el.findall(
"Ipv4FlowClassifier")
158 for flow_el
in simulation_el.findall(
"FlowStats/Flow"):
160 flow_map[flow.flowId] = flow
161 self.
flowsflows.append(flow)
162 for flow_cls
in FlowClassifier_el.findall(
"Flow"):
163 flowId =
int(flow_cls.get(
'flowId'))
164 flow_map[flowId].fiveTuple =
FiveTuple(flow_cls)
166 for probe_elem
in simulation_el.findall(
"FlowProbes/FlowProbe"):
167 probeId =
int(probe_elem.get(
'index'))
168 for stats
in probe_elem.findall(
"FlowStats"):
169 flowId =
int(stats.get(
'flowId'))
171 s.packets =
int(stats.get(
'packets'))
172 s.bytes = float(stats.get(
'bytes'))
175 s.delayFromFirstProbe =
parse_time_ns(stats.get(
'delayFromFirstProbeSum')) / float(s.packets)
177 s.delayFromFirstProbe = 0
178 flow_map[flowId].probe_stats_unsorted.append(s)
182 file_obj = open(argv[1])
183 print(
"Reading XML file ", end=
" ")
188 for event, elem
in ElementTree.iterparse(file_obj, events=(
"start",
"end")):
193 if level == 0
and elem.tag ==
'FlowMonitor':
197 sys.stdout.write(
".")
203 for flow
in sim.flows:
205 proto = {6:
'TCP', 17:
'UDP'} [t.protocol]
206 print(
"FlowID: %i (%s %s/%s --> %s/%i)" % \
207 (flow.flowId, proto, t.sourceAddress, t.sourcePort, t.destinationAddress, t.destinationPort))
208 if flow.txBitrate
is None:
209 print(
"\tTX bitrate: None")
211 print(
"\tTX bitrate: %.2f kbit/s" % (flow.txBitrate*1e-3,))
212 if flow.rxBitrate
is None:
213 print(
"\tRX bitrate: None")
215 print(
"\tRX bitrate: %.2f kbit/s" % (flow.rxBitrate*1e-3,))
216 if flow.delayMean
is None:
217 print(
"\tMean Delay: None")
219 print(
"\tMean Delay: %.2f ms" % (flow.delayMean*1e3,))
220 if flow.packetLossRatio
is None:
221 print(
"\tPacket Loss Ratio: None")
223 print(
"\tPacket Loss Ratio: %.2f %%" % (flow.packetLossRatio*100))
226 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.