From 4abce32a130da4a4c96bf3d1ae320d4a3fa19adb Mon Sep 17 00:00:00 2001 From: Kanzhe Jiang <kanzhe.jiang@bigswitch.com> Date: Wed, 29 Feb 2012 14:19:23 -0800 Subject: [PATCH] add stats for broadcast, multicast --- .../counter/CounterStore.java | 69 ++++++++++++++++--- .../counter/ICounterStoreService.java | 6 ++ 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/counter/CounterStore.java b/src/main/java/net/floodlightcontroller/counter/CounterStore.java index 041130459..6f497e768 100644 --- a/src/main/java/net/floodlightcontroller/counter/CounterStore.java +++ b/src/main/java/net/floodlightcontroller/counter/CounterStore.java @@ -49,7 +49,7 @@ public class CounterStore implements ICounterStoreService { protected static Logger log = LoggerFactory.getLogger(CounterStore.class); public enum NetworkLayer { - L3, L4 + L2, L3, L4 } protected class CounterEntry { @@ -111,8 +111,34 @@ public class CounterStore implements ICounterStoreService { packetName, etherType, NetworkLayer.L3); + + String l2Type = null; + if (eth.isBroadcast()) { + l2Type = BROADCAST; + } else if (eth.isMulticast()) { + l2Type = MULTICAST; + } else { + l2Type = UNICAST; + } + + // Construct both port and switch L3 counter for the packet_in + String controllerL2CategoryCounterName = CounterStore.createCounterName(CONTROLLER_NAME, + -1, + packetName, + l2Type, + NetworkLayer.L2); + String switchL2CategoryCounterName = CounterStore.createCounterName(switchIdHex, + -1, + packetName, + l2Type, + NetworkLayer.L2); + String portL2CategoryCounterName = CounterStore.createCounterName(switchIdHex, + packet.getInPort(), + packetName, + l2Type, + NetworkLayer.L2); - // Construct both port and switch counter for the packet_in + // Construct both port and switch L3 counter for the packet_in String portCounterName = CounterStore.createCounterName(switchIdHex, packet.getInPort(), @@ -135,45 +161,68 @@ public class CounterStore implements ICounterStoreService { etherType, NetworkLayer.L3); - try { + try { + // Controller counters ICounter controllerCounter = getCounter(controllerCounterName); if (controllerCounter == null) { controllerCounter = createCounter(controllerCounterName, CounterType.LONG); } + controllerCounter.increment(); ICounter portCounter = getCounter(portCounterName); if (portCounter == null) { portCounter = createCounter(portCounterName, CounterType.LONG); } + portCounter.increment(); ICounter switchCounter = getCounter(switchCounterName); if (switchCounter == null) { switchCounter = createCounter(switchCounterName, CounterType.LONG); } + switchCounter.increment(); + // L2 counters + ICounter controllerL2Counter = getCounter(controllerL2CategoryCounterName); + if (controllerL2Counter == null) { + controllerL2Counter = createCounter(controllerL2CategoryCounterName, + CounterType.LONG); + } + controllerL2Counter.increment(); + ICounter switchL2Counter = getCounter(switchL2CategoryCounterName); + if (switchL2Counter == null) { + switchL2Counter = createCounter(switchL2CategoryCounterName, + CounterType.LONG); + } + switchL2Counter.increment(); + ICounter portL2Counter = getCounter(portL2CategoryCounterName); + if (portL2Counter == null) { + portL2Counter = createCounter(portL2CategoryCounterName, + CounterType.LONG); + } + portL2Counter.increment(); + + // L3 counters ICounter controllerL3Counter = getCounter(controllerL3CategoryCounterName); if (controllerL3Counter == null) { controllerL3Counter = createCounter(controllerL3CategoryCounterName, CounterType.LONG); } + controllerL3Counter.increment(); ICounter portL3Counter = getCounter(portL3CategoryCounterName); if (portL3Counter == null) { portL3Counter = createCounter(portL3CategoryCounterName, CounterType.LONG); } + portL3Counter.increment(); ICounter switchL3Counter = getCounter(switchL3CategoryCounterName); if (switchL3Counter == null) { switchL3Counter = createCounter(switchL3CategoryCounterName, CounterType.LONG); } - controllerCounter.increment(); - portCounter.increment(); - switchCounter.increment(); - controllerL3Counter.increment(); - portL3Counter.increment(); switchL3Counter.increment(); + // L4 counters if (etherType.compareTo(CounterStore.L3ET_IPV4) == 0) { IPv4 ipV4 = (IPv4)eth.getPayload(); String l4Type = String.format("%02x", ipV4.getProtocol()); @@ -206,18 +255,18 @@ public class CounterStore implements ICounterStoreService { controllerL4Counter = createCounter(controllerL4CategoryCounterName, CounterType.LONG); } + controllerL4Counter.increment(); ICounter portL4Counter = getCounter(portL4CategoryCounterName); if (portL4Counter == null) { portL4Counter = createCounter(portL4CategoryCounterName, CounterType.LONG); } + portL4Counter.increment(); ICounter switchL4Counter = getCounter(switchL4CategoryCounterName); if (switchL4Counter == null) { switchL4Counter = createCounter(switchL4CategoryCounterName, CounterType.LONG); } - controllerL4Counter.increment(); - portL4Counter.increment(); switchL4Counter.increment(); } } diff --git a/src/main/java/net/floodlightcontroller/counter/ICounterStoreService.java b/src/main/java/net/floodlightcontroller/counter/ICounterStoreService.java index b3cce75da..c89eee003 100644 --- a/src/main/java/net/floodlightcontroller/counter/ICounterStoreService.java +++ b/src/main/java/net/floodlightcontroller/counter/ICounterStoreService.java @@ -14,6 +14,12 @@ public interface ICounterStoreService extends IFloodlightService { public final static String CONTROLLER_NAME = "controller"; public final static String TitleDelimitor = "__"; + + /** Broadcast and multicast */ + public final static String BROADCAST = "broadcast"; + public final static String MULTICAST = "multicast"; + public final static String UNICAST = "unicast"; + /** L2 EtherType subCategories */ public final static String L3ET_IPV4 = "L3_IPv4"; -- GitLab