From 257e1ee70be3d57f898ddcd27660ddf56900e0a8 Mon Sep 17 00:00:00 2001 From: Shudong Zhou <shudongzhou@gmail.com> Date: Tue, 23 Apr 2013 07:21:57 -0700 Subject: [PATCH] Do not flood packets on a switch in overload --- .../java/net/floodlightcontroller/core/IOFSwitch.java | 8 ++++++++ .../java/net/floodlightcontroller/core/OFSwitchBase.java | 9 +++++++++ .../util/OFMessageDamperMockSwitch.java | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java index 55195c66e..388349f2b 100644 --- a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java +++ b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java @@ -114,6 +114,14 @@ public interface IOFSwitch { */ public boolean inputThrottled(OFMessage ofm); + /** + * Return if the switch is currently overloaded. The definition of + * overload refers to excessive traffic in the control path, namely + * a high packet in rate. + * @return + */ + boolean isOverloaded(); + /** * Write OFMessage to the output stream, subject to switch rate limiting. * The message will be handed to the floodlightProvider for possible filtering diff --git a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java index 3da2f4e9d..351e3717b 100644 --- a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java +++ b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java @@ -787,6 +787,15 @@ public abstract class OFSwitchBase implements IOFSwitch { packetInRatePerPortThreshold = pktInPerPort; } + /** + * Return if switch has exceeded the high threshold of packet in rate. + * @return + */ + @Override + public boolean isOverloaded() { + return packetInThrottleEnabled; + } + /** * Determine if this message should be dropped. * diff --git a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java index 650ead70d..1d1ff169b 100644 --- a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java +++ b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java @@ -439,4 +439,10 @@ public class OFMessageDamperMockSwitch implements IOFSwitch { return false; } + @Override + public boolean isOverloaded() { + // TODO Auto-generated method stub + return false; + } + } -- GitLab