Пример #1
0
    def runTest(self):
        queue_id = QUEUE_ID
        sup_acts = supported_actions_get(self)
        if not (sup_acts & 1<<ofp.OFPAT_SET_QUEUE):
            skip_message_emit(self, "Forward to queue test")
            return
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        pkt = simple_tcp_packet(pktlen = 100)
        queue_act = action.action_set_queue()
        queue_act.queue_id = queue_id
        flow_match_test_port_pair(parent=self, ing_port=of_ports[0], egr_port=of_ports[1], pkt=pkt, exp_pkt=pkt, apply_action_list = [queue_act])


        stat_req = message.queue_stats_request()
        stat_req.port_no = ofp.OFPP_ANY
        stat_req.queue_id = ofp.OFPQ_ALL

        pa_logger.info("Sending stats request")
        do_barrier(self.controller)

        (response, raw) = self.controller.transact(stat_req)
        self.assertTrue(response,"Got no queue stats reply")
        queue_stats = response.stats[0]
        self.assertTrue(queue_stats.tx_bytes == 100,"Queue Stats Incorrect")
Пример #2
0
    def runTest(self):

        logging.info("Running QueueOpFailedBadQueue Grp100No310 test")

        of_ports = config["port_map"].keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")

        logging.info("Sending queue_stats request ..")
        request = message.queue_stats_request()
        request.port_no = of_ports[0]
        request.queue_id = -1  # Invalid queue_id
        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Unable to send the message")

        logging.info("Waiting for OFPT_ERROR message...")

        count = 0
        while True:

            (response, raw) = self.controller.poll(ofp.OFPT_ERROR)
            if not response:  # Timeout
                break
            if not response.type == ofp.OFPET_QUEUE_OP_FAILED:
                logging.info("Error Type is not as expected")
                break
            if not response.code == ofp.OFPQOFC_BAD_QUEUE:
                logging.info("Error Code is not as expected")
                break
            if not config["relax"]:  # Only one attempt to match
                break
            count += 1
            if count > 10:  # Too many tries
                break
Пример #3
0
    def runTest(self):
        logging = get_logger()
        logging.info("Running QueueOpFailedBadQueue Grp100No290 test")

        of_ports = config["port_map"].keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")

        logging.info("Sending queue_stats request ..")
        request = message.queue_stats_request()
        request.port_no = of_ports[0]
        request.queue_id = 4294967290  # Invalid queue_id
        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Unable to send the message")

        logging.info("Waiting for OFPT_ERROR message...")
        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, timeout=10)
        self.assertTrue(response is not None, "Did not receive an error")
        self.assertTrue(
            response.type == ofp.OFPET_QUEUE_OP_FAILED,
            "Unexpected Error type. Expected OFPET_QUEUE_OP_FAILED error type",
        )
        self.assertTrue(
            response.code == ofp.OFPQOFC_BAD_QUEUE, " Unexpected error code, Expected OFPQOFC_BAD_QUEUE error code"
        )
Пример #4
0
def verify_queuestats(self,port_num,queue_id,expect_packet=None,expect_byte=None):
    
    # Verify queue counters : tx_packets and tx_bytes

    request = message.queue_stats_request()
    request.port_no  = port_num
    request.queue_id = queue_id
    
    for i in range(0,100):

        logging.info("Sending stats request")
     
        (queue_stats, p) = self.controller.transact(request)
        self.assertNotEqual(queue_stats, None, "Queue stats request failed")
        packet_counter = 0
        byte_counter = 0 
        
        for item in queue_stats.stats:
            packet_counter += item.tx_packets
            byte_counter += item.tx_bytes

            logging.info("Transmitted" + str(packet_counter) + " packets")
            logging.info("Transmitted" + str(byte_counter) + "bytes")
           
        if (expect_packet == None or packet_counter == expect_packet) and \
           (expect_byte == None or byte_counter == expect_byte):
            break

        sleep(0.1)
    
    if expect_packet != None :
        self.assertEqual(packet_counter,expect_packet,"tx_packets counter is not incremented correctly")

    if expect_byte != None :   
        self.assertEqual(byte_counter,expect_byte,"tx_bytes counter is not incremented correctly")
Пример #5
0
    def runTest(self):
        queue_id = QUEUE_ID
        sup_acts = supported_actions_get(self)
        if not (sup_acts & 1 << ofp.OFPAT_SET_QUEUE):
            skip_message_emit(self, "Forward to queue test")
            return
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        pkt = simple_tcp_packet(pktlen=100)
        queue_act = action.action_set_queue()
        queue_act.queue_id = queue_id
        flow_match_test_port_pair(parent=self,
                                  ing_port=of_ports[0],
                                  egr_port=of_ports[1],
                                  pkt=pkt,
                                  exp_pkt=pkt,
                                  apply_action_list=[queue_act])

        stat_req = message.queue_stats_request()
        stat_req.port_no = ofp.OFPP_ANY
        stat_req.queue_id = ofp.OFPQ_ALL

        pa_logger.info("Sending stats request")
        do_barrier(self.controller)

        (response, raw) = self.controller.transact(stat_req)
        self.assertTrue(response, "Got no queue stats reply")
        queue_stats = response.stats[0]
        self.assertTrue(queue_stats.tx_bytes == 100, "Queue Stats Incorrect")
Пример #6
0
    def runTest(self):
        logging = get_logger()
        logging.info("Running Grp100No280 QueueOpFailedBadPort test")

        of_ports = config["port_map"].keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")

        logging.info("Sending queue_stats request ..")
        request = message.queue_stats_request()
        request.port_no = ofp.OFPP_MAX
        request.queue_id = ofp.OFPQ_ALL
        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Unable to send the message")

        logging.info("Waiting for OFPT_ERROR message...")

        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, timeout=10)
        self.assertTrue(response is not None, "Did not receive an error")
        self.assertTrue(
            response.type == ofp.OFPET_QUEUE_OP_FAILED,
            "Unexpected Error type. Expected OFPET_QUEUE_OP_FAILED error type")
        self.assertTrue(
            response.code == ofp.OFPQOFC_BAD_PORT,
            " Unexpected error code, Expected OFPQOFC_BAD_PORT error code")
Пример #7
0
def get_queuestats(self,port_num,queue_id):
#Generate Queue Stats request 

    request = message.queue_stats_request()
    request.port_no  = port_num
    request.queue_id = queue_id
    (queue_stats, p) = self.controller.transact(request)
    self.assertNotEqual(queue_stats, None, "Queue stats request failed")

    return (queue_stats,p)
Пример #8
0
def get_queuestats(self,port_num,queue_id):
#Generate Queue Stats request 

    request = message.queue_stats_request()
    request.port_no  = port_num
    request.queue_id = queue_id
    (queue_stats, p) = self.controller.transact(request)
    self.assertNotEqual(queue_stats, None, "Queue stats request failed")
    self.assertNotEqual(queue_stats.header.type, ofp.OFPT_ERROR, ' Cannot retreive the queue_stats: Check if the switch supports queue_stats request')
    return (queue_stats,p)
Пример #9
0
def get_queuestats(self,port_num,queue_id):
#Generate Queue Stats request 

    request = message.queue_stats_request()
    request.port_no  = port_num
    request.queue_id = queue_id
    (queue_stats, p) = self.controller.transact(request)
    self.assertNotEqual(queue_stats, None, "Queue stats request failed")
    self.assertNotEqual(queue_stats.header.type, ofp.OFPT_ERROR, ' Cannot retreive the queue_stats: Check if the switch supports queue_stats request')
    return (queue_stats,p)
Пример #10
0
def verify_queuestats(self,
                      port_num,
                      queue_id,
                      expect_packet=None,
                      expect_byte=None):

    # Verify queue counters : tx_packets and tx_bytes

    request = message.queue_stats_request()
    request.port_no = port_num
    request.queue_id = queue_id

    for i in range(0, 60):

        logging.info("Sending stats request")

        (queue_stats, p) = self.controller.transact(request)
        self.assertNotEqual(queue_stats, None, "Queue stats request failed")
        packet_counter = 0
        byte_counter = 0

        sleep(1)

        for item in queue_stats.stats:
            packet_counter += item.tx_packets
            byte_counter += item.tx_bytes

            logging.info("Transmitted" + str(packet_counter) + " packets")
            logging.info("Transmitted" + str(byte_counter) + "bytes")

        if expect_packet != None and packet_counter != expect_packet: continue
        if expect_byte != None and byte_counter != expect_byte: continue
        break

    if expect_packet != None:
        self.assertEqual(packet_counter, expect_packet,
                         "tx_packets counter is not incremented correctly")

    if expect_byte != None:
        self.assertEqual(byte_counter, expect_byte,
                         "tx_bytes counter is not incremented correctly")