added
diff --git a/tests/actions.py b/tests/actions.py
new file mode 100644
index 0000000..49f8b65
--- /dev/null
+++ b/tests/actions.py
@@ -0,0 +1,847 @@
+
+"""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)
diff --git a/tests/detailed_contr_sw_messages.py b/tests/detailed_contr_sw_messages.py
new file mode 100644
index 0000000..158f787
--- /dev/null
+++ b/tests/detailed_contr_sw_messages.py
@@ -0,0 +1,837 @@
+"""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 3 --> Detailed Controller to switch messages"
+
+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
+
+from testutils import *
+from time import sleep
+from FuncUtils import *
+
+cs_port_map = None
+cs_logger = None
+cs_config = None
+
+def test_set_init(config):
+   
+
+    basic.test_set_init(config)
+
+    global cs_port_map
+    global cs_logger
+    global cs_config
+
+    cs_logger = logging.getLogger("Detailed controller to switch messages")
+    cs_logger.info("Initializing test set")
+    cs_port_map = config["port_map"]
+    cs_config = config
+
+
+class OverlapChecking(basic.SimpleDataPlane):
+    
+    """Verify that if overlap check flag is set in the flow entry and an overlapping flow is inserted then an error 
+        is generated and switch refuses flow entry"""
+    
+    def runTest(self):
+        
+        cs_logger.info("Running Overlap_Checking test")
+       
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear Switch State
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting two overlapping flows")
+        cs_logger.info("Expecting switch to return an error")
+
+        #Insert a flow F with wildcarded all fields
+        (pkt,match) = Wildcard_All(self,of_ports)
+
+        #Verify flow is active  
+        Verify_TableStats(self,active_entries=1)
+        
+        # Build a overlapping flow F'-- Wildcard All except ingress with check overlap bit set
+        Pkt_MatchIngress = simple_tcp_packet()
+        match3 = parse.packet_to_flow_match(Pkt_MatchIngress)
+        self.assertTrue(match3 is not None, "Could not generate flow match from pkt")
+        match3.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT
+        match3.in_port = of_ports[0]
+
+        msg3 = message.flow_mod()
+        msg3.command = ofp.OFPFC_ADD
+        msg3.match = match3
+        msg3.flags |= ofp.OFPFF_CHECK_OVERLAP
+        msg3.cookie = random.randint(0,9007199254740992)
+        msg3.buffer_id = 0xffffffff
+       
+        act3 = action.action_output()
+        act3.port = of_ports[1]
+        self.assertTrue(msg3.actions.add(act3), "could not add action")
+        rv = self.controller.message_send(msg3)
+        self.assertTrue(rv != -1, "Error installing flow mod")
+        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+        # Verify Flow does not get inserted 
+        Verify_TableStats(self,active_entries=1)
+
+        #Verify OFPET_FLOW_MOD_FAILED/OFPFMFC_OVERLAP error is recieved on the control plane
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR,         
+                                               timeout=5)
+        self.assertTrue(response is not None, 
+                               'Switch did not reply with error message') 
+        self.assertTrue(response.type==ofp.OFPET_FLOW_MOD_FAILED, 
+                               'Error message type is not flow mod failed ') 
+        self.assertTrue(response.code==ofp.OFPFMFC_OVERLAP, 
+                               'Error Message code is not overlap')
+
+
+class NoOverlapChecking(basic.SimpleDataPlane):
+
+    """Verify that without overlap check flag set, overlapping flows can be created."""  
+    
+    def runTest(self):
+     
+        cs_logger.info("Running No_Overlap_Checking test")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear Switch State
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting two overlapping flows")
+        cs_logger.info("Expecting switch to insert the flows without generating errors")
+
+        #Build a flow F with wildcarded all fields.
+        (pkt,match) = Wildcard_All(self,of_ports)
+        
+        #Verify flow is active  
+        Verify_TableStats(self,active_entries=1)
+        
+        # Build a overlapping flow F' without check overlap bit set.
+        Wildcard_All_Except_Ingress(self,of_ports)
+
+        # Verify Flow gets inserted 
+        Verify_TableStats(self,active_entries=2)
+
+
+class IdenticalFlows(basic.SimpleDataPlane):
+    
+    """Verify that adding two identical flows overwrites the existing one and clears counters"""
+
+    def runTest(self):
+        
+        cs_logger.info("Running Identical_Flows test ")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting two identical flows one by one")
+        cs_logger.info("Expecting switch to overwrite the first flow and clear the counters associated with it ")
+        
+        # Create and add flow-1, check on dataplane it is active.
+        (pkt,match) = Wildcard_All(self,of_ports)
+
+        # Verify active_entries in table_stats_request =1 
+        Verify_TableStats(self,active_entries=1)
+        
+        # Send Packet (to increment counters like byte_count and packet_count)
+        SendPacket(self,pkt,of_ports[0],of_ports[1])
+
+        # Verify Flow counters have incremented
+        Verify_FlowStats(self,match,byte_count=len(str(pkt)),packet_count=1)
+        
+        #Send Identical flow 
+        (pkt1,match1) = Wildcard_All(self,of_ports)
+
+        # Verify active_entries in table_stats_request =1 
+        Verify_TableStats(self,active_entries=1)
+
+        # Verify Flow counters reset
+        Verify_FlowStats(self,match,byte_count=0,packet_count=0)
+
+   
+class EmerFlowTimeout(basic.SimpleProtocol): 
+
+    """Timeout values are not allowed for emergency flows"""
+
+    def runTest(self):
+
+        cs_logger.info("Running Emergency_Flow_Timeout test")
+        
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting an emergency flow with timeout values")
+        cs_logger.info("Expecting switch to generate error ")
+        
+        #Insert an emergency flow 
+        pkt = simple_tcp_packet()
+        match = parse.packet_to_flow_match(pkt)
+        match.in_port = of_ports[0]
+        
+        request = message.flow_mod()
+        request.match = match
+        request.command = ofp.OFPFC_ADD
+        request.flags = request.flags|ofp.OFPFF_EMERG
+        request.hard_timeout =9
+        request.idle_timeout =9
+        
+        act = action.action_output()
+        act.port = of_ports[1]
+        
+        request.actions.add(act)
+        cs_logger.info("Inserting flow")
+        rv = self.controller.message_send(request)
+        self.assertTrue(rv != -1, "Flow addition did not fail.")
+
+        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+        #Verify OFPET_FLOW_MOD_FAILED/OFPFMFC_OVERLAP error is recieved on the control plane
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR,         
+                                               timeout=5)
+        self.assertTrue(response is not None, 
+                               'Switch did not reply with error message') 
+        self.assertTrue(response.type==ofp.OFPET_FLOW_MOD_FAILED, 
+                               'Error message type is not flow mod failed ') 
+        self.assertTrue(response.code==ofp.OFPFMFC_BAD_EMERG_TIMEOUT, 
+                               'Error Message code is not bad emergency timeout')
+
+
+class MissingModifyAdd(basic.SimpleDataPlane):
+
+    """If a modify does not match an existing flow, the flow gets added """
+    
+    def runTest(self):
+        
+        cs_logger.info("Running Missing_Modify_Add test")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        cs_logger.info("Inserting a flow-modify that does not match an existing flow")
+        cs_logger.info("Expecting flow to get added i.e OFPFC_MODIFY command should be taken as OFPFC_ADD ")
+
+        #Clear Switch State
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        #Generate a flow-mod,command OFPC_MODIFY 
+
+        request = message.flow_mod()
+        request.command = ofp.OFPFC_MODIFY
+        request.match.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT
+        request.match.in_port = of_ports[0]
+        request.cookie = random.randint(0,9007199254740992)
+        request.buffer_id = 0xffffffff
+        act3 = action.action_output()
+        act3.port = of_ports[1]
+        self.assertTrue(request.actions.add(act3), "could not add action")
+
+        cs_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") 
+
+        #Verify the flow gets added i.e. active_count= 1
+        Verify_TableStats(self,active_entries=1)
+
+
+class ModifyAction(basic.SimpleDataPlane):
+
+    """A modified flow preserves counters"""
+    
+    def runTest(self):
+        
+        cs_logger.info("Running Modify_Action test ")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting a Flow and incrementing flow counters. Modifying the flow action")
+        cs_logger.info("Expecting the flow action to be modified , but the flow-counters should be preserved")
+           
+        #Create and add flow-1 Match on all, except one wildcarded (src adddress).Action A , output to of_port[1]
+        (pkt,match) = Match_All_Except_Source_Address(self,of_ports)
+
+        #Send Packet matching the flow thus incrementing counters like packet_count,byte_count
+        SendPacket(self,pkt,of_ports[0],of_ports[1])
+
+        #Verify flow counters
+        Verify_FlowStats(self,match,byte_count=len(str(pkt)),packet_count=1)
+
+        #Modify flow- 1 
+        Modify_Flow_Action(self,of_ports,match)
+        
+        # Send Packet matching the flow-1 i.e ingress_port=port[0] and verify it is recieved on corret dataplane port i.e port[2]
+        SendPacket(self,pkt,of_ports[0],of_ports[2])
+        
+        #Verify flow counters are preserved
+        Verify_FlowStats(self,match,byte_count=(2*len(str(pkt))),packet_count=2)
+
+
+class StrictModifyAction(basic.SimpleDataPlane):
+
+    """Strict Modify Flow also changes action preserves counters"""
+
+    def runTest(self):
+        
+        cs_logger.info("Running Strict_Modify_Action test")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting Flows and incrementing flow counters. Strict Modify the flow action ")
+        cs_logger.info("Expecting the flow action to be modified , but the flow-counters should be preserved")
+        
+        #Create and add flow-1 Match on all, except one wildcarded (src adddress).Action A
+        (pkt,match) = Match_All_Except_Source_Address(self,of_ports,priority=100)
+        
+        #Create and add flow-2 , Match on ingress_port only, Action A
+        (pkt1,match1) = Wildcard_All_Except_Ingress(self,of_ports,priority=10)
+        
+        # Verify both the flows are active
+        Verify_TableStats(self,active_entries=2)
+
+        #Send a packet matching the flows, thus incrementing flow-counters (packet matches the flow F-1 with higher priority)
+        SendPacket(self,pkt,of_ports[0],of_ports[1])
+
+        # Verify flow counters of the flow-1
+        Verify_FlowStats(self,match,byte_count=len(str(pkt)),packet_count=1)
+
+        # Strict-Modify flow- 1 
+        Strict_Modify_Flow_Action(self,of_ports[2],match,priority=100)
+        
+        # Send Packet matching the flow-1 i.e ingress_port=port[0] and verify it is recieved on corret dataplane port i.e port[2]
+        SendPacket(self,pkt,of_ports[0],of_ports[2])
+        
+        # Verify flow counters are preserved
+        Verify_FlowStats(self,match,byte_count=(2*len(str(pkt))),packet_count=2)
+
+
+class DeleteNonexistingFlow(basic.SimpleDataPlane):
+    
+    """Request deletion of non-existing flow"""
+    
+    def runTest(self):
+        
+        cs_logger.info("Delete_NonExisting_Flow test begins")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Deleting a non-existing flow")
+        cs_logger.info("Expecting switch to ignore the command , without generating errors")
+
+        # Issue a delete command 
+        msg = message.flow_mod()
+        msg.match.wildcards = ofp.OFPFW_ALL
+        msg.out_port = ofp.OFPP_NONE
+        msg.command = ofp.OFPFC_DELETE
+        msg.buffer_id = 0xffffffff
+
+        # Verify no message or error is generated by polling the the control plane
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR,         
+                                               timeout=2)
+        self.assertTrue(response is None, 
+                        'Recieved Error for deleting non-exiting flow ')
+
+
+        
+class SendFlowRem(basic.SimpleDataPlane):
+    
+    """Check deletion of flows happens and generates messages as configured.
+    If Send Flow removed message Flag is set in the flow entry, the flow deletion of that respective flow should generate the flow removed message, 
+    vice versa also exists """
+
+    def runTest(self):
+
+        cs_logger.info("Running Send_Flow_Rem test ")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear swicth state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting flows F1 and F2 without and with send_flow_removed_message flag set ")
+        cs_logger.info("Deleting the flows")
+        cs_logger.info("Expecting flow removed message only for F2")
+
+        # Insert flow-1 with F without OFPFF_SEND_FLOW_REM flag set.
+        (pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+
+        # Verify flow is inserted 
+        Verify_TableStats(self,active_entries=1)
+
+        #Delete the flow-1
+        NonStrict_Delete(self,match,priority=0)
+
+        # Verify no flow removed message is generated for the FLOW-1
+
+        (response1, pkt1) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED,
+                                               timeout=2)
+        self.assertTrue(response1 is None, 
+                        'Received flow removed message for the flow with flow_rem flag not set')
+        
+        # Insert another flow F' with OFPFF_SEND_FLOW_REM flag set.
+        msg9 = message.flow_mod()
+        msg9.match.wildcards = ofp.OFPFW_ALL
+        msg9.cookie = random.randint(0,9007199254740992)
+        msg9.buffer_id = 0xffffffff
+        msg9.idle_timeout = 1
+        msg9.flags |= ofp.OFPFF_SEND_FLOW_REM
+        rv1 = self.controller.message_send(msg9)
+        self.assertTrue(rv1 != -1, "Error installing flow mod")
+        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+        # Delete the flow-2
+        rc2 = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc2, 0, "Failed to delete all flows")
+
+        # Verify flow removed message is generated for the FLOW-2
+
+        (response2, pkt2) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED,
+                                               timeout=2)
+        self.assertTrue(response2 is not None, 
+                        'Did not receive flow removed message for this flow')
+
+
+class DeleteEmerFlow(basic.SimpleProtocol):
+
+    """Delete emergency flow and verify no message is generated.An emergency flow deletion will not generate flow-removed messages even if 
+    Send Flow removed message flag was set during the emergency flow entry"""
+
+    def runTest(self):
+
+        cs_logger.info("Running Delete_Emer_Flow")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        
+        #Clear switch state        
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting a emergency flow with send_flow_removed flag set")
+        cs_logger.info("Expecting no flow_removed_message on the deletion of the emergency flow")
+        
+        # Insert a flow with emergency bit set.
+        pkt = simple_tcp_packet()
+        match = parse.packet_to_flow_match(pkt)
+        match.in_port = of_ports[0]
+        request = message.flow_mod()
+        request.match = match
+        request.command = ofp.OFPFC_ADD
+        request.flags = request.flags|ofp.OFPFF_EMERG|ofp.OFPFF_SEND_FLOW_REM
+        act = action.action_output()
+        act.port = of_ports[1]
+        request.actions.add(act)
+
+        rv = self.controller.message_send(request)
+        self.assertTrue(rv != -1, "Flow addition failed.")
+        
+        # Delete the emergency flow
+        
+        NonStrict_Delete(self,match)
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPFF_SEND_FLOW_REM ,
+                                               timeout=2)
+        self.assertTrue(response is None, 
+                        'Test Failed ')
+
+
+class StrictVsNonstrict(basic.SimpleDataPlane):
+
+    """Delete and verify strict and non-strict behaviors
+    This test compares the behavior of delete strict and non-strict"""
+
+    def runTest(self):
+        
+        cs_logger.info("Strict_Vs_Nonstrict test begins")
+        
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+        
+        cs_logger.info("Inserting a flow with exact match")
+        cs_logger.info("Issue Strict Delete command , verify it gets deleted")     
+        
+        #Insert F with an exact Match 
+        (pkt,match) = Exact_Match(self,of_ports)  
+        Verify_TableStats(self,active_entries=1)
+
+        #Issue Strict Delete Command , verify F gets deleted.
+        Strict_Delete(self,match)
+        Verify_TableStats(self,active_entries=0)
+
+        cs_logger.info("Inserting two overlapping flows")
+        cs_logger.info("Issue Strict Delete command ")
+        cs_logger.info("Expecting only one flow gets deleted , because Strict Delete matches on wildcards as well")     
+        
+        #Insert Flow T with match on all , except one wildcarded ( say src adddress ). 
+        (pkt,match) = Match_All_Except_Source_Address(self,of_ports)
+
+        #Insert another flow T' with match on ingress_port , wildcarded rest.  
+        (pkt1,match1) = Wildcard_All_Except_Ingress(self,of_ports)
+        Verify_TableStats(self,active_entries=2)
+
+        #Issue Strict Delete matching on ingress_port. Verify only T' gets deleted
+        Strict_Delete(self,match1)
+        Verify_TableStats(self,active_entries=1) 
+
+        cs_logger.info("Inserting two overlapping flows")
+        cs_logger.info("Issue Non-Strict Delete command ")
+        cs_logger.info("Expecting both the flow gets deleted , because wildcards are active")    
+
+        #Insert T and T' again . 
+        (pkt,match) = Match_All_Except_Source_Address(self,of_ports)
+        (pkt1,match1) = Wildcard_All_Except_Ingress(self,of_ports)
+        Verify_TableStats(self,active_entries=2)
+
+        #Issue Non-strict Delete with match on ingress_port.Verify T+T' gets deleted . 
+        NonStrict_Delete(self,match1)
+        Verify_TableStats(self,active_entries=0)
+
+        cs_logger.info("Inserting three overlapping flows with different priorities")
+        cs_logger.info("Issue Non-Strict Delete command ")
+        cs_logger.info("Expecting all the flows to get deleted")  
+  
+        #Insert T , add Priority P (say 100 ) 
+        (pkt,match) = Match_All_Except_Source_Address(self,of_ports,priority=100)
+
+        #Insert T' add priority (200).
+        (pkt1,match1) = Wildcard_All_Except_Ingress(self,of_ports,priority=200)
+        
+        #Insert T' again add priority 300 --> T" . 
+        (pkt2,match2) = Wildcard_All_Except_Ingress(self,of_ports,priority=300)
+        Verify_TableStats(self,active_entries=3)
+
+        #Issue Non-Strict Delete and verify all getting deleted
+        NonStrict_Delete(self,match1,priority=200)
+        Verify_TableStats(self,active_entries=0)
+
+        cs_logger.info("Inserting three overlapping flows with different priorities")
+        cs_logger.info("Issue Strict Delete command ")
+        cs_logger.info("Expecting only one to get deleted because here priorities & wildcards are being matched")  
+
+        #Issue Strict-Delete and verify only T'' gets deleted. 
+        (pkt,match) = Match_All_Except_Source_Address(self,of_ports,priority=100)
+        (pkt1,match1) = Wildcard_All_Except_Ingress(self,of_ports,priority=200)
+        (pkt2,match2) = Wildcard_All_Except_Ingress(self,of_ports,priority=300)
+        Strict_Delete(self,match1,priority=200)
+        Verify_TableStats(self,active_entries=2)
+
+        
+   
+class Outport1(basic.SimpleDataPlane):
+
+    """Delete flows filtered by action outport.If the out_port field in the delete command contains a value other than OFPP_NONE,
+    it introduces a constraint when matching. This constraint is that the rule must contain an output action directed at that port."""
+
+    def runTest(self):
+        
+        cs_logger.info("Outport1 test begins")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting a flow with output action --> of_port[1]")
+        cs_logger.info("Deleting the flow but with out_port set to of_port[2]")
+        cs_logger.info("Expecting switch to filter the delete command")
+        
+        #Build and send Flow-1 with action output to of_port[1]
+        (pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+
+        # Verify active_entries in table_stats_request = 1
+        Verify_TableStats(self,active_entries=1)
+
+        #Send delete command matching the flow-1 but with contraint out_port = of_port[2]
+        msg7 = message.flow_mod()
+        msg7.out_port = of_ports[2]
+        msg7.command = ofp.OFPFC_DELETE
+        msg7.buffer_id = 0xffffffff
+        msg7.match = match
+
+        rv = self.controller.message_send(msg7)
+        self.assertTrue(rv != -1, "Error installing flow mod")
+        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+        # Verify flow will not get deleted, active_entries in table_stats_request = 1
+        Verify_TableStats(self,active_entries=1)
+
+        cs_logger.info("Deleting the flow with out_port set to of_port[1]")
+        cs_logger.info("Expecting switch to delete the flow")
+
+        #Send Delete command with contraint out_port = of_ports[1]
+        msg7 = message.flow_mod()
+        msg7.out_port = of_ports[1]
+        msg7.command = ofp.OFPFC_DELETE
+        msg7.buffer_id = 0xffffffff
+        msg7.match = match
+
+        rv = self.controller.message_send(msg7)
+        self.assertTrue(rv != -1, "Error installing flow mod")
+        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+        
+        #Verify flow gets deleted.
+        Verify_TableStats(self,active_entries=0)
+
+
+class IdleTimeout(basic.SimpleDataPlane):
+
+    """ Verify that idle timeout is implemented"""
+
+    def runTest(self):
+        
+        cs_logger.info("Running Idle_Timeout test ")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+        
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting flow entry with idle_timeout set. Also send_flow_removed_message flag set")
+        cs_logger.info("Expecting the flow entry to delete with given idle_timeout")
+
+        #Insert a flow entry with idle_timeout=1.Send_Flow_Rem flag set
+        msg9 = message.flow_mod()
+        msg9.match.wildcards = ofp.OFPFW_ALL
+        msg9.cookie = random.randint(0,9007199254740992)
+        msg9.buffer_id = 0xffffffff
+        msg9.idle_timeout = 1
+        msg9.flags |= ofp.OFPFF_SEND_FLOW_REM
+        rv1 = self.controller.message_send(msg9)
+        self.assertTrue(rv1 != -1, "Error installing flow mod")
+        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+        #Verify flow gets inserted
+        Verify_TableStats(self,active_entries=1)
+        
+        # Verify flow removed message is recieved.
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED,
+                                               timeout=5)
+        self.assertTrue(response is not None, 
+                        'Did not receive flow removed message ')
+        self.assertEqual(ofp.OFPRR_IDLE_TIMEOUT, response.reason,
+                         'Flow table entry removal reason is not idle_timeout')
+        self.assertEqual(1, response.duration_sec,
+                         'Flow was not alive for 1 sec')
+
+
+class Outport2(basic.SimpleDataPlane):
+
+    """Add, modify flows with outport set. This field is ignored by ADD, MODIFY, and MODIFY STRICT messages."""
+
+    def runTest(self):
+        
+        cs_logger.info("Running Outport2 test ")
+
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Adding and modifying flow with out_port fields set")
+        cs_logger.info("Expecting switch to ignore out_port")
+
+        # Create and add flow-1,Action A ,output to port of_port[1], out_port set to of_ports[2]
+        (pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+
+        # Verify flow is active
+        Verify_TableStats(self,active_entries=1)
+        
+        # Send Packet matching the flow
+        SendPacket(self,pkt,of_ports[0],of_ports[1])
+        
+        # Insert Flow-Modify matching flow F-1 ,action A', output to port[2], out_port set to port[3]
+        Modify_Flow_Action(self,of_ports,match)
+
+        # Again verify active_entries in table_stats_request =1 
+        Verify_TableStats(self,active_entries=1)
+
+        #Verify action is modified
+        SendPacket(self,pkt,of_ports[0],of_ports[2])
+
+
+
+
+class HardTimeout(basic.SimpleDataPlane):
+
+    """ Verify that hard timeout is implemented """
+
+    def runTest(self):
+
+        cs_logger.info("Running Hard_Timeout test ")
+        
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting flow entry with hard_timeout set. Also send_flow_removed_message flag set")
+        cs_logger.info("Expecting the flow entry to delete with given hard_timeout")
+
+        # Insert a flow entry with hardtimeout=1 and send_flow_removed flag set
+        msg9 = message.flow_mod()
+        msg9.match.wildcards = ofp.OFPFW_ALL
+        msg9.cookie = random.randint(0,9007199254740992)
+        msg9.buffer_id = 0xffffffff
+        msg9.hard_timeout = 1
+        msg9.flags |= ofp.OFPFF_SEND_FLOW_REM
+        rv1 = self.controller.message_send(msg9)
+        self.assertTrue(rv1 != -1, "Error installing flow mod")
+        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+        #Verify flow gets inserted
+        Verify_TableStats(self,active_entries=1)
+
+        # Verify flow removed message is recieved.
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED,
+                                               timeout=5)
+        self.assertTrue(response is not None, 
+                        'Did not receive flow removed message ')
+        self.assertEqual(ofp.OFPRR_HARD_TIMEOUT, response.reason,
+                         'Flow table entry removal reason is not hard_timeout')
+        self.assertEqual(1, response.duration_sec,
+                         'Flow was not alive for 1 sec')
+
+
+class FlowTimeout(basic.SimpleDataPlane):
+  
+    """Verify that Flow removed messages are generated as expected
+    Flow removed messages being generated when flag is set, is already tested in the above tests 
+    So here, we test the vice-versa condition"""
+
+    
+    def runTest(self):
+
+        cs_logger.info("Running Flow_Timeout test ")
+        
+        of_ports = cs_port_map.keys()
+        of_ports.sort()
+        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, cs_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        cs_logger.info("Inserting flow entry with hard_timeout set and send_flow_removed_message flag not set")
+        cs_logger.info("Expecting the flow entry to delete, but no flow removed message")
+
+        # Insert a flow with hard_timeout = 1 but no Send_Flow_Rem flag set
+        pkt = simple_tcp_packet()
+        match3 = parse.packet_to_flow_match(pkt)
+        self.assertTrue(match3 is not None, "Could not generate flow match from pkt")
+        match3.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT
+        match3.in_port = of_ports[0]
+        msg3 = message.flow_mod()
+        msg3.out_port = of_ports[2] # ignored by flow add,flow modify 
+        msg3.command = ofp.OFPFC_ADD
+        msg3.cookie = random.randint(0,9007199254740992)
+        msg3.buffer_id = 0xffffffff
+        msg3.hard_timeout = 1
+        msg3.buffer_id = 0xffffffff
+        msg3.match = match3
+        act3 = action.action_output()
+        act3.port = of_ports[1]
+        self.assertTrue(msg3.actions.add(act3), "could not add action")
+
+        rv = self.controller.message_send(msg3)
+        self.assertTrue(rv != -1, "Error installing flow mod")
+        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+        #Verify no flow removed message is generated
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED,
+                                               timeout=3)
+        self.assertTrue(response is None, 
+                        'Recieved flow removed message ')
+
+        # Verify no entries in the table
+        Verify_TableStats(self,active_entries=0)
+
+
+
+        
+
+
+
+
+       
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/openflow_protocol_messages.py b/tests/openflow_protocol_messages.py
new file mode 100644
index 0000000..2bc934e
--- /dev/null
+++ b/tests/openflow_protocol_messages.py
@@ -0,0 +1,385 @@
+"""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 2 --> Openflow Protocol messages"
+
+
+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
+
+from testutils import *
+from time import sleep
+from FuncUtils import *
+
+
+of_port_map = None
+of_logger = None
+of_config = None
+
+def test_set_init(config):
+   
+
+    basic.test_set_init(config)
+
+    global of_port_map
+    global of_logger
+    global of_config
+
+    of_logger = logging.getLogger("Start Openflow_Protocol_Messages Conformance Test-suite")
+    of_logger.info("Initializing test set")
+    of_port_map = config["port_map"]
+    of_config = config
+
+
+class FeaturesRequest(basic.SimpleProtocol): 
+
+    """Verify Features_Request-Reply is implemented 
+    a) Send OFPT_FEATURES_REQUEST
+	b) Verify OFPT_FEATURES_REPLY is received without errors"""
+
+    def runTest(self):
+        of_logger.info("Running Features_Request test")
+        
+        of_ports = of_port_map.keys()
+        of_ports.sort()
+        
+        #Clear switch state
+        rc = delete_all_flows(self.controller, of_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+        
+        of_logger.info("Sending Features_Request")
+        of_logger.info("Expecting Features_Reply")
+
+        request = message.features_request()
+        rv = self.controller.message_send(request)
+        self.assertTrue(rv != -1, "Not able to send features request.")
+        
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FEATURES_REPLY,
+                                               timeout=2)
+        self.assertTrue(response is not None, 
+                        'Did not receive Features Reply')
+
+
+class ConfigurationRequest(basic.SimpleProtocol):
+    
+    """Check basic Get Config request is implemented
+    a) Send OFPT_GET_CONFIG_REQUEST
+    b) Verify OFPT_GET_CONFIG_REPLY is received without errors"""
+
+    def runTest(self):
+
+        of_logger.info("Running Configuration_Request test ")
+        
+        of_ports = of_port_map.keys()
+        of_ports.sort()
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, of_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        of_logger.info("Sending OFPT_GET_CONFIG_REQUEST ")
+        of_logger.info("Expecting OFPT_GET_CONFIG_REPLY ")
+
+        request = message.get_config_request()
+        rv = self.controller.message_send(request)
+        self.assertTrue(rv != -1, " Not able to send get_config request.")
+        
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_GET_CONFIG_REPLY,
+                                               timeout=2)
+        self.assertTrue(response is not None, 
+                        'Did not receive OFPT_GET_CONFIG_REPLY')
+
+class ModifyStateAdd(basic.SimpleProtocol):
+    
+    """Check basic Flow Add request is implemented
+    a) Send  OFPT_FLOW_MOD , command = OFPFC_ADD 
+    c) Send ofp_table_stats request , verify active_count=1 in reply"""
+
+    def runTest(self):
+
+        of_logger.info("Running Modify_State_Add test")
+
+        of_ports = of_port_map.keys()
+        of_ports.sort()
+        
+        #Clear switch state
+        rc = delete_all_flows(self.controller,of_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        of_logger.info("Inserting a flow entry")
+        of_logger.info("Expecting active_count=1 in table_stats_reply")
+
+        #Insert a flow entry matching on ingress_port
+        (Pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+
+        # Send Table_Stats_Request and verify flow gets inserted.
+        Verify_TableStats(self,active_entries=1)
+
+
+class ModifyStateDelete(basic.SimpleProtocol):
+    
+    """Check Basic Flow Delete request is implemented
+    a) Send OFPT_FLOW_MOD, command = OFPFC_ADD
+    b) Send ofp_table_stats request , verify active_count=1 in reply
+    c) Send OFPT_FLOW_MOD, command = OFPFC_DELETE
+    c) Send ofp_table_stats request , verify active_count=0 in reply"""
+
+    def runTest(self):
+
+        of_logger.info("Running Modify_State_Delete test")
+
+        of_ports = of_port_map.keys()
+        of_ports.sort()
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller,of_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        of_logger.info("Inserting a flow entry and then deleting it")
+        of_logger.info("Expecting the active_count=0 in table_stats_reply")
+
+        #Insert a flow matching on ingress_port 
+        (Pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+
+        #Verify Flow inserted.
+        Verify_TableStats(self,active_entries=1)
+
+        #Delete the flow 
+        NonStrict_Delete(self,match)
+
+        # Send Table_Stats_Request and verify flow deleted.
+        Verify_TableStats(self,active_entries=0)
+
+      
+
+class ModifyStateModify(basic.SimpleDataPlane):
+    
+    """Verify basic Flow Modify request is implemented
+    a) Send OFPT_FLOW_MOD, command = OFPFC_ADD, Action A 
+    b) Send OFPT_FLOW_MOD, command = OFPFC_MODIFY , with output action A'
+    c) Send a packet matching the flow, verify packet implements action A' """
+
+    def runTest(self):
+
+        of_logger.info("Running Modify_State_Modify test")
+
+        of_ports = of_port_map.keys()
+        of_ports.sort()
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, of_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        of_logger.info("Inserting a flow entry and then modifying it")
+        of_logger.info("Expecting the Test Packet to implement the modified action")
+
+        # Insert a flow matching on ingress_port with action A (output to of_port[1])    
+        (pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+  
+        # Modify the flow action (output to of_port[2])
+        Modify_Flow_Action(self,of_ports,match)
+        
+        # Send the Test Packet and verify action implemented is A' (output to of_port[2])
+        SendPacket(self, pkt, of_ports[0],of_ports[2])
+                       
+
+class ReadState(basic.SimpleProtocol):
+    
+    """Test that a basic Read state request (like flow_stats_get request) does not generate an error
+    a) Send OFPT_FLOW_MOD, command = OFPFC_ADD
+    b) Send ofp_flow_stats request
+    b) Verify switch replies without errors"""
+
+    def runTest(self):
+
+        of_logger.info("Running Read_State test")
+
+        of_ports = of_port_map.keys()
+        of_ports.sort()
+
+        #Clear switch state
+        rc = delete_all_flows(self.controller, of_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        of_logger.info("Inserting a flow entry and then sending flow_stats request")
+        of_logger.info("Expecting the a flow_stats_reply without errors")
+
+        # Insert a flow with match on ingress_port
+        (pkt,match ) = Wildcard_All_Except_Ingress(self,of_ports)
+        
+        #Verify Flow_Stats request does not generate errors
+        Verify_FlowStats(self,match)
+        
+class SendPacket(basic.SimpleDataPlane):
+    
+    """Test packet out function
+    a) Send packet out message for each dataplane port.
+    b) Verify the packet appears on the appropriate dataplane port"""
+    
+    def runTest(self):
+
+        of_logger.info("Running Send_Packet test")
+
+        of_ports = of_port_map.keys()
+        of_ports.sort()
+       
+        #Clear Switch state
+        rc = delete_all_flows(self.controller, of_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        of_logger.info("Sending a packet-out for each dataplane port")
+        of_logger.info("Expecting the packet on appropriate dataplane port")
+
+        for dp_port in of_ports:
+            for outpkt, opt in [
+                (simple_tcp_packet(), "simple TCP packet"),
+                (simple_eth_packet(), "simple Ethernet packet"),
+                (simple_eth_packet(pktlen=40), "tiny Ethernet packet")]:
+            
+                msg = message.packet_out()
+                msg.data = str(outpkt)
+                act = action.action_output()
+                act.port = dp_port
+                self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
+
+                of_logger.info("PacketOut to: " + str(dp_port))
+                rv = self.controller.message_send(msg)
+                self.assertTrue(rv == 0, "Error sending out message")
+
+                exp_pkt_arg = None
+                exp_port = None
+                if of_config["relax"]:
+                    exp_pkt_arg = outpkt
+                    exp_port = dp_port
+                (of_port, pkt, pkt_time) = self.dataplane.poll(timeout=2, 
+                                                                port_number=exp_port,
+                                                                exp_pkt=exp_pkt_arg)
+                
+                self.assertTrue(pkt is not None, 'Packet not received')
+                of_logger.info("PacketOut: got pkt from " + str(of_port))
+                if of_port is not None:
+                    self.assertEqual(of_port, dp_port, "Unexpected receive port")
+                if not dataplane.match_exp_pkt(outpkt, pkt):
+                    of_logger.debug("Sent %s" % format_packet(outpkt))
+                    of_logger.debug("Resp %s" % format_packet(
+                            str(pkt)[:len(str(outpkt))]))
+                self.assertEqual(str(outpkt), str(pkt)[:len(str(outpkt))],
+                                    'Response packet does not match send packet')
+
+        
+class PacketIn(basic.SimpleDataPlane):
+    
+    """Test basic packet_in function
+    a) Send a simple tcp packet to a dataplane port, without any flow-entry 
+    b) Verify that a packet_in event is sent to the controller"""
+    
+    def runTest(self):
+        
+        of_logger.info("Running Packet_In test")
+
+        of_ports = of_port_map.keys()
+        of_ports.sort()
+        ingress_port = of_ports[0]
+
+        #Clear Switch state
+        rc = delete_all_flows(self.controller, of_logger)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+        of_logger.info("Sending a Simple tcp packet a dataplane port")
+        of_logger.info("Expecting a packet_in event on the control plane")
+
+        # Send  packet on dataplane port and verify packet_in event gets generated.
+        pkt = simple_tcp_packet()
+        self.dataplane.send(ingress_port, str(pkt))
+        of_logger.info("Sending packet to dp port " + str(ingress_port) +
+                   ", expecting packet_in on control plane" )
+      
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_PACKET_IN,
+                                               timeout=2)
+        self.assertTrue(response is not None, 
+                               'Packet in event is not sent to the controller') 
+
+
+class Hello(basic.SimpleDataPlane):
+    
+    """Test Hello messages are implemented
+    a) Create Hello messages from controller
+    b) Verify switch also exchanges hello message -- (Poll the control plane)
+    d) Verify the version field in the hello messages is openflow 1.0.0 """
+
+    def runTest(self):
+        
+        of_logger.info("Running Hello test")
+
+        of_logger.info("Sending Hello")
+        of_logger.info("Expecting a Hello on the control plane with version--1.0.0")
+        
+        #Send Hello message
+        request = message.hello()
+        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_HELLO,
+                                               timeout=1)
+        self.assertTrue(response is not None, 
+                               'Switch did not exchange hello message in return') 
+        self.assertTrue(response.header.version == 0x01, 'switch openflow-version field is not 1.0.0')
+
+
+
+class EchoWithoutBody(basic.SimpleProtocol):
+    
+    """Test basic echo-reply is implemented
+    a)  Send echo-request from the controller side, note echo body is empty here.
+    b)  Verify switch responds back with echo-reply with same xid """
+    
+    def runTest(self):
+
+        of_logger.info("Running Echo_Without_Body test")
+
+        of_logger.info("Sending Echo Request")
+        of_logger.info("Expecting a Echo Reply with version--1.0.0 and same xid")
+
+        # Send echo_request
+        request = message.echo_request()
+        (response, pkt) = self.controller.transact(request)
+        self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY,'response is not echo_reply')
+        self.assertEqual(request.header.xid, response.header.xid,
+                         'response xid != request xid')
+        self.assertTrue(response.header.version == 0x01, 'switch openflow-version field is not 1.0.1')
+        self.assertEqual(len(response.data), 0, 'response data non-empty')
+
+
+class BarrierRequestReply(basic.SimpleProtocol):
+
+    """ Check basic Barrier request is implemented
+    a) Send OFPT_BARRIER_REQUEST
+    c) Verify OFPT_BARRIER_REPLY is recieved"""
+    
+    def runTest(self):
+
+        of_logger.info("Running Barrier_Request_Reply test")
+
+        of_logger.info("Sending Barrier Request")
+        of_logger.info("Expecting a Barrier Reply with same xid")
+
+        #Send Barrier Request
+        request = message.barrier_request()
+        (response, pkt) = self.controller.transact(request)
+        self.assertEqual(response.header.type, ofp.OFPT_BARRIER_REPLY,'response is not barrier_reply')
+        self.assertEqual(request.header.xid, response.header.xid,
+                         'response xid != request xid')
+
+
+
+
+