diff --git a/tests/FuncUtils.py b/tests/FuncUtils.py
index ad00246..9e3fea6 100644
--- a/tests/FuncUtils.py
+++ b/tests/FuncUtils.py
@@ -1,4 +1,4 @@
-""" Defined Some common functions used by Conformance tests -- OF-SWITCH 1.0.0 Testcases """
+""" Some common function definitions used by Conformance tests -- OF-SWITCH 1.0.0 Testcases """
 
 import sys
 import copy
@@ -104,11 +104,11 @@
 
     return (pkt_wildcardsrc,match1)
 
-def match_wthernet_src_address(self,of_ports,priority=None):
+def match_ethernet_src_address(self,of_ports,priority=None):
     #Generate Match_Ethernet_SrC_Address flow
 
     #Create a simple tcp packet and generate match on ethernet src address flow
-    pkt_MatchSrc = simple_tcp_packet(dl_src='00:01:01:01:01:01')
+    pkt_MatchSrc = simple_eth_packet(dl_src='00:01:01:01:01:01')
     match = parse.packet_to_flow_match(pkt_MatchSrc)
     self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
@@ -136,7 +136,7 @@
     #Generate Match_Ethernet_Dst_Address flow
 
     #Create a simple tcp packet and generate match on ethernet dst address flow
-    pkt_matchdst = simple_tcp_packet(dl_dst='00:01:01:01:01:01')
+    pkt_matchdst = simple_eth_packet(dl_dst='00:01:01:01:01:01')
     match = parse.packet_to_flow_match(pkt_matchdst)
     self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
@@ -254,8 +254,6 @@
     return (pkt_matchingress,match3)
 
 
-
-
 def match_vlan_id(self,of_ports,priority=None):
     #Generate Match_Vlan_Id
 
@@ -264,7 +262,7 @@
     match = parse.packet_to_flow_match(pkt_matchvlanid)
     self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
-    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_VLAN
+    match.wildcards = ofp.OFPFW_ALL^ofp.OFPFW_DL_TYPE ^ofp.OFPFW_DL_VLAN
     msg = message.flow_mod()
     msg.out_port = ofp.OFPP_NONE
     msg.command = ofp.OFPFC_ADD
@@ -291,7 +289,7 @@
     match = parse.packet_to_flow_match(pkt_matchvlanpcp)
     self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
-    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_VLAN_PCP 
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_TYPE^ofp.OFPFW_DL_VLAN^ofp.OFPFW_DL_VLAN_PCP 
     msg = message.flow_mod()
     msg.out_port = ofp.OFPP_NONE
     msg.command = ofp.OFPFC_ADD
@@ -339,14 +337,14 @@
     return (pkt_mulL2,match)
 
 
-def match_mul_L4(self,of_ports,priority=None):
+def match_mul_l4(self,of_ports,priority=None):
     #Generate Match_Mul_L4 flow
 
         #Create a simple tcp packet and generate match on tcp protocol flow
     pkt_mulL4 = simple_tcp_packet(tcp_sport=111,tcp_dport=112)
     match = parse.packet_to_flow_match(pkt_mulL4)
     self.assertTrue(match is not None, "Could not generate flow match from pkt")
-    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_TP_SRC ^ofp.OFPFW_TP_DST 
+    match.wildcards = ofp.OFPFW_ALL^ofp.OFPFW_DL_TYPE ^ofp.OFPFW_NW_PROTO^ofp.OFPFW_TP_SRC ^ofp.OFPFW_TP_DST 
     msg = message.flow_mod()
     msg.out_port = ofp.OFPP_NONE
     msg.command = ofp.OFPFC_ADD
@@ -369,11 +367,11 @@
     #Generate a Match on IP Type of service flow
 
         #Create a simple tcp packet and generate match on Type of service 
-    pkt_iptos = simple_tcp_packet(ip_tos=3)
+    pkt_iptos = simple_tcp_packet(ip_tos=30)
     match = parse.packet_to_flow_match(pkt_iptos)
     self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
-    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_NW_TOS
+    match.wildcards = ofp.OFPFW_ALL^ofp.OFPFW_DL_TYPE^ofp.OFPFW_NW_PROTO ^ofp.OFPFW_NW_TOS
     msg = message.flow_mod()
     msg.out_port = ofp.OFPP_NONE
     msg.command = ofp.OFPFC_ADD
@@ -391,6 +389,33 @@
 
     return (pkt_iptos,match)
 
+def match_ip_protocol(self,of_ports,priority=None):
+    #Generate a Match on IP Protocol
+
+    #Create a simple tcp packet and generate match on Type of service 
+    pkt_iptos = simple_tcp_packet()
+    match = parse.packet_to_flow_match(pkt_iptos)
+    self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+    match.wildcards = ofp.OFPFW_ALL^ofp.OFPFW_DL_TYPE^ofp.OFPFW_NW_PROTO 
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != None :
+        msg.priority = priority
+    act = action.action_output()
+    act.port = of_ports[1]
+    self.assertTrue(msg.actions.add(act), "could not add action")
+
+    rv = self.controller.message_send(msg)
+    self.assertTrue(rv != -1, "Error installing flow mod")
+    self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+    return (pkt_iptos,match)
+
+
 def match_tcp_src(self,of_ports,priority=None):
     #Generate Match_Tcp_Src
 
@@ -399,7 +424,7 @@
     match = parse.packet_to_flow_match(pkt_matchtSrc)
     self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
-    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_TP_SRC  
+    match.wildcards = ofp.OFPFW_ALL^ofp.OFPFW_DL_TYPE ^ofp.OFPFW_NW_PROTO ^ofp.OFPFW_TP_SRC  
     msg = message.flow_mod()
     msg.out_port = ofp.OFPP_NONE
     msg.command = ofp.OFPFC_ADD
@@ -422,11 +447,11 @@
     #Generate Match_Tcp_Dst
 
         #Create a simple tcp packet and generate match on tcp destination port flow
-    pkt_Matchtdst = simple_tcp_packet(tcp_dport=112)
-    match = parse.packet_to_flow_match(pkt_matchtdst)
+    pkt_matchdst = simple_tcp_packet(tcp_dport=112)
+    match = parse.packet_to_flow_match(pkt_matchdst)
     self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
-    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_TP_DST  
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_TYPE^ofp.OFPFW_NW_PROTO^ofp.OFPFW_TP_DST  
     msg = message.flow_mod()
     msg.out_port = ofp.OFPP_NONE
     msg.command = ofp.OFPFC_ADD
@@ -442,11 +467,7 @@
     self.assertTrue(rv != -1, "Error installing flow mod")
     self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-    return (pkt_matchtdst,match)        
-
-
-
-
+    return (pkt_matchdst,match)        
 
 def match_ethernet_type(self,of_ports,priority=None):
     #Generate a Match_Ethernet_Type flow
@@ -472,11 +493,11 @@
     rv = self.controller.message_send(msg)
     self.assertTrue(rv != -1, "Error installing flow mod")
     self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
-
     return (pkt_matchtype,match)
 
    
    
+
 def strict_modify_flow_action(self,egress_port,match,priority=None):
 # Strict Modify the flow Action 
         
@@ -546,8 +567,6 @@
     return (pkt,match)
 
 
-
-
 ###########################   Verify Stats Functions   ###########################################################################################
 def get_flowstats(self,match):
     # Generate flow_stats request
@@ -768,7 +787,6 @@
         self.assertEqual(tx_byte,item.tx_bytes,"tx_bytes counter is not incremented correctly")
 
 
-
 def verify_queuestats(self,port_num,queue_id,expect_packet=None,expect_byte=None):
     
     # Verify queue counters : tx_packets and tx_bytes
diff --git a/tests/flow_matches.py b/tests/flow_matches.py
new file mode 100644
index 0000000..dc91616
--- /dev/null
+++ b/tests/flow_matches.py
@@ -0,0 +1,689 @@
+"""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 --> Flow Matches"
+
+
+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 oftest.base_tests as base_tests
+import time
+
+from oftest.testutils import *
+from time import sleep
+from FuncUtils import *
+
+    
+
+class AllWildcardMatch(base_tests.SimpleDataPlane):
+
+    """Verify for an all wildcarded flow all the injected packets would match that flow"""
+
+    def runTest(self):
+        
+        logging.info("Running All Wildcard Match test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting an all wildcarded flow and sending packets with various match fields")
+        logging.info("Expecting all sent packets to match")
+
+        #Insert an All Wildcarded flow.
+        wildcard_all(self,of_ports)
+
+        #check for different  match fields and verify packet implements the action specified in the flow
+        pkt1 = simple_tcp_packet(dl_src="00:01:01:01:01:01");
+        self.dataplane.send(of_ports[0], str(pkt1))
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt1,[yes_ports],no_ports,self)
+
+        pkt2 = simple_tcp_packet(dl_dst="00:01:01:01:01:01");    
+        self.dataplane.send(of_ports[0], str(pkt2))
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt2,[yes_ports],no_ports,self)
+        
+        pkt3 = simple_tcp_packet(ip_src="192.168.2.1");
+        self.dataplane.send(of_ports[0], str(pkt3))
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt3,[yes_ports],no_ports,self)
+
+        pkt4 = simple_tcp_packet(ip_dst="192.168.2.2");
+        self.dataplane.send(of_ports[0], str(pkt4))
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt4,[yes_ports],no_ports,self)
+
+        pkt5 = simple_tcp_packet(ip_tos=2);
+        self.dataplane.send(of_ports[0], str(pkt5))
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt5,[yes_ports],no_ports,self)
+
+        pkt6 = simple_tcp_packet(tcp_sport=8080);
+        self.dataplane.send(of_ports[0], str(pkt6))
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt6,[yes_ports],no_ports,self)
+                  
+        pkt7 = simple_tcp_packet(tcp_dport=8081);
+        self.dataplane.send(of_ports[0], str(pkt7))
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt7,[yes_ports],no_ports,self)
+
+
+
+class EthernetSrcAddress(base_tests.SimpleDataPlane):
+    
+    """Verify match on single header field -- Ethernet Src Address """
+    
+    def runTest(self):
+
+        logging.info("Running Ethernet Src Address test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with match on Ethernet Source Address ")
+        logging.info("Sending matching and non-matching ethernet packets")
+        logging.info("Verifying only matching packets implements the action specified in the flow")
+
+        #Insert a Match On Ethernet Src Address flow
+        (pkt,match) = match_ethernet_src_address(self,of_ports)   
+
+        #Sending packet matching the flow, verify it implements the action
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+        #Sending non matching packet , verify Packetin event gets triggered.
+        pkt2 = simple_eth_packet(dl_src='00:01:01:01:01:02');
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packets")
+
+class EthernetDstAddress(base_tests.SimpleDataPlane):
+    
+    """Verify match on single Header Field Field -- Ethernet Dst Address """
+
+    def runTest(self):
+
+        logging.info("Running Ethernet Dst Address test")
+
+        of_ports = config["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)
+        self.assertEqual(rv, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with match on Ethernet Destination Address ")
+        logging.info("Sending matching and non-matching ethernet packets")
+        logging.info("Verifying only matching packets implements the action specified in the flow")
+        
+        #Insert a Match on Destination Address flow   
+        (pkt,match) = match_ethernet_dst_address(self,of_ports)
+        
+        #Send Packet matching the flow 
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+        
+        #Send Non-matching packet
+        pkt2 = simple_eth_packet(dl_dst='00:01:01:01:01:02');
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        #Verify PacketIn event gets triggered
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+
+class EthernetType(base_tests.SimpleDataPlane):
+    
+    """Verify match on single header field -- Ethernet Type """
+    
+    def runTest(self):
+
+        logging.info("Running Ethernet Type test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with match on Ethernet Type ")
+        logging.info("Sending matching and non-matching ethernet packets")
+        logging.info("Verifying only matching packets implements the action specified in the flow")
+
+        #Insert a Match on Ethernet-Type flow
+        (pkt,match) = match_ethernet_type(self,of_ports)   
+
+        #Sending packet matching the flow 
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+        #Sending non matching packet , 
+        pkt2 = simple_eth_packet(dl_type=0x0806);
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        #verify Packetin event gets triggered.
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non-matching packet")
+
+            
+class IngressPort(base_tests.SimpleDataPlane):
+    
+    """Verify match on single Header Field Field -- In_port """
+
+    def runTest(self):
+
+        logging.info("Running Ingress Port test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with match on Ingress Port ")
+        logging.info("Sending matching and non-matching packets")
+        logging.info("Verifying only matching packets implements the action specified in the flow")
+        
+        #Insert a Match on Ingress Port FLow
+        (pkt,match) = wildcard_all_except_ingress(self,of_ports,priority=0)
+        
+        #Send Packet matching the flow i.e on in_port specified in the flow
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+        #Send Non-Matching Packet 
+        self.dataplane.send(of_ports[1],str(pkt))
+
+        #Verify PacketIn event gets triggered
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non-matching packet")
+
+class VlanId(base_tests.SimpleDataPlane):
+
+    """Verify match on single Header Field Field -- Vlan Id """
+
+    def runTest(self):
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with match on VLAN ID ")
+        logging.info("Sending matching and non-matching tagged packets")
+        logging.info("Verifying matching packets implements the action specified in the flow")
+    
+        #Create a flow with match on Vlan Id
+        (pkt,match) = match_vlan_id(self,of_ports)
+
+        #Send tagged packet matching the flow i.e packet with same vlan id as in flow
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+        
+        #Send Non-matching packet, i.e packet with different Vlan Id
+        pkt2 = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=4);
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        #Verify PacketIn event gets triggered
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+class VlanPCP(base_tests.SimpleDataPlane):
+
+    """"Verify match on single Header Field Field -- Vlan Priority"""
+
+    def runTest(self):
+
+        logging.info("Running VlanPCP1 test")
+
+        of_ports = config["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)
+        self.assertEqual(rv, 0, "Failed to delete all flows")
+        
+        logging.info("Inserting a flow with match on VLAN Priority ")
+        logging.info("Sending matching and non-matching tagged packets")
+        logging.info("Verifying matching packet implements the action specified in the flow")
+
+        #Create a flow matching on VLAN Priority
+        (pkt,match) = match_vlan_pcp(self,of_ports)
+
+        #Send tagged Packet matching the flow 
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+        
+        #Send tagged packet with same vlan_id but different vlan priority
+        pkt2 = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1,dl_vlan_pcp=20);
+        self.dataplane.send(in_port, str(pkt))
+       
+class MultipleHeaderFieldL2(base_tests.SimpleDataPlane):
+    
+    """Verify match on multiple header field -- Ethernet Type, Ethernet Source Address, Ethernet Destination Address """
+    
+    def runTest(self):
+
+        logging.info("Running Multiple Header Field L2 test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with match on Multiple Header Fields in L2 ")
+        logging.info("Sending matching and non-matching packets")
+        logging.info("Verifying matching packets implements the action specified in the flow")
+
+        (pkt,match) = match_mul_l2(self,of_ports)   
+
+        #Send eth packet matching the dl_type field, verify it implements the action
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+        #Sending non matching packet (only dl_dst is different) , verify Packetin event gets triggered.
+        pkt2 = simple_eth_packet(dl_type=0x88cc,dl_src='00:01:01:01:01:01',dl_dst='00:01:01:02:01:01');
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+        #Sending non matching packet (only dl_src is different) , verify Packetin event gets triggered.
+        pkt2 = simple_eth_packet(dl_type=0x88cc,dl_src='00:01:01:01:01:02',dl_dst='00:01:01:01:01:02');
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+        #Sending non matching packet (only ether_type is different) , verify Packetin event gets triggered.
+        pkt2 = simple_eth_packet(dl_type=0x0806,dl_src='00:01:01:01:01:01',dl_dst='00:01:01:01:01:02');
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+class IpTos(base_tests.SimpleDataPlane):
+
+    """"Verify match on single Header Field Field -- Type of service"""
+
+    def runTest(self):
+
+        logging.info("Running Ip_Tos test")
+
+        of_ports = config["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)
+        self.assertEqual(rv, 0, "Failed to delete all flows")
+        
+        logging.info("Inserting a flow with match on Ip_Tos ")
+        logging.info("Sending matching and non-matching tcp/ip packets")
+        logging.info("Verifying only matching packets implements the action specified in the flow")
+
+        #Create a flow matching on VLAN Priority
+        (pkt,match) = match_ip_tos(self,of_ports)
+
+        #Send Packet matching the flow 
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+        
+        #Create a non-matching packet , verify packet_in get generated
+        pkt2 = simple_tcp_packet(ip_tos=2);
+        self.dataplane.send(of_ports[0], str(pkt2))
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+class IpProtocol(base_tests.SimpleDataPlane):
+
+    """"Verify match on single Header Field Field -- Ip Protocol"""
+
+    def runTest(self):
+
+        logging.info("Running Ip Protocol test")
+
+        of_ports = config["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)
+        self.assertEqual(rv, 0, "Failed to delete all flows")
+        
+        logging.info("Inserting a flow with match on Ip Protocol ")
+        logging.info("Sending matching and non-matching tcp/ip packets")
+        logging.info("Verifying only matching packets implements the action specified in the flow")
+
+        #Create a flow matching on VLAN Priority
+        (pkt,match) = match_ip_protocol(self,of_ports)
+
+        #Send Packet matching the flow 
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+        
+        #Create a non-matching packet , verify packet_in get generated
+        pkt2 = simple_icmp_packet();
+        self.dataplane.send(of_ports[0], str(pkt2))
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+
+class TcpSrcPort(base_tests.SimpleDataPlane):
+    
+    """Verify match on Single header field -- Tcp Source Port,  """
+    
+    def runTest(self):
+
+        logging.info("Running Tcp Src Port test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with match on Tcp Tcp Source Port ")
+        logging.info("Sending matching and non-matching tcp packets")
+        logging.info("Verifying matching packets implements the action specified in the flow")
+
+        (pkt,match) = match_tcp_src(self,of_ports)   
+
+        #Sending packet matching the tcp_sport, verify it implements the action
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+        #Sending non matching packet , verify Packetin event gets triggered.
+        pkt2 = simple_tcp_packet(tcp_sport=540);
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+class TcpDstPort(base_tests.SimpleDataPlane):
+    
+    """Verify match on Single header field -- Tcp Destination Port """
+    
+    def runTest(self):
+
+        logging.info("Running Tcp Destination Port test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with match on Tcp Destination Port ")
+        logging.info("Sending matching and non-matching packets")
+        logging.info("Verifying matching packets implements the action specified in the flow")
+
+        (pkt,match) = match_tcp_dst(self,of_ports)   
+
+        #Sending packet matching the tcp_dport, verify it implements the action
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+        #Sending non matching packet , verify Packetin event gets triggered.
+        pkt2 = simple_tcp_packet(tcp_dport=541);
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=10)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+
+class ExactMatch(base_tests.SimpleDataPlane):
+    
+    """Verify match on Single header field -- Exact Match  """
+    
+    def runTest(self):
+
+        logging.info("Running Tcp Exact Match test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with match for Exact Match ")
+        logging.info("Sending matching and non-matching packets")
+        logging.info("Verifying matching packets implements the action specified in the flow")
+
+        (pkt,match) = exact_match(self,of_ports)   
+
+        #Sending packet matching all the fields of a tcp_packet, verify it implements the action
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+        #Sending non matching packet , verify Packetin event gets triggered.
+        pkt2 = simple_tcp_packet(tcp_sport=540);
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+
+class MultipleHeaderFieldL4(base_tests.SimpleDataPlane):
+    
+    """Verify match on multiple header field -- Tcp Source Port, Tcp Destination Port  """
+    
+    def runTest(self):
+
+        logging.info("Running Multiple Header Field L4 test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with match on Multiple Header Field L4 ")
+        logging.info("Sending matching and non-matching packets")
+        logging.info("Verifying matching packets implements the action specified in the flow")
+
+        (pkt,match) = match_mul_l4(self,of_ports)   
+
+        #Sending packet matching the tcp_sport and tcp_dport field, verify it implements the action
+        self.dataplane.send(of_ports[0], str(pkt))
+
+        #Verify packet implements the action specified in the flow
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+        #Sending non matching packet , verify Packetin event gets triggered.
+        pkt2 = simple_tcp_packet(tcp_sport=540,tcp_dport=541);
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+
+class ExactMatchPrio(base_tests.SimpleDataPlane):
+    
+    """Verify that Exact Match has highest priority """
+    
+    def runTest(self):
+
+        logging.info("Running Exact Match High Priority test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting a flow with Exact Match (low priority)")
+        logging.info("Inserting an overlapping wildcarded flow (higher priority)")
+        logging.info("Sending packets matching both the flows ")
+        logging.info("Verifying matching packets implements the action specified in the exact match flow")
+
+        #Insert two Overlapping Flows : Exact Match and Wildcard All.
+        (pkt,match) = exact_match_with_prio(self,of_ports,priority=10) 
+        (pkt2,match2) = wildcard_all(self,of_ports,priority=20);  
+        
+        #Sending packet matching both the flows , 
+        self.dataplane.send(of_ports[0], str(pkt2))
+
+        #verify it implements the action specified in Exact Match Flow
+        egress_port=of_ports[2]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = egress_port
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+
+class WildcardMatchPrio(base_tests.SimpleDataPlane):
+    
+    """Verify that Wildcard Match with highest priority overrides the low priority WildcardMatch """
+    
+    def runTest(self):
+
+        logging.info("Running Wildcard Match High Priority test")
+
+        of_ports = config["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)
+        self.assertEqual(rc, 0, "Failed to delete all flows")
+
+        logging.info("Inserting two wildcarded flows with priorities ")
+        logging.info("Sending packets matching the flows")
+        logging.info("Verifying matching packets implements the action specified in the flow with higher priority")
+
+        (pkt,match) = wildcard_all(self,of_ports,priority=20) 
+        (pkt1,match1) =  wildcard_all_except_ingress1(self,of_ports,priority=10)  
+
+        #Sending packet matching both the flows , verify it implements the action specified by Higher Priority flow
+        self.dataplane.send(of_ports[0], str(pkt1))
+
+        egress_port=of_ports[1]
+        no_ports=set(of_ports).difference([egress_port])
+        yes_ports = of_ports[1]
+        receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+
+
+
+
