Пример #1
0
    def runTest(self):
        logging = get_logger()
        logging.info("Running Grp40No190: Delete with constraint out_port")

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

        ok = delete_all_flows(self.controller)
        self.assertEqual(ok, 0, "Could not delete all flows.")

        ok = do_barrier(self.controller)
        self.assertEqual(ok, 0, "Barrier request failed.")

        # Craft a match with all fields but OFPFW_IN_PORT wildcarded.
        match = ofp.ofp_match()
        match.wildcards = ofp.OFPFW_ALL & ~ofp.OFPFW_IN_PORT
        match.in_port = ports[0]
        pkt = simple_tcp_packet()

        fmod = message.flow_mod()
        fmod.buffer_id = 0xffffffff
        fmod.command = ofp.OFPFC_ADD
        fmod.match = match

        fmod.actions = action_list.action_list()
        act = action.action_output()
        act.port = ports[1]
        fmod.actions.add(act)
        fmod.priority = 12
        ok = self.controller.message_send(fmod)
        self.assertNotEqual(ok, -1, "Error occurred while installing flow mod.")

        fmod.actions = action_list.action_list()
        act = action.action_output()
        act.port = ports[2]
        fmod.actions.add(act)
        fmod.priority = 11
        ok = self.controller.message_send(fmod)
        self.assertNotEqual(ok, -1, "Error occurred while installing flow mod.")

        ok = do_barrier(self.controller)
        self.assertEqual(ok, 0, "Barrier request failed.")

        # Verify data plane traffic is forwarded correctly.
        self.dataplane.send(ports[0], str(pkt))
        invalid = [ports[0], ports[2]]
        valid = [ports[1]]
        receive_pkt_check(self.dataplane, pkt, valid, invalid, self)

        # Send flow_mod with command set to delete. This will delete the
        # flow that forwards pkt out to ports[1].
        dmod = message.flow_mod()
        dmod.buffer_id = 0xffffffff
        dmod.command = ofp.OFPFC_DELETE
        dmod.match = match # Use the match that was used above.
        dmod.out_port = ports[1] # Add additional match contraint.
        ok = self.controller.message_send(dmod)
        self.assertNotEqual(ok, -1, "Error occurred while deleting flow mod.")

        ok = do_barrier(self.controller)
        self.assertEqual(ok, 0, "Barrier request failed.")

        # Verify data plane traffic is forwarded correctly.
        self.dataplane.send(ports[0], str(pkt))
        invalid = [ports[0], ports[1]]
        valid = [ports[2]]
        receive_pkt_check(self.dataplane, pkt, valid, invalid, self)
Пример #2
0
 def unpack(self, binary_string):
     binary_string = ofp_bucket.unpack(self, binary_string)
     self.actions = action_list()
     return self.actions.unpack(binary_string)
Пример #3
0
 def __init__(self):
     ofp_bucket.__init__(self)
     self.actions = action_list()
     self.type = None
     self.len = self.__len__()
Пример #4
0
    def runTest(self):
        logging = get_logger()
        logging.info("Running Grp40No190: Delete with constraint out_port")

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

        ok = delete_all_flows(self.controller)
        self.assertEqual(ok, 0, "Could not delete all flows.")

        ok = do_barrier(self.controller)
        self.assertEqual(ok, 0, "Barrier request failed.")

        # Craft a match with all fields but OFPFW_IN_PORT wildcarded.
        match = ofp.ofp_match()
        match.wildcards = ofp.OFPFW_ALL & ~ofp.OFPFW_IN_PORT
        match.in_port = ports[0]
        pkt = simple_tcp_packet()

        fmod = message.flow_mod()
        fmod.buffer_id = 0xffffffff
        fmod.command = ofp.OFPFC_ADD
        fmod.match = match

        fmod.actions = action_list.action_list()
        act = action.action_output()
        act.port = ports[1]
        fmod.actions.add(act)
        fmod.priority = 12
        ok = self.controller.message_send(fmod)
        self.assertNotEqual(ok, -1,
                            "Error occurred while installing flow mod.")

        fmod.actions = action_list.action_list()
        act = action.action_output()
        act.port = ports[2]
        fmod.actions.add(act)
        fmod.priority = 11
        ok = self.controller.message_send(fmod)
        self.assertNotEqual(ok, -1,
                            "Error occurred while installing flow mod.")

        ok = do_barrier(self.controller)
        self.assertEqual(ok, 0, "Barrier request failed.")

        # Verify data plane traffic is forwarded correctly.
        self.dataplane.send(ports[0], str(pkt))
        invalid = [ports[0], ports[2]]
        valid = [ports[1]]
        receive_pkt_check(self.dataplane, pkt, valid, invalid, self)

        # Send flow_mod with command set to delete. This will delete the
        # flow that forwards pkt out to ports[1].
        dmod = message.flow_mod()
        dmod.buffer_id = 0xffffffff
        dmod.command = ofp.OFPFC_DELETE
        dmod.match = match  # Use the match that was used above.
        dmod.out_port = ports[1]  # Add additional match contraint.
        ok = self.controller.message_send(dmod)
        self.assertNotEqual(ok, -1, "Error occurred while deleting flow mod.")

        ok = do_barrier(self.controller)
        self.assertEqual(ok, 0, "Barrier request failed.")

        # Verify data plane traffic is forwarded correctly.
        self.dataplane.send(ports[0], str(pkt))
        invalid = [ports[0], ports[1]]
        valid = [ports[2]]
        receive_pkt_check(self.dataplane, pkt, valid, invalid, self)
Пример #5
0
 def unpack(self, binary_string):
     binary_string = ofp_bucket.unpack(self, binary_string)
     self.actions = action_list()
     return self.actions.unpack(binary_string)
Пример #6
0
 def __init__(self):
     ofp_bucket.__init__(self)
     self.actions = action_list()
     self.type = None
     self.len = self.__len__()