diff --git a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java index 428dc7f7e07ceb0598b2854668d6705a2cfa7efe..5678035f4741afc6e4eba05b4f47bca9c660e870 100644 --- a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java +++ b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java @@ -107,7 +107,17 @@ public interface IOFSwitch { public void setChannel(Channel channel); /** - * Writes to the OFMessage to the output stream. + * Write OFMessage to the output stream, subject to switch rate limiting. + * The message will be handed to the floodlightProvider for possible filtering + * and processing by message listeners + * @param msg + * @param cntx + * @throws IOException + */ + public void writeThrottled(OFMessage msg, FloodlightContext cntx) throws IOException; + + /** + * Writes to the OFMessage to the output stream, bypassing rate limiting. * The message will be handed to the floodlightProvider for possible filtering * and processing by message listeners * @param m diff --git a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java index 65265ca0caae46d6424d5bc1974ea030c1d8459d..6e99419612625291ce01718374ef9075f26dace1 100644 --- a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java +++ b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java @@ -183,6 +183,13 @@ public abstract class OFSwitchBase implements IOFSwitch { this.channel = channel; } + @Override + public void writeThrottled(OFMessage m, FloodlightContext bc) + throws IOException { + // By default, there is no throttling + write(m, bc); + } + @Override public void write(OFMessage m, FloodlightContext bc) throws IOException { diff --git a/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java b/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java index 5de554f273b5badb6137fe8e5221326e37b2090a..75b0b00d3a9fb082e14a18e3da34712fcdee4e36 100644 --- a/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java +++ b/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java @@ -134,7 +134,7 @@ public class OFMessageDamper { FloodlightContext cntx, boolean flush) throws IOException { if (! msgTypesToCache.contains(msg.getType())) { - sw.write(msg, cntx); + sw.writeThrottled(msg, cntx); if (flush) { sw.flush(); } @@ -146,7 +146,7 @@ public class OFMessageDamper { // entry exists in cache. Dampening. return false; } else { - sw.write(msg, cntx); + sw.writeThrottled(msg, cntx); if (flush) { sw.flush(); }