Ejemplo n.º 1
0
 def __init__(self, domain, traffic_type, policy_type, src_dvg, dst_dvg, ttl, action):
     '''
     Constructor:
     @param domain: The Domain Object
     @type domain: Domain
     @param traffic_type: The Traffic Type (0: Unicast, 1:Multicast)
     @type traffic_type: Integer
     @param policy_type: The Policy Type
     @type policy_type: Integer
     @param src_dvg: The Source DVG Object
     @type src_dvg: DVG
     @param dst_dvg: The Destination DVG Object
     @type dst_dvg: DVG
     @param ttl: Time-To-Live cached in DPS client
     @type ttl: Integer
     @param action: Action taken to traffic from Source DVG to destination DVG
     @type action: IPAddressList or Integer depends on action_type
     @raise DOVE_STATUS_INVALID_POLICY: Bad policy type
     '''
     #Based on Object Model Chapter 5: Policy Object
     if policy_type <= 0 or policy_type >= self.type_bad:
         raise DOVEStatus.DOVE_STATUS_INVALID_POLICY
     if policy_type == self.type_ip_list:
         raise DOVEStatus.DOVE_STATUS_NOT_SUPPORTED
     self.domain = domain
     self.traffic_type = traffic_type
     self.type = policy_type
     self.src_dvg = src_dvg
     self.dst_dvg = dst_dvg
     self.ttl = ttl
     self.action = action
     action_struct  = struct.unpack(self.fmt_action_struct_hdr,
                                    self.action[:self.fmt_action_struct_hdr_size])
     self.action_connectivity = self.action_drop
     if self.type == self.type_connectivity:
         self.action_connectivity = action_struct[2] #3rd parameter
     self.version = action_struct[0]
     self.key = self.key_fmt%(src_dvg.unique_id, dst_dvg.unique_id)
     #TODO: Store the Policy result in a packed data format that
     #      can be sent to the C Code when needed.
     #
     #############################################################
     dcs_object.__init__(self, self.key)
     #############################################################
     #Add the policy into a Policy_Hash table in a domain,
     #source DVG and destination DVG
     #############################################################
     Domain.policy_add(self.domain, self)
     DVG.policy_add_src(src_dvg, dst_dvg.unique_id, self)
     DVG.policy_add_dst(dst_dvg, src_dvg.unique_id, self)
Ejemplo n.º 2
0
 def __init__(self, domain, traffic_type, policy_type, src_dvg, dst_dvg, ttl, action):
     """
     Constructor:
     @param domain: The Domain Object
     @type domain: Domain
     @param traffic_type: The Traffic Type (0: Unicast, 1:Multicast)
     @type traffic_type: Integer
     @param policy_type: The Policy Type
     @type policy_type: Integer
     @param src_dvg: The Source DVG Object
     @type src_dvg: DVG
     @param dst_dvg: The Destination DVG Object
     @type dst_dvg: DVG
     @param ttl: Time-To-Live cached in DPS client
     @type ttl: Integer
     @param action: Action taken to traffic from Source DVG to destination DVG
     @type action: IPAddressList or Integer depends on action_type
     @raise DOVE_STATUS_INVALID_POLICY: Bad policy type
     """
     # Based on Object Model Chapter 5: Policy Object
     if policy_type <= 0 or policy_type >= self.type_bad:
         raise DOVEStatus.DOVE_STATUS_INVALID_POLICY
     if policy_type == self.type_ip_list:
         raise DOVEStatus.DOVE_STATUS_NOT_SUPPORTED
     self.domain = domain
     self.traffic_type = traffic_type
     self.type = policy_type
     self.src_dvg = src_dvg
     self.dst_dvg = dst_dvg
     self.ttl = ttl
     self.action = action
     action_struct = struct.unpack(self.fmt_action_struct_hdr, self.action[: self.fmt_action_struct_hdr_size])
     self.action_connectivity = self.action_drop
     if self.type == self.type_connectivity:
         self.action_connectivity = action_struct[2]  # 3rd parameter
     self.version = action_struct[0]
     self.key = self.key_fmt % (src_dvg.unique_id, dst_dvg.unique_id)
     # TODO: Store the Policy result in a packed data format that
     #      can be sent to the C Code when needed.
     #
     #############################################################
     dcs_object.__init__(self, self.key)
     #############################################################
     # Add the policy into a Policy_Hash table in a domain,
     # source DVG and destination DVG
     #############################################################
     Domain.policy_add(self.domain, self)
     DVG.policy_add_src(src_dvg, dst_dvg.unique_id, self)
     DVG.policy_add_dst(dst_dvg, src_dvg.unique_id, self)
Ejemplo n.º 3
0
    def __init__(self, domain_id, active):
        '''
        Constructor:
        @param domain_id: The Domain ID
        @type domain_id: Integer
        @param active: Whether the Domain is active
        @type active: Boolean
        '''
        if domain_id < 0 or domain_id > 16777215:
            raise Exception ('Domain ID %s not valid'%(domain_id))
        self.IP_Subnet_List = IPSubnetList()
        self.active = active
        self.replication_factor = 1
        self.mass_transfer = None
        #Set of nodes to forward updates after Mass Transfer is complete
        #and waiting for all other nodes to see this new DPS Node
        #as part of the domain.
        self.mass_transfer_forward_nodes = {}
        #Create Timer for the Domain Object
        #Create the Replication Dictionary
        #The Replication dictionary
        self.replication_query_id_server = {}
        self.replication_query_id_client = {}
        #Based on Object Model Chapter 5.1: Domain Object
        #Collection of DVGs hashed by DVG id.
        #TODO: Add to Domain Object in Domain Object Model
        self.DVG_Hash = {}
        #############################################################
        #Endpoint Object Tables (Requirement 1.1 and 1.2)
        #############################################################
        #Endpoint Object Hash Table (IP Address)
        #Separating IPv4 and IPv6 into different Hashes since one
        #will be hashed by integer, the other string
        self.Endpoint_Hash_IPv4 = {}
        self.Endpoint_Hash_IPv6 = {}
        #Endpoint Object Hash Table (MAC Address)
        self.Endpoint_Hash_MAC = {}
        #############################################################
        #Policy Object Hash Table (Requirement 1.2)
        #The first index is for unicast policy, the second for multicast
        #############################################################
        self.Policy_Hash_DVG = [{}, {}]
        #############################################################
        #DPS Client Hash Tables (Requirement 1.5)
        #############################################################
        #This is to store the DPS Client IPs Address (Different from 
        #the DOVE Switch/Gateway IP address)
        self.DPSClients_Hash_IPv4 = {}
        self.DPSClients_Hash_IPv6 = {}
        #This is to store the Tunnel Endpoint IP Address
        self.Tunnel_Endpoints_Hash_IPv4 = {}
        self.Tunnel_Endpoints_Hash_IPv6 = {}
        #List of Implicit Gateway IP Address for this Domain
        self.ImplicitGatewayIPListv4 = IPAddressList(socket.AF_INET)
        self.ImplicitGatewayIPListv6 = IPAddressList(socket.AF_INET6)
        #Multicast Object
        self.Multicast = Multicast(self, domain_id)
        #Address Resolution
        self.AddressResolution = AddressResolution(domain_id)
        self.ConflictDetection = ConflictDetection(domain_id)
        #############################################################
        #Add the domain into DPS Collection Hash Table
        #############################################################
        DpsCollection.Domain_Hash[domain_id] = self
        #DpsCollection.VNID_Hash[domain_id] = domain_id
        #############################################################
        #Statistics 
        #############################################################
        self.Stats_Array = []
        curr_time = time.time()
        self.Stats_Array.append([curr_time, 0, 0, 0])

        self.Endpoint_Update_Count = 0
        self.Endpoint_Update_Count_Delta = 0
        self.Endpoint_Lookup_Count = 0
        self.Endpoint_Lookup_Count_Delta = 0
        self.Policy_Lookup_Count = 0
        self.Policy_Lookup_Count_Delta = 0
        self.Multicast_Lookup_Count = 0
        self.Internal_Gateway_Lookup_Count = 0
        #############################################################
        #To be finished
        #############################################################
        # Initialize the common part
        dcs_object.__init__(self, domain_id)
Ejemplo n.º 4
0
    def __init__(self, domain_id, active):
        '''
        Constructor:
        @param domain_id: The Domain ID
        @type domain_id: Integer
        @param active: Whether the Domain is active
        @type active: Boolean
        '''
        if domain_id < 0 or domain_id > 16777215:
            raise Exception('Domain ID %s not valid' % (domain_id))
        self.IP_Subnet_List = IPSubnetList()
        self.active = active
        self.replication_factor = 1
        self.mass_transfer = None
        #Set of nodes to forward updates after Mass Transfer is complete
        #and waiting for all other nodes to see this new DPS Node
        #as part of the domain.
        self.mass_transfer_forward_nodes = {}
        #Create Timer for the Domain Object
        #Create the Replication Dictionary
        #The Replication dictionary
        self.replication_query_id_server = {}
        self.replication_query_id_client = {}
        #Based on Object Model Chapter 5.1: Domain Object
        #Collection of DVGs hashed by DVG id.
        #TODO: Add to Domain Object in Domain Object Model
        self.DVG_Hash = {}
        #############################################################
        #Endpoint Object Tables (Requirement 1.1 and 1.2)
        #############################################################
        #Endpoint Object Hash Table (IP Address)
        #Separating IPv4 and IPv6 into different Hashes since one
        #will be hashed by integer, the other string
        self.Endpoint_Hash_IPv4 = {}
        self.Endpoint_Hash_IPv6 = {}
        #Endpoint Object Hash Table (MAC Address)
        self.Endpoint_Hash_MAC = {}
        #############################################################
        #Policy Object Hash Table (Requirement 1.2)
        #The first index is for unicast policy, the second for multicast
        #############################################################
        self.Policy_Hash_DVG = [{}, {}]
        #############################################################
        #DPS Client Hash Tables (Requirement 1.5)
        #############################################################
        #This is to store the DPS Client IPs Address (Different from
        #the DOVE Switch/Gateway IP address)
        self.DPSClients_Hash_IPv4 = {}
        self.DPSClients_Hash_IPv6 = {}
        #This is to store the Tunnel Endpoint IP Address
        self.Tunnel_Endpoints_Hash_IPv4 = {}
        self.Tunnel_Endpoints_Hash_IPv6 = {}
        #List of Implicit Gateway IP Address for this Domain
        self.ImplicitGatewayIPListv4 = IPAddressList(socket.AF_INET)
        self.ImplicitGatewayIPListv6 = IPAddressList(socket.AF_INET6)
        #Multicast Object
        self.Multicast = Multicast(self, domain_id)
        #Address Resolution
        self.AddressResolution = AddressResolution(domain_id)
        self.ConflictDetection = ConflictDetection(domain_id)
        #############################################################
        #Add the domain into DPS Collection Hash Table
        #############################################################
        DpsCollection.Domain_Hash[domain_id] = self
        #DpsCollection.VNID_Hash[domain_id] = domain_id
        #############################################################
        #Statistics
        #############################################################
        self.Stats_Array = []
        curr_time = time.time()
        self.Stats_Array.append([curr_time, 0, 0, 0])

        self.Endpoint_Update_Count = 0
        self.Endpoint_Update_Count_Delta = 0
        self.Endpoint_Lookup_Count = 0
        self.Endpoint_Lookup_Count_Delta = 0
        self.Policy_Lookup_Count = 0
        self.Policy_Lookup_Count_Delta = 0
        self.Multicast_Lookup_Count = 0
        self.Internal_Gateway_Lookup_Count = 0
        #############################################################
        #To be finished
        #############################################################
        # Initialize the common part
        dcs_object.__init__(self, domain_id)