keep ratelimit unit in KBps; modified rate-limiting algorithm to follow...

keep ratelimit unit in KBps; modified rate-limiting algorithm to follow additive increase and multiplicative decrease to keep the traffic throughput with a tap at 90 to 95 optimal range if higher decrease the tap traffic otherwise increase
parent 51551ec9
......@@ -236,12 +236,15 @@ class TapPolicyController(ControllerBase):
LOG.debug("tap_port: %d", tap_port)
LOG.debug("vlan_id : %d", vlan_id)
rate = 1000 * 1 #KBps -> 1Mbps
#set it to 50% of the bw
rate = 5000 * 1 #5000 Kbps -> 125 KBps
rateKBps = round(rate /8); #Kbps -> KBps
tapDbEntry= {
'dpid': dpid_pd, 'monitorPort':tap_port, 'bandwidth':10,
'trafficType':'all', 'tunnelVlan':int(vlan_id),
'destinationVlan':int(vlan_id), 'ratelimit':rate
'destinationVlan':int(vlan_id), 'ratelimit':rateKBps
}
......
......@@ -60,14 +60,15 @@ class dynamicRateLimiter(simple_switch_13.SimpleSwitch13):
bandwidth = bw.get('bandwidth')
usedbw = bw.get('usedbw')
pktError = bw.get('pktError')
ratelimit = int(tap.get('limit'))
ratelimit = int(tap.get('ratelimit'))
rateKBps = ratelimit;
tapid = int(tap.get('tapID'))
meterid = tapid +1
self.logger.info('usedbw: %d', usedbw)
max_rate_limit = (bandwidth / 2) #max limit = 50%
increment = (bandwidth *(0.1)) # 5% increment [bandwidth is in Kbps]
increment = (bandwidth *(0.05)) # 5% increment [bandwidth is in KBps]
meterdbEntry= {
'dpid':tap.get('dpid'),
......@@ -77,15 +78,20 @@ class dynamicRateLimiter(simple_switch_13.SimpleSwitch13):
'timeStamp':0
};
if (pktError > 0):
self.logger.info("Reduce the rate limiting in multiples of increment")
no_of_increments = (pktError/increment) + 1; #always have higher allocation
new_limit = increment * no_of_increments;
if (90 <= usedbw <= 100):
if (90 < usedbw <= 95):
self.logger.info("Optimal State Attained...")
return;
self.logger.info("Reduce the rate limiting rapidly by dividing it by 2")
new_limit = round(ratelimit/2 )
new_limitKbps = new_limit * 8 #KBps -> Kbps
self.logger.info("meterid[%d] Increase the rate[%d] for tunnel traffic",
meterid, new_limit)
of = datapath.ofproto
ofp = datapath.ofproto_parser
burst_size = 0
bands = []
bands.append(ofp.OFPMeterBandDrop(new_limit, burst_size))
bands.append(ofp.OFPMeterBandDrop(new_limitKbps, burst_size))
meter_mod = ofp.OFPMeterMod(datapath, of.OFPMC_MODIFY,
(of.OFPMF_KBPS), meterid, bands)
datapath.send_msg(meter_mod)
......@@ -97,26 +103,23 @@ class dynamicRateLimiter(simple_switch_13.SimpleSwitch13):
tapDB.udpateRateLimit(rateEntry)
#meterDB.resetMeterEntry(meterdbEntry);
return ;
if ratelimit == max_rate_limit:
self.logger.info("Already at maximum time ratelimit")
return ;
if (usedbw < 100): #less than 50%
if (usedbw > ratelimit):
self.logger.info("Higher service traffic .. don't grow")
else:
self.logger.info("Increasing the rate limit additively..")
if rateKBps == max_rate_limit:
self.logger.info("Already at maximum time ratelimit")
return ;
new_limit = ratelimit + increment;
new_limit = round(rateKBps + increment);
if new_limit > max_rate_limit:
new_limit = max_rate_limit;
new_limit = new_limit * 8 #KBps -> kbps
new_limitKbps = new_limit * 8 #KBps -> Kbps
self.logger.info("meterid[%d] Increase the rate[%d] for tunnel traffic",
meterid, new_limit)
of = datapath.ofproto
ofp = datapath.ofproto_parser
burst_size = 0
bands = []
bands.append(ofp.OFPMeterBandDrop(new_limit, burst_size))
bands.append(ofp.OFPMeterBandDrop(new_limitKbps, burst_size))
meter_mod = ofp.OFPMeterMod(datapath, of.OFPMC_MODIFY,
of.OFPMF_KBPS, meterid, bands)
datapath.send_msg(meter_mod)
......
......@@ -177,7 +177,7 @@ def updateBWDict(bwDBEntry):
cursor = conn.cursor()
rc = True;
meterlimit = (tapDB.getTapRateLimit(bwDBEntry)).get('limit')
meterlimit = (tapDB.getTapRateLimit(bwDBEntry)).get('ratelimit')
try:
cursor.execute("""
......@@ -205,7 +205,7 @@ def updateBWDict(bwDBEntry):
try:
KB = ((float(newBytes))/(1024)); #bytes -> KB
rate = (KB/sec); #KBps
serviceTrafficRate = rate - meterlimit;
serviceTrafficRate = rate;
utilization = ((float((serviceTrafficRate) * 100 )/bandwidth))
#in percentage
except ZeroDivisionError:
......
......@@ -303,10 +303,10 @@ def getTapRateLimit(rateEntry):
rateEntry);
row = cursor.fetchone();
if row is not None:
rateEntry['limit'] = (row[0]/8); #kbps -> KBps
rateEntry['ratelimit'] = row[0];
rateEntry['tapID'] = row[1];
else:
rateEntry['limit'] = 0;
rateEntry['ratelimit'] = 0;
rateEntry['tapID'] = 0;
except sql.Error as e:
......@@ -453,7 +453,7 @@ def getAllTapMeters():
'tapID':row[0],
'dpid':row[1],
'port':row[2],
'limit':(row[3]/8) #kbps -> KBps
'ratelimit':(row[3]) #kbps -> KBps
}
print rowDict;
tapList.append(rowDict);
......
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