示例#1
0
    def runTest(self):
        """
        ** Currently, same scenario with "NoGoto" **

        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; do nothing // match but stop pipeline
        Fourth Table; Match IP Src A; send to 2  // not match, just a fake

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.WC_ACL_TABLE, testutils.WC_SERV_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE, testutils.EX_L2_TABLE,
                                                                        of_ports[0], of_ports[2])

        # Set up third match, "Empty Instruction"
        pkt = testutils.simple_tcp_packet()
        request = testutils.flow_msg_create(self, pkt, ing_port = of_ports[2], table_id = testutils.EX_L2_TABLE)
        testutils.flow_msg_install(self, request)

        # Set up fourth match
        testutils.write_output(self, testutils.EX_VLAN_TABLE, of_ports[1])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[0]
        testutils.reply_check_dp(self, tcp_sport=1234,
                       ing_port = of_ports[2], egr_port = of_ports[0])
示例#2
0
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; do nothing // match but stop pipeline
        Fourth Table; Match IP Src A; send to 2  // not match, just a fake

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_VLAN_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.EX_ACL_TABLE, testutils.WC_ACL_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_ACL_TABLE, testutils.WC_SERV_TABLE, of_ports[0])

        # Set up third match
        testutils.write_output(self, testutils.WC_SERV_TABLE, of_ports[1], of_ports[2])

        # Set up fourth match
        testutils.write_output(self, testutils.EX_VLAN_TABLE, of_ports[1])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[0]
        testutils.reply_check_dp(self, tcp_sport=1234,
                       ing_port = of_ports[2], egr_port = of_ports[1])
示例#3
0
    def runTest(self):
        """
        Set table config as "Continue" and add flow entry:
        First Table; Match IP Src A; send to 1 // not match then continue
        Second Table; Match IP Src B; send to 2 // do execution

        Then send in 2 packets:
        IP B; expect out port 2
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set table config as "continue"
        testutils.set_table_config(self, testutils.WC_ACL_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTINUE, True)

        # Set up flow entries
        #write_output(self, testutils.EX_ACL_TABLE, of_ports[0], ip_src="192.168.1.10")
        testutils.write_output(self,
                               testutils.WC_ACL_TABLE,
                               of_ports[0],
                               ip_src="192.168.1.10")
        testutils.write_output(self,
                               testutils.WC_SERV_TABLE,
                               of_ports[1],
                               of_ports[2],
                               ip_src="192.168.1.70")
        testutils.do_barrier(self.controller)

        # Generate a packet not matching in the first table, but in the second
        testutils.reply_check_dp(self,
                                 ip_src='192.168.1.70',
                                 tcp_sport=1234,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[1])
示例#4
0
    def runTest(self):
        """
        Set the first table config as "Send to Controller" and the second
        table as "Drop", add flow entries:
        First Table; Match IP Src A; send to 1 // if not match, packet_in
        Second Table; Match IP Src B; send to 2 // if not match, drop

        Then send a packet:
        IP B; expect packet_in
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set table config as "send to controller" and "drop"
        testutils.set_table_config(self, testutils.WC_ACL_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTROLLER, True)
        testutils.set_table_config(self, testutils.WC_SERV_TABLE,
                                   ofp.OFPTC_TABLE_MISS_DROP, True)

        # Set up matches
        testutils.write_output(self,
                               testutils.WC_ACL_TABLE,
                               of_ports[0],
                               ip_src="192.168.1.10")
        testutils.write_output(self,
                               testutils.WC_SERV_TABLE,
                               of_ports[1],
                               of_ports[2],
                               ip_src="192.168.1.70")

        # Generate a packet not matching to any flow entry in the first table
        testutils.reply_check_ctrl(self,
                                   ip_src='192.168.1.70',
                                   tcp_sport=1234,
                                   ing_port=of_ports[2])
示例#5
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        # Clear flow table
        rv = testutils.initialize_table_config(self)
        self.assertEqual(rv, 0, "Failed to initialize table config")
        rv = testutils.delete_all_flows(self.controller, pa_logger)
        self.assertEqual(rv, 0, "Failed to delete all flows")

        # Set up first match,fengqiang modify at 20130109
        testutils.write_goto_output(self, testutils.EX_ACL_TABLE, testutils.WC_ACL_TABLE, of_ports[0])

        # Set up fourth match,fengqiang modify at 20130109
        testutils.write_output(self, testutils.WC_ACL_TABLE, of_ports[1])    
        
        # Generate a packet matching both flow 1 and flow 2; rcv on port[1]
        pkt = testutils.simple_tcp_packet(ip_src = testutils.MT_TEST_IP)
        self.dataplane.send(of_ports[2], str(pkt))
        (rcv_port, rcv_pkt, _) = self.dataplane.poll(timeout=5)
        self.assertTrue(rcv_pkt is not None, "Did not receive packet")
        pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
                        str(rcv_port))
        self.assertEqual(rcv_port, of_ports[1], "Unexpected receive port")
示例#6
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        # Clear flow table
        rv = testutils.initialize_table_config(self)
        self.assertEqual(rv, 0, "Failed to initialize table config")
        rv = testutils.delete_all_flows(self.controller, pa_logger)
        self.assertEqual(rv, 0, "Failed to delete all flows")

        # Set up first match,fengqiang modify at 20130109
        testutils.write_goto_output(self, testutils.EX_ACL_TABLE,
                                    testutils.WC_ACL_TABLE, of_ports[0])

        # Set up fourth match,fengqiang modify at 20130109
        testutils.write_output(self, testutils.WC_ACL_TABLE, of_ports[1])

        # Generate a packet matching both flow 1 and flow 2; rcv on port[1]
        pkt = testutils.simple_tcp_packet(ip_src=testutils.MT_TEST_IP)
        self.dataplane.send(of_ports[2], str(pkt))
        (rcv_port, rcv_pkt, _) = self.dataplane.poll(timeout=5)
        self.assertTrue(rcv_pkt is not None, "Did not receive packet")
        pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
                        str(rcv_port))
        self.assertEqual(rcv_port, of_ports[1], "Unexpected receive port")
示例#7
0
    def runTest(self):
        """
        Set the first table config as "Drop" and second table as "Controller"
        add flow entry:
        First Table; Match IP Src A; send to 1 // if not match, then drop
        Second Table; Match IP Src B; send to 2 // if not match, controller

        Then send in a packet:
        IP B; expect drop
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set table config as "drop" and "send to controller"
        testutils.set_table_config(self, testutils.WC_ACL_TABLE, ofp.OFPTC_TABLE_MISS_DROP, True)
        testutils.set_table_config(self, testutils.WC_SERV_TABLE, ofp.OFPTC_TABLE_MISS_CONTROLLER, True)

        # Set up first match
        testutils.write_output(self, testutils.WC_ACL_TABLE, of_ports[0], ip_src="192.168.1.10")
        testutils.write_output(self, testutils.WC_SERV_TABLE, of_ports[1], of_ports[2], 
                                                                        ip_src="192.168.1.70")

        # Generate a packet not matching to any flow, then drop
        pkt = testutils.simple_tcp_packet(ip_src='192.168.1.70', tcp_sport=10)
        self.dataplane.send(of_ports[2], str(pkt))
        # checks no response from controller and dataplane
        (response, _) = self.controller.poll(ofp.OFPT_PACKET_IN, 2)
        # self.assertIsNone() is preferable for newer python
        self.assertFalse(response is not None, "PacketIn message is received")
        (_, rcv_pkt, _) = self.dataplane.poll(timeout=5)
        self.assertFalse(rcv_pkt is not None, "Packet on dataplane")
示例#8
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        ing_port = of_ports[1]
        egr_port = of_ports[2]

        "clear swtich;"
        testutils.delete_all_flows(self.controller, self.logger)
        # Set table config as "continue"
        testutils.set_table_config(self, testutils.EX_ACL_TABLE, ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.WC_ACL_TABLE, ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.WC_SERV_TABLE, ofp.OFPTC_TABLE_MISS_CONTROLLER, True)
        testutils.set_table_config(self, testutils.EX_L2_TABLE, ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.EX_VLAN_TABLE, ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.EX_MPLS_TABLE, ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.EX_L3_TABLE, ofp.OFPTC_TABLE_MISS_CONTROLLER, True)

        #"make test packet;"
        pkt = testutils.simple_icmp_packet()

        inst_write_metadata = instruction.instruction_write_metadata();
        inst_write_metadata.metadata = 0x20000000
        inst_write_metadata.metadata_mask = 0xf0000000

        testutils.write_goto(self, testutils.WC_SERV_TABLE, testutils.EX_L2_TABLE, ing_port, add_inst = inst_write_metadata)

        pkt_metadata = {'metadata_val':inst_write_metadata.metadata, 
                        'metadata_msk':inst_write_metadata.metadata_mask}
        match_fields = testutils.packet_to_exact_flow_match(pkt_metadata = pkt_metadata, table_id = testutils.EX_L3_TABLE)
        testutils.write_output(self, testutils.EX_L3_TABLE, egr_port, match_fields=match_fields)

        testutils.reply_check_dp(self, tcp_sport=1234, ing_port = ing_port, egr_port = egr_port)
        
        testutils.set_table_config(self, testutils.EX_L3_TABLE, ofp.OFPTC_TABLE_MISS_CONTROLLER)
示例#9
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        ing_port = of_ports[1]
        egr_port =ofp.OFPP_CONTROLLER

        "clear swtich;"
        testutils.delete_all_flows(self.controller, self.logger)
        # Set table config as "continue"
        testutils.set_table_config(self, testutils.WC_ACL_TABLE, ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.WC_SERV_TABLE, ofp.OFPTC_TABLE_MISS_DROP, True)
        testutils.set_table_config(self, testutils.EX_L2_TABLE, ofp.OFPTC_TABLE_MISS_CONTROLLER, True)

        #"make test packet;"
        pkt = testutils.simple_icmp_packet()

        inst_write_metadata = instruction.instruction_write_metadata();
        inst_write_metadata.metadata = 0x20000000
        inst_write_metadata.metadata_mask = 0xf0000000

        testutils.write_goto(self, testutils.WC_SERV_TABLE, testutils.EX_L2_TABLE, ing_port, add_inst = inst_write_metadata)

        pkt_metadata = {'metadata_val':inst_write_metadata.metadata, 'metadata_msk':inst_write_metadata.metadata_mask}
        match_fields = testutils.packet_to_exact_flow_match(pkt_metadata = pkt_metadata, table_id = testutils.EX_L2_TABLE)
        testutils.write_output(self, testutils.EX_L2_TABLE, egr_port, match_fields=match_fields)
        
        self.dataplane.send(ing_port, str(pkt))
        (response, _) = self.controller.poll(ofp.OFPT_PACKET_IN, 2)
        self.assertTrue(response is not None, 'Packet in message not received on port ' + str(egr_port))
        if str(pkt) != response.data:
               pa_logger.debug("pkt  len " + str(len(str(pkt))) +": " + str(pkt))
               pa_logger.debug("resp len " + str(len(str(response.data))) + ": " + str(response.data))
示例#10
0
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; send to 1, goto Second Table
        Second Table; Match IP Src A; write metadata, goto Third Table
        Third Table; Match IP Src A and metadata; send to 2 // stop, do action
        Fourth Table; Match IP Src A; send to 1 // not match, just a trap

        Then send in 2 packets:
        IP A, TCP C; expect out port 2
        IP A, TCP B; expect out port 2

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_VLAN_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto_output(self, testutils.WC_ACL_TABLE,
                                    testutils.WC_SERV_TABLE, of_ports[0])

        # Set up second match
        inst = instruction.instruction_write_metadata()
        inst.metadata = 0xfedcba9876543210
        inst.metadata_mask = 0xffffffffffffffff
        testutils.write_goto(self,
                             testutils.WC_SERV_TABLE,
                             testutils.EX_L2_TABLE,
                             of_ports[2],
                             add_inst=inst)

        # Set up third match
        pkt_metadata = {
            'metadata_val': inst.metadata,
            'metadata_msk': inst.metadata_mask
        }
        match_fields = testutils.packet_to_exact_flow_match(
            pkt_metadata=pkt_metadata, table_id=testutils.EX_L2_TABLE)

        testutils.write_output(self,
                               testutils.EX_L2_TABLE,
                               of_ports[1],
                               match_fields=match_fields)

        # Set up fourth match
        #write_output(self, testutils.EX_VLAN_TABLE, of_ports[0])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        testutils.reply_check_dp(self,
                                 tcp_sport=1234,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[1])
示例#11
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        ing_port = of_ports[1]
        egr_port = of_ports[2]

        "clear swtich;"
        testutils.delete_all_flows(self.controller, self.logger)
        # Set table config as "continue"
        testutils.set_table_config(self, testutils.EX_ACL_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.WC_ACL_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.WC_SERV_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTROLLER, True)
        testutils.set_table_config(self, testutils.EX_L2_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.EX_VLAN_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.EX_MPLS_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.EX_L3_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTROLLER, True)

        #"make test packet;"
        pkt = testutils.simple_icmp_packet()

        inst_write_metadata = instruction.instruction_write_metadata()
        inst_write_metadata.metadata = 0x20000000
        inst_write_metadata.metadata_mask = 0xf0000000

        testutils.write_goto(self,
                             testutils.WC_SERV_TABLE,
                             testutils.EX_L2_TABLE,
                             ing_port,
                             add_inst=inst_write_metadata)

        pkt_metadata = {
            'metadata_val': inst_write_metadata.metadata,
            'metadata_msk': inst_write_metadata.metadata_mask
        }
        match_fields = testutils.packet_to_exact_flow_match(
            pkt_metadata=pkt_metadata, table_id=testutils.EX_L3_TABLE)
        testutils.write_output(self,
                               testutils.EX_L3_TABLE,
                               egr_port,
                               match_fields=match_fields)

        testutils.reply_check_dp(self,
                                 tcp_sport=1234,
                                 ing_port=ing_port,
                                 egr_port=egr_port)

        testutils.set_table_config(self, testutils.EX_L3_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTROLLER)
示例#12
0
    def runTest(self):
        """
        Add five flow entries:
        First Table; Match IP Src A; send to 1
        Second Table; Match IP Src B; send to 1
        Third Table; Match IP Src C; send to 1
        Fourth Table; Match IP Src D; send to 1

        Then send in 2 packets:
        IP F, TCP C; expect packet_in
        IP G, TCP B; expect packet_in

        @param self object instance
        @param first_table first table
        @param second_table second table
        @param third_table third table
        @param fourth_table fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up matches
        #write_output(self, testutils.EX_ACL_TABLE, 1, ip_src="192.168.1.10")
        #write_output(self, testutils.EX_ACL_TABLE, of_ports[0], ip_src="128.128.128.10")
        testutils.set_table_config(self, config = ofp.OFPTC_TABLE_MISS_CONTROLLER)
        testutils.write_output(self, testutils.WC_ACL_TABLE, of_ports[0], ip_src="192.168.1.10")
        testutils.write_output(self, testutils.WC_SERV_TABLE, of_ports[0],
                                                ing_port=of_ports[1], ip_src="192.168.1.20")
        testutils.write_output(self, testutils.EX_L2_TABLE, of_ports[0], ip_src="192.168.1.30")
        testutils.write_output(self, testutils.EX_L3_TABLE, of_ports[0], ip_src="192.168.1.40")

        # Generate a packet not matching to any flow, then packet_in
        testutils.reply_check_ctrl(self, ip_src='192.168.1.70', tcp_sport=1234,
                         ing_port = of_ports[2])
示例#13
0
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; clear action, goto Fourth Table
        Fourth Table; Match IP Src A; send to 2

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_L2_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        #write_goto(self, testutils.EX_ACL_TABLE, testutils.WC_ACL_TABLE)
        act = action.action_set_field()
        field = match.eth_src(parse.parse_mac("aa:aa:aa:aa:aa:aa"))
        act.field.add(field)
        testutils.write_goto_action(self,
                                    testutils.WC_ACL_TABLE,
                                    testutils.WC_SERV_TABLE,
                                    act=act)
        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE,
                                    testutils.EX_L3_TABLE, of_ports[0],
                                    of_ports[2])
        # Set up third match, "Clear Action"
        inst = instruction.instruction_clear_actions()
        testutils.write_goto(self,
                             testutils.EX_L3_TABLE,
                             testutils.WC_L3_TABLE,
                             of_ports[2],
                             add_inst=inst)
        # Set up fourth match
        testutils.write_output(self, testutils.WC_L3_TABLE, of_ports[1])
        #write_output(self, testutils.EX_L2_TABLE, 4)

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        testutils.reply_check_dp(self,
                                 tcp_sport=1234,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[1])
示例#14
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        ing_port = of_ports[1]
        egr_port = ofp.OFPP_CONTROLLER

        "clear swtich;"
        testutils.delete_all_flows(self.controller, self.logger)
        # Set table config as "continue"
        testutils.set_table_config(self, testutils.WC_ACL_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTINUE, True)
        testutils.set_table_config(self, testutils.WC_SERV_TABLE,
                                   ofp.OFPTC_TABLE_MISS_DROP, True)
        testutils.set_table_config(self, testutils.EX_L2_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTROLLER, True)

        #"make test packet;"
        pkt = testutils.simple_icmp_packet()

        inst_write_metadata = instruction.instruction_write_metadata()
        inst_write_metadata.metadata = 0x20000000
        inst_write_metadata.metadata_mask = 0xf0000000

        testutils.write_goto(self,
                             testutils.WC_SERV_TABLE,
                             testutils.EX_L2_TABLE,
                             ing_port,
                             add_inst=inst_write_metadata)

        pkt_metadata = {
            'metadata_val': inst_write_metadata.metadata,
            'metadata_msk': inst_write_metadata.metadata_mask
        }
        match_fields = testutils.packet_to_exact_flow_match(
            pkt_metadata=pkt_metadata, table_id=testutils.EX_L2_TABLE)
        testutils.write_output(self,
                               testutils.EX_L2_TABLE,
                               egr_port,
                               match_fields=match_fields)

        self.dataplane.send(ing_port, str(pkt))
        (response, _) = self.controller.poll(ofp.OFPT_PACKET_IN, 2)
        self.assertTrue(
            response is not None,
            'Packet in message not received on port ' + str(egr_port))
        if str(pkt) != response.data:
            pa_logger.debug("pkt  len " + str(len(str(pkt))) + ": " + str(pkt))
            pa_logger.debug("resp len " + str(len(str(response.data))) + ": " +
                            str(response.data))
示例#15
0
    def runTest(self):
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.WC_ACL_TABLE, testutils.WC_SERV_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE, testutils.EX_L2_TABLE, of_ports[0], of_ports[1])

        # Set up third match
        testutils.write_output(self, testutils.EX_L2_TABLE, of_ports[2])
        
        # Generate a packet and receive 3 responses
        pkt = testutils.simple_tcp_packet(ip_src = testutils.MT_TEST_IP)
        self.dataplane.send(of_ports[1], str(pkt))

        testutils.receive_pkt_verify(self, of_ports[2], pkt)
示例#16
0
     def runTest(self):
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.WC_ACL_TABLE, testutils.EX_L3_TABLE)

        # Set up second match
        testutils.write_goto(self, testutils.WC_SERV_TABLE, testutils.EX_L2_TABLE, of_ports[2])

        # Set up third match
        testutils.write_goto(self, testutils.EX_L2_TABLE, testutils.EX_L3_TABLE)
        
        # Set up fourth match
        testutils.write_output(self, testutils.EX_L3_TABLE, of_ports[1])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        testutils.reply_check_dp(self, tcp_sport=1234,
                       ing_port = of_ports[2], egr_port = of_ports[1])
示例#17
0
    def runTest(self):
        """
        Add flow entries:
        First Table; Match IP Src A; set ToS = tos1, goto Second Table
        First Table; Match IP Src B; set ToS = tos2, goto Second Table
        Second Table; Match IP Src A; send to 1
        Second Table; Match IP Src B; send to 1

        Then send packets:
        IP A;  expect port 1 with DSCP = dscp1
        IP B;  expect port 1 with DSCP = dscp2

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param dscp1 DSCP value to be set for first flow
        @param dscp2 DSCP value to be set for second flow
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up flow match in table A: set ToS
        #t_act = action.action_set_nw_tos()
        #t_act.nw_tos = tos1
        dscp1 = 4
        dscp2 = 8
        t_act = action.action_set_field()
        t_act.field = match.ip_dscp(dscp1)
        testutils.write_goto_action(self, testutils.WC_ACL_TABLE, testutils.WC_ALL_TABLE, t_act,
                          ip_src='192.168.1.10')
        t_act.field = match.ip_dscp(dscp2)
        #t_act.field = match.ip_ecn(3)
        testutils.write_goto_action(self, testutils.WC_ACL_TABLE, testutils.WC_ALL_TABLE, t_act,
                          ip_src='192.168.1.30',clear_tag=False)

        # Set up flow matches in table B: routing
        testutils.write_output(self, testutils.WC_ALL_TABLE, of_ports[1], of_ports[2], ip_src="192.168.1.10")
        testutils.write_output(self, testutils.WC_ALL_TABLE, of_ports[1], of_ports[2], ip_src="192.168.1.30")

        # Generate packets and check them
        exp_pkt = testutils.simple_tcp_packet(ip_src='192.168.1.10',
                                              tcp_sport=1234, ip_dscp=dscp1)
        testutils.reply_check_dp(self, ip_src='192.168.1.10', tcp_sport=1234,
                 exp_pkt=exp_pkt, ing_port=of_ports[2], egr_port=of_ports[1])
示例#18
0
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; send to 1, goto Second Table
        Second Table; Match IP Src A; write metadata, goto Third Table
        Third Table; Match IP Src A and metadata; send to 2 // stop, do action
        Fourth Table; Match IP Src A; send to 1 // not match, just a trap

        Then send in 2 packets:
        IP A, TCP C; expect out port 2
        IP A, TCP B; expect out port 2

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_VLAN_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto_output(self, testutils.WC_ACL_TABLE, testutils.WC_SERV_TABLE, of_ports[0])

        # Set up second match
        inst = instruction.instruction_write_metadata()
        inst.metadata = 0xfedcba9876543210
        inst.metadata_mask = 0xffffffffffffffff
        testutils.write_goto(self, testutils.WC_SERV_TABLE, testutils.EX_L2_TABLE, of_ports[2], add_inst=inst)

        # Set up third match
        pkt_metadata = {'metadata_val':inst.metadata, 'metadata_msk':inst.metadata_mask}
        match_fields = testutils.packet_to_exact_flow_match(pkt_metadata = pkt_metadata,
                                                            table_id = testutils.EX_L2_TABLE)

        testutils.write_output(self, testutils.EX_L2_TABLE, of_ports[1], match_fields=match_fields)

        # Set up fourth match
        #write_output(self, testutils.EX_VLAN_TABLE, of_ports[0])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        testutils.reply_check_dp(self, tcp_sport=1234,
                       ing_port = of_ports[2], egr_port = of_ports[1])
示例#19
0
    def runTest(self):
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.WC_ACL_TABLE,
                             testutils.WC_SERV_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE,
                                    testutils.EX_L2_TABLE, of_ports[0],
                                    of_ports[1])

        # Set up third match
        testutils.write_output(self, testutils.EX_L2_TABLE, of_ports[2])

        # Generate a packet and receive 3 responses
        pkt = testutils.simple_tcp_packet(ip_src=testutils.MT_TEST_IP)
        self.dataplane.send(of_ports[1], str(pkt))

        testutils.receive_pkt_verify(self, of_ports[2], pkt)
示例#20
0
    def runTest(self):
        """
        ** Currently, same scenario with "NoGoto" **

        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; do nothing // match but stop pipeline
        Fourth Table; Match IP Src A; send to 2  // not match, just a fake

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.WC_ACL_TABLE,
                             testutils.WC_SERV_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE,
                                    testutils.EX_L2_TABLE, of_ports[0],
                                    of_ports[2])

        # Set up third match, "Empty Instruction"
        pkt = testutils.simple_tcp_packet()
        request = testutils.flow_msg_create(self,
                                            pkt,
                                            ing_port=of_ports[2],
                                            table_id=testutils.EX_L2_TABLE)
        testutils.flow_msg_install(self, request)

        # Set up fourth match
        testutils.write_output(self, testutils.EX_VLAN_TABLE, of_ports[1])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[0]
        testutils.reply_check_dp(self,
                                 tcp_sport=1234,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[0])
示例#21
0
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; do nothing // match but stop pipeline
        Fourth Table; Match IP Src A; send to 2  // not match, just a fake

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_VLAN_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.EX_ACL_TABLE,
                             testutils.WC_ACL_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_ACL_TABLE,
                                    testutils.WC_SERV_TABLE, of_ports[0])

        # Set up third match
        testutils.write_output(self, testutils.WC_SERV_TABLE, of_ports[1],
                               of_ports[2])

        # Set up fourth match
        testutils.write_output(self, testutils.EX_VLAN_TABLE, of_ports[1])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[0]
        testutils.reply_check_dp(self,
                                 tcp_sport=1234,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[1])
示例#22
0
    def runTest(self):
        """
        Add five flow entries:
        First Table; Match IP Src A; send to 1
        Second Table; Match IP Src B; send to 1
        Third Table; Match IP Src C; send to 1
        Fourth Table; Match IP Src D; send to 1

        Then send in 2 packets:
        IP F, TCP C; expect packet_in
        IP G, TCP B; expect packet_in

        @param self object instance
        @param first_table first table
        @param second_table second table
        @param third_table third table
        @param fourth_table fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up matches
        #write_output(self, testutils.EX_ACL_TABLE, 1, ip_src="192.168.1.10")
        #write_output(self, testutils.EX_ACL_TABLE, of_ports[0], ip_src="128.128.128.10")
        testutils.set_table_config(self,
                                   config=ofp.OFPTC_TABLE_MISS_CONTROLLER)
        testutils.write_output(self,
                               testutils.WC_ACL_TABLE,
                               of_ports[0],
                               ip_src="192.168.1.10")
        testutils.write_output(self,
                               testutils.WC_SERV_TABLE,
                               of_ports[0],
                               ing_port=of_ports[1],
                               ip_src="192.168.1.20")
        testutils.write_output(self,
                               testutils.EX_L2_TABLE,
                               of_ports[0],
                               ip_src="192.168.1.30")
        testutils.write_output(self,
                               testutils.EX_L3_TABLE,
                               of_ports[0],
                               ip_src="192.168.1.40")

        # Generate a packet not matching to any flow, then packet_in
        testutils.reply_check_ctrl(self,
                                   ip_src='192.168.1.70',
                                   tcp_sport=1234,
                                   ing_port=of_ports[2])
示例#23
0
    def runTest(self):
        """
        Set the first table config as "Drop" and second table as "Controller"
        add flow entry:
        First Table; Match IP Src A; send to 1 // if not match, then drop
        Second Table; Match IP Src B; send to 2 // if not match, controller

        Then send in a packet:
        IP B; expect drop
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set table config as "drop" and "send to controller"
        testutils.set_table_config(self, testutils.WC_ACL_TABLE,
                                   ofp.OFPTC_TABLE_MISS_DROP, True)
        testutils.set_table_config(self, testutils.WC_SERV_TABLE,
                                   ofp.OFPTC_TABLE_MISS_CONTROLLER, True)

        # Set up first match
        testutils.write_output(self,
                               testutils.WC_ACL_TABLE,
                               of_ports[0],
                               ip_src="192.168.1.10")
        testutils.write_output(self,
                               testutils.WC_SERV_TABLE,
                               of_ports[1],
                               of_ports[2],
                               ip_src="192.168.1.70")

        # Generate a packet not matching to any flow, then drop
        pkt = testutils.simple_tcp_packet(ip_src='192.168.1.70', tcp_sport=10)
        self.dataplane.send(of_ports[2], str(pkt))
        # checks no response from controller and dataplane
        (response, _) = self.controller.poll(ofp.OFPT_PACKET_IN, 2)
        # self.assertIsNone() is preferable for newer python
        self.assertFalse(response is not None, "PacketIn message is received")
        (_, rcv_pkt, _) = self.dataplane.poll(timeout=5)
        self.assertFalse(rcv_pkt is not None, "Packet on dataplane")
示例#24
0
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; clear action, goto Fourth Table
        Fourth Table; Match IP Src A; send to 2

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_L2_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        #write_goto(self, testutils.EX_ACL_TABLE, testutils.WC_ACL_TABLE)
        act = action.action_set_field()
        field = match.eth_src(parse.parse_mac("aa:aa:aa:aa:aa:aa"))
        act.field.add(field)
        testutils.write_goto_action(self, testutils.WC_ACL_TABLE, testutils.WC_SERV_TABLE ,act = act)
        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE, testutils.EX_L3_TABLE, of_ports[0], of_ports[2])
        # Set up third match, "Clear Action"
        inst = instruction.instruction_clear_actions()
        testutils.write_goto(self, testutils.EX_L3_TABLE, testutils.WC_L3_TABLE, of_ports[2], add_inst=inst)
        # Set up fourth match
        testutils.write_output(self, testutils.WC_L3_TABLE, of_ports[1])
        #write_output(self, testutils.EX_L2_TABLE, 4)

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        testutils.reply_check_dp(self, tcp_sport=1234,
                       ing_port = of_ports[2], egr_port = of_ports[1])
示例#25
0
    def runTest(self):
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.WC_ACL_TABLE,
                             testutils.EX_L3_TABLE)

        # Set up second match
        testutils.write_goto(self, testutils.WC_SERV_TABLE,
                             testutils.EX_L2_TABLE, of_ports[2])

        # Set up third match
        testutils.write_goto(self, testutils.EX_L2_TABLE,
                             testutils.EX_L3_TABLE)

        # Set up fourth match
        testutils.write_output(self, testutils.EX_L3_TABLE, of_ports[1])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        testutils.reply_check_dp(self,
                                 tcp_sport=1234,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[1])
示例#26
0
    def runTest(self):
        """
        Set the first table config as "Send to Controller" and the second
        table as "Drop", add flow entries:
        First Table; Match IP Src A; send to 1 // if not match, packet_in
        Second Table; Match IP Src B; send to 2 // if not match, drop

        Then send a packet:
        IP B; expect packet_in
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set table config as "send to controller" and "drop"
        testutils.set_table_config(self, testutils.WC_ACL_TABLE, ofp.OFPTC_TABLE_MISS_CONTROLLER, True)
        testutils.set_table_config(self, testutils.WC_SERV_TABLE, ofp.OFPTC_TABLE_MISS_DROP, True)

        # Set up matches
        testutils.write_output(self, testutils.WC_ACL_TABLE, of_ports[0], ip_src="192.168.1.10")
        testutils.write_output(self, testutils.WC_SERV_TABLE, of_ports[1], of_ports[2],
                                                                        ip_src="192.168.1.70")

        # Generate a packet not matching to any flow entry in the first table
        testutils.reply_check_ctrl(self, ip_src='192.168.1.70', tcp_sport=1234,
                         ing_port = of_ports[2])
示例#27
0
    def runTest(self):
        """
        Set table config as "Continue" and add flow entry:
        First Table; Match IP Src A; send to 1 // not match then continue
        Second Table; Match IP Src B; send to 2 // do execution

        Then send in 2 packets:
        IP B; expect out port 2
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set table config as "continue"
        testutils.set_table_config(self, testutils.WC_ACL_TABLE, ofp.OFPTC_TABLE_MISS_CONTINUE, True)

        # Set up flow entries
        #write_output(self, testutils.EX_ACL_TABLE, of_ports[0], ip_src="192.168.1.10")
        testutils.write_output(self, testutils.WC_ACL_TABLE, of_ports[0], ip_src="192.168.1.10")
        testutils.write_output(self, testutils.WC_SERV_TABLE, of_ports[1], of_ports[2],
                                                                        ip_src="192.168.1.70")
        testutils.do_barrier(self.controller)

        # Generate a packet not matching in the first table, but in the second
        testutils.reply_check_dp(self, ip_src='192.168.1.70', tcp_sport=1234,
                       ing_port = of_ports[2], egr_port = of_ports[1])
示例#28
0
    def runTest(self):
        """
        Add flow entries:
        First Table; Match IP Src A; set ToS = tos1, goto Second Table
        First Table; Match IP Src B; set ToS = tos2, goto Second Table
        Second Table; Match IP Src A; send to 1
        Second Table; Match IP Src B; send to 1

        Then send packets:
        IP A;  expect port 1 with DSCP = dscp1
        IP B;  expect port 1 with DSCP = dscp2

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param dscp1 DSCP value to be set for first flow
        @param dscp2 DSCP value to be set for second flow
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up flow match in table A: set ToS
        #t_act = action.action_set_nw_tos()
        #t_act.nw_tos = tos1
        dscp1 = 4
        dscp2 = 8
        t_act = action.action_set_field()
        t_act.field = match.ip_dscp(dscp1)
        testutils.write_goto_action(self,
                                    testutils.WC_ACL_TABLE,
                                    testutils.WC_ALL_TABLE,
                                    t_act,
                                    ip_src='192.168.1.10')
        t_act.field = match.ip_dscp(dscp2)
        #t_act.field = match.ip_ecn(3)
        testutils.write_goto_action(self,
                                    testutils.WC_ACL_TABLE,
                                    testutils.WC_ALL_TABLE,
                                    t_act,
                                    ip_src='192.168.1.30',
                                    clear_tag=False)

        # Set up flow matches in table B: routing
        testutils.write_output(self,
                               testutils.WC_ALL_TABLE,
                               of_ports[1],
                               of_ports[2],
                               ip_src="192.168.1.10")
        testutils.write_output(self,
                               testutils.WC_ALL_TABLE,
                               of_ports[1],
                               of_ports[2],
                               ip_src="192.168.1.30")

        # Generate packets and check them
        exp_pkt = testutils.simple_tcp_packet(ip_src='192.168.1.10',
                                              tcp_sport=1234,
                                              ip_dscp=dscp1)
        testutils.reply_check_dp(self,
                                 ip_src='192.168.1.10',
                                 tcp_sport=1234,
                                 exp_pkt=exp_pkt,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[1])