diff --git a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java index ccf8b49612014b10de710a861fcc722565248fbe..d6a0b8ae35e7bd9b87a01f6401f956501fe17df6 100644 --- a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java +++ b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java @@ -127,10 +127,11 @@ public abstract class OFSwitchBase implements IOFSwitch { // Private members for throttling private boolean writeThrottleEnabled = false; protected boolean packetInThrottleEnabled = false; // used by test - private int packetInRateThresholdHigh = Integer.MAX_VALUE; + private int packetInRateThresholdHigh = + Integer.parseInt(System.getProperty("input_threshold", "1000")); private int packetInRateThresholdLow = 1; - private int packetInRatePerMacThreshold = Integer.MAX_VALUE; - private int packetInRatePerPortThreshold = Integer.MAX_VALUE; + private int packetInRatePerMacThreshold = 50; + private int packetInRatePerPortThreshold = 100; private long messageCount = 0; private long messageCountUniqueOFMatch = 0; private long lastMessageTime; @@ -183,6 +184,11 @@ public abstract class OFSwitchBase implements IOFSwitch { this.setAttribute(PROP_FASTWILDCARDS, OFMatch.OFPFW_ALL); this.setAttribute(PROP_SUPPORTS_OFPP_FLOOD, Boolean.valueOf(true)); this.setAttribute(PROP_SUPPORTS_OFPP_TABLE, Boolean.valueOf(true)); + if (packetInRateThresholdHigh == 0) { + packetInRateThresholdHigh = Integer.MAX_VALUE; + } else { + packetInRateThresholdLow = packetInRateThresholdHigh / 2; + } } diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java index 4a36203ece0df154dcce7b1def5314493915179c..4e0916e3010af2115767817fc53225e5ff8f4857 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java +++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java @@ -225,7 +225,7 @@ public class Controller implements IFloodlightProviderService, // Perf. related configuration - protected static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024; + protected static final int SEND_BUFFER_SIZE = 128 * 1024; public static final int BATCH_MAX_SIZE = 100; protected static final boolean ALWAYS_DECODE_ETH = true; diff --git a/src/main/java/net/floodlightcontroller/debugcounter/DebugCounter.java b/src/main/java/net/floodlightcontroller/debugcounter/DebugCounter.java index 754323d0a734b76648ecb261bce613716f5a4184..5bb1ce16757a4faa363205c346887ad1fbbc0d3e 100644 --- a/src/main/java/net/floodlightcontroller/debugcounter/DebugCounter.java +++ b/src/main/java/net/floodlightcontroller/debugcounter/DebugCounter.java @@ -513,6 +513,29 @@ public class DebugCounter implements IFloodlightModule, IDebugCounterService { return (moduleCounters.containsKey(moduleName)) ? true : false; } + @Override + public List<String> getModuleList() { + List<String> retval = new ArrayList<String>(); + retval.addAll(moduleCounters.keySet()); + return retval; + } + + @Override + public List<String> getModuleCounterList(String moduleName) { + if (!moduleCounters.containsKey(moduleName)) + return Collections.emptyList(); + + List<String> retval = new ArrayList<String>(); + RetCtrInfo rci = new RetCtrInfo(); + rci.levels = "".split("/"); + + ArrayList<Integer> cids = getHierarchyBelow(moduleName, rci); + for (int index : cids) { + retval.add(allCounters[index].cinfo.counterHierarchy); + } + return retval; + } + //******************************* // Internal Methods //******************************* diff --git a/src/main/java/net/floodlightcontroller/debugcounter/IDebugCounterService.java b/src/main/java/net/floodlightcontroller/debugcounter/IDebugCounterService.java index b61c8449cbd12cd1544a084c0ca283b902d9fbcd..538e60dad148c600e3802b53271ed6e111d8f6b9 100644 --- a/src/main/java/net/floodlightcontroller/debugcounter/IDebugCounterService.java +++ b/src/main/java/net/floodlightcontroller/debugcounter/IDebugCounterService.java @@ -243,5 +243,17 @@ public interface IDebugCounterService extends IFloodlightService { */ public boolean containsModuleName(String moduleName); + /** + * Returns a list of moduleNames registered for debug counters or an empty + * list if no counters have been registered in the system + */ + public List<String> getModuleList(); + + /** + * Returns a list of all counters registered for a specific moduleName + * or a empty list + */ + public List<String> getModuleCounterList(String moduleName); + } diff --git a/src/main/java/net/floodlightcontroller/debugcounter/NullDebugCounter.java b/src/main/java/net/floodlightcontroller/debugcounter/NullDebugCounter.java index 9aed1951059a056d3d4d5f34c7dfc051af7c4dba..e9081a8e07bead12f847f0a4a2ffe347e9243d9b 100644 --- a/src/main/java/net/floodlightcontroller/debugcounter/NullDebugCounter.java +++ b/src/main/java/net/floodlightcontroller/debugcounter/NullDebugCounter.java @@ -122,6 +122,16 @@ public class NullDebugCounter implements IFloodlightModule, IDebugCounterService return new NullCounterImpl(); } + @Override + public List<String> getModuleList() { + return Collections.emptyList(); + } + + @Override + public List<String> getModuleCounterList(String moduleName) { + return Collections.emptyList(); + } + public class NullCounterImpl implements IDebugCounter { @Override @@ -150,6 +160,4 @@ public class NullDebugCounter implements IFloodlightModule, IDebugCounterService } - - } diff --git a/src/main/java/net/floodlightcontroller/debugcounter/web/DebugCounterResource.java b/src/main/java/net/floodlightcontroller/debugcounter/web/DebugCounterResource.java index ccddb02afe38af34f3789e0bf1ec2932c308b740..f4d00bf14d5d269e8574241e9772f961854747b0 100644 --- a/src/main/java/net/floodlightcontroller/debugcounter/web/DebugCounterResource.java +++ b/src/main/java/net/floodlightcontroller/debugcounter/web/DebugCounterResource.java @@ -28,28 +28,28 @@ public class DebugCounterResource extends DebugCounterResourceBase { public class DebugCounterInfoOutput { protected class DCInfo { private final Long counterValue; - private final CounterType cType; + private final CounterType counterType; private final String counterDesc; private final boolean enabled; private final String counterHierarchy; private final String moduleName; + private final String[] metaData; DCInfo(DebugCounterInfo dci) { this.moduleName = dci.getCounterInfo().getModuleName(); this.counterHierarchy = dci.getCounterInfo().getCounterHierarchy(); - this.counterDesc = dci.getCounterInfo().getCounterHierarchy(); - //this.metaData = dci.getCounterInfo().getMetaData(); + this.counterDesc = dci.getCounterInfo().getCounterDesc(); + this.metaData = dci.getCounterInfo().getMetaData(); this.enabled = dci.getCounterInfo().isEnabled(); - this.cType = dci.getCounterInfo().getCtype(); + this.counterType = dci.getCounterInfo().getCtype(); this.counterValue = dci.getCounterValue(); } public Long getCounterValue() { return counterValue; } - - public CounterType getcType() { - return cType; + public CounterType getCounterType() { + return counterType; } public String getCounterDesc() { @@ -68,13 +68,24 @@ public class DebugCounterResource extends DebugCounterResourceBase { return moduleName; } - } + public String[] getMetaData() { + return metaData; + } + } + // complete counter information - null if only names are requested or + // if an error occurs public Map<String, DCInfo> counterMap; + // list of names could be just moduleNames or counter hierarchical names + // for a specific module + public List<String> names; + public String error; - DebugCounterInfoOutput() { - counterMap = new HashMap<String, DCInfo>(); + DebugCounterInfoOutput(boolean getList) { + if (!getList) { + counterMap = new HashMap<String, DCInfo>(); + } error = null; } public Map<String, DCInfo> getCounterMap() { @@ -85,6 +96,10 @@ public class DebugCounterResource extends DebugCounterResourceBase { return error; } + public List<String> getNames() { + return names; + } + } public enum Option { @@ -258,7 +273,7 @@ public class DebugCounterResource extends DebugCounterResourceBase { */ @Get public DebugCounterInfoOutput handleCounterInfoQuery() { - DebugCounterInfoOutput output = new DebugCounterInfoOutput(); + DebugCounterInfoOutput output; Option choice = Option.ERROR_BAD_PARAM; String param1 = (String)getRequestAttributes().get("param1"); String param2 = (String)getRequestAttributes().get("param2"); @@ -266,14 +281,34 @@ public class DebugCounterResource extends DebugCounterResourceBase { String param4 = (String)getRequestAttributes().get("param4"); if (param1 == null) { - param1 = "all"; - choice = Option.ALL; + output = new DebugCounterInfoOutput(true); + return listCounters(output); } else if (param1.equals("all")) { - choice = Option.ALL; + output = new DebugCounterInfoOutput(false); + populateCounters(debugCounter.getAllCounterValues(), output); + return output; } + output = new DebugCounterInfoOutput(false); String counterHierarchy = ""; - if (param2 != null) { + if (param2 == null) { + // param2 is null -- return list of counternames for param1 + boolean isRegistered = debugCounter.containsModuleName(param1); + output = new DebugCounterInfoOutput(true); + if (isRegistered) { + return listCounters(param1, output); + } else { + choice = Option.ERROR_BAD_MODULE_NAME; + } + } else if (param2.equals("all")) { + // get all counter info for a single module + boolean isRegistered = debugCounter.containsModuleName(param1); + if (isRegistered) { + choice = Option.ONE_MODULE; + } else { + choice = Option.ERROR_BAD_MODULE_NAME; + } + } else { counterHierarchy += param2; if (param3 != null) { counterHierarchy += "/" + param3; @@ -288,22 +323,9 @@ public class DebugCounterResource extends DebugCounterResourceBase { } else { choice = Option.ERROR_BAD_MODULE_COUNTER_NAME; } - } else { - if (!param1.equals("all")) { - // get all counters for a single module - boolean isRegistered = debugCounter.containsModuleName(param1); - if (isRegistered) { - choice = Option.ONE_MODULE; - } else { - choice = Option.ERROR_BAD_MODULE_NAME; - } - } } switch (choice) { - case ALL: - populateCounters(debugCounter.getAllCounterValues(), output); - break; case ONE_MODULE: populateCounters(debugCounter.getModuleCounterValues(param1), output); break; @@ -312,18 +334,30 @@ public class DebugCounterResource extends DebugCounterResourceBase { output); break; case ERROR_BAD_MODULE_NAME: - output.error = "Module name has no corresponding registered counters"; + output.error = "Module name is not registered for debug-counters"; break; case ERROR_BAD_MODULE_COUNTER_NAME: output.error = "Counter not registered"; break; case ERROR_BAD_PARAM: + default: output.error = "Bad param"; } return output; } + private DebugCounterInfoOutput listCounters(String moduleName, + DebugCounterInfoOutput output) { + output.names = debugCounter.getModuleCounterList(moduleName); + return output; + } + + private DebugCounterInfoOutput listCounters(DebugCounterInfoOutput output) { + output.names = debugCounter.getModuleList(); + return output; + } + private void populateSingleCounter(DebugCounterInfo debugCounterInfo, DebugCounterInfoOutput output) { if (debugCounterInfo != null) diff --git a/src/main/java/net/floodlightcontroller/debugcounter/web/DebugCounterRoutable.java b/src/main/java/net/floodlightcontroller/debugcounter/web/DebugCounterRoutable.java index 8b7b2fa6f3bf9b68be3189cb65364dac990c33dc..55ba5bacf95b0257556bd5483a561ca40fa0a8cb 100644 --- a/src/main/java/net/floodlightcontroller/debugcounter/web/DebugCounterRoutable.java +++ b/src/main/java/net/floodlightcontroller/debugcounter/web/DebugCounterRoutable.java @@ -25,6 +25,7 @@ public class DebugCounterRoutable implements RestletRoutable { router.attach("/{param1}/", DebugCounterResource.class); router.attach("/{param1}", DebugCounterResource.class); router.attach("/", DebugCounterResource.class); + router.attach("", DebugCounterResource.class); return router; } } diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowReconcileManager.java b/src/main/java/net/floodlightcontroller/flowcache/FlowReconcileManager.java index 9191216cec3a3096ea1f13dab9952290427d6569..365a222f5dafd4d5ff4f52177bd1bb458316cc3e 100644 --- a/src/main/java/net/floodlightcontroller/flowcache/FlowReconcileManager.java +++ b/src/main/java/net/floodlightcontroller/flowcache/FlowReconcileManager.java @@ -45,13 +45,13 @@ import org.openflow.protocol.OFType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class FlowReconcileManager +public class FlowReconcileManager implements IFloodlightModule, IFlowReconcileService { /** The logger. */ private static Logger logger = LoggerFactory.getLogger(FlowReconcileManager.class); - + /** Reference to dependent modules */ protected IThreadPoolService threadPool; protected ICounterStoreService counterStore; @@ -67,28 +67,28 @@ public class FlowReconcileManager /** A FIFO queue to keep all outstanding flows for reconciliation */ PriorityPendingQueue <OFMatchReconcile> flowQueue; - + /** Asynchronous task to feed the flowReconcile pipeline */ protected SingletonTask flowReconcileTask; - + String controllerPktInCounterName; protected SimpleCounter lastPacketInCounter; - + protected final static int MAX_SYSTEM_LOAD_PER_SECOND = 10000; /** a minimum flow reconcile rate so that it won't stave */ protected final static int MIN_FLOW_RECONCILE_PER_SECOND = 200; - + /** start flow reconcile in 10ms after a new reconcile request is received. * The max delay is 1 second. */ protected final static int FLOW_RECONCILE_DELAY_MILLISEC = 10; protected Date lastReconcileTime; - + /** Config to enable or disable flowReconcile */ protected static final String EnableConfigKey = "enable"; protected boolean flowReconcileEnabled; - + public AtomicInteger flowReconcileThreadRunCount; - + @Override public synchronized void addFlowReconcileListener( IFlowReconcileListener listener) { @@ -111,25 +111,26 @@ public class FlowReconcileManager IFlowReconcileListener listener) { flowReconcileListeners.removeListener(listener); } - + @Override public synchronized void clearFlowReconcileListeners() { flowReconcileListeners.clearListeners(); } - + /** * Add to-be-reconciled flow to the queue. * * @param ofmRcIn the ofm rc in */ + @Override public void reconcileFlow(OFMatchReconcile ofmRcIn, EventPriority priority) { if (ofmRcIn == null) return; - + // Make a copy before putting on the queue. OFMatchReconcile myOfmRc = new OFMatchReconcile(ofmRcIn); - + flowQueue.offer(myOfmRc, priority); - + Date currTime = new Date(); long delay = 0; @@ -143,28 +144,28 @@ public class FlowReconcileManager delay = FLOW_RECONCILE_DELAY_MILLISEC; } flowReconcileTask.reschedule(delay, TimeUnit.MILLISECONDS); - + if (logger.isTraceEnabled()) { logger.trace("Reconciling flow: {}, total: {}", myOfmRc.toString(), flowQueue.size()); } } - + // IFloodlightModule @Override public Collection<Class<? extends IFloodlightService>> getModuleServices() { - Collection<Class<? extends IFloodlightService>> l = + Collection<Class<? extends IFloodlightService>> l = new ArrayList<Class<? extends IFloodlightService>>(); l.add(IFlowReconcileService.class); return l; } @Override - public Map<Class<? extends IFloodlightService>, IFloodlightService> + public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() { Map<Class<? extends IFloodlightService>, - IFloodlightService> m = + IFloodlightService> m = new HashMap<Class<? extends IFloodlightService>, IFloodlightService>(); m.put(IFlowReconcileService.class, this); @@ -172,9 +173,9 @@ public class FlowReconcileManager } @Override - public Collection<Class<? extends IFloodlightService>> + public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { - Collection<Class<? extends IFloodlightService>> l = + Collection<Class<? extends IFloodlightService>> l = new ArrayList<Class<? extends IFloodlightService>>(); l.add(IThreadPoolService.class); l.add(ICounterStoreService.class); @@ -188,9 +189,9 @@ public class FlowReconcileManager counterStore = context.getServiceImpl(ICounterStoreService.class); flowQueue = new PriorityPendingQueue<OFMatchReconcile>(); - flowReconcileListeners = + flowReconcileListeners = new ListenerDispatcher<OFType, IFlowReconcileListener>(); - + Map<String, String> configParam = context.getConfigParams(this); String enableValue = configParam.get(EnableConfigKey); // Set flowReconcile default to true @@ -199,7 +200,7 @@ public class FlowReconcileManager enableValue.equalsIgnoreCase("false")) { flowReconcileEnabled = false; } - + flowReconcileThreadRunCount = new AtomicInteger(0); lastReconcileTime = new Date(0); logger.debug("FlowReconcile is {}", flowReconcileEnabled); @@ -219,23 +220,21 @@ public class FlowReconcileManager TimeUnit.MILLISECONDS); } } catch (Exception e) { - logger.warn("Exception in doReconcile(): {}", - e.getMessage()); - e.printStackTrace(); + logger.warn("Exception in doReconcile(): {}", e); } } }); - + String packetInName = OFType.PACKET_IN.toClass().getName(); - packetInName = packetInName.substring(packetInName.lastIndexOf('.')+1); - + packetInName = packetInName.substring(packetInName.lastIndexOf('.')+1); + // Construct controller counter for the packet_in controllerPktInCounterName = - CounterStore.createCounterName(ICounterStoreService.CONTROLLER_NAME, + CounterStore.createCounterName(ICounterStoreService.CONTROLLER_NAME, -1, packetInName); } - + protected void updateFlush() { // No-OP } @@ -248,13 +247,13 @@ public class FlowReconcileManager if (!flowReconcileEnabled) { return false; } - + // Record the execution time. lastReconcileTime = new Date(); - + ArrayList<OFMatchReconcile> ofmRcList = new ArrayList<OFMatchReconcile>(); - + // Get the maximum number of flows that can be reconciled. int reconcileCapacity = getCurrentCapacity(); if (logger.isTraceEnabled()) { @@ -272,7 +271,7 @@ public class FlowReconcileManager break; } } - + // Run the flow through all the flow reconcile listeners IFlowReconcileListener.Command retCmd; if (ofmRcList.size() > 0) { @@ -284,7 +283,7 @@ public class FlowReconcileManager } return false; } - + for (IFlowReconcileListener flowReconciler : flowReconcileListeners.getOrderedListeners()) { if (logger.isTraceEnabled()) @@ -305,7 +304,7 @@ public class FlowReconcileManager logger.trace("No flow to be reconciled."); } } - + // Return true if there are more flows to be reconciled if (flowQueue.isEmpty()) { return false; @@ -317,10 +316,10 @@ public class FlowReconcileManager return true; } } - + /** * Compute the maximum number of flows to be reconciled. - * + * * It computes the packetIn increment from the counter values in * the counter store; * Then computes the rate based on the elapsed time @@ -339,7 +338,7 @@ public class FlowReconcileManager counterStore.getCounter(controllerPktInCounterName); int minFlows = MIN_FLOW_RECONCILE_PER_SECOND * FLOW_RECONCILE_DELAY_MILLISEC / 1000; - + // If no packetInCounter, then there shouldn't be any flow. if (pktInCounter == null || pktInCounter.getCounterDate() == null || @@ -348,7 +347,7 @@ public class FlowReconcileManager controllerPktInCounterName); return minFlows; } - + // Haven't get any counter yet. if (lastPacketInCounter == null) { logger.debug("First time get the count for {}", @@ -357,9 +356,9 @@ public class FlowReconcileManager SimpleCounter.createCounter(pktInCounter); return minFlows; } - + int pktInRate = getPktInRate(pktInCounter, new Date()); - + // Update the last packetInCounter lastPacketInCounter = (SimpleCounter) SimpleCounter.createCounter(pktInCounter); @@ -369,20 +368,20 @@ public class FlowReconcileManager capacity = (MAX_SYSTEM_LOAD_PER_SECOND - pktInRate) * FLOW_RECONCILE_DELAY_MILLISEC / 1000; } - + if (logger.isTraceEnabled()) { logger.trace("Capacity is {}", capacity); } return capacity; } - + protected int getPktInRate(ICounter newCnt, Date currentTime) { if (newCnt == null || newCnt.getCounterDate() == null || newCnt.getCounterValue() == null) { return 0; } - + // Somehow the system time is messed up. return max packetIn rate // to reduce the system load. if (newCnt.getCounterDate().before( @@ -392,14 +391,14 @@ public class FlowReconcileManager lastPacketInCounter.getCounterDate()); return MAX_SYSTEM_LOAD_PER_SECOND; } - + long elapsedTimeInSecond = (currentTime.getTime() - lastPacketInCounter.getCounterDate().getTime()) / 1000; if (elapsedTimeInSecond == 0) { // This should never happen. Check to avoid division by zero. return 0; } - + long diff = 0; switch (newCnt.getCounterValue().getType()) { case LONG: @@ -412,7 +411,7 @@ public class FlowReconcileManager diff = newLong - oldLong; } break; - + case DOUBLE: double newDouble = newCnt.getCounterValue().getDouble(); double oldDouble = lastPacketInCounter.getCounterValue().getDouble(); @@ -424,7 +423,7 @@ public class FlowReconcileManager } break; } - + return (int)(diff/elapsedTimeInSecond); } } diff --git a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java index 267ad58c733db378655d4b4610bae887886c3911..df255f6134b6d1ccff356f9f16201539a10b2bb4 100644 --- a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java +++ b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java @@ -417,33 +417,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { this.routingEngine = context.getServiceImpl(IRoutingService.class); this.topology = context.getServiceImpl(ITopologyService.class); this.counterStore = context.getServiceImpl(ICounterStoreService.class); - - // read our config options - Map<String, String> configOptions = context.getConfigParams(this); - try { - String idleTimeout = configOptions.get("idletimeout"); - if (idleTimeout != null) { - FLOWMOD_DEFAULT_IDLE_TIMEOUT = Short.parseShort(idleTimeout); - } - } catch (NumberFormatException e) { - log.warn("Error parsing flow idle timeout, " + - "using default of {} seconds", - FLOWMOD_DEFAULT_IDLE_TIMEOUT); - } - try { - String hardTimeout = configOptions.get("hardtimeout"); - if (hardTimeout != null) { - FLOWMOD_DEFAULT_HARD_TIMEOUT = Short.parseShort(hardTimeout); - } - } catch (NumberFormatException e) { - log.warn("Error parsing flow hard timeout, " + - "using default of {} seconds", - FLOWMOD_DEFAULT_HARD_TIMEOUT); - } - log.debug("FlowMod idle timeout set to {} seconds", - FLOWMOD_DEFAULT_IDLE_TIMEOUT); - log.debug("FlowMod hard timeout set to {} seconds", - FLOWMOD_DEFAULT_HARD_TIMEOUT); + try { AppCookie.registerApp(FORWARDING_APP_ID, "Forwarding"); } catch (AppIDInUseException e) { diff --git a/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java b/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java index 02c1bea3e9e5f642ef6f2726eae039653197fd98..e3f748bf19e8fed134dd35d723f761c3f1feba21 100644 --- a/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java +++ b/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java @@ -75,6 +75,9 @@ public abstract class ForwardingBase public static short FLOWMOD_DEFAULT_IDLE_TIMEOUT = 5; // in seconds public static short FLOWMOD_DEFAULT_HARD_TIMEOUT = 0; // infinite + public static final short FLOWMOD_DEFAULT_IDLE_TIMEOUT_CONSTANT = 5; + public static final short FLOWMOD_DEFAULT_HARD_TIMEOUT_CONSTANT = 0; + protected IFloodlightProviderService floodlightProvider; protected IDeviceService deviceManager; protected IRoutingService routingEngine; diff --git a/src/main/java/org/openflow/protocol/OFMatch.java b/src/main/java/org/openflow/protocol/OFMatch.java index 86b9a28f13dcfd3717ad3400ac05af30c66d7161..8fb0264337145b9a000d0fef6f052c1a48cbb99d 100644 --- a/src/main/java/org/openflow/protocol/OFMatch.java +++ b/src/main/java/org/openflow/protocol/OFMatch.java @@ -32,7 +32,7 @@ import org.openflow.util.U8; /** * Represents an ofp_match structure - * + * * @author David Erickson (daviderickson@cs.stanford.edu) * @author Rob Sherwood (rob.sherwood@stanford.edu) */ @@ -137,7 +137,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get dl_dst - * + * * @return an arrays of bytes */ public byte[] getDataLayerDestination() { @@ -146,7 +146,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set dl_dst - * + * * @param dataLayerDestination */ public OFMatch setDataLayerDestination(byte[] dataLayerDestination) { @@ -156,7 +156,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set dl_dst, but first translate to byte[] using HexString - * + * * @param mac * A colon separated string of 6 pairs of octets, e..g., * "00:17:42:EF:CD:8D" @@ -174,7 +174,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get dl_src - * + * * @return an array of bytes */ public byte[] getDataLayerSource() { @@ -183,7 +183,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set dl_src - * + * * @param dataLayerSource */ public OFMatch setDataLayerSource(byte[] dataLayerSource) { @@ -193,7 +193,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set dl_src, but first translate to byte[] using HexString - * + * * @param mac * A colon separated string of 6 pairs of octets, e..g., * "00:17:42:EF:CD:8D" @@ -211,7 +211,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get dl_type - * + * * @return ether_type */ public short getDataLayerType() { @@ -220,7 +220,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set dl_type - * + * * @param dataLayerType */ public OFMatch setDataLayerType(short dataLayerType) { @@ -230,7 +230,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get dl_vlan - * + * * @return vlan tag; VLAN_NONE == no tag */ public short getDataLayerVirtualLan() { @@ -239,7 +239,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set dl_vlan - * + * * @param dataLayerVirtualLan */ public OFMatch setDataLayerVirtualLan(short dataLayerVirtualLan) { @@ -249,7 +249,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get dl_vlan_pcp - * + * * @return */ public byte getDataLayerVirtualLanPriorityCodePoint() { @@ -258,7 +258,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set dl_vlan_pcp - * + * * @param pcp */ public OFMatch setDataLayerVirtualLanPriorityCodePoint(byte pcp) { @@ -268,7 +268,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get in_port - * + * * @return */ public short getInputPort() { @@ -277,7 +277,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set in_port - * + * * @param inputPort */ public OFMatch setInputPort(short inputPort) { @@ -287,7 +287,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get nw_dst - * + * * @return */ public int getNetworkDestination() { @@ -296,7 +296,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set nw_dst - * + * * @param networkDestination */ public OFMatch setNetworkDestination(int networkDestination) { @@ -309,7 +309,7 @@ public class OFMatch implements Cloneable, Serializable { * bits in the IP destination field. NOTE: this returns the number of bits * that are fixed, i.e., like CIDR, not the number of bits that are free * like OpenFlow encodes. - * + * * @return a number between 0 (matches all IPs) and 63 ( 32>= implies exact * match) */ @@ -323,7 +323,7 @@ public class OFMatch implements Cloneable, Serializable { * bits in the IP destination field. NOTE: this returns the number of bits * that are fixed, i.e., like CIDR, not the number of bits that are free * like OpenFlow encodes. - * + * * @return a number between 0 (matches all IPs) and 32 (exact match) */ public int getNetworkSourceMaskLen() { @@ -333,7 +333,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get nw_proto - * + * * @return */ public byte getNetworkProtocol() { @@ -342,7 +342,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set nw_proto - * + * * @param networkProtocol */ public OFMatch setNetworkProtocol(byte networkProtocol) { @@ -352,7 +352,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get nw_src - * + * * @return */ public int getNetworkSource() { @@ -361,7 +361,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set nw_src - * + * * @param networkSource */ public OFMatch setNetworkSource(int networkSource) { @@ -372,7 +372,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get nw_tos OFMatch stores the ToS bits as top 6-bits, so right shift by 2 * bits before returning the value - * + * * @return : 6-bit DSCP value (0-63) */ public byte getNetworkTypeOfService() { @@ -382,7 +382,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set nw_tos OFMatch stores the ToS bits as top 6-bits, so left shift by 2 * bits before storing the value - * + * * @param networkTypeOfService * : 6-bit DSCP value (0-63) */ @@ -393,7 +393,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get tp_dst - * + * * @return */ public short getTransportDestination() { @@ -402,7 +402,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set tp_dst - * + * * @param transportDestination */ public OFMatch setTransportDestination(short transportDestination) { @@ -412,7 +412,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get tp_src - * + * * @return */ public short getTransportSource() { @@ -421,7 +421,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set tp_src - * + * * @param transportSource */ public OFMatch setTransportSource(short transportSource) { @@ -431,7 +431,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get wildcards - * + * * @return */ public int getWildcards() { @@ -440,7 +440,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Get wildcards - * + * * @return */ public Wildcards getWildcardObj() { @@ -449,7 +449,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set wildcards - * + * * @param wildcards */ public OFMatch setWildcards(int wildcards) { @@ -468,7 +468,7 @@ public class OFMatch implements Cloneable, Serializable { * specified packet. Must specify the input port, to ensure that * this.in_port is set correctly. Specify OFPort.NONE or OFPort.ANY if input * port not applicable or available - * + * * @param packetData * The packet's data * @param inputPort @@ -550,6 +550,11 @@ public class OFMatch implements Cloneable, Serializable { } break; default: + // Not ARP or IP. Wildcard NW_DST and NW_SRC + this.wildcards |= OFPFW_NW_DST_ALL | + OFPFW_NW_SRC_ALL | + OFPFW_NW_PROTO | + OFPFW_NW_TOS; setNetworkTypeOfService((byte) 0); setNetworkProtocol((byte) 0); setNetworkSource(0); @@ -580,6 +585,8 @@ public class OFMatch implements Cloneable, Serializable { this.transportDestination = packetDataBB.getShort(); break; default: + // Unknown network proto. + this.wildcards |= OFPFW_TP_DST | OFPFW_TP_SRC; setTransportDestination((short) 0); setTransportSource((short) 0); break; @@ -589,7 +596,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Read this message off the wire from the specified ByteBuffer - * + * * @param data */ public void readFrom(ChannelBuffer data) { @@ -615,7 +622,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Write this message's binary format to the specified ByteBuffer - * + * * @param data */ public void writeTo(ChannelBuffer data) { @@ -734,8 +741,8 @@ public class OFMatch implements Cloneable, Serializable { /** * Output a dpctl-styled string, i.e., only list the elements that are not * wildcarded A match-everything OFMatch outputs "OFMatch[]" - * - * @return + * + * @return * "OFMatch[dl_src:00:20:01:11:22:33,nw_src:192.168.0.0/24,tp_dst:80]" */ @Override @@ -815,6 +822,47 @@ public class OFMatch implements Cloneable, Serializable { return "OFMatch[" + str + "]"; } + /** + * Return a string including all match fields, regardless whether they + * are wildcarded or not. + */ + public String toStringUnmasked() { + String str = ""; + + // l1 + str += STR_IN_PORT + "=" + U16.f(this.inputPort); + + // l2 + str += "," + STR_DL_DST + "=" + + HexString.toHexString(this.dataLayerDestination); + str += "," + STR_DL_SRC + "=" + + HexString.toHexString(this.dataLayerSource); + str += "," + STR_DL_TYPE + "=0x" + + Integer.toHexString(U16.f(this.dataLayerType)); + str += "," + STR_DL_VLAN + "=0x" + + Integer.toHexString(U16.f(this.dataLayerVirtualLan)); + str += "," + STR_DL_VLAN_PCP + "=" + + Integer.toHexString(U8.f(this.dataLayerVirtualLanPriorityCodePoint)); + + // l3 + str += "," + STR_NW_DST + "=" + + cidrToString(networkDestination, + getNetworkDestinationMaskLen()); + str += "," + STR_NW_SRC + "=" + + cidrToString(networkSource, + getNetworkSourceMaskLen()); + str += "," + STR_NW_PROTO + "=" + this.networkProtocol; + str += "," + STR_NW_TOS + "=" + this.getNetworkTypeOfService(); + + // l4 + str += "," + STR_TP_DST + "=" + this.transportDestination; + str += "," + STR_TP_SRC + "=" + this.transportSource; + + // wildcards + str += ", wildcards=" + debugWildCards(wildcards); + return "OFMatch[" + str + "]"; + } + /** * debug a set of wildcards */ @@ -908,7 +956,7 @@ public class OFMatch implements Cloneable, Serializable { * <p> * The CIDR-style netmasks assume 32 netmask if none given, so: * "128.8.128.118/32" is the same as "128.8.128.118" - * + * * @param match * a key=value comma separated string, e.g. * "in_port=5,ip_dst=192.168.0.0/16,tp_src=80" @@ -999,7 +1047,7 @@ public class OFMatch implements Cloneable, Serializable { /** * Set the networkSource or networkDestionation address and their wildcards * from the CIDR string - * + * * @param cidr * "192.168.0.0/16" or "172.16.1.5" * @param which diff --git a/src/main/java/org/sdnplatform/sync/internal/SyncManager.java b/src/main/java/org/sdnplatform/sync/internal/SyncManager.java index 727ccd51992a530a96177246be8b2afa0f6e2931..95bae4316d83cf4963e423a2349c23f5d059c793 100644 --- a/src/main/java/org/sdnplatform/sync/internal/SyncManager.java +++ b/src/main/java/org/sdnplatform/sync/internal/SyncManager.java @@ -515,7 +515,7 @@ public class SyncManager extends AbstractSyncManager { throws FloodlightModuleException { if (context != null) { try { - counterHints = debugCounter.registerCounter(PACKAGE, " hints", + counterHints = debugCounter.registerCounter(PACKAGE, "hints", "Queued sync events processed", CounterType.ALWAYS_COUNT); counterSentValues = debugCounter.registerCounter(PACKAGE, "sent-values", diff --git a/src/test/java/net/floodlightcontroller/core/internal/OFSwitchBaseTest.java b/src/test/java/net/floodlightcontroller/core/internal/OFSwitchBaseTest.java index 6e737bea6be4f52e4fcc6d98f2024bd79ca0f034..004b0dc73d0a1ec7561454bac0e07c04811b6e73 100644 --- a/src/test/java/net/floodlightcontroller/core/internal/OFSwitchBaseTest.java +++ b/src/test/java/net/floodlightcontroller/core/internal/OFSwitchBaseTest.java @@ -227,6 +227,8 @@ public class OFSwitchBaseTest { @Test public void testNoPacketInThrottle() { replay(floodlightProvider); + /* disable input throttle */ + sw.setThresholds(Integer.MAX_VALUE, 1, 0, 0); for (int i = 0; i < 200; i++) { assertFalse(sw.inputThrottled(pi)); }