finally bw measuring works perfectly: bits and bytes miscalculation corrected

parent 0d2e0f98
<?xml version="1.0"?>
<data>
<switch>
<name>switcha</name>
<dpid>0000000000000001</dpid>
</switch>
<switch>
<name>switchb</name>
<dpid>0000000000000002</dpid>
</switch>
<switch>
<name>switchc</name>
<dpid>0000000000000003</dpid>
</switch>
<links>
<src>0000000000000001</src>
<dst>0000000000000002</dst>
<port>3</port>
<emulabvlan>369</emulabvlan>
</links>
<links>
<src>0000000000000002</src>
<dst>0000000000000001</dst>
<port>1</port>
<emulabvlan>369</emulabvlan>
</links>
<links>
<src>0000000000000002</src>
<dst>0000000000000003</dst>
<port>3</port>
<emulabvlan>368</emulabvlan>
</links>
<links>
<src>0000000000000003</src>
<dst>0000000000000002</dst>
<port>1</port>
<emulabvlan>368</emulabvlan>
</links>
<host>
<name>h1</name>
<mac>00:00:00:00:00:21</mac>
<switch>0000000000000001</switch>
<port>1</port>
<emulabvlan>366</emulabvlan>
</host>
<host>
<name>h2</name>
<mac>00:00:00:00:00:22</mac>
<switch>0000000000000001</switch>
<port>2</port>
<emulabvlan>370</emulabvlan>
</host>
<host>
<name>h3</name>
<mac>00:00:00:00:00:23</mac>
<switch>0000000000000002</switch>
<port>2</port>
<emulabvlan>367</emulabvlan>
</host>
<localcloudgateway>
<name>switchc</name>
<switchdpid>0000000000000003</switchdpid>
<outport>2</outport>
<emulabvlan>371</emulabvlan>
</localcloudgateway>
</data>
......@@ -44,7 +44,7 @@ class SimpleMonitor(simple_switch_13.SimpleSwitch13):
self.datapaths[datapath.id] = datapath
for port,desc in datapath.ports.items():
bwDBEntry['port']=port
bwDBEntry['bandwidth']=(desc.curr_speed) / (1024) #Bps -> KBps
bwDBEntry['bandwidth']=(desc.curr_speed) / (8*1024) #bps -> KBps
self.logger.debug('bw : %d', desc.curr_speed)
bwDB.insertBWDBDict(bwDBEntry);
elif ev.state == DEAD_DISPATCHER:
......@@ -58,6 +58,7 @@ class SimpleMonitor(simple_switch_13.SimpleSwitch13):
def _monitor(self):
while True:
for dp in self.datapaths.values():
'''
portList = tapDB.getTapPortsForSwitch({'dpid':dpid_to_str(dp.id)})
for port in portList:
self._request_stats(dp, port)
......@@ -66,6 +67,8 @@ class SimpleMonitor(simple_switch_13.SimpleSwitch13):
for meterID in meterList:
self.logger.debug('meterID: %d', int(meterID))
self._request_mstats(dp, meterID);
'''
self._request_stats(dp, dp.ofproto.OFPP_ANY)
hub.sleep(10)
def _request_mstats(self, datapath, meterID):
......
......@@ -205,7 +205,8 @@ def updateBWDict(bwDBEntry):
KB = ((float(newBytes))/(1024)); #bytes -> KB
rate = (KB/sec); #KBps
serviceTrafficRate = rate - meterRxRate ;
utilization = ((serviceTrafficRate/float(bandwidth)) * 100) #in percentage
utilization = ((float((serviceTrafficRate) * 100 )/bandwidth))
#in percentage
except ZeroDivisionError:
log.info("division by zero error skip update")
rate = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment