コード例 #1
0
ファイル: multi-table.py プロジェクト: HuaweiSwitch/OpenFlow
    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))
コード例 #2
0
ファイル: multi-table.py プロジェクト: HuaweiSwitch/OpenFlow
    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)
コード例 #3
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])
コード例 #4
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)
コード例 #5
0
ファイル: multi-table.py プロジェクト: rrdenicol/oftest11
    def scenario4(self,
                  first_table=0,
                  second_table=1,
                  third_table=2,
                  fourth_table=3):
        """
        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 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 first match
        write_goto_output(self, first_table, second_table, of_ports[0])

        # Set up second match
        inst = instruction.instruction_write_metadata()
        inst.metadata = 0xfedcba9876543210
        inst.metadata_mask = 0xffffffffffffffff
        write_goto(self, second_table, third_table, add_inst=inst)

        # Set up third match
        match = make_match()
        match.metadata = 0xfedcba9876543210
        match.metadata_mask = 0xffffffffffffffff
        write_output(self, third_table, of_ports[1], match=match)

        # Set up fourth match
        write_output(self, fourth_table, of_ports[0])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        reply_check_dp(self,
                       tcp_sport=10,
                       ing_port=of_ports[2],
                       egr_port=of_ports[1])
        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        reply_check_dp(self,
                       tcp_sport=80,
                       ing_port=of_ports[2],
                       egr_port=of_ports[1])
コード例 #6
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))
コード例 #7
0
ファイル: multi-table.py プロジェクト: chesteve/oftest11
    def scenario4(self, first_table = 0, second_table = 1, third_table = 2, fourth_table = 3):
        """
        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 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 first match
        write_goto_output(self, first_table, second_table, of_ports[0])

        # Set up second match
        inst = instruction.instruction_write_metadata()
        inst.metadata =      0xfedcba9876543210
        inst.metadata_mask = 0xffffffffffffffff
        write_goto(self, second_table, third_table, add_inst=inst)

        # Set up third match
        match = make_match()
        match.metadata =      0xfedcba9876543210
        match.metadata_mask = 0xffffffffffffffff
        write_output(self, third_table, of_ports[1], match=match)

        # Set up fourth match
        write_output(self, fourth_table, of_ports[0])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        reply_check_dp(self, tcp_sport=10,
                       ing_port = of_ports[2], egr_port = of_ports[1])
        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        reply_check_dp(self, tcp_sport=80,
                       ing_port = of_ports[2], egr_port = of_ports[1])
コード例 #8
0
ファイル: multi-table.py プロジェクト: HuaweiSwitch/OpenFlow
    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])
コード例 #9
0
ファイル: ipv6.py プロジェクト: HuaweiSwitch/OpenFlow
    def runTest(self):
        of_ports = ipv6_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port = of_ports[2]
        table_id1 = testutils.EX_L3_TABLE
        table_id2 = testutils.WC_ALL_TABLE

        # Remove all entries Add entry match all
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")

        rv = testutils.set_table_config(self, table_id = table_id1)
        self.assertEqual(rv, 0, "Failed to set table config")

        # Add entry match
        pkt = testutils.simple_ipv6_packet(ip_dst='fe80::1:0:1234')
        pkt_metadata = {'metadata_val':0xabcdef0123456789,
                        'metadata_msk':0xffffffffffffffff}

        inst_ls1 = []
        inst1_write = instruction.instruction_write_metadata()
        inst1_write.metadata = pkt_metadata['metadata_val']
        inst1_write.metadata_mask = pkt_metadata['metadata_msk']

        inst1_goto = instruction.instruction_goto_table()
        inst1_goto.table_id = table_id2

        inst_ls1.append(inst1_write)
        inst_ls1.append(inst1_goto)
        request1 = testutils.flow_msg_create(self, pkt, ing_port = ing_port,
                            instruction_list = inst_ls1,
                            table_id = table_id1)

        testutils.flow_msg_install(self, request1)

        act_ls2 = []
        act2_setfld = action.action_set_field()
        act2_setfld.field = match.ipv6_dst(ipaddr.IPv6Address('fe80::1:6554:3e7f:1'))

        act2_out = action.action_output()
        act2_out.port = egr_port

        act_ls2.append(act2_setfld)
        act_ls2.append(act2_out)
        pkt_metadata = {'metadata_val':0xabcdef0100000000,
                        'metadata_msk':0xffffffff00000000}
        request2 = testutils.flow_msg_create(self, pkt, pkt_metadata, ing_port, 
                            action_list = act_ls2, table_id = table_id2)

        testutils.flow_msg_install(self, request2)

        #Send packet
        ipv6_logger.info("Sending IPv6 packet to " + str(ing_port))
        ipv6_logger.debug("Data: " + str(pkt).encode('hex'))
        self.dataplane.send(ing_port, str(pkt))

        #Receive packet
        exp_pkt = testutils.simple_ipv6_packet(ip_dst='fe80::1:6554:3e7f:1')
        testutils.receive_pkt_verify(self, egr_port, exp_pkt)

        #See flow match
        response = testutils.flow_stats_get(self)
        ipv6_logger.debug("Response" + response.show())

        #Remove flows
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")
コード例 #10
0
ファイル: ipv6.py プロジェクト: sun363587351/OpenFlow-1
    def runTest(self):
        of_ports = ipv6_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port = of_ports[2]
        table_id1 = testutils.EX_L3_TABLE
        table_id2 = testutils.WC_ALL_TABLE

        # Remove all entries Add entry match all
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")

        rv = testutils.set_table_config(self, table_id=table_id1)
        self.assertEqual(rv, 0, "Failed to set table config")

        # Add entry match
        pkt = testutils.simple_ipv6_packet(ip_dst='fe80::1:0:1234')
        pkt_metadata = {
            'metadata_val': 0xabcdef0123456789,
            'metadata_msk': 0xffffffffffffffff
        }

        inst_ls1 = []
        inst1_write = instruction.instruction_write_metadata()
        inst1_write.metadata = pkt_metadata['metadata_val']
        inst1_write.metadata_mask = pkt_metadata['metadata_msk']

        inst1_goto = instruction.instruction_goto_table()
        inst1_goto.table_id = table_id2

        inst_ls1.append(inst1_write)
        inst_ls1.append(inst1_goto)
        request1 = testutils.flow_msg_create(self,
                                             pkt,
                                             ing_port=ing_port,
                                             instruction_list=inst_ls1,
                                             table_id=table_id1)

        testutils.flow_msg_install(self, request1)

        act_ls2 = []
        act2_setfld = action.action_set_field()
        act2_setfld.field = match.ipv6_dst(
            ipaddr.IPv6Address('fe80::1:6554:3e7f:1'))

        act2_out = action.action_output()
        act2_out.port = egr_port

        act_ls2.append(act2_setfld)
        act_ls2.append(act2_out)
        pkt_metadata = {
            'metadata_val': 0xabcdef0100000000,
            'metadata_msk': 0xffffffff00000000
        }
        request2 = testutils.flow_msg_create(self,
                                             pkt,
                                             pkt_metadata,
                                             ing_port,
                                             action_list=act_ls2,
                                             table_id=table_id2)

        testutils.flow_msg_install(self, request2)

        #Send packet
        ipv6_logger.info("Sending IPv6 packet to " + str(ing_port))
        ipv6_logger.debug("Data: " + str(pkt).encode('hex'))
        self.dataplane.send(ing_port, str(pkt))

        #Receive packet
        exp_pkt = testutils.simple_ipv6_packet(ip_dst='fe80::1:6554:3e7f:1')
        testutils.receive_pkt_verify(self, egr_port, exp_pkt)

        #See flow match
        response = testutils.flow_stats_get(self)
        ipv6_logger.debug("Response" + response.show())

        #Remove flows
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")