Exemplo n.º 1
0
 def addToTC(self):
     self.__assignTC_ID()
     bw_main.getTCRunner().addClass(self.getInterfaceName(),
                                    "parent 1:%s" % self.__getParentTC_ID(),
                                    "classid 1:%s" % self.getTC_ID(), "htb",
                                    "rate %skbit" % self.getRate(),
                                    "ceil %skbit" % self.getCeil(),
                                    "quantum %s" % self.quantum)
Exemplo n.º 2
0
    def __updateTC(self):
	bw_main.getTCRunner().changeClass(self.getInterfaceName(),
				       "parent 1:%s"%self.__getParentTC_ID(),
				       "classid 1:%s"%self.getTC_ID(),
				       "htb",
				       "rate %skbit"%self.getRate(),
				       "ceil %skbit"%self.getCeil(),
				       "quantum %s"%self.quantum)
Exemplo n.º 3
0
    def addToTC(self):
	self.__assignTC_ID()
	bw_main.getTCRunner().addClass(self.getInterfaceName(),
				       "parent 1:%s"%self.__getParentTC_ID(),
				       "classid 1:%s"%self.getTC_ID(),
				       "htb",
				       "rate %skbit"%self.getRate(),
				       "ceil %skbit"%self.getCeil(),
				       "quantum %s"%self.quantum)
Exemplo n.º 4
0
 def __addDefaultClassAndFilter(self, mark_id, parent_id):
     """
         add default service limit class
         mark_id(int): mark number to user with iptables
         parent_id(int): parent minor id of default class
     """
     minor_id = self.__getNewMinorTC_ID()
     self.default_minor_id = minor_id
     bw_main.getTCRunner().addClass(
         self.getLeafObj().getInterfaceName(), "parent 1:%s" % parent_id,
         "classid 1:%s" % minor_id, "htb",
         "rate %skbit" % self.getLeafObj().getDefaultRate(),
         "ceil %skbit" % self.getLeafObj().getDefaultCeil(), "quantum 3000")
     bw_main.getIPTablesRunner().addMark(mark_id, self.ip_addr,
                                         self.direction, None)
     bw_main.getTCRunner().addFilter(self.getLeafObj().getInterfaceName(),
                                     "protocol ip", "prio 1",
                                     "handle %s fw" % mark_id,
                                     "flowid 1:%s" % minor_id)
Exemplo n.º 5
0
    def __addTotalClass(self):
        """
            add Total Limit class
        """
        if self.getLeafObj().getTotalRate() >= 0:
            _id = self.__getNewMinorTC_ID()
            self.total_minor_id = _id
            bw_main.getTCRunner().addClass(
                self.getLeafObj().getInterfaceName(),
                "parent 1:%s" % self.getLeafObj().getParentNode().getTC_ID(),
                "classid 1:%s" % _id, "htb",
                "rate %skbit" % self.getLeafObj().getTotalRate(),
                "ceil %skbit" % self.getLeafObj().getTotalCeil(),
                "quantum 3000")

            all_parent_id = _id
        else:
            all_parent_id = self.getLeafObj().getParentNode().getTC_ID()

        return all_parent_id
Exemplo n.º 6
0
 def __addService(self, leaf_service, mark_id, parent_id):
     """
         add service limit in "leaf_service"
         mark_id(int): mark number to user with iptables
         parent_id(int): parent minor id of class
     """
     minor_id = self.__getNewMinorTC_ID()
     self.service_minor_ids.append(minor_id)
     bw_main.getTCRunner().addClass(self.getLeafObj().getInterfaceName(),
                                    "parent 1:%s" % parent_id,
                                    "classid 1:%s" % minor_id, "htb",
                                    "rate %skbit" % leaf_service.getRate(),
                                    "ceil %skbit" % leaf_service.getCeil(),
                                    "quantum 3000")
     bw_main.getIPTablesRunner().addMark(mark_id, self.ip_addr,
                                         self.direction, leaf_service)
     bw_main.getTCRunner().addFilter(self.getLeafObj().getInterfaceName(),
                                     "protocol ip", "prio 1",
                                     "handle %s fw" % mark_id,
                                     "flowid 1:%s" % minor_id)
Exemplo n.º 7
0
    def __addTotalClass(self):
	"""
	    add Total Limit class
	"""
	if self.getLeafObj().getTotalRate()>=0:
	    _id=self.__getNewMinorTC_ID()
	    self.total_minor_id=_id
	    bw_main.getTCRunner().addClass(self.getLeafObj().getInterfaceName(),
				           "parent 1:%s"%self.getLeafObj().getParentNode().getTC_ID(),
					   "classid 1:%s"%_id,
					   "htb",
					   "rate %skbit"%self.getLeafObj().getTotalRate(),
					   "ceil %skbit"%self.getLeafObj().getTotalCeil(),
					   "quantum 3000")

	    all_parent_id=_id
	else:
	    all_parent_id=self.getLeafObj().getParentNode().getTC_ID()
	    
	return all_parent_id
Exemplo n.º 8
0
    def __addDefaultClassAndFilter(self,mark_id,parent_id):
	"""
	    add default service limit class
	    mark_id(int): mark number to user with iptables
	    parent_id(int): parent minor id of default class
	"""
	minor_id=self.__getNewMinorTC_ID()
	self.default_minor_id=minor_id
	bw_main.getTCRunner().addClass(self.getLeafObj().getInterfaceName(),
				       "parent 1:%s"%parent_id,
				       "classid 1:%s"%minor_id,
				       "htb",
				       "rate %skbit"%self.getLeafObj().getDefaultRate(),
				       "ceil %skbit"%self.getLeafObj().getDefaultCeil(),
				       "quantum 3000")
	bw_main.getIPTablesRunner().addMark(mark_id,self.ip_addr,self.direction,None)
	bw_main.getTCRunner().addFilter(self.getLeafObj().getInterfaceName(),
					"protocol ip",
					"prio 1",
					"handle %s fw"%mark_id,
					"flowid 1:%s"%minor_id)
Exemplo n.º 9
0
    def __addService(self,leaf_service,mark_id,parent_id):
    	"""
	    add service limit in "leaf_service"
	    mark_id(int): mark number to user with iptables
	    parent_id(int): parent minor id of class
	"""
	minor_id=self.__getNewMinorTC_ID()
	self.service_minor_ids.append(minor_id)
	bw_main.getTCRunner().addClass(self.getLeafObj().getInterfaceName(),
				       "parent 1:%s"%parent_id,
				       "classid 1:%s"%minor_id,
				       "htb",
				       "rate %skbit"%leaf_service.getRate(),
				       "ceil %skbit"%leaf_service.getCeil(),
				       "quantum 3000")
	bw_main.getIPTablesRunner().addMark(mark_id,self.ip_addr,self.direction,leaf_service)
	bw_main.getTCRunner().addFilter(self.getLeafObj().getInterfaceName(),
					"protocol ip",
					"prio 1",
					"handle %s fw"%mark_id,
					"flowid 1:%s"%minor_id)
Exemplo n.º 10
0
 def __updateTC(self):
     bw_main.getTCRunner().changeClass(
         self.getInterfaceName(), "parent 1:%s" % self.__getParentTC_ID(),
         "classid 1:%s" % self.getTC_ID(), "htb",
         "rate %skbit" % self.getRate(), "ceil %skbit" % self.getCeil(),
         "quantum %s" % self.quantum)
Exemplo n.º 11
0
 def delFromTC(self):
     #self.__freeTC_ID() buggy tc doesn't delete node, so let's not release the id
     bw_main.getTCRunner().delClass(self.getInterfaceName(),
                                    "parent 1:%s" % self.__getParentTC_ID(),
                                    "classid 1:%s" % self.getTC_ID())
Exemplo n.º 12
0
 def addRootQdisc(self):
     bw_main.getTCRunner().delQdisc(self.interface_name, "root")
     bw_main.getTCRunner().addQdisc(self.interface_name, "handle 1:",
                                    "root", "htb")
Exemplo n.º 13
0
 def updateCounters(self):
     for int_name in bw_main.getLoader().getAllInterfaceNames():
         self.counters[int_name] = bw_main.getTCRunner().getCounters(
             int_name)
Exemplo n.º 14
0
from core.bandwidth_limit import bw_main

tc = bw_main.getTCRunner()
print tc.getCounters("eth0")
print bw_main.getManager().user_leaves["192.168.1.11/32"][1].getDefaultMinorTC_ID()
print bw_main.getManager().user_leaves["192.168.1.11/32"][0].getTotalMinorTC_ID()
print bw_main.getManager().getAllUserLeavesInfo()["192.168.1.11/32"]
Exemplo n.º 15
0
 def __delFilter(self, mark_id):
     bw_main.getTCRunner().delFilter(self.getLeafObj().getInterfaceName(),
                                     "protocol ip", "prio 1",
                                     "handle %s fw" % mark_id)
Exemplo n.º 16
0
    def addRootQdisc(self):
	bw_main.getTCRunner().delQdisc(self.interface_name,"root")
	bw_main.getTCRunner().addQdisc(self.interface_name,"handle 1:","root","htb")
Exemplo n.º 17
0
    def __delFilter(self,mark_id):
	bw_main.getTCRunner().delFilter(self.getLeafObj().getInterfaceName(),
					"protocol ip",
					"prio 1",
					"handle %s fw"%mark_id)
Exemplo n.º 18
0
    def __delClass(self,minor_id):
	bw_main.getTCRunner().delClass(self.getLeafObj().getInterfaceName(),
				       "classid 1:%s"%minor_id)
Exemplo n.º 19
0
    def delFromTC(self):
	#self.__freeTC_ID() buggy tc doesn't delete node, so let's not release the id
	bw_main.getTCRunner().delClass(self.getInterfaceName(),
				       "parent 1:%s"%self.__getParentTC_ID(),
				       "classid 1:%s"%self.getTC_ID())
Exemplo n.º 20
0
 def updateCounters(self):
     for int_name in bw_main.getLoader().getAllInterfaceNames():
         self.counters[int_name] = bw_main.getTCRunner().getCounters(int_name)
Exemplo n.º 21
0
 def __delClass(self, minor_id):
     bw_main.getTCRunner().delClass(self.getLeafObj().getInterfaceName(),
                                    "classid 1:%s" % minor_id)