1.1 --- a/utils/flowmon/plot.py Thu May 21 11:05:55 2009 +0100
1.2 +++ b/utils/flowmon/plot.py Thu May 21 14:14:12 2009 +0100
1.3 @@ -6,7 +6,7 @@
1.4 except ImportError:
1.5 from xml.etree import ElementTree
1.6 import bz2
1.7 -
1.8 +from array import array
1.9
1.10 class ConfidenceValue(object):
1.11
1.12 @@ -43,6 +43,28 @@
1.13 return self._error
1.14
1.15
1.16 +class Flow(object):
1.17 + __slots__ = ['flowId', 'delayMean', 'packetLossRatio', 'rxBitrate', 'txBitrate']
1.18 + def __init__(self, flow_el):
1.19 + self.flowId = int(flow_el.get('flowId'))
1.20 + rxPackets = long(flow_el.get('rxPackets'))
1.21 + txPackets = long(flow_el.get('txPackets'))
1.22 + tx_duration = float(long(flow_el.get('timeLastTxPacket')[:-2]) - long(flow_el.get('timeFirstTxPacket')[:-2]))*1e-9
1.23 + rx_duration = float(long(flow_el.get('timeLastRxPacket')[:-2]) - long(flow_el.get('timeFirstRxPacket')[:-2]))*1e-9
1.24 +
1.25 + if rxPackets:
1.26 + self.delayMean = float(flow_el.get('delaySum')[:-2]) / rxPackets * 1e-9
1.27 + else:
1.28 + self.delayMean = None
1.29 + if rx_duration > 0:
1.30 + self.rxBitrate = long(flow_el.get('rxBytes'))*8 / rx_duration
1.31 + else:
1.32 + self.rxBitrate = None
1.33 + self.txBitrate = long(flow_el.get('txBytes'))*8 / tx_duration
1.34 + self.packetLossRatio = float(flow_el.get('lostPackets')) / txPackets
1.35 +
1.36 +
1.37 +
1.38 class SimulationResults(object):
1.39 def __init__(self, results_el):
1.40 self.cpu_time = float(results_el.attrib['cpu-time'])
1.41 @@ -53,6 +75,7 @@
1.42 "False": False} [results_el.attrib['enable-monitor']]
1.43 self.max_memory = long(results_el.attrib['max-memory'])
1.44 self.num_nodes_side = int(results_el.attrib['num-nodes-side'])
1.45 + self.flows = [Flow(el) for el in results_el.findall('FlowMonitor/FlowStats/Flow')]
1.46
1.47
1.48 class ResultsDb(object):
1.49 @@ -85,10 +108,52 @@
1.50 results.read_results_file(fname)
1.51 print "Read %i simulations." % (len(results.simulations),)
1.52
1.53 - performance_results(results)
1.54 + #performance_results(results)
1.55 + histograms(results, num_nodes_side=20)
1.56
1.57
1.58 +def histograms(results, num_nodes_side):
1.59 + delays = array('d')
1.60 + losses = array('d')
1.61 + rx_bitrates = array('d')
1.62 + tx_bitrates = array('d')
1.63 + for sim in results.simulations:
1.64 + if sim.num_nodes_side != num_nodes_side:
1.65 + continue
1.66 + if not sim.enable_monitor:
1.67 + continue
1.68 + for flow in sim.flows:
1.69 + if flow.delayMean is not None:
1.70 + delays.append(flow.delayMean)
1.71 + losses.append(flow.packetLossRatio)
1.72 + if flow.rxBitrate is not None:
1.73 + rx_bitrates.append(flow.rxBitrate)
1.74 + tx_bitrates.append(flow.txBitrate)
1.75
1.76 + pylab.subplot(221)
1.77 + pylab.xlabel("Delay (s)")
1.78 + pylab.ylabel("Number of Flows")
1.79 + pylab.hist(delays, 20)
1.80 +
1.81 + pylab.subplot(222)
1.82 + pylab.xlabel("Packet Loss Ratio")
1.83 + pylab.ylabel("Number of Flows")
1.84 + pylab.hist(losses, 20)
1.85 +
1.86 + pylab.subplot(223)
1.87 + pylab.xlabel("Transmitted Bitrate (bit/s)")
1.88 + pylab.ylabel("Number of Flows")
1.89 + pylab.hist(tx_bitrates, 20)
1.90 +
1.91 + pylab.subplot(224)
1.92 + pylab.xlabel("Received Bitrate (bit/s)")
1.93 + pylab.ylabel("Number of Flows")
1.94 + pylab.hist(rx_bitrates, 20)
1.95 +
1.96 +
1.97 + pylab.show()
1.98 +
1.99 +
1.100
1.101 def performance_results(results):
1.102 cpu_time_no_monitor = []