From 8f9fea7a6e381ae5d66676fac6393a950926a91f Mon Sep 17 00:00:00 2001 From: Srinivasan Ramasubramanian <srini@bigswitch.com> Date: Thu, 19 Jan 2012 16:56:18 -0800 Subject: [PATCH] Print warning messages when packet-in processing time exceeds a certain threshold. --- .../core/internal/Controller.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java index 8a0563578..6877c74c1 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() { -- GitLab