Example #1
0
  def __init__ (self, topo_graph):
    # Set up a logger...
    self.log = _log.getChild("main")

    # Save the graph as an instance attribute.
    self.graph = topo_graph
    self.down_switches = {} # Dictionary of down switches
    self.hosts = {} # Dictionary of hosts and their attached switch
    self.edge = {} # Dictionary of edge switches
    self.MST = None # MST of network
    self.down_links = {} # Dictionary of down links

    # Container for our ACL list, or None if we don't have any ACLs.
    # foreach ace in acl_list
    # mode = ace["mode"]
    # src = ace["ether_src"]
    # dst = ace["ether_dst"]
    self.acl_list = None
    # If we should even look at ACLs. Could make this a commandline switch, but nope.
    self.ACL_FEATURE_ENABLED = True
    # Cached host data so we can re-init when we receive ACLs
    self.last_host_data = None

    # This component relies on some other components.  This registers those
    # dependencies and automatically binds event listeners (such as the
    # _handle_openflow_PacketIn event listener below).
    core.listen_to_dependencies(self, components="MessengerNexus".split())
Example #2
0
 def __init__(self, idle_timeout=300):
     self.idle_timeout = idle_timeout
     self.label_table = {}  # (dpid1, dpid2, dst_subnet) -> label number
     self.label_count = LABEL_START
     core.openflow.addListeners(self)
     core.listen_to_dependencies(self, ['topology_tracker', 'dhcp_server'],
                                 short_attrs=True)
Example #3
0
  def __init__ (self, inside_ip, outside_ip, gateway_ip, dns_ip, outside_port,
      dpid, subnet = None):

    self.inside_ip = inside_ip
    self.outside_ip = outside_ip
    self.gateway_ip = gateway_ip
    self.dns_ip = dns_ip # Or None
    self.outside_port = outside_port
    self.dpid = dpid
    self.subnet = subnet

    self._outside_portno = None
    self._gateway_eth = None
    self._connection = None

    # Which NAT ports have we used?
    # proto means TCP or UDP
    self._used_ports = set() # (proto,port)

    # Flow records indexed in both directions
    # match -> Record
    self._record_by_outgoing = {}
    self._record_by_incoming = {}

    core.listen_to_dependencies(self)
Example #4
0
  def __init__ (self):
    log.warning("MyExplorer Constructed.")
    core.listen_to_dependencies(self)
    # Adjacency map.  [sw1][sw2] -> port from sw1 to sw2
    self.adj = defaultdict(lambda:defaultdict(lambda:int))

    # Port map.  [sw1][sw2] -> the output port from sw1 to sw2
    self.ports = defaultdict(lambda:defaultdict(lambda:int))
    
    # Switches we know of.  [dpid] -> Switch
    self.switches = set()

    self.reset_hosts()
    # self.hosts: Hosts we know of. [macaddr (string)] -> Host
    # self.hadj: [h][sw] ->  the ports where switchs connect to the hosts
    # self.sd_pair: [h1][h2] -> source-destination pair id

    self.reset_path_tables()
    # self.path_id_table: Path ID -> Path table
    # self.sd_path_table: [Source][Destination] -> Path ID list

    # Latency test function
    self.adj_test = []
    self.sw_test  = []
    self.sw_lat   = []
    self.lat_test_timer = []
    # Does latency test Start?
    self.lat_test = False
    
    # Update step
    self.update_step  = 0
    self.update_timer = []
    self.config = Configuration()

    random.seed(time.time())
Example #5
0
 def __init__(self, lower, upper, dc, weight):
     self.lower = int(lower)
     self.upper = int(upper)
     self.dc = int(dc)
     self.weight = float(weight)
     core.listen_to_dependencies(self)
     Timer(self.dc, self._handle_timer, recurring=True)
Example #6
0
    def __init__(self, fakeways=[], arp_for_unknowns=False, wide=False):
        # These are "fake gateways" -- we'll answer ARPs for them with MAC
        # of the switch they're connected to.
        self.fakeways = set(fakeways)
        self.wide = wide

        # If this is true and we see a packet for an unknown
        # host, we'll ARP for it.
        self.arp_for_unknowns = arp_for_unknowns

        # (dpid,IP) -> expire_time
        # We use this to keep from spamming ARPs
        self.outstanding_arps = {}

        # (dpid,IP) -> [(expire_time,buffer_id,in_port), ...]
        # These are buffers we've gotten at this datapath for this IP which
        # we can't deliver because we don't know where they go.
        self.lost_buffers = {}

        # For each switch, we map IP addresses to Entries
        self.arpTable = {}

        # This timer handles expiring stuff
        self._expire_timer = Timer(5, self._handle_expiration, recurring=True)

        core.listen_to_dependencies(self)
Example #7
0
  def __init__ (self, send_cycle_time, ttl = 120):
    """
    Initialize an LLDP packet sender

    send_cycle_time is the time (in seconds) that this sender will take to
      send every discovery packet.  Thus, it should be the link timeout
      interval at most.

    ttl is the time (in seconds) for which a receiving LLDP agent should
      consider the rest of the data to be valid.  We don't use this, but
      other LLDP agents might.  Can't be 0 (this means revoke).
    """
    # Packets remaining to be sent in this cycle
    self._this_cycle = []

    # Packets we've already sent in this cycle
    self._next_cycle = []

    # Packets to send in a batch
    self._send_chunk_size = 1

    self._timer = None
    self._ttl = ttl
    self._send_cycle_time = send_cycle_time
    core.listen_to_dependencies(self)
Example #8
0
    def __init__(self, send_cycle_time, ttl=120):
        """
        Initialize an LLDP packet sender
    
        send_cycle_time is the time (in seconds) that this sender will take to
          send every discovery packet.  Thus, it should be the link timeout
          interval at most.
    
        ttl is the time (in seconds) for which a receiving LLDP agent should
          consider the rest of the data to be valid.  We don't use this, but
          other LLDP agents might.  Can't be 0 (this means revoke).
        """
        # Packets remaining to be sent in this cycle
        self._this_cycle = []

        # Packets we've already sent in this cycle
        self._next_cycle = []

        # Packets to send in a batch
        self._send_chunk_size = 1

        self._timer = None
        self._ttl = ttl
        self._send_cycle_time = send_cycle_time
        core.listen_to_dependencies(self)
Example #9
0
    def __init__(self,
                 inside_ip,
                 outside_ip,
                 gateway_ip,
                 dns_ip,
                 outside_port,
                 dpid,
                 subnet=None):

        self.inside_ip = inside_ip
        self.outside_ip = outside_ip
        self.gateway_ip = gateway_ip
        self.dns_ip = dns_ip  # Or None
        self.outside_port = outside_port
        self.dpid = dpid
        self.subnet = subnet

        self._outside_portno = None
        self._gateway_eth = None
        self._connection = None

        # Which NAT ports have we used?
        # proto means TCP or UDP
        self._used_ports = set()  # (proto,port)

        # Flow records indexed in both directions
        # match -> Record
        self._record_by_outgoing = {}
        self._record_by_incoming = {}

        core.listen_to_dependencies(self)
Example #10
0
  def __init__ (self):
    core.listen_to_dependencies(self, components=['MessengerNexus'])
    self.switches = set()
    self.links = set()
    self.hosts = set()

    self.pending = False
Example #11
0
 def __init__ (self, poll_period = DEFAULT_POLL_PERIOD):
   core.listen_to_dependencies(self, ['topology', 'openflow'])
   self.poll_period = poll_period
   self.switches = {}
   self.peak = 1 # bps
   core.openflow.addListeners(self)
   log.info("poll_period: %s", self.poll_period)
Example #12
0
 def startup():
   core.openflow.addListeners(self)
   core.openflow_discovery.addListeners(self)
   core.host_tracker.addListeners(self)
   core.listen_to_dependencies(self)
   
   self.transparent = transparent
  def __init__ (self, fakeways = [], arp_for_unknowns = False):
    # These are "fake gateways" -- we'll answer ARPs for them with MAC
    # of the switch they're connected to.
    self.fakeways = set(fakeways)

    # If this is true and we see a packet for an unknown
    # host, we'll ARP for it.
    self.arp_for_unknowns = arp_for_unknowns

    # (dpid,IP) -> expire_time
    # We use this to keep from spamming ARPs
    self.outstanding_arps = {}

    # (dpid,IP) -> [(expire_time,buffer_id,in_port), ...]
    # These are buffers we've gotten at this datapath for this IP which
    # we can't deliver because we don't know where they go.
    self.lost_buffers = {}

    # For each switch, we map IP addresses to Entries
    self.arpTable = {}

    # This timer handles expiring stuff
    self._expire_timer = Timer(5, self._handle_expiration, recurring=True)

    core.listen_to_dependencies(self)
Example #14
0
 def __init__ (self):
   core.listen_to_dependencies(self, components=['MessengerNexus', 'FlowStat'])
   #core.FlowStat.addListeners(self)
   self.pending = False
   self.keys  = ['n1-nl', 'n1-de']
   self.keys  = ['subflow 1', 'subflow 2']
   self.data = {}
  def __init__ (self, gateways = [],k ="",victim ="",limitervariation= ""):
    # Mapeamento de IP para portas
    self.arpTable = {}

    # Instalacao de gateways - Tenho DPID.
    self.gateways = set(gateways)

    # Gateways e K saltos
    self.k = k
    self.victim = victim
    
    # Mapeamento
    self.G = nx.Graph()
    self.MappingHosts = {}
    self.SwitchesToApply = []
    
    self.Trigger = False
    
    # Configuracao do Rate-Limiting 
    self.Limiter = 15
    self.LimiterVariation = limitervariation
    self.oldLimiter =  self.Limiter

    # Inicializa funcao para disparar regra e habilitar filtro.
    t = Timer(15.0, self.CalculatePath)
    t.start()

    core.openflow_discovery.addListenerByName("LinkEvent", self._handle_LinkEvent)  # listen to openflow_discovery
    core.host_tracker.addListenerByName("HostEvent", self._handle_HostEvent)  # listen to host_tracker
    core.listen_to_dependencies(self)
Example #16
0
    def __init__(self):
        """Create a Controller instance."""

        # get number of hosts and switches
        self._num_hosts, self._num_switches = comm.count_nodes()

        # counter for connected switches
        self._num_connect = 0

        # broken links
        self._bad_links = set()

        # keep track of flow entries in each switch
        self._flow_table = FlowTable()

        # mutex locks
        self._mutex_connect = Lock()
        self._mutex_link_state = Lock()

        # add event handlers
        core.listen_to_dependencies(self)

        # log DCell info
        log.info("DCellController init | dcell_k={} | dcell_n={} | num_hosts={} | num_switches={}" \
                 .format(comm.DCELL_K, comm.DCELL_N, self._num_hosts, self._num_switches))
Example #17
0
File: main.py Project: chimly/drox
    def __init__(self):
        core.listen_to_dependencies(self, listen_args={'openflow': {'priority':0}})

        if config.USE_STATIC_GATEWAY:
            bucket.gateway = config.STATIC_GATEWAY

        Timer(10, self._routing, recurring=True)
        Timer(1, self._send_FlowStatsReq, recurring=True)
	def __init__ (self, transparent):
  		core.openflow.addListeners(self)
		core.listen_to_dependencies(self)
		self.transparent = transparent
		self.hosts = {}
		# CLI
		m = Monitor()
		log.debug("Monitor added\n")
Example #19
0
 def __init__ (self):
   parent.TinyTopo.__init__(self)
   core.listen_to_dependencies(self, components=['LinkUtil'])
   core.LinkUtil.addListeners(self)
   self.util = {}
   self.node_type = {}
   self.min = None
   self.max = None
Example #20
0
  def __init__ (self,links = [], ports = [],flows = []):

    core.listen_to_dependencies(self, ['openflow_discovery','openflow_topology','flow_stats'], short_attrs=True)
    # core.listen_to_dependencies(self, ['flow_stats'], short_attrs=True)
    self.listenTo(core)
    self.links = links
    self.ports = ports
    self.flows = flows 
Example #21
0
 def __init__(self, mode=None):
     if mode is None: mode = 'stable'
     self._mode_function = getattr(type(self), '_compute_' + mode)
     self.log = log
     self.topo = Topo()
     self.switches = {}  # dpid -> Switch
     self.t = None
     core.listen_to_dependencies(self)
Example #22
0
 def __init__(self, transparent):
     core.openflow.addListeners(self)
     core.listen_to_dependencies(self)
     self.transparent = transparent
     self.hosts = {}
     # CLI
     m = Monitor()
     log.debug("Monitor added\n")
Example #23
0
  def __init__ (self,links = [], ports = [],flows = []):

    core.listen_to_dependencies(self, ['openflow_discovery','openflow_topology','flow_stats'], short_attrs=True)
    # core.listen_to_dependencies(self, ['flow_stats'], short_attrs=True)
    self.listenTo(core)
    self.links = links
    self.ports = ports
    self.flows = flows 
Example #24
0
 def __init__(self):
     parent.TinyTopo.__init__(self)
     core.listen_to_dependencies(self, components=['LinkUtil'])
     core.LinkUtil.addListeners(self)
     self.util = {}
     self.node_type = {}
     self.min = None
     self.max = None
Example #25
0
 def __init__(self):
     self.count = 0
     self.timer_count = 0
     self.call_proacitve_info = False
     core.listen_to_dependencies(self,
                                 listen_args={'openflow': {
                                     'priority': 0
                                 }})
Example #26
0
 def __init__ (self, install_flow = True, explicit_drop = True,
               link_timeout = None, eat_early_packets = False):
   self._eat_early_packets = eat_early_packets
   self._explicit_drop = explicit_drop
   self._install_flow = install_flow
   self.adjacency = {} # From Link to time.time() stamp
   # Listen with a high priority (mostly so we get PacketIns early)
   core.listen_to_dependencies(self,
       listen_args={'openflow':{'priority':0xffffffff}})
 def __init__(self):
     self.groups = {}
     self.incomplete_groups = {}
     self.group_addrs = set()
     self.member_state_builder = None
     
     core.addListeners(self)
     core.listen_to_dependencies(self, ['MemberStateBuilder'])
     core.openflow.addListeners(self)
Example #28
0
	def __init__ (self, G):

		self.G = G
		self.REQUEST_STATS_RATE = 5

		core.openflow.addListeners(self)
		core.listen_to_dependencies(self)
		self.polling_timer = Timer(self.REQUEST_STATS_RATE, self.request_stats, recurring=True)
		Timer(1, self.get_controller_usage, recurring=True)
Example #29
0
    def __init__(self):
        self._discovered_links = dict()  # maps from discovered link to time stamp
        self._lldpBroker = LLDPMessageBroker()
        self._port_authorizer = PortAuthorizer()

        # listen to events with high priorit so we get them before all others
        core.listen_to_dependencies(self, listen_args={'openflow': {'priority': 0xffffffff}})

        Timer(Discovery.LINK_TIMEOUT_CHECK_INTERVAL, self._remove_expired_links, recurring=True)
    def __init__(self):
        self._discovered_links = dict()  # maps from discovered link to time stamp
        self._lldpBroker = LLDPMessageBroker()
        self._port_authorizer = PortAuthorizer()

        # listen to events with high priorit so we get them before all others
        core.listen_to_dependencies(self, listen_args={'openflow': {'priority': 0xffffffff}})

        Timer(Discovery.LINK_TIMEOUT_CHECK_INTERVAL, self._remove_expired_links, recurring=True)
Example #31
0
 def __init__(self):
     # Create empty topology
     self.topology = None
     # Create empty dict for switches
     self.listSwitches = {}
     # Create empty list for links
     self.linkList = []
     # Fill topology with data from Topology & Openflow Topology modules
     core.listen_to_dependencies(self, ['topology'], short_attrs=True)
Example #32
0
 def __init__(self, fakeways=[], arp_for_unknowns=False, wide=False):
     self.fakeways = set(fakeways)
     self.wide = wide
     self.arp_for_unknowns = arp_for_unknowns
     self.outstanding_arps = {}
     self.lost_buffers = {}
     self.arpTable = {}
     self._expire_timer = Timer(5, self._handle_expiration, recurring=True)
     core.listen_to_dependencies(self)
Example #33
0
  def __init__ (self, path, enable_websocket=False):
    self.config = {}
    self.path = path
    if enable_websocket:
      super(POXDesk,self).__init__(websocket_path = "/poxdesk/_/ws/main",
                                   websocket_session_type = DispatcherSession)
      if 'ws' not in self.config: self.config['ws'] = {}

    core.listen_to_dependencies(self, components=["WebServer"])
Example #34
0
 def __init__(self, controller):
     self.controller = controller
     # Register listeners
     core.listen_to_dependencies(self)
     # Simple switch topology graph.
     self.topo_graph = nx.Graph()
     # Key value pairs where the keys are the switch MAC addresses
     # and values are the list of partition nodes.
     self.partitioned_graph = None # Its an nx.Graph() copy
     self.nt = NetworkType( )
Example #35
0
    def __init__(self):
        core.listen_to_dependencies(self,
                                    listen_args={'openflow': {
                                        'priority': 0
                                    }})

        if config.USE_STATIC_GATEWAY:
            bucket.gateway = config.STATIC_GATEWAY

        Timer(10, self._routing, recurring=True)
        Timer(1, self._send_FlowStatsReq, recurring=True)
Example #36
0
    def __init__(self, tableno=DEFAULT_TABLENO):
        super(LinuxRIPRouter, self).__init__()
        self.tableno = tableno

        self.init_table()
        self.init_socks()

        self.add_iface_routes()
        self.add_local_routes()

        core.listen_to_dependencies(self)
  def __init__ (self, gateways = []):
    # Mapeamento de IP para portas
    self.arpTable = {}

    # Instalacao de gateways - Tenho DPID.
    self.gateways = set(gateways)
    
    # Inicializa funcao para disparar regra e habilitar filtro.
    t = Timer(50.0, ActivateFilters)
    t.start()

    core.listen_to_dependencies(self)
Example #38
0
  def __init__(self, flow_idle_timeout=30, flow_hard_timeout=60,
                default_latency=1, default_bandwidth=100):
    core.listen_to_dependencies(self)

    self.log = core.getLogger()
    # self.path_preference_table = PathPreferenceTable.Instance()
    self.path_preference_table = PathPreferenceTable()
    self.flow_idle_timeout = flow_idle_timeout
    self.flow_hard_timeout = flow_hard_timeout
    self.default_latency = default_latency  # Milliseconds
    self.default_bandwidth = default_bandwidth  # Megabits
    self.path_preferences = dict()
Example #39
0
    def __init__(self, install_flow=True, explicit_drop=True, link_timeout=None):
        self._explicit_drop = explicit_drop
        self._install_flow = install_flow
        if link_timeout:
            self._link_timeout = link_timeout

        self.adjacency = {}  # From Link to time.time() stamp
        self._sender = LLDPSender(self._link_timeout / 2.0)

        core.listen_to_dependencies(self)

        Timer(self._timeout_check_period, self._expire_links, recurring=True)
Example #40
0
 def __init__(self, interval=10, threshold = 10000):
     '''
         interval = time between pings (seconds)
         threshold = minimum amount of port activity to print the stats (bytes)
     '''
     core.listen_to_dependencies(self)
     self.interval = interval
     self.threshold = threshold
     G = nx.Graph()
     self._db_init()
     ping_thread = threading.Thread(target = self._start_ping_switches)
     ping_thread.daemon = True
     ping_thread.start()
    def __init__ (self, host_tracker=False, pusher_stream="pox"):
        core.listen_to_dependencies(self)
        core.addListeners(self)
        self.initModel()
        self.stream = pusher_stream

        if host_tracker:
            # TODO: Don't seem to be getting host events at the moment?
            log.info("Host tracking enabled")
            host_tracker.addListenerByName("HostEvent", self.__handle_host_tracker_HostEvent)

        self.stopSyncThread = Event()
        self.syncThread = TimerThread(self.stopSyncThread, self.sync, 15)
        self.syncThread.start()
Example #42
0
 def __init__(self):
   core.listen_to_dependencies(self, components=['MessengerNexus'])
   #self.connection = connection
   self.blocked = ['00:16:3e:41:75:ed']
   self.dmz = '00:16:3e:04:0d:b7'
   self.actionhandle = "forward"
   self.hackers = {
     'hacker02':'00:16:3e:5e:21:83',
     'hacker04':'00:16:3e:65:b9:5a',
     'hacker01':'00:16:3e:41:5c:55',
     'hacker03':'00:16:3e:72:ab:44'
   }
   
   self.bad_src = [ self.hackers[i] for i in self.hackers ]
Example #43
0
    def __init__(self, fakeways=[], arp_for_unknowns=False, wide=False):
        # These are "fake gateways" -- we'll answer ARPs for them with MAC
        # of the switch they're connected to.
        self.fakeways = set(fakeways)

        # If True, we create "wide" matches.  Otherwise, we create "narrow"
        # (exact) matches.
        self.wide = wide

        # If this is true and we see a packet for an unknown
        # host, we'll ARP for it.
        self.arp_for_unknowns = arp_for_unknowns

        # (dpid,IP) -> expire_time
        # We use this to keep from spamming ARPs
        self.outstanding_arps = {}

        # (dpid,IP) -> [(expire_time,buffer_id,in_port), ...]
        # These are buffers we've gotten at this datapath for this IP which
        # we can't deliver because we don't know where they go.
        self.lost_buffers = {}

        # For each switch, we map IP addresses to Entries
        self.arpTable = {}

        #Tabela de ARP de IPServidores
        self.arpTableServidores = {
            '10.0.0.18': '00:00:00:00:03:18',
            '10.0.0.19': '00:00:00:00:03:19',
            '10.0.0.20': '00:00:00:00:03:20',
            '10.0.0.21': '00:00:00:00:03:21',
            '10.0.0.22': '00:00:00:00:03:22',
            '10.0.0.23': '00:00:00:00:03:23'
        }

        #Tabela de servidores Multicast
        self.tableIPServidores = []

        #Tabela de swtichs que contem o fluxo de determinado IP
        self.tableSwtichFluxo = {
            '00:00:00:00:00:01': [],
            '00:00:00:00:00:02': [],
            '00:00:00:00:00:03': [],
            '00:00:00:00:00:04': []
        }

        # This timer handles expiring stuff
        #self._expire_timer = Timer(5, self._handle_expiration, recurring=True)

        core.listen_to_dependencies(self)
    def __init__(self, install_flow=True, explicit_drop=True, link_timeout=None, eat_early_packets=False):
        self._eat_early_packets = eat_early_packets
        self._explicit_drop = explicit_drop
        self._install_flow = install_flow
        if link_timeout:
            self._link_timeout = link_timeout

        self.adjacency = {}  # From Link to time.time() stamp
        self._sender = LLDPSender(self.send_cycle_time)

        # Listen with a high priority (mostly so we get PacketIns early)
        core.listen_to_dependencies(self, listen_args={"openflow": {"priority": 0xFFFFFFFF}})

        Timer(self._timeout_check_period, self._expire_links, recurring=True)
    def __init__(self, host_tracker=False, pusher_stream="pox"):
        core.listen_to_dependencies(self)
        core.addListeners(self)
        self.initModel()
        self.stream = pusher_stream

        if host_tracker:
            # TODO: Don't seem to be getting host events at the moment?
            log.info("Host tracking enabled")
            host_tracker.addListenerByName(
                "HostEvent", self.__handle_host_tracker_HostEvent)

        self.stopSyncThread = Event()
        self.syncThread = TimerThread(self.stopSyncThread, self.sync, 15)
        self.syncThread.start()
Example #46
0
    def __init__(self,
                 flow_idle_timeout=30,
                 flow_hard_timeout=60,
                 default_latency=1,
                 default_bandwidth=100):
        core.listen_to_dependencies(self)

        self.log = core.getLogger()
        # self.path_preference_table = PathPreferenceTable.Instance()
        self.path_preference_table = PathPreferenceTable()
        self.flow_idle_timeout = flow_idle_timeout
        self.flow_hard_timeout = flow_hard_timeout
        self.default_latency = default_latency  # Milliseconds
        self.default_bandwidth = default_bandwidth  # Megabits
        self.path_preferences = dict()
Example #47
0
    def __init__(self, install_flow=True, explicit_drop=True,
                 link_timeout=None, eat_early_packets=False):
        self._eat_early_packets = eat_early_packets
        self._explicit_drop = explicit_drop
        self._install_flow = install_flow
        if link_timeout: self._link_timeout = link_timeout  # default: 10

        self.adjacency = {}  # From Link to time.time() stamp
        self._sender = LLDPSender(self.send_cycle_time)

        # Listen with a high priority (mostly so we get PacketIns early)
        core.listen_to_dependencies(self,
                                    listen_args={'openflow': {'priority': 0xffffffff}})

        Timer(self._timeout_check_period, self._expire_links, recurring=True)
Example #48
0
    def __init__(self, controller):
        self.controller = controller
        # Register listeners
        core.listen_to_dependencies(self)
        core.openflow.addListenerByName("ConnectionUp", self._handle_ConnectionUp)
        core.openflow.addListenerByName("ConnectionDown", self._handle_ConnectionDown)
        self.controller.ms_msg_proc.addListenerByName("ElementMachineUp", self._handle_ElementMachineUp)
        self.controller.ms_msg_proc.addListenerByName("ElementMachineDown", self._handle_ElementMachineDown)
        self.controller.ms_msg_proc.addListenerByName("ElementInstanceEvent", self._handle_ElementInstanceEvent)
        # Required to detect edge vs non-edge switches.
        # To keep track of middlebox machine location.
        core.host_tracker.addListenerByName("HostEvent", self._handle_host_tracker_HostEvent)
        def startup():
            core.openflow_discovery.addListeners(self)
        core.call_when_ready(startup, ('openflow_discovery'))

        # Data Structures.
        # Overlay Graph
        self.overlay_graph_nx = nx.DiGraph( )
        self.overlay_graph_eds = nx.DiGraph( )
        self.overlay_graph = defaultdict(Set)
        # Set of Edge switches. This set is used to add edges.
        self.edge_switches = Set([ ])
        # Set of switches that have element machines attached to them.
        self.element_switches = Set([ ])
        # Set of all the switches in the network.
        self.switches = { }# Set([ ])
        # List of MACs that are currently hosting the middleboxes.
        self.element_machines = Set([ ])
        # Keep track of hosts attached to the switches
        # This allows us to see which switch is attached to which MB machine.
        # mac -> (dpid, port)
        self.hosts = { }
        # Map of switch to middlebox element IDs.
        # so that we know when to remove the element_machine_switch
        # from the overlay graph.
        # dpid -> element descriptors.
        self.switch_to_elem_desc = defaultdict(list)
        # Unique ID for the vertex.
        self.vertex_descriptor = 0 
        # Utilization of links 
        self.phy_link_utilizations = { }
        self.max_phy_link_utilizations = { }
	self.avg_link_utilizations =  defaultdict(list)
        self.link_utilizations = { }
        # Network state callback
        Timer(5, self.update_overlay_graph_link_weights, recurring = True)
        Timer(1, self.update_physical_network_utilization, recurring = True)
Example #49
0
 def __init__(self):
     core.openflow.addListeners(self)
     self.multicast_ip = {}
     ipdb = IPDB()
     br = ipdb.interfaces[BRIDGE_INTERFACE_NAME]
     self.bridge_mac = EthAddr(br['address'])
     self.mac_permit = set()
     self.mac_whitelist = set()
     core.listen_to_dependencies(self)
     vr_all = self.get_DHCP_mapping().get_data()
     for vr in vr_all:
         val = vr['value']
         if val['state'] == 'permit':
             self.permit_mac(EthAddr(val['mac_address']))
         if val['state'] == 'deny':
             self.whitelist_mac(EthAddr(val['mac_address']))
Example #50
0
    def __init__(self, round_time=1):
        """
        round_time: time in seconds that all LLDP packets must be sent to all neighbours. it can be
                    equals to link timeout at maximum.
        """

        # hold packets that needs to be sent to neighbours.
        self._neighbours_queue = list()

        # hold packets that needs to be sen
        self._send_round_time = round_time

        self._timer = None

        # register for switch events
        core.listen_to_dependencies(self)
Example #51
0
	def __init__(self, firewall_capability, migration_capability, firewall_policy_file, migration_events_file):
		super(EventMixin, self).__init__()

		#generic controller information
		self.switches = {}	   # key=dpid, value = SwitchWithPaths instance
		self.sw_sw_ports = {}  # key = (dpid1,dpid2), value = outport of dpid1
		self.adjs = {}		   # key = dpid, value = list of neighbors
		self.arpmap = {} # key=host IP, value = (mac,dpid,port)
		self._paths_computed = False #boolean to indicate if all paths are computed (converged routing)
		self.ignored_IPs = [IPAddr("0.0.0.0"), IPAddr("255.255.255.255")] #these are used by openflow discovery module

		#invoke event listeners
		if not core.listen_to_dependencies(self, self._neededComponents):
			self.listenTo(core)
		self.listenTo(core.openflow)

		#module-specific information
		self.firewall_capability = firewall_capability
		self.migration_capability = migration_capability
		self.firewall_policies = None
		self.migration_events = None
		self.migrated_IPs = None
		if self.firewall_capability:
			self.firewall_policies = self.read_firewall_policies(firewall_policy_file)
		if self.migration_capability:
			self.migration_events = self.read_migration_events(migration_events_file)
			self.old_migrated_IPs = {} #key=old_IP, value=new_IP
			self.new_migrated_IPs = {} #key=new_IP, value=old_IP
			for event in self.migration_events:
				migration_time = event[0]
				old_IP = event[1]
				new_IP = event[2]
				Timer(migration_time, self.handle_migration, args = [IPAddr(old_IP), IPAddr(new_IP)])
Example #52
0
    def __init__(self):
        super(ReactiveForwarding, self).__init__()

        # generic controller information
        self.switches = {}  # key=dpid, value = SwitchWithPaths instance
        self.sw_sw_ports = {}  # key = (dpid1,dpid2), value = outport of dpid1
        self.sw_port_sw = {}  # key = (dpid1, outport) , value = dpid2
        self.adjs = {}  # key = dpid, value = list of neighbors
        self.arpmap = {}  # key=host IP, value = (mac,dpid,port)
        self.ignored_IPs = [IPAddr("0.0.0.0"), IPAddr("255.255.255.255")]  # these are used by openflow discovery module
        self.graph = nx.DiGraph()  # graph global

        # measure bandwidth utilization
        # key = dpid, value = dict( key = port, value = last seen bytes)
        self.sw_port_bytes = defaultdict(lambda: defaultdict(int))

        # key = dpid, value = dict( key = port, value = bandwidth utilization)
        self.sw_port_util = defaultdict(lambda: defaultdict(int))

        # timers
        # Timer(5, self.stats_timer, recurring=True)

        # invoke event listeners
        if not core.listen_to_dependencies(self, self._neededComponents):
            self.listenTo(core)
        self.listenTo(core.openflow)

        # core.openflow.addListener(FlowStatsReceived, self._handle_openflow_FlowStatsReceived)
        log.info("Started ReactiveForwarding!")

        # statistics
        self.num_ip_pktin = 0
    def __init__(self, round_time=1):
        """
        round_time: time in seconds that all LLDP packets must be sent to all neighbours. it can be
                    equals to link timeout at maximum.
        """

        # hold packets that needs to be sent to neighbours.
        self._neighbours_queue = list()

        # hold packets that needs to be sen
        self._send_round_time = round_time

        self._timer = None

        # register for switch events
        core.listen_to_dependencies(self)
 def __init__( self ):
     core.openflow.addListeners( self )
     self.multicast_ip = {}
     ipdb = IPDB()
     br = ipdb.interfaces[BRIDGE_INTERFACE_NAME]
     self.bridge_mac = EthAddr( br['address'] )
     self.mac_permit = set()
     self.mac_blacklist = set()
     self.mac_whitelist = set()
     core.listen_to_dependencies(self)
     vr_all = self.get_DHCP_mapping().get_data()
     for vr in vr_all:
         val = vr['value']
         if val['state'] == 'permit':
             self.permit_mac(EthAddr(val['mac_address']))
         if val['state'] == 'deny':
             self.whitelist_mac(EthAddr(val['mac_address']))
         if val['state'] == 'blacklist':
             self.blacklist_mac(EthAddr(val['mac_address']))
Example #55
0
    def __init__(self, ping_src_mac=None, install_flow=True, eat_packets=True):

        if ping_src_mac is None:
            ping_src_mac = DEFAULT_ARP_PING_SRC_MAC

        self.ping_src_mac = EthAddr(ping_src_mac)
        self.install_flow = install_flow
        self.eat_packets = eat_packets

        # The following tables should go to Topology later
        self.entryByMAC = {}
        self._t = Timer(timeoutSec["timerInterval"], self._check_timeouts, recurring=True)
        # Listen to openflow with high priority if we want to eat our ARP replies
        listen_args = {}
        if eat_packets:
            listen_args = {"openflow": {"priority": 0}}
        core.listen_to_dependencies(self, listen_args=listen_args)

        if core.hasComponent("DHCPD"):
            core.DHCPD.addListenerByName("DHCPLease", self._handle_DHCPLease)
Example #56
0
  def __init__ (self, ping_src_mac = None, install_flow = True,
      eat_packets = True):

    if ping_src_mac is None:
      ping_src_mac = DEFAULT_ARP_PING_SRC_MAC

    self.ping_src_mac = EthAddr(ping_src_mac)
    self.install_flow = install_flow
    self.eat_packets = eat_packets

    # The following tables should go to Topology later
    self.entryByMAC = {}
    self._t = Timer(timeoutSec['timerInterval'],
                    self._check_timeouts, recurring=True)

    # Listen to openflow with high priority if we want to eat our ARP replies
    listen_args = {}
    if eat_packets:
      listen_args={'openflow':{'priority':0}}
    core.listen_to_dependencies(self, listen_args=listen_args)
Example #57
0
	def __init__(self):
		core.listen_to_dependencies(self, ['openflow_discovery'])
		core.openflow.addListeners(self)
		
		#self._switch_list = []
		self._proc_num = None
		self._host_list = {}
		self._datapath_list = {}

		self._topo_graph = Graph()
		self._conn_graph = Graph()
		self._reduce_plan = {}

		self._host_host_path = {}  # shortest path from host to host

		self._mac_to_port = {}

		self._link_num = 0

		# for construct binomial tree improve version
		self._reduced_tree_node = {}

		thread = Thread(target = self._handle_ConnectionFromHost)
		thread.start()
Example #58
0
	def __init__(self):
		core.listen_to_dependencies(self)