Exemplo n.º 1
0
def datapath_join_callback(nddi, dp_id, ip_address, stats):

    # NOX gives us the IP address in the native order, move it to network
    tmp = struct.pack("@I", ip_address)
    ip_address = struct.unpack("!I", tmp)[0]

    if not dp_id in switches:
        switches.append(dp_id)

    ports = stats['ports'];
    #print str(ports)

    #--- we know we are going to need to get the set of flows so lets just do that now
    nddi.collection_epoch += 1
    flow = of.ofp_match()
    flow.wildcards = 0xffffffff
    nddi.send_flow_stats_request(dp_id, flow,0xff)
    
    port_list = []
    for p in ports:
        port = p
        port['hw_addr'] = mac_to_int(p['hw_addr'])
        port_list.append(port)
    #print str(port_list)
    nddi.rmqi_rpc.emit_signal('datapath_join','OF.NOX.event',
        dpid=dp_id,
        ip=ip_address,
        ports=ports
    )
Exemplo n.º 2
0
def datapath_join_callback(nddi, dp_id, ip_address, stats):

    # NOX gives us the IP address in the native order, move it to network
    tmp = struct.pack("@I", ip_address)
    ip_address = struct.unpack("!I", tmp)[0]

    if not dp_id in switches:
        switches.append(dp_id)

    ports = stats['ports']
    #print str(ports)

    #--- we know we are going to need to get the set of flows so lets just do that now
    nddi.collection_epoch += 1
    flow = of.ofp_match()
    flow.wildcards = 0xffffffff
    nddi.send_flow_stats_request(dp_id, flow, 0xff)

    port_list = []
    for p in ports:
        port = p
        port['hw_addr'] = mac_to_int(p['hw_addr'])
        port_list.append(port)
    #print str(port_list)
    nddi.rmqi_rpc.emit_signal('datapath_join',
                              'OF.NOX.event',
                              dpid=dp_id,
                              ip=ip_address,
                              ports=ports)
Exemplo n.º 3
0
    def trace_flow(self, _match, dpid):
        ''' Trace flow entry from a given dp'''
        # Build match for flowstats request
        match = of.ofp_match()

        #print _match

        match.wildcards = of.OFPFW_ALL

        if 'dl_vlan' in _match:
            match.dl_vlan = _match['dl_vlan']
            match.wildcards -= of.OFPFW_DL_VLAN
        if 'dl_vlan_pcp' in _match:
            match.dl_vlan_pcp = _match['dl_vlan_pcp']
            match.wildcards -= of.OFPFW_DL_VLAN_PCP
        if 'nw_tos' in _match:
            match.nw_tos = _match['nw_tos']
            match.wildcards -= of.OFPFW_NW_TOS
        if 'nw_proto' in _match:
            match.nw_proto = _match['nw_proto']
            match.wildcards -= of.OFPFW_NW_PROTO
        if 'tp_src' in _match:
            match.tp_src = _match['tp_src']
            match.wildcards -= of.OFPFW_TP_SRC
        if 'tp_dst' in _match:
            match.tp_dst = _match['tp_dst']
            match.wildcards -= of.OFPFW_TP_DST
        if 'nw_src' in _match:
            match.nw_src = _match['nw_src']
            match.wildcards -= of.OFPFW_NW_SRC_ALL
        if 'nw_dst' in _match:
            match.nw_dst = _match['nw_dst']
            match.wildcards -= of.OFPFW_NW_DST_ALL
        '''
        if 'dl_vlan' in _match:
            if this is commented out, it doesn't match although vlan=65535
            # what is the expected format/type of dl_vlan ?
            print _match['dl_vlan']
            match.dl_vlan = _match['dl_vlan']
            match.wildcards -= of.OFPFW_DL_VLAN
        if 'dl_src' in _match:
            #if this is commented out, match's format gets bad (pack() doesn't work)
            # what is the expected format/type of dl_src/dl_dst ?
            print _match['dl_src']
            match.dl_src = _match['dl_src']
            match.wildcards -= of.OFPFW_DL_SRC
        if 'dl_dst' in _match:
            print _match['dl_dst']
            match.dl_dst = _match['dl_dst']
            match.wildcards -= of.OFPFW_DL_DST
        '''
        self.match = match
        self.pending_query_xid = self.send_flow_stats_request(dpid, match)

        # Add first node to trace path
        strid = str(dpid)
        while len(strid) < 12:
            strid = "0" + strid
        self.current_path.append(strid)
 def trace_flow(self, _match, dpid):
     ''' Trace flow entry from a given dp'''
     # Build match for flowstats request
     match = of.ofp_match()
     
     #print _match
     
     match.wildcards = of.OFPFW_ALL
     
     if 'dl_vlan' in _match:
         match.dl_vlan = _match['dl_vlan']
         match.wildcards -= of.OFPFW_DL_VLAN
     if 'dl_vlan_pcp' in _match:
         match.dl_vlan_pcp = _match['dl_vlan_pcp']
         match.wildcards -= of.OFPFW_DL_VLAN_PCP
     if 'nw_tos' in _match:
         match.nw_tos = _match['nw_tos']
         match.wildcards -= of.OFPFW_NW_TOS
     if 'nw_proto' in _match:
         match.nw_proto = _match['nw_proto']
         match.wildcards -= of.OFPFW_NW_PROTO
     if 'tp_src' in _match:
         match.tp_src = _match['tp_src']
         match.wildcards -= of.OFPFW_TP_SRC
     if 'tp_dst' in _match:
         match.tp_dst = _match['tp_dst']
         match.wildcards -= of.OFPFW_TP_DST
     if 'nw_src' in _match:
         match.nw_src = _match['nw_src']
         match.wildcards -= of.OFPFW_NW_SRC_ALL
     if 'nw_dst' in _match:
         match.nw_dst = _match['nw_dst']
         match.wildcards -= of.OFPFW_NW_DST_ALL
     '''
     if 'dl_vlan' in _match:
         if this is commented out, it doesn't match although vlan=65535
         # what is the expected format/type of dl_vlan ?
         print _match['dl_vlan']
         match.dl_vlan = _match['dl_vlan']
         match.wildcards -= of.OFPFW_DL_VLAN
     if 'dl_src' in _match:
         #if this is commented out, match's format gets bad (pack() doesn't work)
         # what is the expected format/type of dl_src/dl_dst ?
         print _match['dl_src']
         match.dl_src = _match['dl_src']
         match.wildcards -= of.OFPFW_DL_SRC
     if 'dl_dst' in _match:
         print _match['dl_dst']
         match.dl_dst = _match['dl_dst']
         match.wildcards -= of.OFPFW_DL_DST
     '''
     self.match = match
     self.pending_query_xid = self.send_flow_stats_request(dpid, match)
     
     # Add first node to trace path
     strid = str(dpid)
     while len(strid) < 12 :
         strid = "0"+strid
     self.current_path.append(strid)
Exemplo n.º 5
0
    def fire_flow_stats_timer(self):
        for dpid in switches:
            self.collection_epoch += 1
            flow = of.ofp_match()
            flow.wildcards = 0xffffffff
            self.send_flow_stats_request(dpid, flow, 0xff)

        self.post_callback(30, self.fire_flow_stats_timer)
Exemplo n.º 6
0
    def fire_flow_stats_timer(self):
        for dpid in switches:
            self.sg.collection_epoch += 1
            flow = of.ofp_match()
            flow.wildcards = 0xffffffff
            self.send_flow_stats_request(dpid, flow,0xff)

        self.post_callback(30, self.fire_flow_stats_timer)
Exemplo n.º 7
0
	def send_flow_stats_request_timer(self, dpid):
		log.debug("I am able to enter the flow_stats_request_timer method.")
		global xid
		flows = of.ofp_match()
		flows.wildcards = of.OFPFW_ALL #wildcarded all match fields, which means that all the flows will be retrieved.
		self.Monitoring.send_flow_stats_request(dpid, flows, 0xff, xid)
		xid += 1
		self.post_callback(FLOW_MONITOR_INTERVAL, lambda : self.send_flow_stats_request_timer(dpid))
Exemplo n.º 8
0
 def send_flow_stats_request_timer(self, dpid):
     log.debug("I am able to enter the flow_stats_request_timer method.")
     global xid
     flows = of.ofp_match()
     flows.wildcards = of.OFPFW_ALL  #wildcarded all match fields, which means that all the flows will be retrieved.
     self.Monitoring.send_flow_stats_request(dpid, flows, 0xff, xid)
     xid += 1
     self.post_callback(FLOW_MONITOR_INTERVAL,
                        lambda: self.send_flow_stats_request_timer(dpid))
Exemplo n.º 9
0
def datapath_join_callback(ref, sg, dp_id, ip_address, stats):

    # NOX gives us the IP address in the native order, move it to network
    tmp = struct.pack("@I", ip_address)
    ip_address = struct.unpack("!I", tmp)[0]

    if not dp_id in switches:
        switches.append(dp_id)

    ports = stats['ports']
    #print str(ports)

    #--- we know we are going to need to get the set of flows so lets just do that now
    sg.collection_epoch += 1
    flow = of.ofp_match()
    flow.wildcards = 0xffffffff
    ref.send_flow_stats_request(dp_id, flow, 0xff)

    port_list = []
    for i in range(0, len(ports)):
        port = {}  #ports[i]
        port['name'] = ports[i]['name']
        port['hw_addr'] = dbus.UInt64(mac_to_int(ports[i]['hw_addr']))
        port['port_no'] = dbus.UInt16(ports[i]['port_no'])

        #assert(ports[i]['state'] <= 4294967295)
        port['config'] = ports[i]['config']  #dbus.UInt32(ports[i]['config'])
        port['state'] = dbus.UInt32(ports[i]['state'])
        port['curr'] = dbus.UInt32(ports[i]['curr'])
        port['advertised'] = dbus.UInt32(ports[i]['advertised'])
        port['supported'] = dbus.UInt32(ports[i]['supported'])
        port['peer'] = dbus.UInt32(ports[i]['peer'])
        #print str(port['config']) +  " vs " + str(ports[i]['config'])
        port_dict = dbus.Dictionary(port, signature='sv')
        port_list.append(port)

    #print str(port_list)
    sg.datapath_join(dp_id, ip_address, port_list)
Exemplo n.º 10
0
def datapath_join_callback(ref,sg,dp_id,ip_address,stats):

    # NOX gives us the IP address in the native order, move it to network
    tmp = struct.pack("@I", ip_address)
    ip_address = struct.unpack("!I", tmp)[0]

    if not dp_id in switches:
        switches.append(dp_id)

    ports = stats['ports'];
    #print str(ports)

    #--- we know we are going to need to get the set of flows so lets just do that now
    sg.collection_epoch += 1
    flow = of.ofp_match()
    flow.wildcards = 0xffffffff
    ref.send_flow_stats_request(dp_id, flow,0xff)

    port_list = []
    for i in range(0, len(ports)):
      port = {}#ports[i]
      port['name']    = ports[i]['name']
      port['hw_addr'] = dbus.UInt64(mac_to_int(ports[i]['hw_addr']))
      port['port_no'] = dbus.UInt16(ports[i]['port_no'])

      #assert(ports[i]['state'] <= 4294967295)
      port['config']      = ports[i]['config'] #dbus.UInt32(ports[i]['config'])
      port['state']       = dbus.UInt32(ports[i]['state'])
      port['curr']        = dbus.UInt32(ports[i]['curr'])
      port['advertised']  = dbus.UInt32(ports[i]['advertised'])
      port['supported']   = dbus.UInt32(ports[i]['supported'])
      port['peer']        = dbus.UInt32(ports[i]['peer'])
      #print str(port['config']) +  " vs " + str(ports[i]['config'])
      port_dict = dbus.Dictionary(port, signature='sv') 
      port_list.append(port)

    #print str(port_list)
    sg.datapath_join(dp_id,ip_address,port_list)
Exemplo n.º 11
0
    def send_flow_stats_requests(self):
        #send request to all switches
        #self.monitoring.send_flow_stats_request()
        dpids = self.pytop.get_datapaths()
        sent = False
        global xid
        self.requests_queue[xid] = []
        ips = self.ip.keys()
        for ip in ips:
            for dpid in dpids:
                #if True:
                #print type(dpid)
                sent = True
                flow = of.ofp_match()
                flow.wildcards = of.OFPFW_ALL & 0xFFF03FFF
                #print "%x" %flow.wildcards
                #ips = self.ip.keys()
                #for ip in ips:
                flow.nw_dst = ip  #self.ip.keys()[0]#convert_to_ipaddr("51.0.168.192")

                #print ipstr_to_int("192.168.0.51") == convert_to_ipaddr("51.0.168.192") the same
                #attrs[core.NW_DST] = "192.168.0.51"
                #a = set_match(attrs)

                self.monitoring.send_flow_stats_request(
                    dpid.as_host(), flow, 0xff, xid)
                self.requests_queue[xid].append((dpid.as_host(), xid))
                #ready for stor
                self.ip[ip][xid] = {}
                if self.ip[ip].has_key(xid - 5):
                    del self.ip[ip][xid - 5]

            #print self.monitoring.get_latest_switch_stats(dpid.as_host())
            if sent:
                xid = xid + 1
        self.post_callback(INTERVAL, self.send_flow_stats_requests)
Exemplo n.º 12
0
    def send_flow_stats_requests(self):
        #send request to all switches
        #self.monitoring.send_flow_stats_request()
        dpids = self.pytop.get_datapaths();
        sent = False
        global xid
        self.requests_queue[xid] = []
        ips = self.ip.keys()
        for ip in ips:
            for dpid in dpids:
            #if True:
                #print type(dpid)
                sent = True
                flow = of.ofp_match()
                flow.wildcards = of.OFPFW_ALL & 0xFFF03FFF
                #print "%x" %flow.wildcards
                #ips = self.ip.keys()
                #for ip in ips:
                flow.nw_dst = ip#self.ip.keys()[0]#convert_to_ipaddr("51.0.168.192")
            
                #print ipstr_to_int("192.168.0.51") == convert_to_ipaddr("51.0.168.192") the same
                #attrs[core.NW_DST] = "192.168.0.51"
                #a = set_match(attrs)

                self.monitoring.send_flow_stats_request(dpid.as_host(),flow,0xff,xid)
                self.requests_queue[xid].append((dpid.as_host(),xid))
                #ready for stor
                self.ip[ip][xid] = {}
                if self.ip[ip].has_key(xid-5):
                    del self.ip[ip][xid-5]

   
            #print self.monitoring.get_latest_switch_stats(dpid.as_host())
            if sent:
                xid = xid + 1
        self.post_callback(INTERVAL,self.send_flow_stats_requests)