Stats Improvement
diff --git a/src/main/java/net/floodlightcontroller/core/IOF13Switch.java b/src/main/java/net/floodlightcontroller/core/IOF13Switch.java
index 6cb5b15..53f90f3 100644
--- a/src/main/java/net/floodlightcontroller/core/IOF13Switch.java
+++ b/src/main/java/net/floodlightcontroller/core/IOF13Switch.java
@@ -5,6 +5,8 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import org.projectfloodlight.openflow.types.TableId;
+
 import net.onrc.onos.core.matchaction.MatchActionOperationEntry;
 import net.onrc.onos.core.util.Dpid;
 import net.onrc.onos.core.util.PortNumber;
@@ -131,5 +133,12 @@
     public void removePortFromGroups(PortNumber port);
 
     public void addPortToGroups(PortNumber port);
+    /**
+     * give string tableType (ip, mpls, acl)
+     * @param tableType  String equal to only one of (ip, mpls, acl)
+     * @return TableId 
+     */
+    
+    public TableId getTableId(String tableType);
 
 }
diff --git a/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java b/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java
index 74cccfb..8608b20 100644
--- a/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java
+++ b/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java
@@ -43,6 +43,7 @@
         router.attach("/switch/{switchId}/role/json", SwitchRoleResource.class);
         router.attach("/switch/all/{statType}/json", AllSwitchStatisticsResource.class);
         router.attach("/switch/{switchId}/{statType}/json", SwitchStatisticsResource.class);
+        router.attach("/switch/{switchId}/table/{tableType}/{statType}/json", SwitchStatisticsResource.class);
         router.attach("/controller/switches/json", ControllerSwitchesResource.class);
         router.attach("/memory/json", ControllerMemoryResource.class);
         router.attach("/health/json", HealthCheckResource.class);
diff --git a/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java b/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
index 8e4208c..e6abf2d 100644
--- a/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
+++ b/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
@@ -25,6 +25,7 @@
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IOFSwitch;
 import net.floodlightcontroller.core.annotations.LogMessageDoc;
+import net.onrc.onos.core.drivermanager.OFSwitchImplCPqD13;
 
 import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
 import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry;
@@ -102,7 +103,6 @@
                 try {
                     future = sw.getStatistics(req);
                     values = future.get(10, TimeUnit.SECONDS);
-                    System.out.println("value\n\n\n"+ values);
                     for (OFFlowStatsEntry entry : ((OFFlowStatsReply)values.get(0)).getEntries()) {
                         OFFlowStatsEntryMod entryMod = new OFFlowStatsEntryMod(entry);
                         flowStats.add(entryMod);
@@ -212,6 +212,54 @@
     protected Object getSwitchStatistics(String switchId, OFStatsType statType) {
         return getSwitchStatistics(HexString.toLong(switchId), statType);
     }
+    //TODO: Java doc
+    protected List<?> getSwitchStatisticsForTable(long switchId,
+            OFStatsType statType, String tableType) {
+        IFloodlightProviderService floodlightProvider =
+                (IFloodlightProviderService) getContext().getAttributes().
+                get(IFloodlightProviderService.class.getCanonicalName());
+        IOFSwitch sw = floodlightProvider.getSwitches().get(switchId);
+        Future<List<OFStatsReply>> future;
+        List<OFStatsReply> values = null;
+        //getting tableId from CPqD driver
+        TableId tableId;
+        if (sw != null) {
+            if((tableId = ((OFSwitchImplCPqD13) sw).getTableId(tableType)) == null){
+                log.error("Invalid tableType {} " + tableType);
+                return null;
+            }
+            OFStatsRequest<?> req = null;
+            if (statType == OFStatsType.FLOW) {
+                log.debug("Switch Flow Stats req for table {} sent to switch {}",
+                        tableType,sw.getStringId());
+                OFMatchV3 match = sw.getFactory().buildMatchV3()
+                        .setOxmList(OFOxmList.EMPTY).build();
+                req = sw.getFactory()
+                        .buildFlowStatsRequest()
+                        .setMatch(match)
+                        .setOutPort(OFPort.ANY)
+                        .setTableId(tableId)
+                        .setXid(sw.getNextTransactionId()).build();
+                List<OFFlowStatsEntryMod> flowStats = new ArrayList<OFFlowStatsEntryMod>();
+                try {
+                    future = sw.getStatistics(req);
+                    values = future.get(10, TimeUnit.SECONDS);
+                    for (OFFlowStatsEntry entry : ((OFFlowStatsReply)values.get(0)).getEntries()) {
+                        OFFlowStatsEntryMod entryMod = new OFFlowStatsEntryMod(entry);
+                        flowStats.add(entryMod);
+                    }
+                    log.debug("Switch flow Stats Entries for table {} from switch {} are {}",
+                            tableType, sw.getStringId(), flowStats);
+                } catch (Exception e) {
+                    log.error("Failure retrieving per table statistics from switch " + sw, e);
+                }
+                return flowStats;
+            } 
+        }
+        //should never get to this point
+        log.error("Failure retrieving  {} table statistics from switch {}",tableType, sw);
+        return null;
+    }
 
     protected OFFeaturesReply getSwitchFeaturesReply(long switchId) {
         IFloodlightProviderService floodlightProvider =
diff --git a/src/main/java/net/floodlightcontroller/core/web/SwitchStatisticsResource.java b/src/main/java/net/floodlightcontroller/core/web/SwitchStatisticsResource.java
index 4f45463..ce2221e 100644
--- a/src/main/java/net/floodlightcontroller/core/web/SwitchStatisticsResource.java
+++ b/src/main/java/net/floodlightcontroller/core/web/SwitchStatisticsResource.java
@@ -20,6 +20,7 @@
 import java.util.HashMap;
 
 import org.projectfloodlight.openflow.protocol.OFStatsType;
+import org.projectfloodlight.openflow.util.HexString;
 import org.restlet.resource.Get;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,14 +42,24 @@
 
         String switchId = (String) getRequestAttributes().get("switchId");
         String statType = (String) getRequestAttributes().get("statType");
+        String tableType = null;
+        if(getRequestAttributes().containsKey("tableType")){
+            tableType = (String) getRequestAttributes().get("tableType");
+        }
 
         if (statType.equals("port")) {
             values = getSwitchStatistics(switchId, OFStatsType.PORT);
         } else if (statType.equals("queue")) {
             values = getSwitchStatistics(switchId, OFStatsType.QUEUE);
         } else if (statType.equals("flow")) {
-            values = getSwitchStatistics(switchId, OFStatsType.FLOW);
-        } else if (statType.equals("aggregate")) {
+            if (tableType != null){
+                values = getSwitchStatisticsForTable(HexString.toLong(switchId), OFStatsType.FLOW, tableType);
+            }
+            else{
+                values = getSwitchStatistics(switchId, OFStatsType.FLOW);
+            }
+        }
+        else if (statType.equals("aggregate")) {
             values = getSwitchStatistics(switchId, OFStatsType.AGGREGATE);
         } else if (statType.equals("desc")) {
             values = getSwitchStatistics(switchId, OFStatsType.DESC);
diff --git a/src/main/java/net/floodlightcontroller/core/web/serializers/OFFlowStatsEntryModSerializer.java b/src/main/java/net/floodlightcontroller/core/web/serializers/OFFlowStatsEntryModSerializer.java
index e04487d..4f71dc9 100644
--- a/src/main/java/net/floodlightcontroller/core/web/serializers/OFFlowStatsEntryModSerializer.java
+++ b/src/main/java/net/floodlightcontroller/core/web/serializers/OFFlowStatsEntryModSerializer.java
@@ -8,6 +8,7 @@
 import net.floodlightcontroller.core.web.OFFlowStatsEntryMod;
 
 import org.projectfloodlight.openflow.protocol.action.*;
+import org.apache.commons.codec.binary.Hex;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.JsonGenerator;
 import org.codehaus.jackson.map.SerializerProvider;
@@ -73,7 +74,7 @@
                 jGen.writeStringField("dataLayerSource", matchGeneric.getValue().toString());
             }
             else if (matchGeneric.getMatchField().id == MatchFields.ETH_TYPE){
-                jGen.writeStringField("dataLayerType", "0x"+matchGeneric.getValue().toString());
+                jGen.writeNumberField("dataLayerType", Integer.decode("0x"+matchGeneric.getValue().toString()));
             }
             else if (matchGeneric.getMatchField().id == MatchFields.IN_PORT){
                 jGen.writeNumberField("inputPort", Integer.parseInt(matchGeneric.getValue().toString()));