hardcode speed to be 4 Mbps as the mininet reports the wrong one

parent f0d96220
......@@ -38,18 +38,23 @@ class SimpleMonitor(simple_switch_13.SimpleSwitch13):
'pktError':0,
'timeStamp':0
}
hardcode_speed = 4194304
if ev.state == MAIN_DISPATCHER:
if not datapath.id in self.datapaths:
self.logger.debug('register datapath: %016x', datapath.id)
self.logger.info('register datapath: %016x', datapath.id)
self.datapaths[datapath.id] = datapath
for port,desc in datapath.ports.items():
self.logger.info('bw : %s', str(desc))
bwDBEntry['port']=port
bwDBEntry['bandwidth']=(desc.curr_speed) / (8*1024) #bps -> KBps
self.logger.debug('bw : %d', desc.curr_speed)
#mininet bug speed reported is always 10 Mbps
#bwDBEntry['bandwidth']=(desc.curr_speed) / (8*1024) #bps -> KBps
bwDBEntry['bandwidth']=(hardcode_speed) / (8*1024) #bps -> KBps
self.logger.info('bw : reported:%d hard:%d', desc.curr_speed,
hardcode_speed)
bwDB.insertBWDBDict(bwDBEntry);
elif ev.state == DEAD_DISPATCHER:
if datapath.id in self.datapaths:
self.logger.debug('unregister datapath: %016x', datapath.id)
self.logger.info('unregister datapath: %016x', datapath.id)
for port in datapath.ports:
bwDBEntry['port']=port
bwDB.deleteBWDict(bwDBEntry);
......@@ -63,16 +68,16 @@ class SimpleMonitor(simple_switch_13.SimpleSwitch13):
self._request_stats(dp, port)
'''
meterList = tapDB.getMeterIDs({'dpid':dpid_to_str(dp.id)})
self.logger.debug('meter: %s', str(meterList))
self.logger.info('meter: %s', str(meterList))
for meterID in meterList:
self.logger.debug('meterID: %d', int(meterID))
self.logger.info('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):
self.logger.debug('send meter stats request: %016x with meterID: %d',
self.logger.info('send meter stats request: %016x with meterID: %d',
datapath.id, meterID)
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
......@@ -80,7 +85,7 @@ class SimpleMonitor(simple_switch_13.SimpleSwitch13):
datapath.send_msg(req)
def _request_stats(self, datapath, port):
self.logger.debug('send stats request: %016x for port: %d',
self.logger.info('send stats request: %016x for port: %d',
datapath.id, port)
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
......@@ -90,10 +95,10 @@ class SimpleMonitor(simple_switch_13.SimpleSwitch13):
@set_ev_cls(ofp_event.EventOFPMeterConfigStatsReply, MAIN_DISPATCHER)
def _meter_stats_reply_handler(self, ev):
self.logger.debug("_meter_stats_reply_handler : %s", str(ev.msg.body))
self.logger.info("_meter_stats_reply_handler : %s", str(ev.msg.body))
dp_str = dpid_to_str(ev.msg.datapath.id)
for stat in ev.msg.body:
self.logger.debug('meter_id=0x%08x len=%d flow_count=%d '
self.logger.info('meter_id=0x%08x len=%d flow_count=%d '
'band_stats=%s' %
(stat.meter_id, stat.length, stat.flow_count,
stat.band_stats))
......@@ -136,5 +141,5 @@ class SimpleMonitor(simple_switch_13.SimpleSwitch13):
'txDrops':stat.tx_dropped,
'timeStamp':stat.duration_sec
};
self.logger.debug('bwDbEntry: %s', str(bwDbEntry))
self.logger.info('bwDbEntry: %s', str(bwDbEntry))
bwDB.updateBWDict(bwDbEntry);
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