Esempio n. 1
0
    def runTest(self):
        ing_port = flow_mods_port_map.keys()[0]
        egr_port = flow_mods_port_map.keys()[1]
        table_id = testutils.EX_L3_TABLE
        flow_count = 10

        testutils.delete_all_flows_one_table(self.controller, self.logger,
                                             table_id)
        match_fields_ls = []
        ipv6_src_addr = 'fe80::2420:52ff:fe8f:5188'
        metadata_val = 0xaa22334455667788
        for i in range(flow_count):
            match_fields_ls.append(match_list())
            match_fields_ls[i].add(match.eth_type(testutils.IPV6_ETHERTYPE))
            match_fields_ls[i].add(
                match.ipv6_src(ipaddr.IPv6Address(ipv6_src_addr)))
            ipv6_dst_addr = 'fe80::2420:52ff:fe8f:' + str(5190 + i)
            match_fields_ls[i].add(
                match.ipv6_dst(ipaddr.IPv6Address(ipv6_dst_addr)))
            match_fields_ls[i].add(match.metadata(metadata_val))

            request = testutils.flow_msg_create(
                self,
                None,
                ing_port=ing_port,
                match_fields=match_fields_ls[i],
                egr_port=egr_port,
                table_id=table_id)
            testutils.flow_msg_install(self, request, False)

        match_fields = match_list()
        match_fields.add(match.eth_type(testutils.IPV6_ETHERTYPE))
        match_fields.add(match.ipv6_src(ipaddr.IPv6Address(ipv6_src_addr)))

        response = testutils.flow_stats_get(self, table_id=table_id)
        self.assertTrue(
            len(response.stats) == flow_count,
            'Did not add all flows successfully! Get table entry num is %d' %
            len(response.stats))

        request = testutils.flow_msg_create(self,
                                            None,
                                            None,
                                            ing_port,
                                            match_fields,
                                            table_id=table_id)
        request.command = ofp.OFPFC_DELETE
        testutils.flow_msg_install(self, request, False)

        response = testutils.flow_stats_get(self, table_id=table_id)

        self.assertTrue(
            len(response.stats) == 0,
            'Switch did not del the flow entry! Current table entry num is %d'
            % len(response.stats))
Esempio n. 2
0
    def runTest(self):
        of_ports = ipv6_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port = of_ports[3]
        
        # 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")

        # Add entry match 

        request = message.flow_mod()
        request.match.type = ofp.OFPMT_OXM
        port = match.in_port(of_ports[0])
        eth_type = match.eth_type(IPV6_ETHERTYPE)
        ipv6_src = match.ipv6_src(ipaddr.IPv6Address('fe80::2420:52ff:fe8f:5189'))
        
        request.match_fields.tlvs.append(port)
        request.match_fields.tlvs.append(eth_type)
        request.match_fields.tlvs.append(ipv6_src)
        
        field_2b_set = match.ipv6_dst(ipaddr.IPv6Address('fe80::2420:52ff:fe8f:DDDD'))
        act_setfield = action.action_set_field()
        act_setfield.field = field_2b_set
        
#       TODO: insert action set field properly
        act_out = action.action_output()
        act_out.port = of_ports[3]
        
        
        inst = instruction.instruction_apply_actions()
        inst.actions.add(act_setfield)
        inst.actions.add(act_out)
        request.instructions.add(inst)
        request.buffer_id = 0xffffffff
        
        request.priority = 1000
        ipv6_logger.debug("Adding flow ")
        
        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Failed to insert test flow")

        #Send packet
        pkt = testutils.simple_ipv6_packet(ip_src='fe80::2420:52ff:fe8f:5189',ip_dst='fe80::2420:52ff:fe8f:5190')
        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::2420:52ff:fe8f:DDDD')
        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")    
Esempio n. 3
0
    def runTest(self):
       	# Config
        of_ports = ipv6_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port =   of_ports[3]
        
        # Remove flows
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")

        # Add entry match 

        request = message.flow_mod()
        request.match.type = ofp.OFPMT_OXM
        port = match.in_port(of_ports[0])
        eth_type = match.eth_type(IPV6_ETHERTYPE)
        ipv6_src = match.ipv6_src(ipaddr.IPv6Address('fe80::2420:52ff:fe8f:5189'))        
        ip_proto = match.ip_proto(TCP_PROTOCOL)
        tcp_port = match.tcp_src(80)
        
        
        request.match_fields.tlvs.append(port)
        request.match_fields.tlvs.append(eth_type)
        request.match_fields.tlvs.append(ipv6_src)
        request.match_fields.tlvs.append(ip_proto)
        request.match_fields.tlvs.append(tcp_port)
        
        act = action.action_output()
        act.port = of_ports[3]
        inst = instruction.instruction_apply_actions()
        inst.actions.add(act)
        request.instructions.add(inst)
        request.buffer_id = 0xffffffff
        
        request.priority = 1000
        ipv6_logger.debug("Adding flow ")
        
        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Failed to send test flow")

        #Send packet
        pkt = testutils.simple_ipv6_packet(tcp_sport=80, tcp_dport=8080) 

        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(tcp_sport=80, tcp_dport=8080) 

        testutils.receive_pkt_verify(self, egr_port, exp_pkt)

        #Remove flows
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")
Esempio n. 4
0
    def runTest(self):
        # Config
        of_ports = ipv6_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port = of_ports[3]

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

        # Add entry match

        request = message.flow_mod()
        request.match.type = ofp.OFPMT_OXM
        port = match.in_port(of_ports[0])
        eth_type = match.eth_type(IPV6_ETHERTYPE)
        ipv6_src = match.ipv6_src(
            ipaddr.IPv6Address('fe80::2420:52ff:fe8f:5189'))
        ip_proto = match.ip_proto(TCP_PROTOCOL)
        tcp_port = match.tcp_src(80)

        request.match_fields.tlvs.append(port)
        request.match_fields.tlvs.append(eth_type)
        request.match_fields.tlvs.append(ipv6_src)
        request.match_fields.tlvs.append(ip_proto)
        request.match_fields.tlvs.append(tcp_port)

        act = action.action_output()
        act.port = of_ports[3]
        inst = instruction.instruction_apply_actions()
        inst.actions.add(act)
        request.instructions.add(inst)
        request.buffer_id = 0xffffffff

        request.priority = 1000
        ipv6_logger.debug("Adding flow ")

        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Failed to send test flow")

        #Send packet
        pkt = testutils.simple_ipv6_packet(tcp_sport=80, tcp_dport=8080)

        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(tcp_sport=80, tcp_dport=8080)

        testutils.receive_pkt_verify(self, egr_port, exp_pkt)

        #Remove flows
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")
Esempio n. 5
0
    def runTest(self):
        ing_port = flow_mods_port_map.keys()[0]
        egr_port = flow_mods_port_map.keys()[1]
        table_id = testutils.EX_L3_TABLE
        flow_count = 10

        testutils.delete_all_flows_one_table(self.controller, self.logger, table_id)
        match_fields_ls = []
        ipv6_src_addr = 'fe80::2420:52ff:fe8f:5188'
        metadata_val = 0xaa22334455667788
        for i in range(flow_count):
            match_fields_ls.append(match_list())
            match_fields_ls[i].add(match.eth_type(testutils.IPV6_ETHERTYPE))
            match_fields_ls[i].add(match.ipv6_src(ipaddr.IPv6Address(ipv6_src_addr)))
            ipv6_dst_addr = 'fe80::2420:52ff:fe8f:' + str(5190+i)
            match_fields_ls[i].add(match.ipv6_dst(ipaddr.IPv6Address(ipv6_dst_addr)))
            match_fields_ls[i].add(match.metadata(metadata_val))

            request = testutils.flow_msg_create(self, None, ing_port=ing_port, 
                                    match_fields = match_fields_ls[i], egr_port = egr_port, table_id = table_id)
            testutils.flow_msg_install(self, request, False)

        match_fields = match_list()
        match_fields.add(match.eth_type(testutils.IPV6_ETHERTYPE))
        match_fields.add(match.ipv6_src(ipaddr.IPv6Address(ipv6_src_addr)))

        response = testutils.flow_stats_get(self, table_id = table_id)
        self.assertTrue(len(response.stats) == flow_count,
                    'Did not add all flows successfully! Get table entry num is %d'  %len(response.stats))

        request = testutils.flow_msg_create(self, None, None, ing_port, match_fields, table_id = table_id)
        request.command = ofp.OFPFC_DELETE
        testutils.flow_msg_install(self, request, False)

        response = testutils.flow_stats_get(self, table_id = table_id)
        
        self.assertTrue(len(response.stats) == 0,
                    'Switch did not del the flow entry! Current table entry num is %d' %len(response.stats))
Esempio n. 6
0
    def runTest(self):
        of_ports = ipv6_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port = of_ports[3]

        # 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")

        # Add entry match

        request = message.flow_mod()
        request.match.type = ofp.OFPMT_OXM
        port = match.in_port(of_ports[0])
        eth_type = match.eth_type(IPV6_ETHERTYPE)
        ipv6_src = match.ipv6_src(
            ipaddr.IPv6Address('fe80::2420:52ff:fe8f:5189'))

        request.match_fields.tlvs.append(port)
        request.match_fields.tlvs.append(eth_type)
        request.match_fields.tlvs.append(ipv6_src)

        field_2b_set = match.ipv6_dst(
            ipaddr.IPv6Address('fe80::2420:52ff:fe8f:DDDD'))
        act_setfield = action.action_set_field()
        act_setfield.field = field_2b_set

        #       TODO: insert action set field properly
        act_out = action.action_output()
        act_out.port = of_ports[3]

        inst = instruction.instruction_apply_actions()
        inst.actions.add(act_setfield)
        inst.actions.add(act_out)
        request.instructions.add(inst)
        request.buffer_id = 0xffffffff

        request.priority = 1000
        ipv6_logger.debug("Adding flow ")

        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Failed to insert test flow")

        #Send packet
        pkt = testutils.simple_ipv6_packet(ip_src='fe80::2420:52ff:fe8f:5189',
                                           ip_dst='fe80::2420:52ff:fe8f:5190')
        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::2420:52ff:fe8f:DDDD')
        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")