示例#1
0
    def __init__(self, sw_name, vtables_num=8):
        self.topo = Topology(db="../p4/topology.db")
        self.sw_name = sw_name
        self.thrift_port = self.topo.get_thrift_port(self.sw_name)
        self.cpu_port = self.topo.get_cpu_port_index(self.sw_name)
        self.controller = SimpleSwitchAPI(self.thrift_port)

        self.custom_calcs = self.controller.get_custom_crc_calcs()
        self.sketch_register_num = len(self.custom_calcs)

        self.vtables = []
        self.vtables_num = vtables_num

        # create a pool of ids (as much as the total amount of keys)
        # this pool will be used to assign index to keys which will be
        # used to index the cached key counter and the validity register
        self.ids_pool = range(0, VTABLE_ENTRIES * VTABLE_SLOT_SIZE)

        # array of bitmap, which marks available slots per cache line
        # as 0 bits and occupied slots as 1 bits
        self.mem_pool = [0] * VTABLE_ENTRIES

        # number of memory slots used (useful for lfu eviction policy)
        self.used_mem_slots = 0

        # dictionary storing the value table index, bitmap and counter/validity
        # register index in the P4 switch that corresponds to each key
        self.key_map = {}

        self.setup()
示例#2
0
    def __init__(self, sw_name):
        self.sw_name = sw_name
        self.thrift_port = 9090
        self.cpu_port = 2
        self.controller = SimpleSwitchAPI(self.thrift_port)

        self.init()
示例#3
0
    def __init__(self, sw_name):

        self.sw_name = sw_name
        self.topo = Topology(db="topology.db")
        self.sw_name = sw_name
        self.thrift_port = self.topo.get_thrift_port(sw_name)
        self.controller = SimpleSwitchAPI(self.thrift_port)
示例#4
0
 def connect_to_switches(self):
     """Connects to all the switches in the topology and saves them
      in self.controllers.
     """
     for p4switch in self.topo.get_p4switches():
         thrift_port = self.topo.get_thrift_port(p4switch)
         self.controllers[p4switch] = SimpleSwitchAPI(thrift_port)
示例#5
0
 def __init__(self, sw_name):
     self.sw_name = sw_name
     self.topo = Topology(db='topology.db')
     self.thrift_port = self.topo.get_thrift_port(sw_name)
     self.controller = SimpleSwitchAPI(self.thrift_port)
     self.sub = None
     self.flag = 1
示例#6
0
 def __init__(self):
     self.topo = Topology(db='topology.db')
     dic = self.topo.get_p4switches()
     self.sw_name = [sw for sw in dic.keys()]
     self.controller = {
         sw: SimpleSwitchAPI(self.topo.get_thrift_port(sw))
         for sw in self.sw_name
     }
     self.multicast_table = dict()
示例#7
0
    def __init__(self, sw_name):
        #self.topo = Topology(db="topology.db")
        self.sw_name = sw_name
        self.thrift_port = 9090
        #self.thrift_port = self.topo.get_thrift_port(sw_name)
        #self.cpu_port =  self.topo.get_cpu_port_index(self.sw_name)
        self.cpu_port = 2
        self.controller = SimpleSwitchAPI(self.thrift_port)

        self.init()
示例#8
0
    def __init__(self, sw_name):
        self.topo = Topology(db="./topology.db")
        self.sw_name = sw_name
        self.thrift_port = self.topo.get_thrift_port(self.sw_name)
        self.cpu_port = self.topo.get_cpu_port_index(self.sw_name)
        self.controller = SimpleSwitchAPI(self.thrift_port)

        self.custom_calcs = self.controller.get_custom_crc_calcs()
        self.sketch_register_num = len(self.custom_calcs)

        self.setup()
 def __init__(self, sw_name, program):
     threading.Thread.__init__(self)
     if program == "f":
         self.topo = Topology(
             db="../p4src_flowsize/topology.db")  #set the topology
     elif program == "i":
         self.topo = Topology(
             db="../p4src_interval/topology.db")  #set the topology
     self.sw_name = sw_name
     self.thrift_port = self.topo.get_thrift_port(sw_name)
     self.cpu_port = self.topo.get_cpu_port_index(self.sw_name)
     self.controller = SimpleSwitchAPI(self.thrift_port)
     self.flow = {}
     self.flag = True
     self.init()
示例#10
0
    def __init__(self, topo_db, sw_name, ip_controller, port_controller, log_dir, \
        monitoring=True, routing_file=None):

        self.topo = Topology(db=topo_db)
        self.sw_name = sw_name
        self.thrift_port = self.topo.get_thrift_port(sw_name)
        self.cpu_port = self.topo.get_cpu_port_index(self.sw_name)
        self.controller = SimpleSwitchAPI(self.thrift_port)
        self.controller.reset_state()
        self.log_dir = log_dir

        print 'connecting to ', ip_controller, port_controller
        # Socket used to communicate with the controller
        self.sock_controller = socket.socket(socket.AF_INET,
                                             socket.SOCK_STREAM)
        server_address = (ip_controller, port_controller)
        self.sock_controller.connect(server_address)
        print 'Connected!'

        # Send the switch name to the controller
        self.sock_controller.sendall(str(sw_name))

        self.make_logging()

        if monitoring:
            # Monitoring scheduler
            self.t_sched = sched_timer.RepeatingTimer(10, 0.5, self.scheduling)
            self.t_sched.start()

        self.mapping_dic = {}
        tmp = list(self.topo.get_hosts()) + list(self.topo.get_p4switches())
        self.mapping_dic = {k: v for v, k in enumerate(tmp)}
        self.log.info(str(self.mapping_dic))

        self.routing_file = routing_file
        print 'routing_file ', routing_file
        if self.routing_file is not None:
            json_data = open(self.routing_file)
            self.topo_routing = json.load(json_data)
 def connect_to_switches(self):
     for p4switch in self.topo.get_p4switches():
         thrift_port = self.topo.get_thrift_port(p4switch)
         self.controllers[p4switch] = SimpleSwitchAPI(thrift_port)
示例#12
0
 def __init__(self, *args, **kwargs):
     self._switch_api = SimpleSwitchAPI(*args, **kwargs)
示例#13
0
 def connect_to_switches(self):
     for p4switch in self.topo.get_p4switches():
         thrift_port = self.topo.get_thrift_port(p4switch)
         #print "p4switch:", p4switch, "thrift_port:", thrift_port
         self.controllers[p4switch] = SimpleSwitchAPI(thrift_port)