diff --git a/ofdpa/flows.py b/ofdpa/flows.py
index 069d856..f9dffe3 100755
--- a/ofdpa/flows.py
+++ b/ofdpa/flows.py
@@ -12,114 +12,84 @@
 from accton_util import *
 
 
-class PacketInUDP(base_tests.SimpleDataPlane):
+class PacketInUDP( base_tests.SimpleDataPlane ):
     """
     Verify a ACL rule that matches on IP_PROTO 2 will not match a UDP packet.
     Next it verify a rule that matches on IP_PROTO 17 WILL match a UDP packet.
     """
 
-    def runTest(self):
+    def runTest( self ):
         try:
-            parsed_vlan_pkt = simple_udp_packet(pktlen=104,
-                                                vlan_vid=0x1001,
-                                                dl_vlan_enable=True)
-            vlan_pkt = str(parsed_vlan_pkt)
+            parsed_vlan_pkt = simple_udp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
+            vlan_pkt = str( parsed_vlan_pkt )
             # create match
-            match = ofp.match()
-            match.oxm_list.append(ofp.oxm.eth_type(0x0800))
-            match.oxm_list.append(ofp.oxm.ip_proto(2))
-            request = ofp.message.flow_add(
-                    table_id=60,
-                    cookie=42,
-                    match=match,
-                    instructions=[
-                        ofp.instruction.apply_actions(
-                                actions=[
-                                    ofp.action.output(
-                                            port=ofp.OFPP_CONTROLLER,
-                                            max_len=ofp.OFPCML_NO_BUFFER)]), ],
-                    buffer_id=ofp.OFP_NO_BUFFER,
-                    priority=1)
-            logging.info("Inserting packet in flow to controller")
-            self.controller.message_send(request)
+            match = ofp.match( )
+            match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
+            match.oxm_list.append( ofp.oxm.ip_proto( 2 ) )
+            request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
+                ofp.instruction.apply_actions( actions=[
+                    ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
+                    buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
+            logging.info( "Inserting packet in flow to controller" )
+            self.controller.message_send( request )
 
-            for of_port in config["port_map"].keys():
-                logging.info("PacketInMiss test, port %d", of_port)
-                self.dataplane.send(of_port, vlan_pkt)
+            for of_port in config[ "port_map" ].keys( ):
+                logging.info( "PacketInMiss test, port %d", of_port )
+                self.dataplane.send( of_port, vlan_pkt )
 
-                verify_no_packet_in(self, vlan_pkt, of_port)
-            delete_all_flows(self.controller)
-            do_barrier(self.controller)
+                verify_no_packet_in( self, vlan_pkt, of_port )
+            delete_all_flows( self.controller )
+            do_barrier( self.controller )
 
-            match = ofp.match()
-            match.oxm_list.append(ofp.oxm.eth_type(0x0800))
-            match.oxm_list.append(ofp.oxm.ip_proto(17))
-            request = ofp.message.flow_add(
-                    table_id=60,
-                    cookie=42,
-                    match=match,
-                    instructions=[
-                        ofp.instruction.apply_actions(
-                                actions=[
-                                    ofp.action.output(
-                                            port=ofp.OFPP_CONTROLLER,
-                                            max_len=ofp.OFPCML_NO_BUFFER)]), ],
-                    buffer_id=ofp.OFP_NO_BUFFER,
-                    priority=1)
-            logging.info("Inserting packet in flow to controller")
-            self.controller.message_send(request)
-            do_barrier(self.controller)
+            match = ofp.match( )
+            match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
+            match.oxm_list.append( ofp.oxm.ip_proto( 17 ) )
+            request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
+                ofp.instruction.apply_actions( actions=[
+                    ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
+                    buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
+            logging.info( "Inserting packet in flow to controller" )
+            self.controller.message_send( request )
+            do_barrier( self.controller )
 
-            for of_port in config["port_map"].keys():
-                logging.info("PacketInMiss test, port %d", of_port)
-                self.dataplane.send(of_port, vlan_pkt)
+            for of_port in config[ "port_map" ].keys( ):
+                logging.info( "PacketInMiss test, port %d", of_port )
+                self.dataplane.send( of_port, vlan_pkt )
 
-                verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
+                verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_ACTION )
 
-                verify_no_other_packets(self)
+                verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_all_groups( self.controller )
 
 
 @disabled
-class ArpNL2(base_tests.SimpleDataPlane):
-    def runTest(self):
-        delete_all_flows(self.controller)
-        delete_all_groups(self.controller)
+class ArpNL2( base_tests.SimpleDataPlane ):
+    def runTest( self ):
+        delete_all_flows( self.controller )
+        delete_all_groups( self.controller )
 
-        ports = sorted(config["port_map"].keys())
-        match = ofp.match()
-        match.oxm_list.append(ofp.oxm.eth_type(0x0806))
-        request = ofp.message.flow_add(
-                table_id=60,
-                cookie=42,
-                match=match,
-                instructions=[
-                    ofp.instruction.apply_actions(
-                            actions=[
-                                ofp.action.output(
-                                        port=ofp.OFPP_CONTROLLER,
-                                        max_len=ofp.OFPCML_NO_BUFFER)]),
-                ],
-                buffer_id=ofp.OFP_NO_BUFFER,
-                priority=40000)
-        self.controller.message_send(request)
+        ports = sorted( config[ "port_map" ].keys( ) )
+        match = ofp.match( )
+        match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
+        request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
+            ofp.instruction.apply_actions( actions=[
+                ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
+                buffer_id=ofp.OFP_NO_BUFFER, priority=40000 )
+        self.controller.message_send( request )
         for port in ports:
-            add_one_l2_interface_group(self.controller, port, 1, False, False)
-            add_one_vlan_table_flow(self.controller, port, 1,
-                                    flag=VLAN_TABLE_FLAG_ONLY_BOTH)
-            group_id = encode_l2_interface_group_id(1, port)
-            add_bridge_flow(self.controller,
-                            [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id,
-                            True)
-        do_barrier(self.controller)
-        parsed_arp_pkt = simple_arp_packet()
-        arp_pkt = str(parsed_arp_pkt)
+            add_one_l2_interface_group( self.controller, port, 1, False, False )
+            add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
+            group_id = encode_l2_interface_group_id( 1, port )
+            add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True )
+        do_barrier( self.controller )
+        parsed_arp_pkt = simple_arp_packet( )
+        arp_pkt = str( parsed_arp_pkt )
 
         for out_port in ports:
-            self.dataplane.send(out_port, arp_pkt)
-            verify_packet_in(self, arp_pkt, out_port, ofp.OFPR_ACTION)
+            self.dataplane.send( out_port, arp_pkt )
+            verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION )
             # change dest based on port number
             mac_dst = '00:12:34:56:78:%02X' % out_port
             for in_port in ports:
@@ -127,61 +97,52 @@
                     continue
                 # change source based on port number to avoid packet-ins from learning
                 mac_src = '00:12:34:56:78:%02X' % in_port
-                parsed_pkt = simple_tcp_packet(eth_dst=mac_dst, eth_src=mac_src)
-                pkt = str(parsed_pkt)
-                self.dataplane.send(in_port, pkt)
+                parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src )
+                pkt = str( parsed_pkt )
+                self.dataplane.send( in_port, pkt )
 
                 for ofport in ports:
-                    if ofport in [out_port]:
-                        verify_packet(self, pkt, ofport)
+                    if ofport in [ out_port ]:
+                        verify_packet( self, pkt, ofport )
                     else:
-                        verify_no_packet(self, pkt, ofport)
+                        verify_no_packet( self, pkt, ofport )
 
-                verify_no_other_packets(self)
+                verify_no_other_packets( self )
 
-
-class PacketInArp(base_tests.SimpleDataPlane):
+class PacketInArp( base_tests.SimpleDataPlane ):
     """
     Verify an ACL rule matching on ethertyper 0x806 will result in a packet-in
     """
 
-    def runTest(self):
+    def runTest( self ):
         try:
-            parsed_arp_pkt = simple_arp_packet()
-            arp_pkt = str(parsed_arp_pkt)
+            parsed_arp_pkt = simple_arp_packet( )
+            arp_pkt = str( parsed_arp_pkt )
             # create match
-            match = ofp.match()
-            match.oxm_list.append(ofp.oxm.eth_type(0x0806))
-            request = ofp.message.flow_add(
-                    table_id=60,
-                    cookie=42,
-                    match=match,
-                    instructions=[
-                        ofp.instruction.apply_actions(
-                                actions=[
-                                    ofp.action.output(
-                                            port=ofp.OFPP_CONTROLLER,
-                                            max_len=ofp.OFPCML_NO_BUFFER)]),
-                    ],
-                    buffer_id=ofp.OFP_NO_BUFFER,
-                    priority=1)
+            match = ofp.match( )
+            match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
+            request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
+                ofp.instruction.apply_actions( actions=[
+                    ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
+                    buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
 
-            logging.info("Inserting packet in flow to controller")
-            self.controller.message_send(request)
-            do_barrier(self.controller)
+            logging.info( "Inserting packet in flow to controller" )
+            self.controller.message_send( request )
+            do_barrier( self.controller )
 
-            for of_port in config["port_map"].keys():
-                logging.info("PacketInMiss test, port %d", of_port)
-                self.dataplane.send(of_port, arp_pkt)
+            for of_port in config[ "port_map" ].keys( ):
+                logging.info( "PacketInMiss test, port %d", of_port )
+                self.dataplane.send( of_port, arp_pkt )
 
-                verify_packet_in(self, arp_pkt, of_port, ofp.OFPR_ACTION)
+                verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION )
 
-                verify_no_other_packets(self)
+                verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_all_groups( self.controller )
 
-class PacketInIPTable(base_tests.SimpleDataPlane):
+
+class PacketInIPTable( base_tests.SimpleDataPlane ):
     """
     Test packet in function on IPTABLE
     Send a packet to each dataplane port and verify that a packet
@@ -189,163 +150,156 @@
     #todo verify you stop receiving after adding rule
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
-            dip=0xc0a80001
-            ports = sorted(config["port_map"].keys())
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
+            dip = 0xc0a80001
+            ports = sorted( config[ "port_map" ].keys( ) )
 
             for port in ports:
-                #add l2 interface group
-                vlan_id=port
-                add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False)
-                dst_mac[5]=vlan_id
-                l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
-                #add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id,  flag=VLAN_TABLE_FLAG_ONLY_TAG)
-                #add termination flow
-                add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
-                #add unicast routing flow
-                dst_ip = dip + (vlan_id<<8)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id, send_ctrl=True)
-                Groups.put(l3_msg.group_id)
+                # add l2 interface group
+                vlan_id = port
+                add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True,
+                        send_barrier=False )
+                dst_mac[ 5 ] = vlan_id
+                l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
+                        src_mac=intf_src_mac, dst_mac=dst_mac )
+                # add vlan flow table
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                # add termination flow
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
+                # add unicast routing flow
+                dst_ip = dip + (vlan_id << 8)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id,
+                        send_ctrl=True )
+                Groups.put( l3_msg.group_id )
 
-            do_barrier(self.controller)
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
-                mac_src='00:00:00:22:22:%02X' % in_port
-                ip_src='192.168.%02d.1' % in_port
+                mac_src = '00:00:00:22:22:%02X' % in_port
+                ip_src = '192.168.%02d.1' % in_port
                 for out_port in ports:
                     if in_port == out_port:
                         continue
-                    ip_dst='192.168.%02d.1' % out_port
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
-                                                   eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
-                                                   ip_dst=ip_dst)
-                    pkt=str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
-                    verify_packet_in(self, pkt, in_port, ofp.OFPR_ACTION)
-                    #verify_no_other_packets(self)
+                    ip_dst = '192.168.%02d.1' % out_port
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
+                            eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
+                    verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION )
+                    # verify_no_other_packets(self)
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class L2FloodQinQ(base_tests.SimpleDataPlane):
+
+class L2FloodQinQ( base_tests.SimpleDataPlane ):
     """
     Verify a tagged frame can be flooded based on its outer vlan
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            ports = sorted(config["port_map"].keys())
+            ports = sorted( config[ "port_map" ].keys( ) )
             vlan_id = 1
 
             for port in ports:
-                L2gid, l2msg = add_one_l2_interface_group(self.controller, port,
-                                                          vlan_id, True, False)
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
-                Groups.put(L2gid)
+                L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                Groups.put( L2gid )
 
-            msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id)
-            Groups.put(msg.group_id)
-            add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True)
-            do_barrier(self.controller)
+            msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
+            Groups.put( msg.group_id )
+            add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
+            do_barrier( self.controller )
 
             # verify flood
             for ofport in ports:
                 # change dest based on port number
                 mac_src = '00:12:34:56:78:%02X' % ofport
-                parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108,
-                                                        out_dl_vlan_enable=True,
-                                                        out_vlan_vid=vlan_id,
-                                                        in_dl_vlan_enable=True,
-                                                        in_vlan_vid=10,
-                                                        eth_dst='00:12:34:56:78:9a',
-                                                        eth_src=mac_src)
-                pkt = str(parsed_pkt)
-                self.dataplane.send(ofport, pkt)
+                parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
+                        out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
+                        eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
+                pkt = str( parsed_pkt )
+                self.dataplane.send( ofport, pkt )
                 # self won't rx packet
-                verify_no_packet(self, pkt, ofport)
+                verify_no_packet( self, pkt, ofport )
                 # others will rx packet
-                tmp_ports = list(ports)
-                tmp_ports.remove(ofport)
-                verify_packets(self, pkt, tmp_ports)
+                tmp_ports = list( ports )
+                tmp_ports.remove( ofport )
+                verify_packets( self, pkt, tmp_ports )
 
-            verify_no_other_packets(self)
+            verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
+
 
 @disabled
-class L2FloodTagged(base_tests.SimpleDataPlane):
+class L2FloodTagged( base_tests.SimpleDataPlane ):
     """
     Test L2 flood to a vlan
     Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
     """
 
-    def runTest(self):
+    def runTest( self ):
         # Hashes Test Name and uses it as id for installing unique groups
-        vlan_id = abs(hash(inspect.stack()[0][3])) % (256)
+        vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256)
         print vlan_id
 
-        ports = sorted(config["port_map"].keys())
+        ports = sorted( config[ "port_map" ].keys( ) )
 
-        delete_all_flows(self.controller)
-        delete_all_groups(self.controller)
+        delete_all_flows( self.controller )
+        delete_all_groups( self.controller )
 
         # Installing flows to avoid packet-in
         for port in ports:
-            add_one_l2_interface_group(self.controller, port, vlan_id, True,
-                                       False)
-            add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                    flag=VLAN_TABLE_FLAG_ONLY_TAG)
-        msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id)
-        add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True)
-        do_barrier(self.controller)
+            add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
+            add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+        msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
+        add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
+        do_barrier( self.controller )
 
         # verify flood
         for ofport in ports:
             # change dest based on port number
-            pkt = str(simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id,
-                                        eth_dst='00:12:34:56:78:9a'))
-            self.dataplane.send(ofport, pkt)
+            pkt = str(
+                    simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) )
+            self.dataplane.send( ofport, pkt )
             # self won't rx packet
-            verify_no_packet(self, pkt, ofport)
+            verify_no_packet( self, pkt, ofport )
             # others will rx packet
-            tmp_ports = list(ports)
-            tmp_ports.remove(ofport)
-            verify_packets(self, pkt, tmp_ports)
-        verify_no_other_packets(self)
+            tmp_ports = list( ports )
+            tmp_ports.remove( ofport )
+            verify_packets( self, pkt, tmp_ports )
+        verify_no_other_packets( self )
 
 
-class L2UnicastTagged(base_tests.SimpleDataPlane):
+class L2UnicastTagged( base_tests.SimpleDataPlane ):
     """
     Verify L2 forwarding works
     """
 
-    def runTest(self):
+    def runTest( self ):
 
-        Groups = Queue.LifoQueue()
+        Groups = Queue.LifoQueue( )
         try:
-            ports = sorted(config["port_map"].keys())
+            ports = sorted( config[ "port_map" ].keys( ) )
             vlan_id = 1;
             for port in ports:
-                L2gid, l2msg = add_one_l2_interface_group(self.controller, port,
-                                                          vlan_id, True, False)
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
-                Groups.put(L2gid)
-                add_bridge_flow(self.controller,
-                                [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id,
-                                L2gid, True)
-            do_barrier(self.controller)
+                L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                Groups.put( L2gid )
+                add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
+                        True )
+            do_barrier( self.controller )
 
             for out_port in ports:
                 # change dest based on port number
@@ -353,37 +307,33 @@
                 for in_port in ports:
                     if in_port == out_port:
                         continue
-                    pkt = str(
-                            simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id,
-                                              eth_dst=mac_dst))
-                    self.dataplane.send(in_port, pkt)
+                    pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) )
+                    self.dataplane.send( in_port, pkt )
                     for ofport in ports:
-                        if ofport in [out_port]:
-                            verify_packet(self, pkt, ofport)
+                        if ofport in [ out_port ]:
+                            verify_packet( self, pkt, ofport )
                         else:
-                            verify_no_packet(self, pkt, ofport)
-                    verify_no_other_packets(self)
+                            verify_no_packet( self, pkt, ofport )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class Mtu1500(base_tests.SimpleDataPlane):
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+
+class Mtu1500( base_tests.SimpleDataPlane ):
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            ports = sorted(config["port_map"].keys())
+            ports = sorted( config[ "port_map" ].keys( ) )
             vlan_id = 18
             for port in ports:
-                L2gid, msg = add_one_l2_interface_group(self.controller, port,
-                                                        vlan_id, True, False)
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
-                Groups.put(L2gid)
-                add_bridge_flow(self.controller,
-                                [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id,
-                                L2gid, True)
-            do_barrier(self.controller)
+                L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                Groups.put( L2gid )
+                add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
+                        True )
+            do_barrier( self.controller )
 
             for out_port in ports:
                 # change dest based on port number
@@ -391,63 +341,58 @@
                 for in_port in ports:
                     if in_port == out_port:
                         continue
-                    pkt = str(simple_tcp_packet(pktlen=1500, dl_vlan_enable=True,
-                                                vlan_vid=vlan_id, eth_dst=mac_dst))
-                    self.dataplane.send(in_port, pkt)
+                    pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id,
+                            eth_dst=mac_dst ) )
+                    self.dataplane.send( in_port, pkt )
                     for ofport in ports:
-                        if ofport in [out_port]:
-                            verify_packet(self, pkt, ofport)
+                        if ofport in [ out_port ]:
+                            verify_packet( self, pkt, ofport )
                         else:
-                            verify_no_packet(self, pkt, ofport)
-                    verify_no_other_packets(self)
+                            verify_no_packet( self, pkt, ofport )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _32UcastTagged(base_tests.SimpleDataPlane):
+
+class _32UcastTagged( base_tests.SimpleDataPlane ):
     """
     Verify a IP forwarding works for a /32 rule to L3 Unicast Interface
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
             test_id = 26
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
 
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             dip = 0xc0a80001
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 # add l2 interface group
                 vlan_id = port + test_id
-                l2gid, msg = add_one_l2_interface_group(self.controller, port,
-                                                        vlan_id=vlan_id,
-                                                        is_tagged=True,
-                                                        send_barrier=False)
-                dst_mac[5] = vlan_id
-                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
-                                              id=vlan_id, src_mac=intf_src_mac,
-                                              dst_mac=dst_mac)
+                l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
+                        is_tagged=True, send_barrier=False )
+                dst_mac[ 5 ] = vlan_id
+                l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
+                        src_mac=intf_src_mac, dst_mac=dst_mac )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
-                                     vlan_id)
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
                 dst_ip = dip + (vlan_id << 8)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
-                                         0xffffffff, l3_msg.group_id)
-                Groups.put(l2gid)
-                Groups.put(l3_msg.group_id)
-            do_barrier(self.controller)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
+                Groups.put( l2gid )
+                Groups.put( l3_msg.group_id )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 mac_src = '00:00:00:22:32:%02X' % (test_id + in_port)
                 ip_src = '192.168.%02d.1' % (test_id + in_port)
@@ -455,239 +400,209 @@
                     if in_port == out_port:
                         continue
                     ip_dst = '192.168.%02d.1' % (test_id + out_port)
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                   vlan_vid=(test_id + in_port),
-                                                   eth_dst=switch_mac,
-                                                   eth_src=mac_src, ip_ttl=64,
-                                                   ip_src=ip_src,
-                                                   ip_dst=ip_dst)
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
+                            vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
+                            ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expected packet
                     mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
-                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                vlan_vid=(test_id + out_port),
-                                                eth_dst=mac_dst, eth_src=switch_mac,
-                                                ip_ttl=63,
-                                                ip_src=ip_src, ip_dst=ip_dst)
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
+                            vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
+                            ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _32VPN(base_tests.SimpleDataPlane):
+
+class _32VPN( base_tests.SimpleDataPlane ):
     """
             Insert IP packet
             Receive MPLS packet
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
 
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             dip = 0xc0a80001
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 # add l2 interface group
                 id = port
                 vlan_id = port
-                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
-                                                            vlan_id, True, True)
-                dst_mac[5] = vlan_id
+                l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
+                dst_mac[ 5 ] = vlan_id
                 # add MPLS interface group
-                mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
-                                                         dst_mac, intf_src_mac,
-                                                         vlan_id, id)
+                mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
+                        vlan_id, id )
                 # add MPLS L3 VPN group
-                mpls_label_gid, mpls_label_msg = add_mpls_label_group(
-                        self.controller,
-                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
-                        index=id, ref_gid=mpls_gid, push_mpls_header=True,
-                        set_mpls_label=port, set_bos=1, set_ttl=32)
+                mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
+                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
+                        push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
                 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
-                do_barrier(self.controller)
+                do_barrier( self.controller )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=2,
+                        flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
-                                     vlan_id)
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add routing flow
                 dst_ip = dip + (vlan_id << 8)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
-                                         0xffffffff, mpls_label_gid,vrf=2)
-                Groups._put(l2_gid)
-                Groups._put(mpls_gid)
-                Groups._put(mpls_label_gid)
-            do_barrier(self.controller)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 )
+                Groups._put( l2_gid )
+                Groups._put( mpls_gid )
+                Groups._put( mpls_label_gid )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 ip_src = '192.168.%02d.1' % (in_port)
                 for out_port in ports:
                     if in_port == out_port:
                         continue
                     ip_dst = '192.168.%02d.1' % (out_port)
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                   vlan_vid=(in_port),
-                                                   eth_dst=switch_mac, ip_ttl=64,
-                                                   ip_src=ip_src,
-                                                   ip_dst=ip_dst)
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
+                            eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expect packet
                     mac_dst = '00:00:00:22:22:%02X' % (out_port)
                     label = (out_port, 0, 1, 32)
-                    exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
-                                          vlan_vid=(out_port), ip_ttl=63,
-                                          ip_src=ip_src,
-                                          ip_dst=ip_dst, eth_dst=mac_dst,
-                                          eth_src=switch_mac, label=[label])
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
+                            ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
+                            label=[ label ] )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _32EcmpVpn(base_tests.SimpleDataPlane):
+
+class _32EcmpVpn( base_tests.SimpleDataPlane ):
     """
             Insert IP packet
             Receive MPLS packet
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
 
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             dip = 0xc0a80001
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 # add l2 interface group
                 id = port
                 vlan_id = port
-                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
-                                                            vlan_id, True, True)
-                dst_mac[5] = vlan_id
+                l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
+                dst_mac[ 5 ] = vlan_id
                 # add MPLS interface group
-                mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
-                                                         dst_mac, intf_src_mac,
-                                                         vlan_id, id)
+                mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
+                        vlan_id, id )
                 # add MPLS L3 VPN group
-                mpls_label_gid, mpls_label_msg = add_mpls_label_group(
-                        self.controller,
-                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
-                        index=id, ref_gid=mpls_gid, push_mpls_header=True,
-                        set_mpls_label=port, set_bos=1, set_ttl=32)
-                ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
-                do_barrier(self.controller)
+                mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
+                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
+                        push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
+                ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
+                do_barrier( self.controller )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0,
+                        flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
-                                     vlan_id)
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add routing flow
                 dst_ip = dip + (vlan_id << 8)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
-                                         0xffffffff, ecmp_msg.group_id)
-                Groups._put(l2_gid)
-                Groups._put(mpls_gid)
-                Groups._put(mpls_label_gid)
-                Groups._put(ecmp_msg.group_id)
-            do_barrier(self.controller)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
+                Groups._put( l2_gid )
+                Groups._put( mpls_gid )
+                Groups._put( mpls_label_gid )
+                Groups._put( ecmp_msg.group_id )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 ip_src = '192.168.%02d.1' % (in_port)
                 for out_port in ports:
                     if in_port == out_port:
                         continue
                     ip_dst = '192.168.%02d.1' % (out_port)
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                   vlan_vid=(in_port),
-                                                   eth_dst=switch_mac, ip_ttl=64,
-                                                   ip_src=ip_src,
-                                                   ip_dst=ip_dst)
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
+                            eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expect packet
                     mac_dst = '00:00:00:22:22:%02X' % (out_port)
                     label = (out_port, 0, 1, 32)
-                    exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
-                                          vlan_vid=(out_port), ip_ttl=63,
-                                          ip_src=ip_src,
-                                          ip_dst=ip_dst, eth_dst=mac_dst,
-                                          eth_src=switch_mac, label=[label])
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
+                            ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
+                            label=[ label ] )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _32ECMPL3(base_tests.SimpleDataPlane):
+
+class _32ECMPL3( base_tests.SimpleDataPlane ):
     """
         Insert IP packet
         Receive IP packet
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
 
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             dip = 0xc0a80001
             # Hashes Test Name and uses it as id for installing unique groups
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 vlan_id = port
                 id = port
                 # add l2 interface group
-                l2_gid, msg = add_one_l2_interface_group(self.controller, port,
-                                                         vlan_id=vlan_id,
-                                                         is_tagged=True,
-                                                         send_barrier=False)
-                dst_mac[5] = vlan_id
-                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
-                                              id=id, src_mac=intf_src_mac,
-                                              dst_mac=dst_mac)
-                ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
+                l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
+                        is_tagged=True, send_barrier=False )
+                dst_mac[ 5 ] = vlan_id
+                l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
+                        src_mac=intf_src_mac, dst_mac=dst_mac )
+                ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
-                                     vlan_id)
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
                 dst_ip = dip + (vlan_id << 8)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
-                                         0xffffffff, ecmp_msg.group_id)
-                Groups._put(l2_gid)
-                Groups._put(l3_msg.group_id)
-                Groups._put(ecmp_msg.group_id)
-            do_barrier(self.controller)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
+                Groups._put( l2_gid )
+                Groups._put( l3_msg.group_id )
+                Groups._put( ecmp_msg.group_id )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 mac_src = '00:00:00:22:22:%02X' % in_port
                 ip_src = '192.168.%02d.1' % in_port
@@ -695,161 +610,143 @@
                     if in_port == out_port:
                         continue
                     ip_dst = '192.168.%02d.1' % out_port
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                   vlan_vid=in_port,
-                                                   eth_dst=switch_mac,
-                                                   eth_src=mac_src, ip_ttl=64,
-                                                   ip_src=ip_src,
-                                                   ip_dst=ip_dst)
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
+                            eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expected packet
                     mac_dst = '00:00:00:22:22:%02X' % out_port
-                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                vlan_vid=out_port,
-                                                eth_dst=mac_dst, eth_src=switch_mac,
-                                                ip_ttl=63,
-                                                ip_src=ip_src, ip_dst=ip_dst)
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
+                            eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _24VPN(base_tests.SimpleDataPlane):
+
+class _24VPN( base_tests.SimpleDataPlane ):
     """
             Insert IP packet
             Receive MPLS packet
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
 
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             dip = 0xc0a80001
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 # add l2 interface group
                 id = port
                 vlan_id = port
-                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
-                dst_mac[5] = vlan_id
+                l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
+                dst_mac[ 5 ] = vlan_id
                 # add MPLS interface group
-                mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, id)
+                mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
+                        vlan_id, id )
                 # add MPLS L3 VPN group
-                mpls_label_gid, mpls_label_msg = add_mpls_label_group(
-                        self.controller,
-                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
-                        index=id, ref_gid=mpls_gid, push_mpls_header=True,
-                        set_mpls_label=port, set_bos=1, set_ttl=32)
+                mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
+                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
+                        push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
                 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
-                do_barrier(self.controller)
+                do_barrier( self.controller )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0,
+                        flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
-                                     vlan_id)
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add routing flow
                 dst_ip = dip + (vlan_id << 8)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
-                                         0xffffff00, mpls_label_gid)
-                Groups._put(l2_gid)
-                Groups._put(mpls_gid)
-                Groups._put(mpls_label_gid)
-            do_barrier(self.controller)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid )
+                Groups._put( l2_gid )
+                Groups._put( mpls_gid )
+                Groups._put( mpls_label_gid )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 ip_src = '192.168.%02d.1' % (in_port)
                 for out_port in ports:
                     if in_port == out_port:
                         continue
                     ip_dst = '192.168.%02d.1' % (out_port)
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                   vlan_vid=(in_port),
-                                                   eth_dst=switch_mac, ip_ttl=64,
-                                                   ip_src=ip_src,
-                                                   ip_dst=ip_dst)
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
+                            eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expect packet
                     mac_dst = '00:00:00:22:22:%02X' % (out_port)
                     label = (out_port, 0, 1, 32)
-                    exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
-                                          vlan_vid=(out_port), ip_ttl=63,
-                                          ip_src=ip_src,
-                                          ip_dst=ip_dst, eth_dst=mac_dst,
-                                          eth_src=switch_mac, label=[label])
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
+                            ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
+                            label=[ label ] )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _24EcmpVpn(base_tests.SimpleDataPlane):
+
+class _24EcmpVpn( base_tests.SimpleDataPlane ):
     """
 	    Insert IP packet
 	    Receive MPLS packet
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             dip = 0xc0a80001
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 # add l2 interface group
                 id = port
                 vlan_id = id
-                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
-                                                            vlan_id, True, True)
-                dst_mac[5] = vlan_id
+                l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
+                dst_mac[ 5 ] = vlan_id
                 # add MPLS interface group
-                mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
-                                                         dst_mac, intf_src_mac,
-                                                         vlan_id, id)
+                mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
+                        vlan_id, id )
                 # add MPLS L3 VPN group
-                mpls_label_gid, mpls_label_msg = add_mpls_label_group(
-                        self.controller,
-                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
-                        index=id, ref_gid=mpls_gid, push_mpls_header=True,
-                        set_mpls_label=port, set_bos=1, set_ttl=32)
-                ecmp_msg = add_l3_ecmp_group(self.controller, id, [mpls_label_gid])
-                do_barrier(self.controller)
+                mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
+                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
+                        push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
+                ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
+                do_barrier( self.controller )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0,
+                        flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
-                                     vlan_id)
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add routing flow
                 dst_ip = dip + (vlan_id << 8)
                 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
-                                         0xffffff00, ecmp_msg.group_id, vrf=0)
-                Groups._put(l2_gid)
-                Groups._put(mpls_gid)
-                Groups._put(mpls_label_gid)
-                Groups._put(ecmp_msg.group_id)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id,
+                        vrf=0 )
+                Groups._put( l2_gid )
+                Groups._put( mpls_gid )
+                Groups._put( mpls_label_gid )
+                Groups._put( ecmp_msg.group_id )
 
-            do_barrier(self.controller)
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 mac_src = '00:00:00:22:22:%02X' % (in_port)
                 ip_src = '192.168.%02d.1' % (in_port)
@@ -857,77 +754,116 @@
                     if in_port == out_port:
                         continue
                     ip_dst = '192.168.%02d.1' % (out_port)
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                   vlan_vid=(in_port),
-                                                   eth_dst=switch_mac,
-                                                   eth_src=mac_src, ip_ttl=64,
-                                                   ip_src=ip_src,
-                                                   ip_dst=ip_dst)
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
+                            eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expect packet
                     mac_dst = '00:00:00:22:22:%02X' % out_port
                     label = (out_port, 0, 1, 32)
-                    exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
-                                          vlan_vid=(out_port), ip_ttl=63,
-                                          ip_src=ip_src,
-                                          ip_dst=ip_dst, eth_dst=mac_dst,
-                                          eth_src=switch_mac, label=[label])
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
+                            ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
+                            label=[ label ] )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _24ECMPL3(base_tests.SimpleDataPlane):
+
+class FloodGroupMod( base_tests.SimpleDataPlane ):
+    """
+       Modify referenced group test
+    """
+
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
+        try:
+            ports = sorted( config[ "port_map" ].keys( ) )
+            vlan_id = 1
+
+            for port in ports:
+                L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                Groups.put( L2gid )
+
+            msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
+            Groups.put( msg.group_id )
+            add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
+            do_barrier( self.controller )
+            # verify flood
+            for ofport in ports:
+                # change dest based on port number
+                mac_src = '00:12:34:56:78:%02X' % ofport
+                parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
+                        out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
+                        eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
+                pkt = str( parsed_pkt )
+                self.dataplane.send( ofport, pkt )
+                # self won't rx packet
+                verify_no_packet( self, pkt, ofport )
+                # others will rx packet
+                tmp_ports = list( ports )
+                tmp_ports.remove( ofport )
+                verify_packets( self, pkt, tmp_ports )
+            verify_no_other_packets( self )
+            msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id )
+            mac_src = '00:12:34:56:78:%02X' % ports[ 1 ]
+            parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
+                    out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a',
+                    eth_src=mac_src )
+            pkt = str( parsed_pkt )
+            self.dataplane.send( ports[ 1 ], pkt )
+            verify_packets( self, pkt, [ ports[ 0 ] ] )
+        finally:
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
+
+
+class _24ECMPL3( base_tests.SimpleDataPlane ):
     """
         Insert IP packet
         Receive IP packet
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
 
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             dip = 0xc0a80001
             # Hashes Test Name and uses it as id for installing unique groups
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 vlan_id = port
                 id = port
                 # add l2 interface group
-                l2_gid, msg = add_one_l2_interface_group(self.controller, port,
-                                                         vlan_id=vlan_id,
-                                                         is_tagged=True,
-                                                         send_barrier=False)
-                dst_mac[5] = vlan_id
-                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
-                                              id=id, src_mac=intf_src_mac,
-                                              dst_mac=dst_mac)
-                ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
+                l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
+                        is_tagged=True, send_barrier=False )
+                dst_mac[ 5 ] = vlan_id
+                l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
+                        src_mac=intf_src_mac, dst_mac=dst_mac )
+                ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
-                                     vlan_id)
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
                 dst_ip = dip + (vlan_id << 8)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
-                                         0xffffff00, ecmp_msg.group_id)
-                Groups._put(l2_gid)
-                Groups._put(l3_msg.group_id)
-                Groups._put(ecmp_msg.group_id)
-            do_barrier(self.controller)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
+                Groups._put( l2_gid )
+                Groups._put( l3_msg.group_id )
+                Groups._put( ecmp_msg.group_id )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 mac_src = '00:00:00:22:22:%02X' % in_port
                 ip_src = '192.168.%02d.1' % in_port
@@ -935,70 +871,58 @@
                     if in_port == out_port:
                         continue
                     ip_dst = '192.168.%02d.1' % out_port
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                   vlan_vid=in_port,
-                                                   eth_dst=switch_mac,
-                                                   eth_src=mac_src, ip_ttl=64,
-                                                   ip_src=ip_src,
-                                                   ip_dst=ip_dst)
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
+                            eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expected packet
                     mac_dst = '00:00:00:22:22:%02X' % out_port
-                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                vlan_vid=out_port,
-                                                eth_dst=mac_dst, eth_src=switch_mac,
-                                                ip_ttl=63,
-                                                ip_src=ip_src, ip_dst=ip_dst)
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
+                            eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
+
 
 @disabled
-class MPLSBUG(base_tests.SimpleDataPlane):
-    def runTest(self):
-        if len(config["port_map"]) < 2:
-            logging.info("Port count less than 2, can't run this case")
+class MPLSBUG( base_tests.SimpleDataPlane ):
+    def runTest( self ):
+        if len( config[ "port_map" ] ) < 2:
+            logging.info( "Port count less than 2, can't run this case" )
             return
-        intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-        dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+        intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+        dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
         dip = 0xc0a80001
-        Groups = Queue.LifoQueue()
-        ports = config["port_map"].keys()
+        Groups = Queue.LifoQueue( )
+        ports = config[ "port_map" ].keys( )
         for port in ports:
             # add l2 interface group
             vlan_id = port
-            l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
-                                                        vlan_id, True, False)
-            dst_mac[5] = vlan_id
+            l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
+            dst_mac[ 5 ] = vlan_id
             # add L3 Unicast  group
-            l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
-                                          id=vlan_id, src_mac=intf_src_mac,
-                                          dst_mac=dst_mac)
+            l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
+                    src_mac=intf_src_mac, dst_mac=dst_mac )
             # add vlan flow table
-            add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                    flag=VLAN_TABLE_FLAG_ONLY_BOTH)
+            add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
             # add termination flow
-            add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
-                                 vlan_id, goto_table=24)
+            add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
             # add mpls flow
-            add_mpls_flow(self.controller, l3_msg.group_id, port)
+            add_mpls_flow( self.controller, l3_msg.group_id, port )
             # add termination flow
-            add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
-                                 vlan_id)
+            add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
             # add unicast routing flow
             dst_ip = dip + (vlan_id << 8)
-            add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
-                                     0xffffffff, l3_msg.group_id)
-            Groups._put(l2_gid)
-            Groups._put(l3_msg.group_id)
-        do_barrier(self.controller)
+            add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
+            Groups._put( l2_gid )
+            Groups._put( l3_msg.group_id )
+        do_barrier( self.controller )
 
-        switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+        switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
         for in_port in ports:
             mac_src = '00:00:00:22:22:%02X' % in_port
             ip_src = '192.168.%02d.1' % in_port
@@ -1008,136 +932,115 @@
                 ip_dst = '192.168.%02d.1' % out_port
                 switch_mac = "00:00:00:cc:cc:cc"
                 label = (out_port, 0, 1, 32)
-                parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
-                                         vlan_vid=in_port, ip_src=ip_src,
-                                         ip_dst=ip_dst, eth_dst=switch_mac,
-                                         eth_src=mac_src, label=[label])
-                pkt = str(parsed_pkt)
-                self.dataplane.send(in_port, pkt)
+                parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
+                        ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] )
+                pkt = str( parsed_pkt )
+                self.dataplane.send( in_port, pkt )
 
                 # build expect packet
                 mac_dst = '00:00:00:22:22:%02X' % out_port
-                exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                            vlan_vid=out_port,
-                                            eth_dst=mac_dst, eth_src=switch_mac,
-                                            ip_ttl=31, ip_src=ip_src,
-                                            ip_dst=ip_dst)
-                pkt = str(exp_pkt)
-                verify_packet(self, pkt, out_port)
-                verify_no_other_packets(self)
+                exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
+                        eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
+                pkt = str( exp_pkt )
+                verify_packet( self, pkt, out_port )
+                verify_no_other_packets( self )
 
-                parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                               vlan_vid=in_port,
-                                               eth_dst=switch_mac,
-                                               eth_src=mac_src, ip_ttl=64,
-                                               ip_src=ip_src,
-                                               ip_dst=ip_dst)
-                pkt = str(parsed_pkt)
-                self.dataplane.send(in_port, pkt)
+                parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
+                        eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
+                pkt = str( parsed_pkt )
+                self.dataplane.send( in_port, pkt )
                 # build expected packet
                 mac_dst = '00:00:00:22:22:%02X' % out_port
-                exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                            vlan_vid=out_port,
-                                            eth_dst=mac_dst, eth_src=switch_mac,
-                                            ip_ttl=63,
-                                            ip_src=ip_src, ip_dst=ip_dst)
-                pkt = str(exp_pkt)
-                verify_packet(self, pkt, out_port)
-                verify_no_other_packets(self)
-        delete_all_flows(self.controller)
-        delete_groups(self.controller, Groups)
+                exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
+                        eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
+                pkt = str( exp_pkt )
+                verify_packet( self, pkt, out_port )
+                verify_no_other_packets( self )
+        delete_all_flows( self.controller )
+        delete_groups( self.controller, Groups )
 
-class L3McastToL2(base_tests.SimpleDataPlane):
+
+class L3McastToL2( base_tests.SimpleDataPlane ):
     """
     Mcast routing to L2
     """
 
-    def runTest(self):
+    def runTest( self ):
         """
         port1 (vlan 300)-> All Ports (vlan 300)
         """
-        Groups = Queue.LifoQueue()
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 3:
-                logging.info("Port count less than 3, can't run this case")
+            if len( config[ "port_map" ] ) < 3:
+                logging.info( "Port count less than 3, can't run this case" )
                 assert (False)
                 return
             vlan_id = 300
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac])
-            dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
-            dst_mac_str = ':'.join(['%02X' % x for x in dst_mac])
-            port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
-            port1_mac_str = ':'.join(['%02X' % x for x in port1_mac])
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
+            dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
+            dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
+            port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
+            port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
             src_ip = 0xc0a80101
             src_ip_str = "192.168.1.1"
             dst_ip = 0xe0010101
             dst_ip_str = "224.1.1.1"
 
-            port1 = config["port_map"].keys()[0]
-            port2 = config["port_map"].keys()[1]
+            port1 = config[ "port_map" ].keys( )[ 0 ]
+            port2 = config[ "port_map" ].keys( )[ 1 ]
 
-            switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00]
+            switch_mac = [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ]
 
             # add l2 interface group
-            l2_intf_group_list = []
-            for port in config["port_map"].keys():
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+            l2_intf_group_list = [ ]
+            for port in config[ "port_map" ].keys( ):
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 if port == port2:
                     continue
-                l2_intf_gid, msg = add_one_l2_interface_group(self.controller, port,
-                                                              vlan_id=vlan_id,
-                                                              is_tagged=True,
-                                                              send_barrier=False)
-                l2_intf_group_list.append(l2_intf_gid)
-                Groups.put(l2_intf_gid)
+                l2_intf_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
+                        is_tagged=True, send_barrier=False )
+                l2_intf_group_list.append( l2_intf_gid )
+                Groups.put( l2_intf_gid )
 
                 # add termination flow
-            add_termination_flow(self.controller, port1, 0x0800, switch_mac,
-                                 vlan_id)
+            add_termination_flow( self.controller, port1, 0x0800, switch_mac, vlan_id )
 
             # add l3 interface group
-            mcat_group_msg = add_l3_mcast_group(self.controller, vlan_id, 2,
-                                                l2_intf_group_list)
-            add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip,
-                                    mcat_group_msg.group_id)
-            Groups._put(mcat_group_msg.group_id)
+            mcat_group_msg = add_l3_mcast_group( self.controller, vlan_id, 2, l2_intf_group_list )
+            add_mcast4_routing_flow( self.controller, vlan_id, src_ip, 0, dst_ip, mcat_group_msg.group_id )
+            Groups._put( mcat_group_msg.group_id )
 
-            parsed_pkt = simple_udp_packet(pktlen=100,
-                                           dl_vlan_enable=True,
-                                           vlan_vid=vlan_id,
-                                           eth_dst=dst_mac_str,
-                                           eth_src=port1_mac_str,
-                                           ip_ttl=64,
-                                           ip_src=src_ip_str,
-                                           ip_dst=dst_ip_str)
-            pkt = str(parsed_pkt)
-            self.dataplane.send(port1, pkt)
-            for port in config["port_map"].keys():
+            parsed_pkt = simple_udp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=vlan_id,
+                    eth_dst=dst_mac_str, eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str,
+                    ip_dst=dst_ip_str )
+            pkt = str( parsed_pkt )
+            self.dataplane.send( port1, pkt )
+            for port in config[ "port_map" ].keys( ):
                 if port == port2 or port == port1:
-                    verify_no_packet(self, pkt, port)
+                    verify_no_packet( self, pkt, port )
                     continue
-                verify_packet(self, pkt, port)
-            verify_no_other_packets(self)
+                verify_packet( self, pkt, port )
+            verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class L3McastToL3(base_tests.SimpleDataPlane):
+
+class L3McastToL3( base_tests.SimpleDataPlane ):
     """
     Mcast routing
     """
 
-    def runTest(self):
+    def runTest( self ):
         """
         port1 (vlan 1)-> port 2 (vlan 2)
         """
-        Groups = Queue.LifoQueue()
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 3:
-                logging.info("Port count less than 3, can't run this case")
+            if len( config[ "port_map" ] ) < 3:
+                logging.info( "Port count less than 3, can't run this case" )
                 assert (False)
                 return
 
@@ -1145,121 +1048,102 @@
             port2_out_vlan = 2
             port3_out_vlan = 3
             in_vlan = 1  # macast group vid shall use input vlan diffe from l3 interface use output vlan
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac])
-            dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
-            dst_mac_str = ':'.join(['%02X' % x for x in dst_mac])
-            port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
-            port1_mac_str = ':'.join(['%02X' % x for x in port1_mac])
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
+            dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
+            dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
+            port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
+            port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
             src_ip = 0xc0a80101
             src_ip_str = "192.168.1.1"
             dst_ip = 0xe0010101
             dst_ip_str = "224.1.1.1"
 
-            port1 = config["port_map"].keys()[0]
-            port2 = config["port_map"].keys()[1]
-            port3 = config["port_map"].keys()[2]
+            port1 = config[ "port_map" ].keys( )[ 0 ]
+            port2 = config[ "port_map" ].keys( )[ 1 ]
+            port3 = config[ "port_map" ].keys( )[ 2 ]
 
             # add l2 interface group
-            for port in config["port_map"].keys():
-                l2gid, msg = add_one_l2_interface_group(self.controller, port,
-                                                        vlan_id=vlan_id,
-                                                        is_tagged=False,
-                                                        send_barrier=False)
+            for port in config[ "port_map" ].keys( ):
+                l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
+                        is_tagged=False, send_barrier=False )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 vlan_id += 1
-                Groups._put(l2gid)
+                Groups._put( l2gid )
 
                 # add termination flow
-            add_termination_flow(self.controller, port1, 0x0800,
-                                 [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
+            add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
+                    vlan_id )
 
             # add l3 interface group
-            port2_ucast_msg = add_l3_interface_group(self.controller, port2,
-                                                     port2_out_vlan, 2,
-                                                     intf_src_mac)
-            port3_ucast_msg = add_l3_interface_group(self.controller, port3,
-                                                     port3_out_vlan, 3,
-                                                     intf_src_mac)
-            mcat_group_msg = add_l3_mcast_group(self.controller, in_vlan, 2,
-                                                [port2_ucast_msg.group_id,
-                                                 port3_ucast_msg.group_id])
-            add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip,
-                                    mcat_group_msg.group_id)
-            Groups._put(port2_ucast_msg.group_id)
-            Groups._put(port3_ucast_msg.group_id)
-            Groups._put(mcat_group_msg.group_id)
-            parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
-                                           vlan_vid=1,
-                                           eth_dst=dst_mac_str,
-                                           eth_src=port1_mac_str,
-                                           ip_ttl=64,
-                                           ip_src=src_ip_str,
-                                           ip_dst=dst_ip_str)
-            pkt = str(parsed_pkt)
-            self.dataplane.send(port1, pkt)
-            parsed_pkt = simple_udp_packet(pktlen=96,
-                                           eth_dst=dst_mac_str,
-                                           eth_src=intf_src_mac_str,
-                                           ip_ttl=63,
-                                           ip_src=src_ip_str,
-                                           ip_dst=dst_ip_str)
-            pkt = str(parsed_pkt)
-            verify_packet(self, pkt, port2)
-            verify_packet(self, pkt, port3)
-            verify_no_other_packets(self)
+            port2_ucast_msg = add_l3_interface_group( self.controller, port2, port2_out_vlan, 2,
+                    intf_src_mac )
+            port3_ucast_msg = add_l3_interface_group( self.controller, port3, port3_out_vlan, 3,
+                    intf_src_mac )
+            mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2,
+                    [ port2_ucast_msg.group_id, port3_ucast_msg.group_id ] )
+            add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id )
+            Groups._put( port2_ucast_msg.group_id )
+            Groups._put( port3_ucast_msg.group_id )
+            Groups._put( mcat_group_msg.group_id )
+            parsed_pkt = simple_udp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
+                    eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
+            pkt = str( parsed_pkt )
+            self.dataplane.send( port1, pkt )
+            parsed_pkt = simple_udp_packet( pktlen=96, eth_dst=dst_mac_str, eth_src=intf_src_mac_str,
+                    ip_ttl=63, ip_src=src_ip_str, ip_dst=dst_ip_str )
+            pkt = str( parsed_pkt )
+            verify_packet( self, pkt, port2 )
+            verify_packet( self, pkt, port3 )
+            verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
+
+
 @disabled
-class _MplsFwd(base_tests.SimpleDataPlane):
+class _MplsFwd( base_tests.SimpleDataPlane ):
     """
         Insert MPLS packet
         Receive MPLS packet
     """
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
             dip = 0xc0a80001
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 # add l2 interface group
                 id = port
                 vlan_id = id
-                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
-                                                            vlan_id, True, False)
-                dst_mac[5] = vlan_id
-                mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
-                                                         dst_mac, intf_src_mac,
-                                                         vlan_id, id)
-                mpls_label_gid, mpls_label_msg = add_mpls_label_group(
-                        self.controller,
-                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL,
-                        index=id, ref_gid=mpls_gid, push_mpls_header=False,
-                        set_mpls_label=port, set_bos=1)
+                l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
+                dst_mac[ 5 ] = vlan_id
+                mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
+                        vlan_id, id )
+                mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
+                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid,
+                        push_mpls_header=False, set_mpls_label=port, set_bos=1 )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
-                                     vlan_id, goto_table=24)
-                add_mpls_flow(self.controller, mpls_label_gid, port, goto_table=29)
+                add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
+                add_mpls_flow( self.controller, mpls_label_gid, port, goto_table=29 )
                 dst_ip = dip + (vlan_id << 8)
-                Groups._put(l2_gid)
-                Groups._put(mpls_gid)
-                Groups._put(mpls_label_gid)
-            do_barrier(self.controller)
+                Groups._put( l2_gid )
+                Groups._put( mpls_gid )
+                Groups._put( mpls_label_gid )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 ip_src = '192.168.%02d.1' % (in_port)
                 for out_port in ports:
@@ -1268,71 +1152,66 @@
                     ip_dst = '192.168.%02d.1' % (out_port)
 
                     label = (out_port, 0, 1, 32)
-                    parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
-                                             vlan_vid=(in_port), ip_src=ip_src,
-                                             ip_dst=ip_dst, eth_dst=switch_mac,
-                                             label=[label])
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_port),
+                            ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
 
                     # build expect packet
                     mac_dst = '00:00:00:22:22:%02X' % (out_port)
                     label = (out_port, 0, 1, 31)
-                    exp_pkt =  mpls_packet(pktlen=104, dl_vlan_enable=True,
-                                             vlan_vid=(out_port), ip_src=ip_src,
-                                             ip_dst=ip_dst, eth_src=switch_mac,
-                                             eth_dst=mac_dst,label=[label])
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port),
+                            ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst,
+                            label=[ label ] )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _MplsTermination(base_tests.SimpleDataPlane):
+
+class _MplsTermination( base_tests.SimpleDataPlane ):
     """
         Insert MPLS packet
         Receive IP packet
     """
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
             dip = 0xc0a80001
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 # add l2 interface group
-                vlan_id, id, dst_mac[5] = port, port, port
-                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
-                                                            vlan_id, True, False)
+                vlan_id, id, dst_mac[ 5 ] = port, port, port
+                l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
                 # add L3 Unicast  group
-                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
-                                              id=id, src_mac=intf_src_mac,dst_mac=dst_mac)
+                l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
+                        src_mac=intf_src_mac, dst_mac=dst_mac )
                 # add L3 ecmp group
-                ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
+                ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
-                                     vlan_id, goto_table=24)
-                #add_mpls_flow(self.controller, ecmp_msg.group_id, port)
-                add_mpls_flow(self.controller, label=port)
+                add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
+                # add_mpls_flow(self.controller, ecmp_msg.group_id, port)
+                add_mpls_flow( self.controller, label=port )
                 dst_ip = dip + (vlan_id << 8)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
-                                         ecmp_msg.group_id, 1)
-                Groups._put(l2_gid)
-                Groups._put(l3_msg.group_id)
-                Groups._put(ecmp_msg.group_id)
-            do_barrier(self.controller)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, 1 )
+                Groups._put( l2_gid )
+                Groups._put( l3_msg.group_id )
+                Groups._put( ecmp_msg.group_id )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 ip_src = '192.168.%02d.1' % (in_port)
                 for out_port in ports:
@@ -1340,68 +1219,64 @@
                         continue
                     ip_dst = '192.168.%02d.1' % (out_port)
                     label = (out_port, 0, 1, 32)
-                    parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,vlan_vid=(in_port),
-                                             ip_src=ip_src,ip_dst=ip_dst, eth_dst=switch_mac,label=[label])
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_port),
+                            ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expect packet
                     mac_dst = '00:00:00:22:22:%02X' % (out_port)
-                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                vlan_vid=(out_port),
-                                                eth_dst=mac_dst, eth_src=switch_mac,
-                                                ip_ttl=31, ip_src=ip_src,
-                                                ip_dst=ip_dst)
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port),
+                            eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _MplsVpnFwd(base_tests.SimpleDataPlane):
+
+class _MplsVpnFwd( base_tests.SimpleDataPlane ):
     """
         Insert MPLS packet
         Receive IP packet
     """
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
             dip = 0xc0a80001
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 # add l2 interface group
-                vlan_id, id, dst_mac[5] = port, port, port
-                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
-                                                            vlan_id, True, False)
+                vlan_id, id, dst_mac[ 5 ] = port, port, port
+                l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
                 # add L3 Unicast  group
-                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
-                                              id=id, src_mac=intf_src_mac,dst_mac=dst_mac)
+                l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
+                        src_mac=intf_src_mac, dst_mac=dst_mac )
                 # add L3 ecmp group
-                ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
+                ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
-                                     vlan_id, goto_table=24)
-                add_mpls_flow(self.controller, ecmp_msg.group_id, port)
-                #add_mpls_flow(self.controller, label=port)
+                add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
+                add_mpls_flow( self.controller, ecmp_msg.group_id, port )
+                # add_mpls_flow(self.controller, label=port)
                 dst_ip = dip + (vlan_id << 8)
-                #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
+                # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
                 #                         ecmp_msg.group_id, 1)
-                Groups._put(l2_gid)
-                Groups._put(l3_msg.group_id)
-                Groups._put(ecmp_msg.group_id)
-            do_barrier(self.controller)
+                Groups._put( l2_gid )
+                Groups._put( l3_msg.group_id )
+                Groups._put( ecmp_msg.group_id )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 ip_src = '192.168.%02d.1' % (in_port)
                 for out_port in ports:
@@ -1409,67 +1284,59 @@
                         continue
                     ip_dst = '192.168.%02d.1' % (out_port)
                     label = (out_port, 0, 1, 32)
-                    parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,vlan_vid=(in_port),
-                                             ip_src=ip_src,ip_dst=ip_dst, eth_dst=switch_mac,label=[label])
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_port),
+                            ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expect packet
                     mac_dst = '00:00:00:22:22:%02X' % (out_port)
-                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                vlan_vid=(out_port),
-                                                eth_dst=mac_dst, eth_src=switch_mac,
-                                                ip_ttl=31, ip_src=ip_src,
-                                                ip_dst=ip_dst)
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port),
+                            eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _24UcastTagged(base_tests.SimpleDataPlane):
+
+class _24UcastTagged( base_tests.SimpleDataPlane ):
     """
     Verify a IP forwarding works for a /32 rule to L3 Unicast Interface
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
             test_id = 26
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             dip = 0xc0a80001
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 # add l2 interface group
                 vlan_id = port + test_id
-                l2gid, msg = add_one_l2_interface_group(self.controller, port,
-                                                        vlan_id=vlan_id,
-                                                        is_tagged=True,
-                                                        send_barrier=False)
-                dst_mac[5] = vlan_id
-                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
-                                              id=vlan_id, src_mac=intf_src_mac,
-                                              dst_mac=dst_mac)
+                l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
+                        is_tagged=True, send_barrier=False )
+                dst_mac[ 5 ] = vlan_id
+                l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
+                        src_mac=intf_src_mac, dst_mac=dst_mac )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
-                                     vlan_id)
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
                 dst_ip = dip + (vlan_id << 8)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
-                                         0xffffff00, l3_msg.group_id)
-                Groups.put(l2gid)
-                Groups.put(l3_msg.group_id)
-            do_barrier(self.controller)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id )
+                Groups.put( l2gid )
+                Groups.put( l3_msg.group_id )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
                 ip_src = '192.168.%02d.1' % (test_id + in_port)
@@ -1477,74 +1344,64 @@
                     if in_port == out_port:
                         continue
                     ip_dst = '192.168.%02d.1' % (test_id + out_port)
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                   vlan_vid=(test_id + in_port),
-                                                   eth_dst=switch_mac,
-                                                   eth_src=mac_src, ip_ttl=64,
-                                                   ip_src=ip_src,
-                                                   ip_dst=ip_dst)
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
+                            vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
+                            ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expected packet
                     mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
-                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                vlan_vid=(test_id + out_port),
-                                                eth_dst=mac_dst, eth_src=switch_mac,
-                                                ip_ttl=63,
-                                                ip_src=ip_src, ip_dst=ip_dst)
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
+                    exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
+                            vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
+                            ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class _0Ucast(base_tests.SimpleDataPlane):
+
+class _0Ucast( base_tests.SimpleDataPlane ):
     """
     Verify a IP forwarding works for a /0 rule to L3 Unicast Interface
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            if len(config["port_map"]) < 2:
-                logging.info("Port count less than 2, can't run this case")
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
                 return
 
-            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
             dip = 0xc0a80001
-            ports = config["port_map"].keys()
+            ports = config[ "port_map" ].keys( )
             for port in ports:
                 # add l2 interface group
                 vlan_id = port
-                l2gid, msg = add_one_l2_interface_group(self.controller, port,
-                                                        vlan_id=vlan_id+1,
-                                                        is_tagged=True,
-                                                        send_barrier=False)
-                dst_mac[5] = vlan_id
-                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id+1,
-                                              id=vlan_id, src_mac=intf_src_mac,
-                                              dst_mac=dst_mac)
+                l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1,
+                        is_tagged=True, send_barrier=False )
+                dst_mac[ 5 ] = vlan_id
+                l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id,
+                        src_mac=intf_src_mac, dst_mac=dst_mac )
                 # add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id,
-                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
-                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
-                                     vlan_id)
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
                 dst_ip = dip + (vlan_id << 8)
-                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
-                                         0xffffffff, l3_msg.group_id)
-                Groups.put(l2gid)
-                Groups.put(l3_msg.group_id)
-            l3_gid = encode_l3_unicast_group_id(ports[0])
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
+                Groups.put( l2gid )
+                Groups.put( l3_msg.group_id )
+            l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
             dst_ip = 0x0
-            add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, l3_gid)
-            do_barrier(self.controller)
+            add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid )
+            do_barrier( self.controller )
 
-            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
             for in_port in ports:
                 mac_src = '00:00:00:22:22:%02X' % (in_port)
                 ip_src = '192.168.%02d.1' % (in_port)
@@ -1552,143 +1409,135 @@
                     if in_port == out_port:
                         continue
                     ip_dst = '192.168.%02d.1' % (out_port)
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                   vlan_vid=(in_port),
-                                                   eth_dst=switch_mac,
-                                                   eth_src=mac_src, ip_ttl=64,
-                                                   ip_src=ip_src,
-                                                   ip_dst=ip_dst)
-                    pkt = str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
+                            eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
                     # build expected packet
                     mac_dst = '00:00:00:22:22:%02X' % (out_port)
-                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
-                                                vlan_vid=(out_port+1),
-                                                eth_dst=mac_dst, eth_src=switch_mac,
-                                                ip_ttl=63,
-                                                ip_src=ip_src, ip_dst=ip_dst)
-                    pkt = str(exp_pkt)
-                    verify_packet(self, pkt, out_port)
-                    verify_no_other_packets(self)
-                    ip_dst='1.168.%02d.1' % ports[0]
-                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
-                                                   eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst)
-                    pkt=str(parsed_pkt)
-                    self.dataplane.send(in_port, pkt)
-                    #build expect packet
-                    mac_dst='00:00:00:22:22:%02X' % ports[0]
-                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0]+1, ip_ttl=63, ip_src=ip_src,
-                                          ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac)
-                    pkt=str(exp_pkt)
-                    verify_packet(self, pkt, ports[0])
-                    verify_no_other_packets(self)
+                    exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1),
+                            eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, out_port )
+                    verify_no_other_packets( self )
+                    ip_dst = '1.168.%02d.1' % ports[ 0 ]
+                    parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
+                            eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
+                    pkt = str( parsed_pkt )
+                    self.dataplane.send( in_port, pkt )
+                    # build expect packet
+                    mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
+                    exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1,
+                            ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac )
+                    pkt = str( exp_pkt )
+                    verify_packet( self, pkt, ports[ 0 ] )
+                    verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
 
-class Unfiltered(base_tests.SimpleDataPlane):
+
+class Unfiltered( base_tests.SimpleDataPlane ):
     """
     Testing addition of unfiltered groups
     """
 
-    def runTest(self):
+    def runTest( self ):
         try:
-            ports = sorted(config["port_map"].keys())
+            ports = sorted( config[ "port_map" ].keys( ) )
             vlan_id = 1;
             for port in ports:
-                add_l2_unfiltered_group(self.controller, [port], False)
-            do_barrier(self.controller)
+                add_l2_unfiltered_group( self.controller, [ port ], False )
+            do_barrier( self.controller )
         finally:
-            delete_all_flows(self.controller)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_all_groups( self.controller )
 
-class L3McastToVPN(base_tests.SimpleDataPlane):
+
+class L3McastToVPN( base_tests.SimpleDataPlane ):
     """
     Mcast routing
     """
-    def runTest(self):
+
+    def runTest( self ):
         """
         port1 (vlan 1)-> port 2 (vlan 2)
         """
         try:
-            delete_all_flows(self.controller)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_all_groups( self.controller )
 
-            if len(config["port_map"]) <3:
-                logging.info("Port count less than 3, can't run this case")
-                assert(False)
+            if len( config[ "port_map" ] ) < 3:
+                logging.info( "Port count less than 3, can't run this case" )
+                assert (False)
                 return
 
-            vlan_id =1
-            port2_out_vlan=2
-            port3_out_vlan=3
-            in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
-            intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
-            intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
-            dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
-            dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
-            port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
-            port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
-            src_ip=0xc0a80101
-            src_ip_str="192.168.1.1"
-            dst_ip=0xe0010101
-            dst_ip_str="224.1.1.1"
+            vlan_id = 1
+            port2_out_vlan = 2
+            port3_out_vlan = 3
+            in_vlan = 1  # macast group vid shall use input vlan diffe from l3 interface use output vlan
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
+            dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
+            dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
+            port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
+            port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
+            src_ip = 0xc0a80101
+            src_ip_str = "192.168.1.1"
+            dst_ip = 0xe0010101
+            dst_ip_str = "224.1.1.1"
 
-            port1=config["port_map"].keys()[0]
-            port2=config["port_map"].keys()[1]
-            #port3=config["port_map"].keys()[2]
+            port1 = config[ "port_map" ].keys( )[ 0 ]
+            port2 = config[ "port_map" ].keys( )[ 1 ]
+            # port3=config["port_map"].keys()[2]
 
-            #add l2 interface group
-            for port in config["port_map"].keys():
-                add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
-                #add vlan flow table
-                add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
-                vlan_id +=1
+            # add l2 interface group
+            for port in config[ "port_map" ].keys( ):
+                add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False,
+                        send_barrier=False )
+                # add vlan flow table
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                vlan_id += 1
 
-                #add termination flow
-            add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
+                # add termination flow
+            add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
+                    vlan_id )
 
-            #add MPLS interface group
-            l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2)
-            mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2)
-            #l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
-            #mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
-            #add L3VPN groups
-            mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
-                                                                   index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True)
-            #mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
+            # add MPLS interface group
+            l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 )
+            mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
+                    port2_out_vlan, port2 )
+            # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
+            # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
+            # add L3VPN groups
+            mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller,
+                    subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2,
+                    push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True )
+            # mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
             #                                                       index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True)
 
-            mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan,  2, [mpls_label_gid2])
-            add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
+            mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] )
+            add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id )
 
-            parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
-                                           eth_dst=dst_mac_str,
-                                           eth_src=port1_mac_str,
-                                           ip_ttl=64,
-                                           ip_src=src_ip_str,
-                                           ip_dst=dst_ip_str)
-            pkt=str(parsed_pkt)
-            self.dataplane.send(port1, pkt)
+            parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
+                    eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
+            pkt = str( parsed_pkt )
+            self.dataplane.send( port1, pkt )
             label = (12, 0, 1, 63)
-            exp_pkt = mpls_packet(pktlen=100,
-                                  eth_dst=dst_mac_str,
-                                  eth_src=intf_src_mac_str,
-                                  ip_ttl=64,
-                                  ip_src=src_ip_str, label= [label],
-                                  ip_dst=dst_ip_str)
-            pkt=str(exp_pkt)
-            verify_packet(self, pkt, port2)
-            #verify_packet(self, pkt, port3)
-            verify_no_other_packets(self)
-            delete_all_groups(self.controller)
+            exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64,
+                    ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str )
+            pkt = str( exp_pkt )
+            verify_packet( self, pkt, port2 )
+            # verify_packet(self, pkt, port3)
+            verify_no_other_packets( self )
+            delete_all_groups( self.controller )
         finally:
-            delete_all_flows(self.controller)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_all_groups( self.controller )
 
 
-class PacketInSrcMacMiss(base_tests.SimpleDataPlane):
+class PacketInSrcMacMiss( base_tests.SimpleDataPlane ):
     """
     Test packet in function on a src-mac miss
     Send a packet to each dataplane port and verify that a packet
@@ -1696,24 +1545,123 @@
     #todo verify you stop receiving after adding rule
     """
 
-    def runTest(self):
-        Groups = Queue.LifoQueue()
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
         try:
-            ports = sorted(config["port_map"].keys())
+            ports = sorted( config[ "port_map" ].keys( ) )
 
-            Groups = Queue.LifoQueue()
+            Groups = Queue.LifoQueue( )
             for port in ports:
-                L2gid, l2msg = add_one_l2_interface_group(self.controller, port, 1, True, False)
-                add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
-                Groups.put(L2gid)
-            parsed_vlan_pkt = simple_tcp_packet(pktlen=104,
-                                                vlan_vid=0x1001, dl_vlan_enable=True)
-            vlan_pkt = str(parsed_vlan_pkt)
-            for of_port in config["port_map"].keys():
-                logging.info("PacketInMiss test, port %d", of_port)
-                self.dataplane.send(of_port, vlan_pkt)
-                verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH)
-                verify_no_other_packets(self)
+                L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False )
+                add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                Groups.put( L2gid )
+            parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
+            vlan_pkt = str( parsed_vlan_pkt )
+            for of_port in config[ "port_map" ].keys( ):
+                logging.info( "PacketInMiss test, port %d", of_port )
+                self.dataplane.send( of_port, vlan_pkt )
+                verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH )
+                verify_no_other_packets( self )
         finally:
-            delete_all_flows(self.controller)
-            delete_all_groups(self.controller)
+            delete_all_flows( self.controller )
+            delete_all_groups( self.controller )
+
+
+class EcmpGroupMod( base_tests.SimpleDataPlane ):
+    """
+        Insert IP packet
+        Receive IP packet
+    """
+
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
+        try:
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
+                return
+
+            intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+            dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
+            dip = 0xc0a80001
+            # Hashes Test Name and uses it as id for installing unique groups
+            ports = config[ "port_map" ].keys( )
+            ecmp=[]
+            for port in ports:
+                vlan_id = port
+                id = port
+                # add l2 interface group
+                l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
+                        is_tagged=True, send_barrier=False )
+                dst_mac[ 5 ] = vlan_id
+                l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
+                        src_mac=intf_src_mac, dst_mac=dst_mac )
+                ecmp +=[l3_msg.group_id]
+                Groups._put( l2_gid )
+                Groups._put( l3_msg.group_id )
+                ecmp_msg = add_l3_ecmp_group( self.controller, ports[0], [l3_msg.group_id])
+                #ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
+                # add vlan flow table
+                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                # add termination flow
+                add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
+                # add unicast routing flow
+                dst_ip = dip + (vlan_id << 8)
+                add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
+                Groups._put( ecmp_msg.group_id )
+            mod_l3_ecmp_group( self.controller, ports[0], ecmp)
+
+            switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
+            parsed_pkt=exp_pkt=0
+            for out_port in ports:
+                mac_src = '00:00:00:22:22:%02X' % ports[0]
+                ip_src = '192.168.%02d.%02d' % (ports[0], 1)
+                ip_dst = '192.168.%02d.%02d' % ( ports[1], 1)
+                tcp= out_port if out_port==24 else 25
+                parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0],
+                    eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst, 
+                      tcp_dport=tcp)
+                pkt = str( parsed_pkt )
+                self.dataplane.send( ports[0], pkt )
+                # build expected packet
+                mac_dst = '00:00:00:22:22:%02X' % out_port
+                exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
+                    eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, tcp_dport=tcp )
+                pkt = str( exp_pkt )
+                verify_packet( self, pkt, out_port )
+                verify_no_other_packets( self )
+            l3_gid = encode_l3_unicast_group_id(ports[0])
+            mod_l3_ecmp_group( self.controller, ports[0], [l3_gid])
+            for port in ports:
+                mac_src = '00:00:00:22:22:%02X' % ports[0]
+                ip_src = '192.168.%02d.%02d' % ( ports[0], 1 )
+                ip_dst = '192.168.%02d.%02d' % ( ports[1], 1 )
+                tcp= port if port==24 else 25
+                parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0],
+                    eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst,
+                      tcp_dport=tcp)
+                pkt = str( parsed_pkt )
+                self.dataplane.send( ports[0], pkt )
+                # build expected packet
+                mac_dst = '00:00:00:22:22:%02X' % ports[0]
+                exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0],
+                    eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, tcp_dport=tcp )
+                pkt = str( exp_pkt )
+                verify_packet( self, pkt, ports[0] )
+                verify_no_other_packets( self )
+            mod_l3_ecmp_group( self.controller, ports[0], [] )
+            for port in ports:
+                mac_src = '00:00:00:22:22:%02X' % ports[0]
+                ip_src = '192.168.%02d.%02d' % ( ports[0], 1 )
+                ip_dst = '192.168.%02d.%02d' % ( ports[1], 1 )
+                tcp= port if port==24 else 25
+                parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0],
+                    eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst,
+                      tcp_dport=tcp)
+                pkt = str( parsed_pkt )
+                self.dataplane.send( ports[0], pkt )
+                verify_no_other_packets( self )
+        finally:
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
+
