def send_flow_stats_request(self, dpid, match):
     """Send a flow stats request to a switch (dpid).
     @param dpid - datapath/switch to contact                               
     @param match - ofp_match structure               
     """
     
     """
     # The API here is *UGLY*.
     Should be able to do smth like 'send_flowstats_request(dpid, match)'
     """
     # Create the stats request header
     request = of.ofp_stats_request()
     
     #TODO: replace with real XID code
     if not hasattr(self, 'xid'):
         xid = 9238
     else:
         xid = getattr(self, 'xid')
     if xid >= 0xFFffFFfe:
         xid = 9238
     setattr(self, 'xid', xid + 1)
     
     log.debug( "sending flow stats request xid: %d", xid )
     
     request.header.xid = xid
     request.header.type = openflow.OFPT_STATS_REQUEST
     request.type = openflow.OFPST_FLOW
     request.flags = 0
     
     # Create the stats request body
     body = of.ofp_flow_stats_request()
     body.match = match
     body.table_id = 0xff
     body.out_port = openflow.OFPP_NONE
     request.header.length = len(request.pack()) + len(body.pack())
     self.pending_query_xid = self.send_openflow_command(dpid, \
                 request.pack() + body.pack())
     
     return xid
Example #2
0
    def send_flow_stats_request(self, dpid, match):
        """Send a flow stats request to a switch (dpid).
        @param dpid - datapath/switch to contact                               
        @param match - ofp_match structure               
        """
        """
        # The API here is *UGLY*.
        Should be able to do smth like 'send_flowstats_request(dpid, match)'
        """
        # Create the stats request header
        request = of.ofp_stats_request()

        #TODO: replace with real XID code
        if not hasattr(self, 'xid'):
            xid = 9238
        else:
            xid = getattr(self, 'xid')
        if xid >= 0xFFffFFfe:
            xid = 9238
        setattr(self, 'xid', xid + 1)

        log.debug("sending flow stats request xid: %d", xid)

        request.header.xid = xid
        request.header.type = openflow.OFPT_STATS_REQUEST
        request.type = openflow.OFPST_FLOW
        request.flags = 0

        # Create the stats request body
        body = of.ofp_flow_stats_request()
        body.match = match
        body.table_id = 0xff
        body.out_port = openflow.OFPP_NONE
        request.header.length = len(request.pack()) + len(body.pack())
        self.pending_query_xid = self.send_openflow_command(dpid, \
                    request.pack() + body.pack())

        return xid
Example #3
0
    def send_flow_stats_request(self, dpid, match, table_id, xid=-1):
        """Send a flow stats request to a switch (dpid).
        @param dpid - datapath/switch to contact
        @param match - ofp_match structure
        @param table_id - table to query
        """
        # Create the stats request header
        request = of.ofp_stats_request()
        if xid == -1:
            request.header.xid = c_htonl(long(self.collection_epoch))
        else:
            request.header.xid = c_htonl(xid)

        request.header.type = openflow.OFPT_STATS_REQUEST
        request.type = openflow.OFPST_FLOW
        request.flags = 0
        # Create the stats request body
        body = of.ofp_flow_stats_request()
        body.match = match
        body.table_id = table_id
        body.out_port = openflow.OFPP_NONE
        request.header.length = len(request.pack()) + len(body.pack())
        self.send_openflow_command(dpid, request.pack() + body.pack())
Example #4
0
 def send_flow_stats_request(self, dpid, match, table_id, xid=-1):
     """Send a flow stats request to a switch (dpid).
     @param dpid - datapath/switch to contact
     @param match - ofp_match structure
     @param table_id - table to query
     """
     # Create the stats request header
     request = of.ofp_stats_request()
     if xid == -1:
         request.header.xid = c_htonl(long(self.sg.collection_epoch))
     else:
         request.header.xid = c_htonl(xid)
         
     request.header.type = openflow.OFPT_STATS_REQUEST
     request.type = openflow.OFPST_FLOW
     request.flags = 0
     # Create the stats request body
     body = of.ofp_flow_stats_request()
     body.match = match
     body.table_id = table_id
     body.out_port = openflow.OFPP_NONE
     request.header.length = len(request.pack()) + len(body.pack())
     self.send_openflow_command(dpid, request.pack() + body.pack())