Skip to content
Snippets Groups Projects
Commit 2e74ac1b authored by Ananth Suryanarayana's avatar Ananth Suryanarayana
Browse files

Add input port as additional field for packet hash computation - further changes

parent f1d3996c
No related branches found
No related tags found
No related merge requests found
...@@ -8,3 +8,5 @@ ...@@ -8,3 +8,5 @@
target target
thrift thrift
logback.xml logback.xml
*.swp
*.pyc
...@@ -330,6 +330,7 @@ public class Ethernet extends BasePacket { ...@@ -330,6 +330,7 @@ public class Ethernet extends BasePacket {
result = prime * result + destinationMACAddress.hashCode(); result = prime * result + destinationMACAddress.hashCode();
result = prime * result + etherType; result = prime * result + etherType;
result = prime * result + vlanID; result = prime * result + vlanID;
result = prime * result + priorityCode;
result = prime * result + (pad ? 1231 : 1237); result = prime * result + (pad ? 1231 : 1237);
result = prime * result + sourceMACAddress.hashCode(); result = prime * result + sourceMACAddress.hashCode();
return result; return result;
......
...@@ -33,7 +33,6 @@ import net.floodlightcontroller.counter.ICounterStoreService; ...@@ -33,7 +33,6 @@ import net.floodlightcontroller.counter.ICounterStoreService;
import net.floodlightcontroller.devicemanager.IDevice; import net.floodlightcontroller.devicemanager.IDevice;
import net.floodlightcontroller.devicemanager.IDeviceListener; import net.floodlightcontroller.devicemanager.IDeviceListener;
import net.floodlightcontroller.devicemanager.IDeviceService; import net.floodlightcontroller.devicemanager.IDeviceService;
import net.floodlightcontroller.devicemanager.IEntityClass;
import net.floodlightcontroller.devicemanager.SwitchPort; import net.floodlightcontroller.devicemanager.SwitchPort;
import net.floodlightcontroller.packet.Ethernet; import net.floodlightcontroller.packet.Ethernet;
import net.floodlightcontroller.packet.IPacket; import net.floodlightcontroller.packet.IPacket;
...@@ -71,7 +70,7 @@ public abstract class ForwardingBase implements ...@@ -71,7 +70,7 @@ public abstract class ForwardingBase implements
// for broadcast loop suppression // for broadcast loop suppression
protected boolean broadcastCacheFeature = true; protected boolean broadcastCacheFeature = true;
public final int prime = 2633; // for hash calculation public final int prime1 = 2633; // for hash calculation
public final int prime2 = 4357; // for hash calculation public final int prime2 = 4357; // for hash calculation
public TimedCache<Long> broadcastCache = public TimedCache<Long> broadcastCache =
new TimedCache<Long>(100, 5*1000); // 5 seconds interval; new TimedCache<Long>(100, 5*1000); // 5 seconds interval;
...@@ -494,24 +493,6 @@ public abstract class ForwardingBase implements ...@@ -494,24 +493,6 @@ public abstract class ForwardingBase implements
packetOutMultiPort(packet.serialize(), sw, inPort, outPorts, cntx); packetOutMultiPort(packet.serialize(), sw, inPort, outPorts, cntx);
} }
protected Long getPacketHash (FloodlightContext cntx, Ethernet eth,
Long seed) {
String address_space_name = "default";
IDevice srcDev = IDeviceService.fcStore.get(
cntx, IDeviceService.CONTEXT_SRC_DEVICE);
if (srcDev != null) {
IEntityClass entityClass = srcDev.getEntityClass();
if (entityClass != null) {
address_space_name = entityClass.getName();
}
}
return seed + prime2 * address_space_name.hashCode() + eth.hashCode();
}
protected boolean isInBroadcastCache(IOFSwitch sw, OFPacketIn pi, protected boolean isInBroadcastCache(IOFSwitch sw, OFPacketIn pi,
FloodlightContext cntx) { FloodlightContext cntx) {
// Get the cluster id of the switch. // Get the cluster id of the switch.
...@@ -525,8 +506,9 @@ public abstract class ForwardingBase implements ...@@ -525,8 +506,9 @@ public abstract class ForwardingBase implements
IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.bcStore.get(cntx,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD); IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
Long broadcastHash = getPacketHash(cntx, eth, Long broadcastHash;
topology.getL2DomainId(sw.getId()) * prime); broadcastHash = topology.getL2DomainId(sw.getId()) * prime1 +
pi.getInPort() * prime2 + eth.hashCode();
if (broadcastCache.update(broadcastHash)) { if (broadcastCache.update(broadcastHash)) {
sw.updateBroadcastCache(broadcastHash, pi.getInPort()); sw.updateBroadcastCache(broadcastHash, pi.getInPort());
return true; return true;
...@@ -542,15 +524,13 @@ public abstract class ForwardingBase implements ...@@ -542,15 +524,13 @@ public abstract class ForwardingBase implements
if (!broadcastCacheFeature) return false; if (!broadcastCacheFeature) return false;
// Get the hash of the Ethernet packet. // Get the hash of the Ethernet packet.
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, Ethernet eth =
IFloodlightProviderService.CONTEXT_PI_PAYLOAD); IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
long hash = pi.getInPort() * prime2 + eth.hashCode();
Long hash = getPacketHash(cntx, eth, new Long(0));
// some FORWARD_OR_FLOOD packets are unicast with unknown destination mac // some FORWARD_OR_FLOOD packets are unicast with unknown destination mac
// if (eth.isBroadcast() || eth.isMulticast())
return sw.updateBroadcastCache(hash, pi.getInPort()); return sw.updateBroadcastCache(hash, pi.getInPort());
// return false;
} }
public static boolean public static boolean
......
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