示例#1
0
def _timer_func():
    """ handler for timer function that sends the requests to all the
        switches connected to the controller.
    """
    log.debug("start check stat")

    for connection in core.openflow._connections.values():

        # FlowStatsReceived
        connection.send(
            of.ofp_stats_request(body=of.ofp_flow_stats_request(), type=of.ofp_stats_types_rev_map.get("OFPST_FLOW"))
        )

        # AggregateFlowStatsReceived
        connection.send(
            of.ofp_stats_request(
                body=of.ofp_aggregate_stats_request(), type=of.ofp_stats_types_rev_map.get("OFPST_AGGREGATE")
            )
        )

        # TableStatsReceived
        # I don't know which methode to call (it's not of.ofp_flow_stats())
        # connection.send(of.ofp_stats_request(body=of.ofp_table_stats()))

        # PortStatsReceived
        connection.send(
            of.ofp_stats_request(
                body=of.ofp_port_stats_request(port_no=of.OFPP_NONE), type=of.ofp_stats_types_rev_map.get("OFPST_PORT")
            )
        )

        # QueueStatsReceived
        body = of.ofp_queue_stats_request(port_no=of.OFPP_NONE, queue_id=of.OFPQ_ALL)
        connection.send(of.ofp_stats_request(body=body, type=of.ofp_stats_types_rev_map.get("OFPST_QUEUE")))
示例#2
0
    def sendAggregateStatsRequest(self, event):
        sr = of.ofp_stats_request()
        sr.type = of.OFPST_AGGREGATE
        sr.body = of.ofp_aggregate_stats_request()

        event.connection.send(sr)
        print "Sending aggregate stat request message to Switch %s " % event.dpid
示例#3
0
    def getSwitchAggregate(self, switch_dpid):

        try:
            bodyMsg = of.ofp_aggregate_stats_request()

            bodyMsg.match = of.ofp_match()
            bodyMsg.table_id = of.TABLE_ALL
            bodyMsg.out_port = of.OFPP_NONE
            msg = of.ofp_stats_request(body=bodyMsg)
            msg.type = of.OFPST_AGGREGATE

            data = {}

            aggStats = self.get_switch_stats(switch_dpid, msg,
                                             "aggregate flows")
            if aggStats == None:
                self.log.error("Error getting aggregate stats")
                return data

            data = {
                "bytes": aggStats.byte_count,
                "flows": aggStats.flow_count,
                "packets": aggStats.packet_count
            }
            return data
        except BaseException, e:
            self.log.error(e.message)
            data = {}
            return data
示例#4
0
def _on_timer():

    for n in nodes:
        #Sends out requests to the network nodes
        core.openflow.getConnection(n.connection.dpid).send(of.ofp_features_request())
        n.connection.send(of.ofp_stats_request(body=of.ofp_port_stats_request()))
        n.connection.send(of.ofp_stats_request(body=of.ofp_aggregate_stats_request()))
        n.connection.send(of.ofp_stats_request(body=of.ofp_flow_stats_request()))
示例#5
0
def timer_func():
    for connection in core.openflow._connections.values():
        connection.send(of.ofp_stats_request(body=of.ofp_flow_stats_request()))
        connection.send(
            of.ofp_stats_request(body=of.ofp_aggregate_stats_request())
        )  # ???????????????not supported in POX yet
        connection.send(of.ofp_stats_request(body=of.ofp_port_stats_request()))
    log.debug("Sent %i flow/port stats request(s)",
              len(core.openflow._connections))
示例#6
0
def sendAggRequests():
	global topoMat
	numRows = len(topoMat)
	for i in range(1,numRows):
		numCols = len(topoMat[i])
		dpID = dpidToStr(i)
		for j in range(0,numCols):
			print "The dpid for which conncetion is requested = ", dpID
			con = core.openflow.getConnection(i) #dpID from above not being used
			if int(topoMat[i][j].start) == i:
				myPort = int(topoMat[i][j].startPort)
			else:
				myPort = int(topoMat[i][j].endPort)
			if con is None:
				print "connection object not available"
				return
			con.send(of.ofp_stats_request(body=of.ofp_aggregate_stats_request(out_port=myPort)))
示例#7
0
def _timer_func ():
  if len(core.openflow._connections.values())==0:
    # since no switch is connected, clean everything.
    del switches[:]
    hosts.clear()
    switch_desc.clear()
    adjacency.clear()
    link_bw.clear()
    link_bw_total.clear()
    byte.clear()
    byte_r.clear()
    clock.clear()
    flow_stats.clear()
    aggr_stats.clear()
    port_stats.clear()
  for connection in core.openflow._connections.values():
    connection.send(of.ofp_stats_request(body=of.ofp_port_stats_request()))
    connection.send(of.ofp_stats_request(body=of.ofp_aggregate_stats_request()))
    connection.send(of.ofp_stats_request(body=of.ofp_flow_stats_request()))
    connection.send(of.ofp_stats_request(body=of.ofp_desc_stats_request()))
示例#8
0
def _timer_func ():
  if len(core.openflow._connections.values())==0:
    # since no switch is connected, clean everything.
    del switches[:]
    hosts.clear()
    switch_desc.clear()
    adjacency.clear()
    link_bw.clear()
    link_bw_total.clear()
    byte.clear()
    byte_r.clear()
    clock.clear()
    flow_stats.clear()
    aggr_stats.clear()
    port_stats.clear()
  for connection in core.openflow._connections.values():
    connection.send(of.ofp_stats_request(body=of.ofp_port_stats_request()))
    connection.send(of.ofp_stats_request(body=of.ofp_aggregate_stats_request()))
    connection.send(of.ofp_stats_request(body=of.ofp_flow_stats_request()))
    connection.send(of.ofp_stats_request(body=of.ofp_desc_stats_request()))
示例#9
0
def get_switch_aggregate(switch_dpid):
    """
    Returns per switch aggregate stats. This includes:
     - Bytes
     - Flows
     - Packets
    
    :param switch_dpid: Switch DPID to request in format XX:XX:XX:XX:XX:XX:XX:XX
    :type switch_dpid: str
    :return: Switch aggregate stats
    :rtype: JSONObject
    :except BaseException: If any error occurs returns an empty object
    """
    try:
        # build openflow message
        bodyMsg = of.ofp_aggregate_stats_request()
        bodyMsg.match = of.ofp_match()
        bodyMsg.table_id = of.TABLE_ALL
        bodyMsg.out_port = of.OFPP_NONE
        msg = of.ofp_stats_request(body=bodyMsg)
        msg.type = of.OFPST_AGGREGATE
        # get and verify stats
        data = {}
        aggStats = get_switch_stats(switch_dpid, msg, "aggregate flows")
        if aggStats == None:
            log.error("Error getting aggregate stats")
            return json.dumps(data)
        # build and return json data
        data = {
            "bytes": aggStats.byte_count,
            "flows": aggStats.flow_count,
            "packets": aggStats.packet_count
        }
        return json.dumps(data)
    except BaseException, e:
        log.error(e.message)
        data = {}
        return json.dumps(data)
def _on_timer():
    path.clear()
    for n in sw_con:
        n.connection.send(
            of.ofp_stats_request(body=of.ofp_aggregate_stats_request()))
def aggregate_stats_request():
    for connection in core.openflow._connections.values():
        connection.send(
            of.ofp_stats_request(body=of.ofp_aggregate_stats_request()))
    log.debug("Sent %i aggregate stats request(s)",
              len(core.openflow._connections))
示例#12
0
文件: Lab5.py 项目: hfskappel/ext
def _on_timer():
    path.clear()
    for n in sw_con:
        n.connection.send(of.ofp_stats_request(body=of.ofp_aggregate_stats_request()))
示例#13
0
def timer_func ():
    for connection in core.openflow._connections.values():
        connection.send(of.ofp_stats_request(body=of.ofp_flow_stats_request()))
        connection.send(of.ofp_stats_request(body=of.ofp_aggregate_stats_request())) # ???????????????not supported in POX yet
        connection.send(of.ofp_stats_request(body=of.ofp_port_stats_request()))
    log.debug("Sent %i flow/port stats request(s)", len(core.openflow._connections))
示例#14
0
 def _init (self):
   sr = of.ofp_stats_request()
   sr.body = of.ofp_aggregate_stats_request()
   self._con.send(sr)
   self.xid = sr.xid