diff --git a/tests/Actions.py b/tests/Actions.py
deleted file mode 100644
index 49f8b65..0000000
--- a/tests/Actions.py
+++ /dev/null
@@ -1,847 +0,0 @@
-
-"""These tests fall under Conformance Test-Suite (OF-SWITCH-1.0.0 TestCases).
-    Refer Documentation -- Detailed testing methodology 
-    <Some of test-cases are directly taken from oftest> """
-
-"Test Suite 6  ---> Actions "
-
-
-import logging
-
-import unittest
-import random
-
-import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
-import oftest.dataplane as dataplane
-import oftest.action as action
-import oftest.parse as parse
-import basic
-import time
-
-from testutils import *
-from time import sleep
-from FuncUtils import *
-
-ac_port_map = None
-ac_logger = None
-ac_config = None
-of_ports = None
-
-def test_set_init(config):
-    basic.test_set_init(config)
-    
-    global ac_port_map
-    global ac_logger
-    global ac_config
-    global of_ports
-
-    ac_logger = logging.getLogger("Running Actions test-suite")
-    ac_logger.info("Initializing test set")
-    ac_port_map = config["port_map"]
-    ac_config = config
-    
-    of_ports = ac_port_map.keys()
-    of_ports.sort()
-
-   
-
-class NoAction(basic.SimpleDataPlane):
-
-    """NoActionDrop : no action added to flow , drops the packet."""
-
-    def runTest(self):
-        
-        ac_logger.info("Running No_Action test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-        
-        ac_logger.info("Install a flow without action")
-        ac_logger.info("Send packets matching that flow")
-        ac_logger.info("Expecting switch to drop all packets")
-
-        # Insert a flow wildcard all without any action 
-        pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
-        match.wildcards=ofp.OFPFW_ALL
-        match.in_port = of_ports[0]
-        
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        rv = self.controller.message_send(msg)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        
-        #Sending N packets matching the flow inserted
-        for pkt_cnt in range(5):
-            self.dataplane.send(of_ports[0],str(pkt))
-        
-        #Verify packets not recieved on any of the dataplane ports 
-        for any_port in of_ports:
-            (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(timeout=1, port_number=any_port,exp_pkt=pkt)
-            self.assertTrue(rcv_pkt is None,
-                   "Packet received on port " + str(any_port))
-
-        #Verify packets not sent on control plane either
-        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN, timeout=1)
-        self.assertTrue(response is None,
-                        'Packets not received on control plane')
-
-
-class Announcement(basic.SimpleDataPlane):
-    
-    """Announcement : Get all supported actions by the switch.
-    Send OFPT_FEATURES_REQUEST to get features supported by sw."""
-
-    def runTest(self):
-
-        ac_logger.info("Running Announcement test")
-
-        ac_logger.info("Sending Features_Request")
-        ac_logger.info("Expecting Features Reply with supported actions")
-
-        # Sending Features_Request
-        request = message.features_request()
-        (reply, pkt) = self.controller.transact(request)
-        self.assertTrue(reply is not None, "Failed to get any reply")
-        self.assertEqual(reply.header.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
-        
-        supported_actions =[]
-        if(reply.actions &1<<ofp.OFPAT_OUTPUT):
-            supported_actions.append('OFPAT_OUTPUT')
-        if(reply.actions &1<<ofp.OFPAT_SET_VLAN_VID):
-            supported_actions.append('OFPAT_SET_VLAN_VID')
-        if(reply.actions &1<<ofp.OFPAT_SET_VLAN_PCP):
-            supported_actions.append('OFPAT_SET_VLAN_PCP')
-        if(reply.actions &1<<ofp.OFPAT_STRIP_VLAN):
-            supported_actions.append('OFPAT_STRIP_VLAN')
-        if(reply.actions &1<<ofp.OFPAT_SET_DL_SRC):
-            supported_actions.append('OFPAT_SET_DL_SRC')
-        if(reply.actions &1<<ofp.OFPAT_SET_DL_DST):
-            supported_actions.append('OFPAT_SET_NW_SRC')
-        if(reply.actions &1<<ofp.OFPAT_SET_NW_DST):
-            supported_actions.append('OFPAT_SET_NW_DST')
-        if(reply.actions &1<<ofp.OFPAT_SET_NW_TOS):
-            supported_actions.append('OFPAT_SET_NW_TOS')
-        if(reply.actions &1<<ofp.OFPAT_SET_TP_SRC):
-            supported_actions.append('OFPAT_SET_TP_SRC')
-        if(reply.actions &1<<ofp.OFPAT_SET_TP_DST):
-            supported_actions.append('OFPAT_SET_TP_DST')
-        if(reply.actions &1<<ofp.OFPAT_VENDOR):
-            supported_actions.append('OFPAT_VENDOR')
-        if(reply.actions &1<<ofp.OFPAT_ENQUEUE):
-            supported_actions.append('OFPAT_ENQUEUE')
-        
-        ac_logger.info(supported_actions)
-        
-
-class ForwardAll(basic.SimpleDataPlane):
-    
-    """ForwardAll : Packet is sent to all dataplane ports
-    except ingress port when output action.port = OFPP_ALL"""
-
-    def runTest(self):
-
-        ac_logger.info("Running Forward_All test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-        
-        ac_logger.info("Insert a flow with output action port OFPP_ALL")
-        ac_logger.info("Send packet matching the flow")
-        ac_logger.info("Expecting packet on all dataplane ports except ingress_port")
-        
-        #Create a packet
-        pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
-        act = action.action_output()
-
-        #Delete all flows 
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-        ingress_port=of_ports[0]
-        match.in_port = ingress_port
-
-        #Create a flow mod with action.port = OFPP_ALL
-        request = message.flow_mod()
-        request.match = match
-        request.match.wildcards = ofp.OFPFW_ALL&~ofp.OFPFW_IN_PORT
-        act.port = ofp.OFPP_ALL
-        request.actions.add(act)
-        
-        ac_logger.info("Inserting flow")
-        rv = self.controller.message_send(request)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
-
-        #Send Packet matching the flow
-        ac_logger.info("Sending packet to dp port " + str(ingress_port))
-        self.dataplane.send(ingress_port, str(pkt))
-
-        #Verifying packets recieved on expected dataplane ports
-        yes_ports = set(of_ports).difference([ingress_port])
-        receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
-                      self, ac_logger, ac_config)
-
-
-class ForwardController(basic.SimpleDataPlane):
-    
-    """ForwardController : Packet is sent to controller 
-    output.port = OFPP_CONTROLLER"""
-
-    def runTest(self):
-        
-        ac_logger.info("Running Forward_Controller test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-        
-        ac_logger.info("Insert a flow with output action port OFPP_CONTROLLER")
-        ac_logger.info("Send packet matching the flow")
-        ac_logger.info("Expecting packet on the control plane")
-        
-        #Create packet
-        pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
-        act = action.action_output()
-
-        for ingress_port in of_ports:
-            #Delete all flows 
-            rv = delete_all_flows(self.controller, ac_logger)
-            self.assertEqual(rv, 0, "Failed to delete all flows")
-
-            match.in_port = ingress_port
-            
-            #Create a flow mod message
-            request = message.flow_mod()
-            request.match = match
-            act.port = ofp.OFPP_CONTROLLER
-            request.actions.add(act)
-
-            ac_logger.info("Inserting flow")
-            rv = self.controller.message_send(request)
-            self.assertTrue(rv != -1, "Error installing flow mod")
-            self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
-            
-            #Send packet matching the flow
-            ac_logger.info("Sending packet to dp port " + str(ingress_port))
-            self.dataplane.send(ingress_port, str(pkt))
-
-            #Verifying packet recieved on the control plane port
-            (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN, timeout=10)
-            self.assertTrue(response is not None,
-                        'Packet in message not received by controller')
-    
-
-
-class ForwardLocal(basic.SimpleDataPlane):
-   
-    """ForwardLocal : Packet is sent to  OFPP_LOCAL port . 
-        TBD : To verify packet recieved in the local networking stack of switch"""
-
-    def runTest(self):
-
-        ac_logger.info("Running Forward_Local test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-        
-        ac_logger.info("Insert a flow with output action port OFPP_LOCAL")
-        ac_logger.info("Send packet matching the flow")
-        ac_logger.info("Expecting packet in the local networking stack of switch")
-        
-        #Clear switch state
-        pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
-        act = action.action_output()
-
-        for ingress_port in of_ports:
-            #Delete the flows
-            rv = delete_all_flows(self.controller, ac_logger)
-            self.assertEqual(rv, 0, "Failed to delete all flows")
-
-            match.in_port = ingress_port
-            #Create flow mod message
-            request = message.flow_mod()
-            request.match = match
-            act.port = ofp.OFPP_LOCAL
-            request.actions.add(act)
-
-            ac_logger.info("Inserting flow")
-            rv = self.controller.message_send(request)
-            self.assertTrue(rv != -1, "Error installing flow mod")
-            self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
-
-            #Send packet matching the flow
-            ac_logger.info("Sending packet to dp port " + str(ingress_port))
-            self.dataplane.send(ingress_port, str(pkt))
-
-            #TBD: Verification of packets being recieved.
-
-
-class ForwardFlood(basic.SimpleDataPlane):
-    
-    """Forward:Flood : Packet is sent to all dataplane ports
-    except ingress port when output action.port = OFPP_FLOOD 
-    TBD : Verification---Incase of STP being implemented, flood the packet along the minimum spanning tree,
-             not including the incoming interface. """
-    
-    def runTest(self):
-
-        ac_logger.info("Running Forward_Flood test")
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-        
-        ac_logger.info("Insert a flow with output action port OFPP_FORWARD")
-        ac_logger.info("Send packet matching the flow")
-        ac_logger.info("Expecting packet on all the ports except the input port")
-        
-        #Create a packet
-        pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
-        act = action.action_output()
-
-        #Delete all flows 
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-        ingress_port=of_ports[0]
-        match.in_port = ingress_port
-
-        #Create a flow mod with action.port = OFPP_ALL
-        request = message.flow_mod()
-        request.match = match
-        request.match.wildcards = ofp.OFPFW_ALL&~ofp.OFPFW_IN_PORT
-        act.port = ofp.OFPP_FLOOD
-        request.actions.add(act)
-        
-        ac_logger.info("Inserting flow")
-        rv = self.controller.message_send(request)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
-
-        #Send Packet matching the flow
-        ac_logger.info("Sending packet to dp port " + str(ingress_port))
-        self.dataplane.send(ingress_port, str(pkt))
-
-        #Verifying packets recieved on expected dataplane ports
-        yes_ports = set(of_ports).difference([ingress_port])
-        receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
-                      self, ac_logger, ac_config)
-
-class ForwardInport(basic.SimpleDataPlane):
-    
-    """ ForwardInPort : Packet sent to virtual port IN_PORT
-    If the output.port = OFPP.INPORT then the packet is sent to the input port itself"""
-
-    def runTest(self):
-
-        ac_logger.info("Running Forward_Inport test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-        
-        ac_logger.info("Insert a flow with output action port OFPP_INPORT")
-        ac_logger.info("Send packet matching the flow")
-        ac_logger.info("Expecting packet on the input port")
-        
-        #Create a packet
-        pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
-        act = action.action_output()
-
-        #Delete the flows
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-        ingress_port=of_ports[0]
-        match.in_port = ingress_port
-
-        # Create a flow mod message
-        request = message.flow_mod()
-        request.match = match
-        act.port = ofp.OFPP_IN_PORT
-            
-        request.actions.add(act)
-        ac_logger.info("Inserting flow")
-        rv = self.controller.message_send(request)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
-
-        #Send packet matching the flow
-        ac_logger.info("Sending packet to dp port " + str(ingress_port))
-        self.dataplane.send(ingress_port, str(pkt))
-        yes_ports = [ingress_port]
-
-        #Verfying packet recieved on expected dataplane ports
-        receive_pkt_check(self.dataplane, pkt, yes_ports,set(of_ports).difference([ingress_port]),
-                            self, ac_logger, ac_config)      
-
-class ForwardTable(basic.SimpleDataPlane):
-   
-    """ForwardTable : Perform actions in flow table. Only for packet-out messages.
-        If the output action.port in the packetout message = OFP.TABLE , then 
-        the packet implements the action specified in the matching flow of the FLOW-TABLE"""
-
-    def runTest(self):
-
-        ac_logger.info("Running Forward_Table test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-        
-        ac_logger.info("Insert a flow F with output action port set to some egress_port")
-        ac_logger.info("Send packet out message (matching flow F) with action.port = OFP.TABLE")
-        ac_logger.info("Expecting packet on the egress_port")
-        
-        #Insert a all wildcarded flow
-        (pkt,match) = Wildcard_All(self,of_ports)
-        
-        #Create a packet out message
-        pkt_out =message.packet_out();
-        pkt_out.data = str(pkt)
-        pkt_out.in_port = of_ports[0]
-        act = action.action_output()
-        act.port = ofp.OFPP_TABLE
-        pkt_out.actions.add(act)
-        rv = self.controller.message_send(pkt_out)
-        self.assertTrue(rv == 0, "Error sending out message")
-
-        #Verifying packet out message recieved on the expected dataplane port. 
-        (of_port, pkt, pkt_time) = self.dataplane.poll(port_number=of_ports[1],
-                                                             exp_pkt=pkt,timeout=3)
-        self.assertTrue(pkt is not None, 'Packet not received')
-
-
-class AddvlanTag(basic.SimpleDataPlane):
-    
-    """AddVlanTag : Adds VLAN Tag to untagged packet."""
-
-    def runTest(self):
-
-        ac_logger.info("Running Add_vlan_tag test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- set vlan id, if not skip the test")
-        ac_logger.info("Insert a flow with set vid action")
-        ac_logger.info("Send packet matching the flow , verify recieved packet has vid set")
-        
-        #Verify set_vlan_id is a supported action
-        sup_acts = sw_supported_actions(self)
-        if not(sup_acts & 1<<ofp.OFPAT_SET_VLAN_VID):
-           skip_message_emit(self, "Add VLAN tag test skipped")
-           return
-        
-        #Create packet to be sent and an expected packet with vid set
-        new_vid = 2
-        len_wo_vid = 100
-        len_w_vid = 104
-        pkt = simple_tcp_packet(pktlen=len_wo_vid)
-        exp_pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True, 
-                                    dl_vlan=new_vid,dl_vlan_pcp=0)
-        vid_act = action.action_set_vlan_vid()
-        vid_act.vlan_vid = new_vid
-
-        #Insert flow with action -- set vid , Send packet matching the flow, Verify recieved packet is expected packet
-        flow_match_test(self, ac_port_map, pkt=pkt, 
-                        exp_pkt=exp_pkt, action_list=[vid_act])
-
-class ModifyVlanTag(basic.SimpleDataPlane):
-
-    """ModifyVlanTag : Modifies VLAN Tag to tagged packet."""
-    
-    def runTest(self):
-
-        ac_logger.info("Running Modify_Vlan_Tag test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- modify vlan id, if not skip the test")
-        ac_logger.info("Insert a flow with action --set vid ")
-        ac_logger.info("Send tagged packet matching the flow , verify recieved packet has vid rewritten")
-        
-        #Verify set_vlan_id is a supported action
-        sup_acts = sw_supported_actions(self)
-        if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_VID):
-            skip_message_emit(self, "Modify VLAN tag test skipped")
-            return
-
-        #Create a tagged packet with old_vid to be sent, and expected packet with new_vid
-        old_vid = 2
-        new_vid = 3
-        pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=old_vid)
-        exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=new_vid)
-        vid_act = action.action_set_vlan_vid()
-        vid_act.vlan_vid = new_vid
-        
-        #Insert flow with action -- set vid , Send packet matching the flow.Verify recieved packet is expected packet.
-        flow_match_test(self, ac_port_map, pkt=pkt, exp_pkt=exp_pkt,
-                        action_list=[vid_act])
-        
-class VlanPrio1(basic.SimpleDataPlane):
-   
-    """AddVlanPrioUntaggedPkt : Add VLAN priority to untagged packet."""
-    
-    def runTest(self):
-
-        ac_logger.info("Running vlan_Prio_1 test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- set vlan priority, if not skip the test")
-        ac_logger.info("Insert a flow with action -- set vlan priority ")
-        ac_logger.info("Send untagged packet matching the flow , verify recieved packet has specified VLAN priority and has vid set tO 0 ")
-        
-        #Verify set_vlan_priority is a supported action
-        sup_acts = sw_supported_actions(self)
-        if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_PCP):
-            skip_message_emit(self, "Set VLAN priority test skipped")
-            return
-        
-        #Create a untagged packet to be sent and an expected packet with vid = 0 , vlan_priority set. 
-        vlan_id = 0
-        pkt = simple_tcp_packet()
-        exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vlan_id,dl_vlan_pcp=0)
-        act = action.action_set_vlan_vid()
-
-        #Insert flow with action -- set vLAN priority, Send packet matching the flow, Verify recieved packet is expected packet
-        flow_match_test(self, ac_port_map, pkt=pkt, exp_pkt=exp_pkt,
-                                action_list=[act])
-
-
-class VlanPrio2(basic.SimpleDataPlane):
-    
-    """ModifyVlanPrio : Modify VLAN priority to tagged packet."""
-    
-    def runTest(self):
-        
-        ac_logger.info("Running Vlan_Prio_2 test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- set vlan priority, if not skip the test")
-        ac_logger.info("Insert a flow with action -- set vlan priority ")
-        ac_logger.info("Send tagged packet matching the flow, verify recieved packet has vlan priority rewritten")
-        
-        #Verify set_vlan_priority is a supported action
-        sup_acts = sw_supported_actions(self,"true")
-        if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_PCP):
-            skip_message_emit(self, "modify_vlan_prio test skipped")
-            return
-        
-        #Create a tagged packet , and an expected packet with vlan_priority set to specified value
-        vid          = 123
-        old_vlan_pcp = 2
-        new_vlan_pcp = 3
-        pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid, dl_vlan_pcp=old_vlan_pcp)
-        exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid, dl_vlan_pcp=new_vlan_pcp)
-        vid_act = action.action_set_vlan_pcp()
-        vid_act.vlan_pcp = new_vlan_pcp
-
-        #Insert flow with action -- set vLAN priority, Send tagged packet matching the flow, Verify recieved packet is expected packet
-        flow_match_test(self, ac_port_map, pkt=pkt, exp_pkt=exp_pkt,
-                        action_list=[vid_act])
-
-
-class ModifyL2Src(basic.SimpleDataPlane):
-    
-    """ModifyL2Src :Modify the source MAC address"""
-
-    def runTest(self):
-
-        ac_logger.info("Running Modify_L2_Src test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- modify_l2_src, if not skip the test")
-        ac_logger.info("Insert a flow with action -- set etherent src address")
-        ac_logger.info("Send packet matching the flow, verify recieved packet src address rewritten ")
-
-        #Verify set_dl_src is a supported action
-        sup_acts = sw_supported_actions(self,use_cache="true")
-        if not (sup_acts & 1 << ofp.OFPAT_SET_DL_SRC):
-            skip_message_emit(self, "modify_l2_src test skipped")
-            return
-
-        #Create packet to be sent and expected packet with dl_src set to specified value
-        (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_src'],
-                                                check_test_params=True)
-        
-        #Insert flow with action -- set src address, Send packet matching the flow, Verify recieved packet is expected packet
-        flow_match_test(self, ac_port_map, pkt=pkt, exp_pkt=exp_pkt, 
-                        action_list=acts, max_test=2)
-
-
-class ModifyL2Dst(basic.SimpleDataPlane):
-    
-    """ModifyL2SDSt :Modify the dest MAC address"""
-
-    def runTest(self):
-
-        ac_logger.info("Running Modify_L2_Dst test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- modify_l2_dst, if not skip the test")
-        ac_logger.info("Insert a flow with action -- set etherent dst address ")
-        ac_logger.info("Send packet matching the flow, verify recieved packet dst address rewritten ")
-
-        #Verify set_dl_dst is a supported action
-        sup_acts = sw_supported_actions(self)
-        if not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST):
-            skip_message_emit(self, "modify_l2_dst test skipped")
-            return
-
-        #Create packet to be sent and expected packet with dl_src set to specified value
-        (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_dst'],
-                                                check_test_params=True)
-        
-        #Insert flow with action -- set dst address, Send packet matching the flow, Verify recieved packet is expected packet
-        flow_match_test(self, ac_port_map, pkt=pkt, exp_pkt=exp_pkt, 
-                        action_list=acts, max_test=2)
-
-class ModifyL3Src(basic.SimpleDataPlane):
-    
-    """ModifyL3Src : Modify the source IP address of an IP packet """
-
-    def runTest(self):
-
-        ac_logger.info("Running Modify_L3_Src test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- modify_l3_src, if not skip the test")
-        ac_logger.info("Insert a flow with action -- set network src address ")
-        ac_logger.info("Send packet matching the flow, verify recieved packet network src address rewritten ")
-        
-        #Verify set_nw_src is a supported action
-        sup_acts = sw_supported_actions(self)
-        if not (sup_acts & 1 << ofp.OFPAT_SET_NW_SRC):
-            skip_message_emit(self, "modify_l3_src test")
-            return
-
-        #Create packet to be sent and expected packet with nw_src set to specified value
-        (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_src'],
-                                                check_test_params=True)
-        
-        #Insert flow with action -- set nw src address, Send packet matching the flow, Verify recieved packet is expected packet
-        flow_match_test(self, ac_port_map, pkt=pkt, exp_pkt=exp_pkt, 
-                        action_list=acts, max_test=2)
-
-class ModifyL3Dst(basic.SimpleDataPlane):
-    
-    """ModifyL3Dst :Modify the dest IP address of an IP packet"""
-    
-    def runTest(self):
-
-        ac_logger.info("Running Modify_L3_Dst test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- modify_l3_dst, if not skip the test")
-        ac_logger.info("Insert a flow with action -- set network dst address ")
-        ac_logger.info("Send packet matching the flow, verify recieved packet network dst address rewritten ")
-
-        #Verify set_nw_dst is a supported action
-        sup_acts = sw_supported_actions(self,use_cache="true")
-        if not (sup_acts & 1 << ofp.OFPAT_SET_NW_DST):
-            skip_message_emit(self, "modify_l3_dst test skipped")
-            return
-        
-        #Create packet to be sent and expected packet with nw_dst set to specified value
-        (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_dst'],
-                                                check_test_params=True)
-        
-        #Insert flow with action -- set nw dst address, Send packet matching the flow, Verify recieved packet is expected packet
-        flow_match_test(self, ac_port_map, pkt=pkt, exp_pkt=exp_pkt, 
-                        action_list=acts, max_test=2)
-
-
-class ModifyL4Src(basic.SimpleDataPlane):
-    
-    """ModifyL4Src : Modify the source TCP port of a TCP packet"""
-    
-    def runTest(self):
-
-        ac_logger.info("Running Modify_L4_Src test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- modify_l4_src, if not skip the test")
-        ac_logger.info("Insert a flow with action -- set src tcp port")
-        ac_logger.info("Send packet matching the flow, verify recieved packet src tcp port is rewritten ")
-        
-        #Verify set_tp_src is a supported action
-        sup_acts = sw_supported_actions(self,use_cache="true")
-        if not (sup_acts & 1 << ofp.OFPAT_SET_TP_SRC):
-            skip_message_emit(self, "modify_l4_src test skipped")
-            return
-
-        #Create packet to be sent and expected packet with tcp_src set to specified value
-        (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['tcp_sport'],
-                                                check_test_params=True)
-        
-        #Insert flow with action -- set tcp src port, Send packet matching the flow, Verify recieved packet is expected packet
-        flow_match_test(self, ac_port_map, pkt=pkt, exp_pkt=exp_pkt, 
-                        action_list=acts, max_test=2)
-
-class ModifyL4Dst(basic.SimpleDataPlane):
-    
-    """ ModifyL4Dst: Modify the dest TCP port of a TCP packet """
-
-    def runTest(self):
-
-        ac_logger.info("Running Modify_L4_Dst test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- modify_l4_dst, if not skip the test")
-        ac_logger.info("Insert a flow with action -- set dst tcp port")
-        ac_logger.info("Send packet matching the flow, verify recieved packet dst tcp port is rewritten ")
-       
-        #Verify set_tp_dst is a supported action
-        sup_acts = sw_supported_actions(self,use_cache="true")
-        if not (sup_acts & 1 << ofp.OFPAT_SET_TP_DST):
-            skip_message_emit(self, "ModifyL4Dst test")
-            return
-
-        #Create packet to be sent and expected packet with tcp_dst set to specified value
-        (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['tcp_dport'],
-                                                check_test_params=True)
-        
-        #Insert flow with action -- set tcp dst port, Send packet matching the flow, Verify recieved packet is expected packet
-        flow_match_test(self, ac_port_map, pkt=pkt, exp_pkt=exp_pkt, 
-                        action_list=acts, max_test=2)
-
-class ModifyTos(basic.SimpleDataPlane):
-    
-    """ModifyTOS :Modify the IP type of service of an IP packet"""
-   
-    def runTest(self):
-
-        ac_logger.info("Running Modify_Tos test")
-
-        of_ports = ac_port_map.keys()
-        of_ports.sort()
-        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
-        
-        #Clear switch state
-        rv = delete_all_flows(self.controller, ac_logger)
-        self.assertEqual(rv, 0, "Failed to delete all flows")
-
-        ac_logger.info("Verify if switch supports the action -- modify_tos, if not skip the test")
-        ac_logger.info("Insert a flow with action -- set type of service ")
-        ac_logger.info("Send packet matching the flow, verify recieved packet has TOS rewritten ")
-       
-        #Verify set_tos is a supported action
-        sup_acts = sw_supported_actions(self,use_cache="true")
-        if not (sup_acts & 1 << ofp.OFPAT_SET_NW_TOS):
-            skip_message_emit(self, "ModifyTOS test")
-            return
-
-        #Create packet to be sent and expected packet with TOS set to specified value
-        (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_tos'],
-                                                check_test_params=True)
-        
-        #Insert flow with action -- set TOS, Send packet matching the flow, Verify recieved packet is expected packet
-        flow_match_test(self, ac_port_map, pkt=pkt, exp_pkt=exp_pkt, 
-                        action_list=acts, max_test=2, egr_count=-1)
