예제 #1
0
    def runTest(self):
        ing_port = flow_mods_port_map.keys()[0]
        out_port1 = flow_mods_port_map.keys()[1]

        testutils.delete_all_flows(self.controller, self.logger)
        flow_add = message.flow_mod()
        flow_add.buffer_id = 0xffffffff
        flow_add.header.xid = 123
        flow_add.table_id = 0
        flow_add.command = ofp.OFPFC_ADD
        flow_add.match_fields.add(match.eth_type(value=0x86dd))
        flow_add.match_fields.add(match.ipv4_src(value=3232235521))
        flow_add.match_fields.add(match.ipv4_dst(value=3232235522))
        flow_add.match_fields.add(match.metadata(value=0))
        "new a instruction"
        inst = instruction.instruction_write_actions()
        "new a output actions"
        act = action.action_output()
        act.port = out_port1
        inst.actions.add(act)
        flow_add.instructions.add(inst)
        #self.controller.message_send(flow_add)
        #print(flow_add.show())
        testutils.ofmsg_send(self, flow_add)

        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, 2)
        self.assertTrue(response is not None, 'No error message received')
        self.assertEqual(
            ofp.OFPET_BAD_MATCH, response.type,
            'Error message type mismatch: ' + str(ofp.OFPET_BAD_MATCH) +
            " != " + str(response.type))
        self.assertEqual(
            ofp.OFPBMC_BAD_PREREQ, response.code,
            'Error message code mismatch: ' + str(ofp.OFPBMC_BAD_PREREQ) +
            " != " + str(response.code))
예제 #2
0
    def runTest(self):
        ing_port = flow_mods_port_map.keys()[0]
        out_port1 = flow_mods_port_map.keys()[1]

        testutils.delete_all_flows(self.controller, self.logger)
        flow_add = message.flow_mod()
        flow_add.buffer_id = 0xffffffff;
        flow_add.header.xid = 123
        flow_add.table_id = 0
        flow_add.command = ofp.OFPFC_ADD
        flow_add.match_fields.add(match.eth_type(value = 0x86dd))
        flow_add.match_fields.add(match.ipv4_src(value = 3232235521))
        flow_add.match_fields.add(match.ipv4_dst(value = 3232235522))
        flow_add.match_fields.add(match.metadata(value = 0))
        "new a instruction"
        inst = instruction.instruction_write_actions()
        "new a output actions"
        act = action.action_output()
        act.port = out_port1
        inst.actions.add(act)
        flow_add.instructions.add(inst)
        #self.controller.message_send(flow_add)
        #print(flow_add.show())
	testutils.ofmsg_send(self, flow_add)

        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, 2)
        self.assertTrue(response is not None, 'No error message received')
        self.assertEqual(ofp.OFPET_BAD_MATCH, response.type,
                       'Error message type mismatch: ' +
                       str(ofp.OFPET_BAD_MATCH) + " != " +
                       str(response.type))
        self.assertEqual(ofp.OFPBMC_BAD_PREREQ, response.code,
                       'Error message code mismatch: ' +
                       str(ofp.OFPBMC_BAD_PREREQ) + " != " +
                       str(response.code))
예제 #3
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))
예제 #4
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))