diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java index 8a0563578286a9c5fabf1b283b10932423c1463d..6877c74c107b2184b5c1737d058094cbb7702596 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java +++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java @@ -174,6 +174,7 @@ public class Controller protected OFMessageFilterManager messageFilterManager; protected PktinProcessingTime pktinProcTime; private StaticFlowEntryPusher staticFlowEntryPusher; + protected long ptWarningThresholdInNano; protected List<RestletRoutable> restlets; @@ -735,6 +736,8 @@ public class Controller FloodlightContext bContext) throws IOException { Ethernet eth = null; + + long startTime = System.nanoTime(); switch (m.getType()) { case PACKET_IN: @@ -808,6 +811,13 @@ public class Controller } else { log.error("Unhandled OF Message: {} from {}", m, sw); } + + long processingTime = System.nanoTime() - startTime; + if (ptWarningThresholdInNano > 0 && processingTime > ptWarningThresholdInNano) { + log.warn("Time to process packet-in: {} us", processingTime/1000.0); + if (eth != null) + log.warn("{}", messageFilterManager.getDataAsString(sw, m, bContext)); + } } } @@ -1431,6 +1441,13 @@ public class Controller restlets.add(new StorageWebRoutable()); restlets.add(new TopologyWebRouteable()); JacksonCustomConverter.replaceConverter(); + + // Processing Time Warning Threshold + ptWarningThresholdInNano = Long.parseLong(System.getProperty("net.floodlightcontroller.core.PTWarningThresholdInMilli", "0")) * 1000000; + if (ptWarningThresholdInNano > 0) { + log.info("Packet processing time threshold for warning set to {} ms.", + ptWarningThresholdInNano/1000000); + } } protected void initStorageSource() {