Skip to content
Snippets Groups Projects
Commit 4abce32a authored by Kanzhe Jiang's avatar Kanzhe Jiang
Browse files

add stats for broadcast, multicast

parent 38e91934
No related branches found
No related tags found
No related merge requests found
...@@ -49,7 +49,7 @@ public class CounterStore implements ICounterStoreService { ...@@ -49,7 +49,7 @@ public class CounterStore implements ICounterStoreService {
protected static Logger log = LoggerFactory.getLogger(CounterStore.class); protected static Logger log = LoggerFactory.getLogger(CounterStore.class);
public enum NetworkLayer { public enum NetworkLayer {
L3, L4 L2, L3, L4
} }
protected class CounterEntry { protected class CounterEntry {
...@@ -111,8 +111,34 @@ public class CounterStore implements ICounterStoreService { ...@@ -111,8 +111,34 @@ public class CounterStore implements ICounterStoreService {
packetName, packetName,
etherType, etherType,
NetworkLayer.L3); 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 = String portCounterName =
CounterStore.createCounterName(switchIdHex, CounterStore.createCounterName(switchIdHex,
packet.getInPort(), packet.getInPort(),
...@@ -135,45 +161,68 @@ public class CounterStore implements ICounterStoreService { ...@@ -135,45 +161,68 @@ public class CounterStore implements ICounterStoreService {
etherType, etherType,
NetworkLayer.L3); NetworkLayer.L3);
try { try {
// Controller counters
ICounter controllerCounter = getCounter(controllerCounterName); ICounter controllerCounter = getCounter(controllerCounterName);
if (controllerCounter == null) { if (controllerCounter == null) {
controllerCounter = createCounter(controllerCounterName, controllerCounter = createCounter(controllerCounterName,
CounterType.LONG); CounterType.LONG);
} }
controllerCounter.increment();
ICounter portCounter = getCounter(portCounterName); ICounter portCounter = getCounter(portCounterName);
if (portCounter == null) { if (portCounter == null) {
portCounter = createCounter(portCounterName, portCounter = createCounter(portCounterName,
CounterType.LONG); CounterType.LONG);
} }
portCounter.increment();
ICounter switchCounter = getCounter(switchCounterName); ICounter switchCounter = getCounter(switchCounterName);
if (switchCounter == null) { if (switchCounter == null) {
switchCounter = createCounter(switchCounterName, switchCounter = createCounter(switchCounterName,
CounterType.LONG); 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); ICounter controllerL3Counter = getCounter(controllerL3CategoryCounterName);
if (controllerL3Counter == null) { if (controllerL3Counter == null) {
controllerL3Counter = createCounter(controllerL3CategoryCounterName, controllerL3Counter = createCounter(controllerL3CategoryCounterName,
CounterType.LONG); CounterType.LONG);
} }
controllerL3Counter.increment();
ICounter portL3Counter = getCounter(portL3CategoryCounterName); ICounter portL3Counter = getCounter(portL3CategoryCounterName);
if (portL3Counter == null) { if (portL3Counter == null) {
portL3Counter = createCounter(portL3CategoryCounterName, portL3Counter = createCounter(portL3CategoryCounterName,
CounterType.LONG); CounterType.LONG);
} }
portL3Counter.increment();
ICounter switchL3Counter = getCounter(switchL3CategoryCounterName); ICounter switchL3Counter = getCounter(switchL3CategoryCounterName);
if (switchL3Counter == null) { if (switchL3Counter == null) {
switchL3Counter = createCounter(switchL3CategoryCounterName, switchL3Counter = createCounter(switchL3CategoryCounterName,
CounterType.LONG); CounterType.LONG);
} }
controllerCounter.increment();
portCounter.increment();
switchCounter.increment();
controllerL3Counter.increment();
portL3Counter.increment();
switchL3Counter.increment(); switchL3Counter.increment();
// L4 counters
if (etherType.compareTo(CounterStore.L3ET_IPV4) == 0) { if (etherType.compareTo(CounterStore.L3ET_IPV4) == 0) {
IPv4 ipV4 = (IPv4)eth.getPayload(); IPv4 ipV4 = (IPv4)eth.getPayload();
String l4Type = String.format("%02x", ipV4.getProtocol()); String l4Type = String.format("%02x", ipV4.getProtocol());
...@@ -206,18 +255,18 @@ public class CounterStore implements ICounterStoreService { ...@@ -206,18 +255,18 @@ public class CounterStore implements ICounterStoreService {
controllerL4Counter = createCounter(controllerL4CategoryCounterName, controllerL4Counter = createCounter(controllerL4CategoryCounterName,
CounterType.LONG); CounterType.LONG);
} }
controllerL4Counter.increment();
ICounter portL4Counter = getCounter(portL4CategoryCounterName); ICounter portL4Counter = getCounter(portL4CategoryCounterName);
if (portL4Counter == null) { if (portL4Counter == null) {
portL4Counter = createCounter(portL4CategoryCounterName, portL4Counter = createCounter(portL4CategoryCounterName,
CounterType.LONG); CounterType.LONG);
} }
portL4Counter.increment();
ICounter switchL4Counter = getCounter(switchL4CategoryCounterName); ICounter switchL4Counter = getCounter(switchL4CategoryCounterName);
if (switchL4Counter == null) { if (switchL4Counter == null) {
switchL4Counter = createCounter(switchL4CategoryCounterName, switchL4Counter = createCounter(switchL4CategoryCounterName,
CounterType.LONG); CounterType.LONG);
} }
controllerL4Counter.increment();
portL4Counter.increment();
switchL4Counter.increment(); switchL4Counter.increment();
} }
} }
......
...@@ -14,6 +14,12 @@ public interface ICounterStoreService extends IFloodlightService { ...@@ -14,6 +14,12 @@ public interface ICounterStoreService extends IFloodlightService {
public final static String CONTROLLER_NAME = "controller"; public final static String CONTROLLER_NAME = "controller";
public final static String TitleDelimitor = "__"; 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 */ /** L2 EtherType subCategories */
public final static String L3ET_IPV4 = "L3_IPv4"; public final static String L3ET_IPV4 = "L3_IPv4";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment