refactored verify_stats func
diff --git a/tests/FuncUtils.py b/tests/FuncUtils.py
index 0ef9dc1..388c86c 100644
--- a/tests/FuncUtils.py
+++ b/tests/FuncUtils.py
@@ -19,544 +19,589 @@
 
 #################### Functions for various types of flow_mod  ##########################################################################################
 
-def Exact_Match(self,of_ports,priority=0):
+def exact_match(self,of_ports,priority=0):
 # Generate ExactMatch flow .
 
-        #Create a simple tcp packet and generate exact flow match from it.
-        Pkt_ExactFlow = simple_tcp_packet()
-        match = parse.packet_to_flow_match(Pkt_ExactFlow)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
-        match.in_port = of_ports[0]
-        #match.nw_src = 1
-        match.wildcards=0
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    #Create a simple tcp packet and generate exact flow match from it.
+    pkt_exactflow = simple_tcp_packet()
+    match = parse.packet_to_flow_match(pkt_exactflow)
+    self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    match.in_port = of_ports[0]
+    #match.nw_src = 1
+    match.wildcards=0
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
 
-        act = action.action_output()
-        act.port = of_ports[1]
-        self.assertTrue(msg.actions.add(act), "could not add action")
+    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")
+    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_ExactFlow,match)
+    return (pkt_exactflow,match)
 
-def Exact_Match_With_Prio(self,of_ports,priority=0):
-    # Generate ExactMatch With Prority flow .
+def exact_match_with_prio(self,of_ports,priority=0):
+    # Generate ExactMatch with action output to port 2
 
-        #Create a simple tcp packet and generate exact flow match from it.
-        Pkt_ExactFlow = simple_tcp_packet()
-        match = parse.packet_to_flow_match(Pkt_ExactFlow)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
-        match.in_port = of_ports[0]
-        #match.nw_src = 1
-        match.wildcards=0
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    #Create a simple tcp packet and generate exact flow match from it.
+    pkt_exactflow = simple_tcp_packet()
+    match = parse.packet_to_flow_match(pkt_exactflow)
+    self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    match.in_port = of_ports[0]
+    #match.nw_src = 1
+    match.wildcards=0
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
 
-        act = action.action_output()
-        act.port = of_ports[2]
-        self.assertTrue(msg.actions.add(act), "could not add action")
+    act = action.action_output()
+    act.port = of_ports[2]
+    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")
+    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_ExactFlow,match)         
+    return (pkt_exactflow,match)         
        
 
-def Match_All_Except_Source_Address(self,of_ports,priority=0):
+def match_all_except_source_address(self,of_ports,priority=0):
 # Generate Match_All_Except_Source_Address flow
         
-        #Create a simple tcp packet and generate match all except src address flow.
-        Pkt_WildcardSrc= simple_tcp_packet()
-        match1 = parse.packet_to_flow_match(Pkt_WildcardSrc)
-        self.assertTrue(match1 is not None, "Could not generate flow match from pkt")
-        match1.in_port = of_ports[0]
-        #match1.nw_src = 1
-        match1.wildcards = ofp.OFPFW_DL_SRC
-        msg1 = message.flow_mod()
-        msg1.out_port = ofp.OFPP_NONE
-        msg1.command = ofp.OFPFC_ADD
-        msg1.buffer_id = 0xffffffff
-        msg1.match = match1
-        if priority != 0 :
-                msg1.priority = priority
+    #Create a simple tcp packet and generate match all except src address flow.
+    pkt_wildcardsrc= simple_tcp_packet()
+    match1 = parse.packet_to_flow_match(pkt_wildcardsrc)
+    self.assertTrue(match1 is not None, "Could not generate flow match from pkt")
+    match1.in_port = of_ports[0]
+    #match1.nw_src = 1
+    match1.wildcards = ofp.OFPFW_DL_SRC
+    msg1 = message.flow_mod()
+    msg1.out_port = ofp.OFPP_NONE
+    msg1.command = ofp.OFPFC_ADD
+    msg1.buffer_id = 0xffffffff
+    msg1.match = match1
+    if priority != 0 :
+        msg1.priority = priority
 
-        act1 = action.action_output()
-        act1.port = of_ports[1]
-        self.assertTrue(msg1.actions.add(act1), "could not add action")
+    act1 = action.action_output()
+    act1.port = of_ports[1]
+    self.assertTrue(msg1.actions.add(act1), "could not add action")
 
-        rv = self.controller.message_send(msg1)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+    rv = self.controller.message_send(msg1)
+    self.assertTrue(rv != -1, "Error installing flow mod")
+    self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-        return (Pkt_WildcardSrc,match1)
+    return (pkt_wildcardsrc,match1)
 
-def Match_Ethernet_Src_Address(self,of_ports,priority=0):
+def match_wthernet_src_address(self,of_ports,priority=0):
     #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')
-        match = parse.packet_to_flow_match(pkt_MatchSrc)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    #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')
+    match = parse.packet_to_flow_match(pkt_MatchSrc)
+    self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
-        match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_SRC
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_SRC
         
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
 
-        act = action.action_output()
-        act.port = of_ports[1]
-        self.assertTrue(msg.actions.add(act), "could not add action")
+    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")
+    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_MatchSrc,match)
+    return (pkt_MatchSrc,match)
       
-def Match_Ethernet_Dst_Address(self,of_ports,priority=0):
+def match_ethernet_dst_address(self,of_ports,priority=0):
     #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')
-        match = parse.packet_to_flow_match(pkt_MatchDst)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    #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')
+    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_DL_DST
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_DST
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
 
-        act = action.action_output()
-        act.port = of_ports[1]
-        self.assertTrue(msg.actions.add(act), "could not add action")
+    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")
+    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_MatchDst,match)
+    return (pkt_matchdst,match)
 
-def Wildcard_All(self,of_ports,priority=0):
+def wildcard_all(self,of_ports,priority=0):
 # Generate a Wildcard_All Flow 
 
-        #Create a simple tcp packet and generate wildcard all flow match from it.  
-        Pkt_Wildcard = simple_tcp_packet()
-        match2 = parse.packet_to_flow_match(Pkt_Wildcard)
-        self.assertTrue(match2 is not None, "Could not generate flow match from pkt")
-        match2.wildcards=ofp.OFPFW_ALL
-        match2.in_port = of_ports[0]
+    #Create a simple tcp packet and generate wildcard all flow match from it.  
+    pkt_wildcard = simple_tcp_packet()
+    match2 = parse.packet_to_flow_match(pkt_wildcard)
+    self.assertTrue(match2 is not None, "Could not generate flow match from pkt")
+    match2.wildcards=ofp.OFPFW_ALL
+    match2.in_port = of_ports[0]
 
-        msg2 = message.flow_mod()
-        msg2.out_port = ofp.OFPP_NONE
-        msg2.command = ofp.OFPFC_ADD
-        msg2.buffer_id = 0xffffffff
-        msg2.match = match2
-        act2 = action.action_output()
-        act2.port = of_ports[1]
-        self.assertTrue(msg2.actions.add(act2), "could not add action")
-        if priority != 0 :
-                msg2.priority = priority
+    msg2 = message.flow_mod()
+    msg2.out_port = ofp.OFPP_NONE
+    msg2.command = ofp.OFPFC_ADD
+    msg2.buffer_id = 0xffffffff
+    msg2.match = match2
+    act2 = action.action_output()
+    act2.port = of_ports[1]
+    self.assertTrue(msg2.actions.add(act2), "could not add action")
+    if priority != 0 :
+        msg2.priority = priority
 
-        rv = self.controller.message_send(msg2)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+    rv = self.controller.message_send(msg2)
+    self.assertTrue(rv != -1, "Error installing flow mod")
+    self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-        return (Pkt_Wildcard,match2)
+    return (pkt_wildcard,match2)
 
-def Wildcard_All_Except_Ingress(self,of_ports,priority=0):
+def wildcard_all_except_ingress(self,of_ports,priority=0):
 # Generate Wildcard_All_Except_Ingress_port flow
         
 
-        #Create a simple tcp packet and generate wildcard all except ingress_port flow.
-        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]
+    #Create a simple tcp packet and generate wildcard all except ingress_port flow.
+    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.out_port = of_ports[2] # ignored by flow add,flow modify 
-        msg3.cookie = random.randint(0,9007199254740992)
-        msg3.buffer_id = 0xffffffff
-        msg3.idle_timeout = 0
-        msg3.hard_timeout = 0
-        msg3.buffer_id = 0xffffffff
+    msg3 = message.flow_mod()
+    msg3.command = ofp.OFPFC_ADD
+    msg3.match = match3
+    msg3.out_port = of_ports[2] # ignored by flow add,flow modify 
+    msg3.cookie = random.randint(0,9007199254740992)
+    msg3.buffer_id = 0xffffffff
+    msg3.idle_timeout = 0
+    msg3.hard_timeout = 0
+    msg3.buffer_id = 0xffffffff
        
-        act3 = action.action_output()
-        act3.port = of_ports[1]
-        self.assertTrue(msg3.actions.add(act3), "could not add action")
+    act3 = action.action_output()
+    act3.port = of_ports[1]
+    self.assertTrue(msg3.actions.add(act3), "could not add action")
 
-        if priority != 0 :
-                msg3.priority = priority
+    if priority != 0 :
+        msg3.priority = priority
 
-        rv = self.controller.message_send(msg3)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+    rv = self.controller.message_send(msg3)
+    self.assertTrue(rv != -1, "Error installing flow mod")
+    self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-        return (Pkt_MatchIngress,match3)
+    return (pkt_matchingress,match3)
 
-def Wildcard_All_Except_Ingress1(self,of_ports,priority=0):
+def wildcard_all_except_ingress1(self,of_ports,priority=0):
 # Generate Wildcard_All_Except_Ingress_port flow with action output to port egress_port 2 
         
 
-        #Create a simple tcp packet and generate wildcard all except ingress_port flow.
-        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]
+    #Create a simple tcp packet and generate wildcard all except ingress_port flow.
+    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.out_port = of_ports[2] # ignored by flow add,flow modify 
-        msg3.cookie = random.randint(0,9007199254740992)
-        msg3.buffer_id = 0xffffffff
-        msg3.idle_timeout = 0
-        msg3.hard_timeout = 0
-        msg3.buffer_id = 0xffffffff
+    msg3 = message.flow_mod()
+    msg3.command = ofp.OFPFC_ADD
+    msg3.match = match3
+    msg3.out_port = of_ports[2] # ignored by flow add,flow modify 
+    msg3.cookie = random.randint(0,9007199254740992)
+    msg3.buffer_id = 0xffffffff
+    msg3.idle_timeout = 0
+    msg3.hard_timeout = 0
+    msg3.buffer_id = 0xffffffff
        
-        act3 = action.action_output()
-        act3.port = of_ports[2]
-        self.assertTrue(msg3.actions.add(act3), "could not add action")
+    act3 = action.action_output()
+    act3.port = of_ports[2]
+    self.assertTrue(msg3.actions.add(act3), "could not add action")
+    if priority != 0 :
+        msg3.priority = priority
 
-        if priority != 0 :
-                msg3.priority = priority
+    rv = self.controller.message_send(msg3)
+    self.assertTrue(rv != -1, "Error installing flow mod")
+    self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-        rv = self.controller.message_send(msg3)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
-
-        return (Pkt_MatchIngress,match3)
+    return (pkt_matchingress,match3)
 
 
 
 
-def Match_Vlan_Id(self,of_ports,priority=0):
+def match_vlan_id(self,of_ports,priority=0):
     #Generate Match_Vlan_Id
 
-        #Create a simple tcp packet and generate match on ethernet dst address flow
-        pkt_MatchVlanId = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1)
-        match = parse.packet_to_flow_match(pkt_MatchVlanId)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    #Create a simple tcp packet and generate match on ethernet dst address flow
+    pkt_matchvlanid = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1)
+    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
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_VLAN
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
 
-        act = action.action_output()
-        act.port = of_ports[1]
-        self.assertTrue(msg.actions.add(act), "could not add action")
+    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")
+    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_MatchVlanId,match)
+    return (pkt_matchvlanid,match)
 
-def Match_Vlan_Pcp(self,of_ports,priority=0):
+def match_vlan_pcp(self,of_ports,priority=0):
     #Generate Match_Vlan_Id
 
-        #Create a simple tcp packet and generate match on ethernet dst address flow
-        pkt_MatchVlanPcp = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1,dl_vlan_pcp=10)
-        match = parse.packet_to_flow_match(pkt_MatchVlanPcp)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    #Create a simple tcp packet and generate match on ethernet dst address flow
+    pkt_matchvlanpcp = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1,dl_vlan_pcp=10)
+    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 
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_VLAN_PCP 
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
 
-        act = action.action_output()
-        act.port = of_ports[1]
-        self.assertTrue(msg.actions.add(act), "could not add action")
+    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")
+    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_MatchVlanPcp,match)
+    return (pkt_matchvlanpcp,match)
 
 
-def Match_Mul_L2(self,of_ports,priority=0):
+def match_mul_l2(self,of_ports,priority=0):
     #Generate Match_Mul_L2 flow
 
-        #Create a simple eth packet and generate match on ethernet protocol flow
-        pkt_MulL2 = simple_eth_packet(dl_type=0x88cc,dl_src='00:01:01:01:01:01',dl_dst='00:01:01:01:01:02')
-        match = parse.packet_to_flow_match(pkt_MulL2)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    #Create a simple eth packet and generate match on ethernet protocol flow
+    pkt_mulL2 = simple_eth_packet(dl_type=0x88cc,dl_src='00:01:01:01:01:01',dl_dst='00:01:01:01:01:02')
+    match = parse.packet_to_flow_match(pkt_mulL2)
+    self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
-        match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_TYPE ^ofp.OFPFW_DL_DST ^ofp.OFPFW_DL_SRC
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_TYPE ^ofp.OFPFW_DL_DST ^ofp.OFPFW_DL_SRC
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
 
-        act = action.action_output()
-        act.port = of_ports[1]
-        self.assertTrue(msg.actions.add(act), "could not add action")
+    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")
+    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_MulL2,match)
+    return (pkt_mulL2,match)
 
 
-def Match_Mul_L4(self,of_ports,priority=0):
+def match_mul_L4(self,of_ports,priority=0):
     #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")
+    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 
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
 
-        match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_TP_SRC ^ofp.OFPFW_TP_DST 
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    act = action.action_output()
+    act.port = of_ports[1]
+    self.assertTrue(msg.actions.add(act), "could not add action")
 
-        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")
 
-        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_mulL4,match)  
 
-        return (pkt_MulL4,match)  
-
-def Match_Ip_Tos(self,of_ports,priority=0):
+def match_ip_tos(self,of_ports,priority=0):
     #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)
-        match = parse.packet_to_flow_match(pkt_IpTos)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    pkt_iptos = simple_tcp_packet(ip_tos=3)
+    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
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_NW_TOS
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
+    act = action.action_output()
+    act.port = of_ports[1]
+    self.assertTrue(msg.actions.add(act), "could not add action")
 
-        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")
 
-        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)
 
-        return (pkt_IpTos,match)
-
-def Match_Tcp_Src(self,of_ports,priority=0):
+def match_tcp_src(self,of_ports,priority=0):
     #Generate Match_Tcp_Src
 
-        #Create a simple tcp packet and generate match on tcp source port flow
-        pkt_MatchTSrc = simple_tcp_packet(tcp_sport=111)
-        match = parse.packet_to_flow_match(pkt_MatchTSrc)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    #Create a simple tcp packet and generate match on tcp source port flow
+    pkt_matchtSrc = simple_tcp_packet(tcp_sport=111)
+    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  
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_TP_SRC  
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
 
-        act = action.action_output()
-        act.port = of_ports[1]
-        self.assertTrue(msg.actions.add(act), "could not add action")
+    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")
+    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_MatchTSrc,match)  
+    return (pkt_matchtSrc,match)  
 
-def Match_Tcp_Dst(self,of_ports,priority=0):
+def match_tcp_dst(self,of_ports,priority=0):
     #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)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    pkt_Matchtdst = simple_tcp_packet(tcp_dport=112)
+    match = parse.packet_to_flow_match(pkt_matchtdst)
+    self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
-        match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_TP_DST  
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_TP_DST  
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
+    act = action.action_output()
+    act.port = of_ports[1]
+    self.assertTrue(msg.actions.add(act), "could not add action")
 
-        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")
 
-        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_MatchTDst,match)        
+    return (pkt_matchtdst,match)        
 
 
 
 
 
-def Match_Ethernet_Type(self,of_ports,priority=0):
+def match_ethernet_type(self,of_ports,priority=0):
     #Generate a Match_Ethernet_Type flow
 
-        #Create a simple tcp packet and generate match on ethernet type flow
-        pkt_MatchType = simple_eth_packet(dl_type=0x88cc)
-        match = parse.packet_to_flow_match(pkt_MatchType)
-        self.assertTrue(match is not None, "Could not generate flow match from pkt")
+    #Create a simple tcp packet and generate match on ethernet type flow
+    pkt_matchtype = simple_eth_packet(dl_type=0x88cc)
+    match = parse.packet_to_flow_match(pkt_matchtype)
+    self.assertTrue(match is not None, "Could not generate flow match from pkt")
 
-        match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_TYPE
-        msg = message.flow_mod()
-        msg.out_port = ofp.OFPP_NONE
-        msg.command = ofp.OFPFC_ADD
-        msg.buffer_id = 0xffffffff
-        msg.match = match
-        if priority != 0 :
-                msg.priority = priority
+    match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_TYPE
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != 0 :
+        msg.priority = priority
 
-        act = action.action_output()
-        act.port = of_ports[1]
-        self.assertTrue(msg.actions.add(act), "could not add action")
+    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")
+    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)
+    return (pkt_matchtype,match)
 
    
    
-def Strict_Modify_Flow_Action(self,egress_port,match,priority=0):
+def strict_modify_flow_action(self,egress_port,match,priority=0):
 # Strict Modify the flow Action 
         
-        #Create a flow_mod message , command MODIFY_STRICT
-        msg5 = message.flow_mod()
-        msg5.match = match
-        msg5.cookie = random.randint(0,9007199254740992)
-        msg5.command = ofp.OFPFC_MODIFY_STRICT
-        msg5.buffer_id = 0xffffffff
-        act5 = action.action_output()
-        act5.port = egress_port
-        self.assertTrue(msg5.actions.add(act5), "could not add action")
+    #Create a flow_mod message , command MODIFY_STRICT
+    msg5 = message.flow_mod()
+    msg5.match = match
+    msg5.cookie = random.randint(0,9007199254740992)
+    msg5.command = ofp.OFPFC_MODIFY_STRICT
+    msg5.buffer_id = 0xffffffff
+    act5 = action.action_output()
+    act5.port = egress_port
+    self.assertTrue(msg5.actions.add(act5), "could not add action")
 
-        if priority != 0 :
-                msg5.priority = priority
+    if priority != 0 :
+        msg5.priority = priority
 
-        # Send the flow with action A'
-        rv = self.controller.message_send (msg5)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+    # Send the flow with action A'
+    rv = self.controller.message_send (msg5)
+    self.assertTrue(rv != -1, "Error installing flow mod")
+    self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-def Modify_Flow_Action(self,of_ports,match,priority=0):
+def modify_flow_action(self,of_ports,match,priority=0):
 # Modify the flow action
         
-        #Create a flow_mod message , command MODIFY 
-        msg8 = message.flow_mod()
-        msg8.match = match
-        msg8.cookie = random.randint(0,9007199254740992)
-        msg8.command = ofp.OFPFC_MODIFY
-        #Will be ignored for flow adds and flow modify (here for test-case Add_Modify_With_Outport)
-        msg8.out_port = of_ports[3]
-        msg8.buffer_id = 0xffffffff
-        act8 = action.action_output()
-        act8.port = of_ports[2]
-        self.assertTrue(msg8.actions.add(act8), "could not add action")
+    #Create a flow_mod message , command MODIFY 
+    msg8 = message.flow_mod()
+    msg8.match = match
+    msg8.cookie = random.randint(0,9007199254740992)
+    msg8.command = ofp.OFPFC_MODIFY
+    #out_port will be ignored for flow adds and flow modify (here for test-case Add_Modify_With_Outport)
+    msg8.out_port = of_ports[3]
+    msg8.buffer_id = 0xffffffff
+    act8 = action.action_output()
+    act8.port = of_ports[2]
+    self.assertTrue(msg8.actions.add(act8), "could not add action")
 
-        if priority != 0 :
-                msg8.priority = priority
+    if priority != 0 :
+        msg8.priority = priority
 
-        # Send the flow with action A'
-        rv = self.controller.message_send (msg8)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+    # Send the flow with action A'
+    rv = self.controller.message_send (msg8)
+    self.assertTrue(rv != -1, "Error installing flow mod")
+    self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-def Enqueue(self,ingress_port,egress_port,egress_queue_id):
+def enqueue(self,ingress_port,egress_port,egress_queue_id):
 #Generate a flow with enqueue action i.e output to a queue configured on a egress_port
 
-        pkt = simple_tcp_packet()
-        match = packet_to_flow_match(self, pkt)
-        match.wildcards &= ~ofp.OFPFW_IN_PORT
-        self.assertTrue(match is not None, 
-                "Could not generate flow match from pkt")
-
-        match.in_port = ingress_port
-        request = message.flow_mod()
-        request.match = match
-        request.buffer_id = 0xffffffff
-        act = action.action_enqueue()
-        act.port     = egress_port
-        act.queue_id = egress_queue_id
-        self.assertTrue(request.actions.add(act), "Could not add action")
-
-        logging.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")
-
-        return (pkt,match)
+    pkt = simple_tcp_packet()
+    match = packet_to_flow_match(self, pkt)
+    match.wildcards &= ~ofp.OFPFW_IN_PORT
+    self.assertTrue(match is not None, 
+            "Could not generate flow match from pkt")
+    
+    match.in_port = ingress_port
+    request = message.flow_mod()
+    request.match = match
+    request.buffer_id = 0xffffffff
+    act = action.action_enqueue()
+    act.port     = egress_port
+    act.queue_id = egress_queue_id
+    self.assertTrue(request.actions.add(act), "Could not add action")
+    
+    logging.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")
+    return (pkt,match)
 
 
 
 
 ###########################   Verify Stats Functions   ###########################################################################################
+def get_flowstats(self,match):
+    # Generate flow_stats request
+    
+    stat_req = message.flow_stats_request()
+    stat_req.match = match
+    stat_req.table_id = 0xff
+    stat_req.out_port = ofp.OFPP_NONE
+
+    logging.info("Sending stats request")
+    response, pkt = self.controller.transact(stat_req,
+                                                     timeout=5)
+    self.assertTrue(response is not None,"No response to stats request")
 
 
-def Get_QueueStats(self,port_num,queue_id):
+def get_portstats(self,port_num):
+
+# Return all the port counters in the form a tuple 
+    port_stats_req = message.port_stats_request()
+    port_stats_req.port_no = port_num  
+    response,pkt = self.controller.transact(port_stats_req)
+    self.assertTrue(response is not None,"No response received for port stats request") 
+    rx_pkts=0
+    tx_pkts=0
+    rx_byts=0
+    tx_byts=0
+    rx_drp =0
+    tx_drp = 0
+    rx_err=0
+    tx_err =0 
+    rx_fr_err=0
+    rx_ovr_err=0
+    rx_crc_err=0
+    collisions = 0
+    tx_err=0
+
+
+    for obj in response.stats:
+        rx_pkts += obj.rx_packets
+        tx_pkts += obj.tx_packets
+        rx_byts += obj.rx_bytes
+        tx_byts += obj.tx_bytes
+        rx_drp += obj.rx_dropped
+        tx_drp += obj.tx_dropped
+        rx_err += obj.rx_errors
+        rx_fr_err += obj.rx_frame_err
+        rx_ovr_err += obj.rx_over_err
+        rx_crc_err += obj.rx_crc_err
+        collisions+= obj.collisions
+        tx_err += obj.tx_errors
+
+    return (rx_pkts,tx_pkts,rx_byts,tx_byts,rx_drp,tx_drp,rx_err,tx_err,rx_fr_err,rx_ovr_err,rx_crc_err,collisions,tx_err)
+
+def get_queuestats(self,port_num,queue_id):
 #Generate Queue Stats request 
 
     request = message.queue_stats_request()
@@ -567,169 +612,239 @@
 
     return (queue_stats,p)
 
-def Verify_TableStats(self,active_entries=0):
-#Verify Table_Stats
+def get_tablestats(self):
+# Send Table_Stats request (retrieve current table counters )
+
+    stat_req = message.table_stats_request()
+    response, pkt = self.controller.transact(stat_req,
+                                                     timeout=5)
+    self.assertTrue(response is not None, 
+                            "No response to stats request")
+    current_lookedup = 0
+    current_matched = 0
+    current_active = 0 
+
+    for obj in response.stats:
+        current_lookedup += obj.lookup_count
+        current_matched  += obj.matched_count
+        current_active += obj.active_count
+
+    return (current_lookedup,current_matched,current_active)
+
+
+
+def verify_tablestats(self,expect_lookup=0,expect_match=0,expect_active=0):
+
+    stat_req = message.table_stats_request()
+
+    all_packets_lookedup = 0
+    all_packets_matched = 0
+    all_entries_active = 0 
+    lookedup = 0 
+    matched = 0 
+    active = 0
         
-        #Send Table_Stats_Request        
-        request = message.table_stats_request()
-        response, pkt = self.controller.transact(request, timeout=1)
-        self.assertTrue(response is not None, "Did not get response")
-        active_count=0
+    for i in range(0,60):
 
-        #Verify active_count in the reply
-        for stat in response.stats:
-            active_count += stat.active_count
-        self.assertTrue(active_entries == active_count,"Incorrect no. of flows in Table")
-
-def Verify_TableStats1(self,current_lookedup,current_matched,expect_lookup,expect_match):
-       
-        stat_req = message.table_stats_request()
+        logging.info("Sending stats request")
+        # TODO: move REPLY_MORE handling to controller.transact?
         response, pkt = self.controller.transact(stat_req,
                                                      timeout=5)
-        self.assertTrue(response is not None, 
-                            "No response to stats request")
-        lookedup = 0
-        matched = 0 
-            
-        for obj in response.stats:
-            lookedup += obj.lookup_count
-            matched += obj.matched_count
-        
-        lookedup_counter = lookedup-current_lookedup
-        matched_counter = matched-current_matched
-        
-        self.assertTrue(lookedup_counter==expect_lookup, "lookup counter is not incremented properly")
-        self.assertTrue(matched_counter==expect_match, "matched counter is not incremented properly")
+        self.assertTrue(response is not None,"No response to stats request")
 
-def Verify_FlowStats(self,match,byte_count=0,packet_count=0):
+        for item in response.stats:
+            lookedup += item.lookup_count
+            matched += item.matched_count
+            active += item.active_count
+
+            logging.info("Packets Looked up " + str(lookedup) + " packets")
+            if expect_lookup != 0 :
+                if lookedup == expect_lookup:
+                    all_packets_lookedup = 1
+            
+            logging.info("Packets matched " + str(matched) + "packets")
+            if expect_match != 0 :
+                if matched == expect_match:
+                    all_packets_matched = 1
+
+            logging.info("Active flow entries" + str(active) + "flows")
+            if active != 0 :
+                if active == expect_active:
+                    all_entries_active = 1
+
+        if all_packets_lookedup == 1 and expect_lookup!= 0 :
+            break
+        if all_packets_matched== 1 and expect_match !=0 :
+            break
+        if all_entries_active ==1 and expect_active != 0 :
+            break 
+        
+        sleep(1)
+
+    if expect_lookup != 0 :
+        self.assertTrue(all_packets_matched, "lookup counter is not incremented properly")
+    if expect_match != 0 :
+        self.assertTrue(all_packets_matched, "matched counter is not incremented properly")
+    if expect_active != 0 :
+        self.assertTrue(all_entries_active, "active counter is not incremented properly")
+
+
+def verify_flowstats(self,match,byte_count=0,packet_count=0):
     # Verify flow counters : byte_count and packet_count
 
-        stat_req = message.flow_stats_request()
-        stat_req.match = match
-        stat_req.table_id = 0xff
-        stat_req.out_port = ofp.OFPP_NONE
+    stat_req = message.flow_stats_request()
+    stat_req.match = match
+    stat_req.table_id = 0xff
+    stat_req.out_port = ofp.OFPP_NONE
+
+    all_packets_rx = 0
+    all_bytes_rx = 0
+    packet_counter = 0
+    byte_counter = 0 
+        
+    for i in range(0,60):
+        logging.info("Sending stats request")
+        # TODO: move REPLY_MORE handling to controller.transact?
         response, pkt = self.controller.transact(stat_req,
-                                                     timeout=4)
+                                                     timeout=5)
+        self.assertTrue(response is not None,"No response to stats request")
+
+        for item in response.stats:
+            packet_counter += item.packet_count
+            byte_counter += item.byte_count
+
+            logging.info("Recieved" + str(item.packet_count) + " packets")
+            if packet_count != 0 :
+                if packet_count == packet_counter:
+                    all_packets_rx = 1
+            
+            logging.info("Received " + str(item.byte_count) + "bytes")
+            if byte_count != 0 :
+                if byte_counter == byte_count:
+                    all_bytes_rx = 1
+
+        if all_packets_rx == 1 and packet_count != 0 :
+            break
+        if all_bytes_rx == 1 and byte_count !=0 :
+            break 
+        sleep(1)
+
+    if packet_count != 0 :
+        self.assertTrue(all_packets_rx,"packet_count counter is not incremented correctly")
+
+    if byte_count != 0 :   
+        self.assertTrue(all_bytes_rx,"byte_count counter is not incremented correctly")
+
+
+def verify_portstats(self, port,tx_packets=0,rx_packets=0,rx_byte=0,tx_byte=0):
+
+    
+    stat_req = message.port_stats_request()
+    stat_req.port_no = port
+    all_packets_received = 0
+    all_packets_sent = 0
+    all_bytes_recieved = 0
+    all_bytes_sent = 0 
+    sentp = recvp = 0
+    sentb = recvb = 0
+    
+    for i in range(0,60):
+        logging.info("Sending stats request")
+        response, pkt = self.controller.transact(stat_req,
+                                                timeout=5)
         self.assertTrue(response is not None, 
-                            "No response to stats request")
-        packetcounter=0
-        bytecounter=0
-        for obj in response.stats:
-            packetcounter += obj.packet_count
-            bytecounter += obj.byte_count
+                       "No response to stats request")
+        self.assertTrue(len(response.stats) == 1,
+                       "Did not receive port stats reply")
+        for item in response.stats:
+            sentp += item.tx_packets
+            recvp += item.rx_packets
+            sentb += item.tx_bytes
+            recvb += item.rx_bytes
+            
+            logging.info("Sent " + str(sentp) + " packets")
+            if tx_packets != 0:
+                if item.tx_packets == tx_packets:
+                    all_packets_sent = 1
+            
+            logging.info("Received " + str(recvp) + " packets")
+            if rx_packets !=0 :
+                if item.rx_packets == rx_packets:
+                    all_packets_received = 1
 
-        self.assertTrue(packetcounter==packet_count, "packet counter is not incremented properly")
-        self.assertTrue(bytecounter==byte_count, "byte counter is not incremented properly")
+            logging.info("Received " + str(recvb) + "bytes")
+            if rx_byte !=0 :
+                if item.rx_bytes == rx_byte:
+                    all_bytes_received = 1  
+
+            logging.info("Sent" + str(sentb) + "bytes")
+            if tx_byte !=0 :
+                if item.tx_bytes == tx_byte:
+                    all_bytes_sent = 1  
+                    
+        if rx_packets !=0  and all_packets_received == 1:
+            break
+        if tx_packets !=0 and all_packets_sent == 1:
+            break 
+        if rx_byte !=0  and all_bytes_received == 1:
+            break
+        if tx_byte !=0 and all_bytes_sent == 1:
+            break
+        
+        sleep(1)
+
+    if (rx_packets !=0):
+        self.assertTrue(all_packets_received == 1 ,"rx_packets counter is not incremented correctly")
+    if (tx_packets !=0):
+        self.assertTrue(all_packets_sent == 1,"tx_packets counter is not incremented correctly")
+    if (rx_byte !=0):
+        self.assertTrue(all_bytes_received == 1 ,"rx_bytes counter is not incremented correctly")
+    if (tx_byte !=0):
+        self.assertTrue(all_bytes_sent == 1,"tx_bytes counter is not incremented correctly")
 
 
-def Verify_PortStats(self,in_port,rx_dropped):
-#Verify Port counters like rx_dropped
-
-        port_stats_req = message.port_stats_request()
-        port_stats_req.port_no = in_port   
-        resp,pkt = self.controller.transact(port_stats_req)
-        self.assertTrue(resp is not None,"No response received for port stats request")        
-        self.assertTrue(resp.rx_dropped == rx_dropped, "Packets not dropped")
-
-def Verify_PortStats1(self,out_port,current_counter,rx_packets):
-#Verify Port counters like rx_packets
-
-        port_stats_req = message.port_stats_request()
-        port_stats_req.port_no = out_port     
-        response,pkt = self.controller.transact(port_stats_req)
-        self.assertTrue(response is not None,"No response received for port stats request") 
-        rxpackets=0
-       
-        for obj in response.stats:
-            rxpackets += obj.rx_packets
-        rx_packet_counter = rxpackets-current_counter    
-        self.assertEqual(rx_packets,rx_packet_counter,"recieved packet counter is not incremented properly")
-
-def Verify_PortStats2(self,out_port,current_counter,tx_packets):
-#Verify Port counters like tx_packets
-
-        port_stats_req = message.port_stats_request()
-        port_stats_req.port_no = out_port     
-        response,pkt = self.controller.transact(port_stats_req)
-        self.assertTrue(response is not None,"No response received for port stats request") 
-        txpackets=0
-       
-        for obj in response.stats:
-            txpackets += obj.tx_packets
-        tx_packet_counter = txpackets-current_counter    
-        self.assertEqual(tx_packets,tx_packet_counter,"Transmitted packet counter is not incremented properly")    
-
-
-def Verify_PortStats3(self,out_port,current_counter,rx_bytes):
-#Verify Port counters like rx_bytes
-
-        port_stats_req = message.port_stats_request()
-        port_stats_req.port_no = out_port     
-        response,pkt = self.controller.transact(port_stats_req)
-        self.assertTrue(response is not None,"No response received for port stats request") 
-        rxbytes=0
-       
-        for obj in response.stats:
-            rxbytes += obj.rx_bytes
-        rx_byte_counter = rxbytes-current_counter    
-        self.assertEqual(rx_bytes,rx_byte_counter,"Recieved byte counter is not incremented properly")   
-
-def Verify_PortStats4(self,out_port,current_counter,tx_bytes):
-#Verify Port counters like tx_bytes
-
-        port_stats_req = message.port_stats_request()
-        port_stats_req.port_no = out_port     
-        response,pkt = self.controller.transact(port_stats_req)
-        self.assertTrue(response is not None,"No response received for port stats request") 
-        txbytes=0
-       
-        for obj in response.stats:
-            txbytes += obj.tx_bytes
-        tx_byte_counter = txbytes-current_counter    
-        self.assertEqual(tx_bytes,tx_byte_counter,"Transmitted byte counter is not incremented properly")  
 
 ############################## Various delete commands #############################################################################################
 
-def Strict_Delete(self,match,priority=0):
+def strict_delete(self,match,priority=0):
 # Issue Strict Delete 
         
-        #Create flow_mod message, command DELETE_STRICT
-        msg4 = message.flow_mod()
-        msg4.out_port = ofp.OFPP_NONE
-        msg4.command = ofp.OFPFC_DELETE_STRICT
-        msg4.buffer_id = 0xffffffff
-        msg4.match = match
+    #Create flow_mod message, command DELETE_STRICT
+    msg4 = message.flow_mod()
+    msg4.out_port = ofp.OFPP_NONE
+    msg4.command = ofp.OFPFC_DELETE_STRICT
+    msg4.buffer_id = 0xffffffff
+    msg4.match = match
 
-        if priority != 0 :
-                msg4.priority = priority
-
-        rv = self.controller.message_send(msg4)
-        self.assertTrue(rv!= -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+    if priority != 0 :
+        msg4.priority = priority
+    rv = self.controller.message_send(msg4)
+    self.assertTrue(rv!= -1, "Error installing flow mod")
+    self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
 
 
-def NonStrict_Delete(self,match,priority=0):
+def nonstrict_delete(self,match,priority=0):
 # Issue Non_Strict Delete 
         
-        #Create flow_mod message, command DELETE
-        msg6 = message.flow_mod()
-        msg6.out_port = ofp.OFPP_NONE
-        msg6.command = ofp.OFPFC_DELETE
-        msg6.buffer_id = 0xffffffff
-        msg6.match = match
+    #Create flow_mod message, command DELETE
+    msg6 = message.flow_mod()
+    msg6.out_port = ofp.OFPP_NONE
+    msg6.command = ofp.OFPFC_DELETE
+    msg6.buffer_id = 0xffffffff
+    msg6.match = match
 
-        if priority != 0 :
-                msg6.priority = priority
+    if priority != 0 :
+        msg6.priority = priority
 
-        rv = self.controller.message_send(msg6)
-        self.assertTrue(rv != -1, "Error installing flow mod")
-        self.assertEqual(do_barrier(self.controller),0, "Barrier failed")
+    rv = self.controller.message_send(msg6)
+    self.assertTrue(rv != -1, "Error installing flow mod")
+    self.assertEqual(do_barrier(self.controller),0, "Barrier failed")
 
 
 ###########################################################################################################################################################
 
-def SendPacket(obj, pkt, ingress_port, egress_port):
+def send_packet(obj, pkt, ingress_port, egress_port):
 #Send Packets on a specified ingress_port and verify if its recieved on correct egress_port.
 
     obj.dataplane.send(ingress_port, str(pkt))