adding meter tests
diff --git a/olt-topo.py b/olt-topo.py
deleted file mode 100755
index 438a59f..0000000
--- a/olt-topo.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/python
-
-from mininet.topo import Topo
-from mininet.node import RemoteController
-from mininet.net import Mininet
-from mininet.util import irange
-from mininet.cli import CLI
-from mininet.log import setLogLevel
-
-class OltTopo( Topo ):
-    "Single switch with OLT port 129 and configurable number of ONU ports"
-
-    def build( self, k=1, **_opts ):
-        "k: number of onu"
-        self.k = k
-        switch = self.addSwitch( 's1' )
-        for h in irange( 1, k ):
-            host = self.addHost( 'h%s' % h, inNamespace=False )
-            self.addLink( host, switch )
-
-        olt_port = self.addHost( 'h129', inNamespace=False )
-        self.addLink( olt_port, switch, port2=129 )
-
-if __name__ == '__main__':
-    setLogLevel('debug')
-    topo = OltTopo()
-
-    net = Mininet( topo=topo, controller=RemoteController )
-
-    net.start()
-
-    CLI( net )
-
-    net.stop()
diff --git a/olt.py b/olt.py
index 95a51f6..0db8111 100644
--- a/olt.py
+++ b/olt.py
@@ -7,6 +7,7 @@
 import oftest.packet as scapy
 
 import ofp
+import time
 
 from oftest.testutils import *
 
@@ -14,6 +15,7 @@
 olt_port = test_param_get("olt_port", 129)
 
 def testPacketIn(self, match, parsed_pkt):
+
     delete_all_flows(self.controller)
 
     pkt = str(parsed_pkt)
@@ -34,8 +36,8 @@
     logging.info("Inserting flow sending matching packets to controller")
     self.controller.message_send(request)
     do_barrier(self.controller)
-
-    for of_port in config["port_map"].keys():
+	
+    for of_port in config["port_map"]:
         logging.info("PacketInExact test, port %d", of_port)
         self.dataplane.send(of_port, pkt)
         verify_packet_in(self, pkt, of_port, ofp.OFPR_ACTION)
@@ -70,30 +72,6 @@
         
         testPacketIn(self, match, pkt)
         
-class RadiusPacketIn(base_tests.SimpleDataPlane):
-    
-    """Verify packet-ins are sent for Radius packets """
-    
-    def runTest(self):
-        logging.info("Running Radius Packet In test")
-
-        pkt = simple_udp_packet(udp_sport=1812, udp_dport=1812)
-        
-        match = ofp.match()
-        match.oxm_list.append(ofp.oxm.eth_type(0x0800))
-        match.oxm_list.append(ofp.oxm.ip_proto(17))
-        match.oxm_list.append(ofp.oxm.udp_src(1812))
-        match.oxm_list.append(ofp.oxm.udp_dst(1812))
-        
-        testPacketIn(self, match, pkt)
-        
-        # Other UDP packets should not match the rule
-        dhcpPkt = simple_udp_packet(udp_sport=68, udp_dport=67)
-        
-        self.dataplane.send(1, str(dhcpPkt))
-        verify_no_packet_in(self, dhcpPkt, 1)
-        
-        
 class DHCPPacketIn(base_tests.SimpleDataPlane):
     
     """Verify packet-ins are sent for DHCP packets """
@@ -134,10 +112,63 @@
         pkt = pkt/("0" * (100 - len(pkt)))
         
         testPacketIn(self, match, pkt)
-        
-class PushVlan(base_tests.SimpleDataPlane):
+
+class TestMeter(base_tests.SimpleDataPlane):
+       
+    def runTest(self):
+        logging.info("Running Meter tests")
+        dropMeterBand = ofp.meter_band.drop(rate = 500)
+        meter_mod = ofp.message.meter_mod(xid = 1, command = ofp.OFPMC_ADD, meter_id = 1, meters = [ dropMeterBand ])
+        self.controller.message_send(meter_mod)
     
-    """Verify the switch can push a VLAN tag and forward out a port """
+        time.sleep(1)
+
+        verify_no_errors(self.controller)
+
+        match = ofp.match()
+        match.oxm_list.append(ofp.oxm.in_port(onu_port))
+        match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | 201))
+
+        request = ofp.message.flow_add(
+            table_id=test_param_get("table", 0),
+            cookie=43,
+            match=match,
+            instructions=[
+                ofp.instruction.apply_actions(
+                    actions=[
+                        ofp.action.output(port=olt_port)]),
+                    ofp.instruction.meter(meter_id = 1)    
+                ],
+            buffer_id=ofp.OFP_NO_BUFFER,
+            priority=1000)
+
+        self.controller.message_send(request)
+        
+        time.sleep(1)
+
+        verify_no_errors(self.controller)
+        
+class TestDuplicateMeter(base_tests.SimpleDataPlane):
+
+    def runTest(self):
+        logging.info("Running Duplicate Meter Test")
+        dropMeterBand = ofp.meter_band.drop(rate = 500)
+        meter_mod = ofp.message.meter_mod(xid = 1, command = ofp.OFPMC_ADD, meter_id = 1, meters = [ dropMeterBand ])
+        self.controller.message_send(meter_mod)
+        self.controller.message_send(meter_mod)
+
+        time.sleep(1)
+    
+        try:
+            verify_no_errors(self.controller)
+        except AssertionError as e:
+            if (not e.message is "unexpected error type=12 code=1"):
+                raise AssertionError("Incorrect error type: %s" % e.message)
+            
+ 
+class VlanTest(base_tests.SimpleDataPlane):
+    
+    """Verify the switch can push/pop a VLAN tag and forward out a port """
     
     def runTest(self):
         logging.info("Running push VLAN test")
@@ -145,10 +176,12 @@
         vlan_id = 200
         
         delete_all_flows(self.controller)
-        
+       
+        #PUSH
         match = ofp.match()
         match.oxm_list.append(ofp.oxm.in_port(onu_port))
-        match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFP_VLAN_NONE))
+        match.oxm_list.append(ofp.oxm.vlan_vid_masked(value=ofp.OFPVID_PRESENT, value_mask=ofp.OFPVID_PRESENT))
+        match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
         
         request = ofp.message.flow_add(
             table_id=test_param_get("table", 0),
@@ -159,44 +192,22 @@
                     actions=[
                         ofp.action.push_vlan(ethertype=0x8100),
                         ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
+                        ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
                         ofp.action.output(port=olt_port)])],
             buffer_id=ofp.OFP_NO_BUFFER,
             priority=1000)
 
-        logging.info("Inserting flow sending matching packets to controller")
+        logging.info("Inserting flow tagging upstream")
         self.controller.message_send(request)
-        do_barrier(self.controller)
-        
-        inPkt = simple_udp_packet()
-        outPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, 
-                                   vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
-        
-        # Send untagged packet in the ONU port and expect tagged packet out the OLT port
-        self.dataplane.send(onu_port, str(inPkt))
-        verify_packet(self, outPkt, olt_port)
-        
-        # Send untagged packet in the OLT port and expect no packets to come out
-        self.dataplane.send(olt_port, str(inPkt))
-        verify_packets(self, outPkt, [])
-        
-class PopVlan(base_tests.SimpleDataPlane):
-    
-    """Verify the switch can pop a VLAN tag and forward out a port """
-    
-    def runTest(self):
-        logging.info("Running pop VLAN test")
-        
-        vlan_id = 200
-        
-        delete_all_flows(self.controller)
-        
+
+   	    #POP
         match = ofp.match()
         match.oxm_list.append(ofp.oxm.in_port(olt_port))
         match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
-        
+
         request = ofp.message.flow_add(
             table_id=test_param_get("table", 0),
-            cookie=42,
+            cookie=43,
             match=match,
             instructions=[
                 ofp.instruction.apply_actions(
@@ -206,18 +217,32 @@
             buffer_id=ofp.OFP_NO_BUFFER,
             priority=1000)
 
-        logging.info("Inserting flow sending matching packets to controller")
+        logging.info("Inserting flow tagging downstream")
         self.controller.message_send(request)
         do_barrier(self.controller)
+        time.sleep(5)
         
-        inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, 
+        inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
+        outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, 
+                                   vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
+        
+        # Send untagged packet in the ONU port and expect tagged packet out the OLT port
+        self.dataplane.send(onu_port, str(inPkt))
+        verify_packet(self, outPkt, olt_port)
+        
+        # Send untagged packet in the OLT port and expect no packets to come out
+        self.dataplane.send(olt_port, str(inPkt))
+        verify_packets(self, outPkt, [])
+
+        inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
                                   vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
-        outPkt = simple_udp_packet()
-        
+        outPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
+
         # Send tagged packet in the OLT port and expect untagged packet out the OLT port
         self.dataplane.send(olt_port, str(inPkt))
         verify_packet(self, outPkt, onu_port)
-        
+
         # Send tagged packet in the ONU port and expect no packets to come out
         self.dataplane.send(onu_port, str(inPkt))
-        verify_packets(self, outPkt, [])
\ No newline at end of file
+        verify_packets(self, outPkt, [])
+