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. 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.
bins.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. 102 rxPackets = long(flow_el.get(
'rxPackets'))
103 txPackets = long(flow_el.get(
'txPackets'))
104 tx_duration = float(long(flow_el.get(
'timeLastTxPacket')[:-4]) - long(flow_el.get(
'timeFirstTxPacket')[:-4]))*1e-9
105 rx_duration = float(long(flow_el.get(
'timeLastRxPacket')[:-4]) - long(flow_el.get(
'timeFirstRxPacket')[:-4]))*1e-9
109 self.
hopCount = float(flow_el.get(
'timesForwarded')) / rxPackets + 1
113 self.
delayMean = float(flow_el.get(
'delaySum')[:-4]) / rxPackets * 1e-9
119 self.
rxBitrate = long(flow_el.get(
'rxBytes'))*8 / rx_duration
123 self.
txBitrate = long(flow_el.get(
'txBytes'))*8 / tx_duration
126 lost = float(flow_el.get(
'lostPackets'))
133 interrupt_hist_elem = flow_el.find(
"flowInterruptionsHistogram")
134 if interrupt_hist_elem
is None:
152 __slots__ = [
'probeId',
'packets',
'bytes',
'delayFromFirstProbe']
161 @param self The object pointer. 162 @param simulation_el The element. 165 FlowClassifier_el, = simulation_el.findall(
"Ipv4FlowClassifier")
167 for flow_el
in simulation_el.findall(
"FlowStats/Flow"):
169 flow_map[flow.flowId] = flow
170 self.
flows.append(flow)
171 for flow_cls
in FlowClassifier_el.findall(
"Flow"):
172 flowId = int(flow_cls.get(
'flowId'))
173 flow_map[flowId].fiveTuple =
FiveTuple(flow_cls)
175 for probe_elem
in simulation_el.findall(
"FlowProbes/FlowProbe"):
176 probeId = int(probe_elem.get(
'index'))
177 for stats
in probe_elem.findall(
"FlowStats"):
178 flowId = int(stats.get(
'flowId'))
180 s.packets = int(stats.get(
'packets'))
181 s.bytes = long(stats.get(
'bytes'))
184 s.delayFromFirstProbe =
parse_time_ns(stats.get(
'delayFromFirstProbeSum')) / float(s.packets)
186 s.delayFromFirstProbe = 0
187 flow_map[flowId].probe_stats_unsorted.append(s)
191 file_obj = open(argv[1])
192 print "Reading XML file ",
197 for event, elem
in ElementTree.iterparse(file_obj, events=(
"start",
"end")):
202 if level == 0
and elem.tag ==
'FlowMonitor':
206 sys.stdout.write(
".")
212 for flow
in sim.flows:
214 proto = {6:
'TCP', 17:
'UDP'} [t.protocol]
215 print "FlowID: %i (%s %s/%s --> %s/%i)" % \
216 (flow.flowId, proto, t.sourceAddress, t.sourcePort, t.destinationAddress, t.destinationPort)
217 if flow.txBitrate
is None:
218 print "\tTX bitrate: None" 220 print "\tTX bitrate: %.2f kbit/s" % (flow.txBitrate*1e-3,)
221 if flow.rxBitrate
is None:
222 print "\tRX bitrate: None" 224 print "\tRX bitrate: %.2f kbit/s" % (flow.rxBitrate*1e-3,)
225 if flow.delayMean
is None:
226 print "\tMean Delay: None" 228 print "\tMean Delay: %.2f ms" % (flow.delayMean*1e3,)
229 if flow.packetLossRatio
is None:
230 print "\tPacket Loss Ratio: None" 232 print "\tPacket Loss Ratio: %.2f %%" % (flow.packetLossRatio*100)
235 if __name__ ==
'__main__':
def __init__(self, simulation_el)
bins
class variableshistogram bins
def __init__(self, flow_el)
flowInterruptionsHistogram
flow histogram
def __init__(self, el=None)
sourceAddress
class variablessource address
packetSizeMean
packet size mean
destinationPort
destination port
flowId
class variablesdelay ID
packetLossRatio
packet loss ratio
probe_stats_unsorted
unsirted probe stats
destinationAddress
destination address
rxBitrate
receive bit rate
txBitrate
transmit bit rate
rx_duration
receive duration
flows
class variableslist of flows