Skip to content
Snippets Groups Projects
Commit 38264975 authored by Kanzhe Jiang's avatar Kanzhe Jiang
Browse files

Add per-port broadcast cache hit counter

parent 0da7f6a0
No related branches found
No related tags found
No related merge requests found
...@@ -308,11 +308,18 @@ public interface IOFSwitch { ...@@ -308,11 +308,18 @@ public interface IOFSwitch {
public void clearAllFlowMods(); public void clearAllFlowMods();
/** /**
* Return a TimedHashMap associated with the switch * Update broadcast cache
* @param data * @param data
* @return true if there is a cache hit
* false if there is no cache hit.
*/
public boolean updateBroadcastCache(Long entry, Short port);
/**
* Get the portBroadcastCacheHits
* @return * @return
*/ */
public TimedCache<Long> getTimedCache(); public Map<Short, Long> getPortBroadcastHits();
/** /**
* Send a flow statistics request to the switch. This call returns after * Send a flow statistics request to the switch. This call returns after
......
...@@ -80,6 +80,7 @@ public class OFSwitchImpl implements IOFSwitch { ...@@ -80,6 +80,7 @@ public class OFSwitchImpl implements IOFSwitch {
protected Role role; protected Role role;
protected TimedCache<Long> timedCache; protected TimedCache<Long> timedCache;
protected ReentrantReadWriteLock listenerLock; protected ReentrantReadWriteLock listenerLock;
protected ConcurrentMap<Short, Long> portBroadcastCacheHitMap;
public static IOFSwitchFeatures switchFeatures; public static IOFSwitchFeatures switchFeatures;
protected static final ThreadLocal<Map<OFSwitchImpl,List<OFMessage>>> local_msg_buffer = protected static final ThreadLocal<Map<OFSwitchImpl,List<OFMessage>>> local_msg_buffer =
...@@ -105,6 +106,8 @@ public class OFSwitchImpl implements IOFSwitch { ...@@ -105,6 +106,8 @@ public class OFSwitchImpl implements IOFSwitch {
this.role = null; this.role = null;
this.timedCache = new TimedCache<Long>(100, 5*1000 ); // 5 seconds interval this.timedCache = new TimedCache<Long>(100, 5*1000 ); // 5 seconds interval
this.listenerLock = new ReentrantReadWriteLock(); this.listenerLock = new ReentrantReadWriteLock();
this.portBroadcastCacheHitMap = new ConcurrentHashMap<Short, Long>();
// Defaults properties for an ideal switch // Defaults properties for an ideal switch
this.setAttribute(PROP_FASTWILDCARDS, (Integer) OFMatch.OFPFW_ALL); this.setAttribute(PROP_FASTWILDCARDS, (Integer) OFMatch.OFPFW_ALL);
this.setAttribute(PROP_SUPPORTS_OFPP_FLOOD, new Boolean(true)); this.setAttribute(PROP_SUPPORTS_OFPP_FLOOD, new Boolean(true));
...@@ -447,11 +450,24 @@ public class OFSwitchImpl implements IOFSwitch { ...@@ -447,11 +450,24 @@ public class OFSwitchImpl implements IOFSwitch {
} }
@Override @Override
public TimedCache<Long> getTimedCache() { public boolean updateBroadcastCache(Long entry, Short port) {
return timedCache; if (timedCache.update(entry)) {
} Long count = portBroadcastCacheHitMap.putIfAbsent(port, new Long(1));
if (count != null) {
count++;
}
return true;
} else {
return false;
}
}
@Override @Override
public Map<Short, Long> getPortBroadcastHits() {
return this.portBroadcastCacheHitMap;
}
public void flush() { public void flush() {
Map<OFSwitchImpl,List<OFMessage>> msg_buffer_map = local_msg_buffer.get(); Map<OFSwitchImpl,List<OFMessage>> msg_buffer_map = local_msg_buffer.get();
List<OFMessage> msglist = msg_buffer_map.get(this); List<OFMessage> msglist = msg_buffer_map.get(this);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment