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 {
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();
}
}
......
......@@ -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";
......
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