Beispiel #1
0
def verifyStats(obj, port, test_timeout, packet_sent, packet_recv):
    stat_req = message.port_stats_request()
    stat_req.port_no = port

    all_packets_received = 0
    all_packets_sent = 0
    sent = recv = 0
    for i in range(0,test_timeout):
        fs_logger.info("Sending stats request")
        response, pkt = obj.controller.transact(stat_req,
                                                timeout=test_timeout)
        obj.assertTrue(response is not None, 
                       "No response to stats request")
        obj.assertTrue(len(response.stats) == 1,
                       "Did not receive port stats reply")
        for item in response.stats:
            sent = item.tx_packets
            recv = item.rx_packets
            fs_logger.info("Sent " + str(item.tx_packets) + " packets")
            if item.tx_packets == packet_sent:
                all_packets_sent = 1
            fs_logger.info("Received " + str(item.rx_packets) + " packets")
            if item.rx_packets == packet_recv:
                all_packets_received = 1

        if all_packets_received and all_packets_sent:
            break
        sleep(1)

    fs_logger.info("Expected port %d stats count: tx %d rx %d" % (port, packet_sent, packet_recv))
    fs_logger.info("Actual port %d stats count: tx %d rx %d" % (port, sent, recv))
    obj.assertTrue(all_packets_sent,
                   "Packet sent does not match number sent")
    obj.assertTrue(all_packets_received,
                   "Packet received does not match number sent")
Beispiel #2
0
def verifyStats(obj, port, test_timeout, packet_sent, packet_recv):
    stat_req = message.port_stats_request()
    stat_req.port_no = port

    all_packets_received = 0
    all_packets_sent = 0
    sent = recv = 0
    for i in range(0,test_timeout):
        logging.info("Sending stats request")
        response, pkt = obj.controller.transact(stat_req,
                                                timeout=test_timeout)
        obj.assertTrue(response is not None, 
                       "No response to stats request")
        obj.assertTrue(len(response.stats) == 1,
                       "Did not receive port stats reply")
        for item in response.stats:
            sent = item.tx_packets
            recv = item.rx_packets
            logging.info("Sent " + str(item.tx_packets) + " packets")
            if item.tx_packets == packet_sent:
                all_packets_sent = 1
            logging.info("Received " + str(item.rx_packets) + " packets")
            if item.rx_packets == packet_recv:
                all_packets_received = 1

        if all_packets_received and all_packets_sent:
            break
        sleep(1)

    logging.info("Expected port %d stats count: tx %d rx %d" % (port, packet_sent, packet_recv))
    logging.info("Actual port %d stats count: tx %d rx %d" % (port, sent, recv))
    obj.assertTrue(all_packets_sent,
                   "Packet sent does not match number sent")
    obj.assertTrue(all_packets_received,
                   "Packet received does not match number sent")
Beispiel #3
0
def Verify_PortStats(self,in_port,rx_dropped):
#Verify Port counters like rx_dropped

        port_stats_req = message.port_stats_request()
        port_stats_req.port_no = in_port   
        resp,pkt = self.controller.transact(port_stats_req)
        self.assertTrue(resp is not None,"No response received for port stats request")        
        self.assertTrue(resp.rx_dropped == rx_dropped, "Packets not dropped")
Beispiel #4
0
def Verify_PortStats(self, in_port, rx_dropped):
    #Verify Port counters like rx_dropped

    port_stats_req = message.port_stats_request()
    port_stats_req.port_no = in_port
    resp, pkt = self.controller.transact(port_stats_req)
    self.assertTrue(resp is not None,
                    "No response received for port stats request")
    self.assertTrue(resp.rx_dropped == rx_dropped, "Packets not dropped")
Beispiel #5
0
def getStats(obj, port):
    stat_req = message.port_stats_request()
    stat_req.port_no = port

    fs_logger.info("Sending stats request")
    response, pkt = obj.controller.transact(stat_req, timeout=2)
    obj.assertTrue(response is not None, "No response to stats request")
    obj.assertTrue(len(response.stats) == 1, "Did not receive port stats reply")
    for item in response.stats:
        fs_logger.info("Sent " + str(item.tx_packets) + " packets")
        packet_sent = item.tx_packets
        packet_recv = item.rx_packets
    fs_logger.info("Port %d stats count: tx %d rx %d" % (port, packet_sent, packet_recv))
    return packet_sent, packet_recv
Beispiel #6
0
def getAllStats(obj):
    stat_req = message.port_stats_request()
    stat_req.port_no = ofp.OFPP_NONE

    logging.info("Sending all port stats request")
    response, pkt = obj.controller.transact(stat_req, timeout=2)
    obj.assertTrue(response is not None, 
                    "No response to stats request")
    obj.assertTrue(len(response.stats) >= 3,
                    "Did not receive all port stats reply")
    stats = {}
    for item in response.stats:
        stats[ item.port_no ] = ( item.tx_packets, item.rx_packets )
    return stats
Beispiel #7
0
def get_portstats(self, port_num):

    # Return all the port counters in the form a tuple
    port_stats_req = message.port_stats_request()
    port_stats_req.port_no = port_num
    response, pkt = self.controller.transact(port_stats_req)
    self.assertTrue(response is not None, "No response received for port stats request")
    rx_pkts = 0
    tx_pkts = 0
    rx_byts = 0
    tx_byts = 0
    rx_drp = 0
    tx_drp = 0
    rx_err = 0
    tx_err = 0
    rx_fr_err = 0
    rx_ovr_err = 0
    rx_crc_err = 0
    collisions = 0
    tx_err = 0

    for obj in response.stats:
        rx_pkts += obj.rx_packets
        tx_pkts += obj.tx_packets
        rx_byts += obj.rx_bytes
        tx_byts += obj.tx_bytes
        rx_drp += obj.rx_dropped
        tx_drp += obj.tx_dropped
        rx_err += obj.rx_errors
        rx_fr_err += obj.rx_frame_err
        rx_ovr_err += obj.rx_over_err
        rx_crc_err += obj.rx_crc_err
        collisions += obj.collisions
        tx_err += obj.tx_errors

    return (
        rx_pkts,
        tx_pkts,
        rx_byts,
        tx_byts,
        rx_drp,
        tx_drp,
        rx_err,
        tx_err,
        rx_fr_err,
        rx_ovr_err,
        rx_crc_err,
        collisions,
        tx_err,
    )
Beispiel #8
0
def verify_portstats(self,
                     port,
                     tx_packets=None,
                     rx_packets=None,
                     rx_byte=None,
                     tx_byte=None):

    stat_req = message.port_stats_request()
    stat_req.port_no = port

    for i in range(0, 60):
        logging.info("Sending stats request")
        response, pkt = self.controller.transact(stat_req, timeout=5)
        self.assertTrue(response is not None, "No response to stats request")

        sentp = recvp = 0
        sentb = recvb = 0

        sleep(1)

        for item in response.stats:
            sentp += item.tx_packets
            recvp += item.rx_packets
            recvb += item.rx_bytes
            sentb += item.tx_bytes

            logging.info("Tx_packet counter " + str(sentp) + " packets")
            logging.info("Rx_packet counter " + str(recvp) + " packets")
            logging.info("Rx_byte counter" + str(recvb) + "bytes")
            logging.info("Tx_byte counter" + str(sentb) + "bytes")

        if tx_packets != None and tx_packets != sentp: continue
        if rx_packets != None and rx_packets != recvp: continue
        if rx_byte != None and rx_byte != recvb: continue
        if tx_byte != None and tx_byte != sentb: continue

        break

    if (tx_packets != None):
        self.assertEqual(tx_packets, sentp,
                         "tx_packets counter is not incremented correctly")
    if (rx_packets != None):
        self.assertEqual(rx_packets, recvp,
                         "rx_packets counter is not incremented correctly")
    if (rx_byte != None):
        self.assertEqual(rx_byte, recvb,
                         "rx_bytes counter is not incremented correctly")
    if (tx_byte != None):
        self.assertEqual(tx_byte, sentb,
                         "tx_bytes counter is not incremented correctly")
Beispiel #9
0
def verify_portstats(self, port,tx_packets=None,rx_packets=None,rx_byte=None,tx_byte=None):

    
    stat_req = message.port_stats_request()
    stat_req.port_no = port
    
    for i in range(0,60):
        logging.info("Sending stats request")
        response, pkt = self.controller.transact(stat_req,
                                                timeout=5)
        self.assertTrue(response is not None, 
                       "No response to stats request")
        self.assertTrue(len(response.stats) == 1,
                       "Did not receive port stats reply")

        sentp = recvp = 0
        sentb = recvb = 0

        sleep(1)
        
        for item in response.stats:
            sentp += item.tx_packets
            recvp += item.rx_packets
            recvb += item.rx_bytes
            sentb += item.tx_bytes
           
            
            logging.info("Sent " + str(sentp) + " packets")
            logging.info("Received " + str(recvp) + " packets")
            logging.info("Received " + str(recvb) + "bytes")
            logging.info("Sent" + str(sentb) + "bytes")
    
        if tx_packets != None  and  tx_packets != sentp: continue
        if rx_packets != None  and  rx_packets != recvp: continue 
        if rx_byte != None  and  rx_byte != recvb: continue
        if tx_byte != None  and  tx_byte != sentb: continue
        
        break
        
        

    if (tx_packets != None):
        self.assertEqual(tx_packets,item.tx_packets,"rx_packets counter is not incremented correctly")
    if (rx_packets != None):
        self.assertEqual(rx_packets,item.rx_packets,"tx_packets counter is not incremented correctly")
    if (rx_byte != None):
        self.assertEqual(rx_byte,item.rx_bytes,"rx_bytes counter is not incremented correctly")
    if (tx_byte != None):
        self.assertEqual(tx_byte,item.tx_bytes,"tx_bytes counter is not incremented correctly")
Beispiel #10
0
def getStats(obj, port):
    stat_req = message.port_stats_request()
    stat_req.port_no = port

    fs_logger.info("Sending stats request")
    response, pkt = obj.controller.transact(stat_req, timeout=2)
    obj.assertTrue(response is not None, 
                    "No response to stats request")
    obj.assertTrue(len(response.stats) == 1,
                    "Did not receive port stats reply")
    for item in response.stats:
        fs_logger.info("Sent " + str(item.tx_packets) + " packets")
        packet_sent = item.tx_packets
        packet_recv = item.rx_packets
    fs_logger.info("Port %d stats count: tx %d rx %d" % (port, packet_sent, packet_recv))
    return packet_sent, packet_recv
Beispiel #11
0
def get_portstats(self, port_num):

    # Return all the port counters in the form a tuple
    port_stats_req = message.port_stats_request()
    port_stats_req.port_no = port_num
    response, pkt = self.controller.transact(port_stats_req)
    self.assertTrue(response is not None,
                    "No response received for port stats request")
    rx_pkts = 0
    tx_pkts = 0
    rx_byts = 0
    tx_byts = 0
    rx_drp = 0
    tx_drp = 0
    rx_err = 0
    tx_err = 0
    rx_fr_err = 0
    rx_ovr_err = 0
    rx_crc_err = 0
    collisions = 0
    tx_err = 0

    for obj in response.stats:
        rx_pkts += obj.rx_packets
        tx_pkts += obj.tx_packets
        rx_byts += obj.rx_bytes
        tx_byts += obj.tx_bytes
        rx_drp += obj.rx_dropped
        tx_drp += obj.tx_dropped
        rx_err += obj.rx_errors
        rx_fr_err += obj.rx_frame_err
        rx_ovr_err += obj.rx_over_err
        rx_crc_err += obj.rx_crc_err
        collisions += obj.collisions
        tx_err += obj.tx_errors

    return (rx_pkts, tx_pkts, rx_byts, tx_byts, rx_drp, tx_drp, rx_err, tx_err,
            rx_fr_err, rx_ovr_err, rx_crc_err, collisions, tx_err)
Beispiel #12
0
 def runTest(self):
     request = message.port_stats_request()
     request.port_no = ofp.OFPP_ANY
     response,_ = self.controller.transact(request)
     #print(response.show())
     self.logger.info(response.show())
Beispiel #13
0
 def runTest(self):
     request = message.port_stats_request()
     request.port_no = ofp.OFPP_ANY
     response, _ = self.controller.transact(request)
     #print(response.show())
     self.logger.info(response.show())