Skip to content
Snippets Groups Projects
Commit 8ab3ceb2 authored by abat's avatar abat
Browse files

Merge into master from pull request #51:

Only learn ip address from ARP replies (https://github.com/floodlight/floodlight/pull/51)
parents 80a1d691 2782f965
No related branches found
No related tags found
No related merge requests found
...@@ -773,7 +773,9 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe ...@@ -773,7 +773,9 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
devMgrMaps.updateMaps(device); devMgrMaps.updateMaps(device);
writeDeviceToStorage(device, currentDate); writeDeviceToStorage(device, currentDate);
updateStatus(device, true); updateStatus(device, true);
log.debug("New device learned {}", device); if (log.isDebugEnabled()) {
log.debug("New device learned {}", device);
}
} }
private boolean isGratArp(Ethernet eth) { private boolean isGratArp(Ethernet eth) {
...@@ -795,15 +797,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe ...@@ -795,15 +797,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
} }
} else if (eth.getPayload() instanceof IPv4) { } else if (eth.getPayload() instanceof IPv4) {
IPv4 ipv4 = (IPv4) eth.getPayload(); IPv4 ipv4 = (IPv4) eth.getPayload();
if (ipv4.getPayload() instanceof UDP) { return ipv4.getSourceAddress();
UDP udp = (UDP)ipv4.getPayload();
if (udp.getPayload() instanceof DHCP) {
DHCP dhcp = (DHCP)udp.getPayload();
if (dhcp.getOpCode() == DHCP.OPCODE_REPLY) {
return ipv4.getSourceAddress();
}
}
}
} }
return 0; return 0;
} }
...@@ -881,9 +875,13 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe ...@@ -881,9 +875,13 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
if (networkAddress != null) { if (networkAddress != null) {
updateNetworkAddressLastSeen = true; updateNetworkAddressLastSeen = true;
} else if (eth != null && (eth.getPayload() instanceof ARP)) { } else if (eth != null && (eth.getPayload() instanceof ARP)) {
networkAddress = new DeviceNetworkAddress(nwSrc, ARP arp = (ARP)eth.getPayload();
// Only learn new MAC-IP mapping on ARP reply
if (arp.getOpCode() == 0x02) {
networkAddress = new DeviceNetworkAddress(nwSrc,
currentDate); currentDate);
newNetworkAddress = true; newNetworkAddress = true;
}
} }
// Also, if this address is currently mapped to a different // Also, if this address is currently mapped to a different
...@@ -913,7 +911,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe ...@@ -913,7 +911,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
new Object[] {networkAddress, new Object[] {networkAddress,
HexString.toHexString(deviceByNwaddr.getDataLayerAddress()), HexString.toHexString(deviceByNwaddr.getDataLayerAddress()),
HexString.toHexString(device.getDataLayerAddress()), HexString.toHexString(device.getDataLayerAddress()),
eth}); eth.toString()});
} }
} }
...@@ -946,8 +944,8 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe ...@@ -946,8 +944,8 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
if (newNetworkAddress) { if (newNetworkAddress) {
// add the address // add the address
nd.addNetworkAddress(networkAddress); nd.addNetworkAddress(networkAddress);
log.debug("Device {} added IP {}", log.info("Device {} added IP {}, packet {}",
nd, IPv4.fromIPv4Address(nwSrc)); new Object[] {nd, IPv4.fromIPv4Address(nwSrc), eth.toString()});
} }
if (updateDeviceVlan) { if (updateDeviceVlan) {
...@@ -1544,7 +1542,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe ...@@ -1544,7 +1542,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
// ******************** // ********************
public boolean readPortChannelConfigFromStorage() { public boolean readPortChannelConfigFromStorage() {
devMgrMaps.clearPortChannelMap(); devMgrMaps.clearPortChannelMap();
try { try {
IResultSet pcResultSet = storageSource.executeQuery( IResultSet pcResultSet = storageSource.executeQuery(
...@@ -2140,7 +2138,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe ...@@ -2140,7 +2138,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
// Register to get updates from topology // Register to get updates from topology
linkDiscovery.addListener(this); linkDiscovery.addListener(this);
} else { } else {
log.error("Could add not toplogy listener"); log.error("Could not add topology listener");
} }
// Create our database tables // Create our database tables
...@@ -2178,20 +2176,20 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe ...@@ -2178,20 +2176,20 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
deviceManagerAware.add(listener); deviceManagerAware.add(listener);
} }
@Override @Override
public Map<String, Object> getInfo(String type) { public Map<String, Object> getInfo(String type) {
if (!"summary".equals(type)) if (!"summary".equals(type))
return null; return null;
Map<String, Object> info = new HashMap<String, Object>(); Map<String, Object> info = new HashMap<String, Object>();
info.put("# hosts", devMgrMaps.dataLayerAddressDeviceMap.size()); info.put("# hosts", devMgrMaps.dataLayerAddressDeviceMap.size());
info.put("# IP Addresses", devMgrMaps.ipv4AddressDeviceMap.size()); info.put("# IP Addresses", devMgrMaps.ipv4AddressDeviceMap.size());
int num_aps = 0; int num_aps = 0;
for (Map<Integer, Device> devAps : devMgrMaps.switchPortDeviceMap.values()) for (Map<Integer, Device> devAps : devMgrMaps.switchPortDeviceMap.values())
num_aps += devAps.size(); num_aps += devAps.size();
info.put("# attachment points", num_aps); info.put("# attachment points", num_aps);
return info; return info;
} }
} }
...@@ -62,12 +62,12 @@ import org.openflow.protocol.OFPhysicalPort; ...@@ -62,12 +62,12 @@ import org.openflow.protocol.OFPhysicalPort;
* @author David Erickson (daviderickson@cs.stanford.edu) * @author David Erickson (daviderickson@cs.stanford.edu)
*/ */
public class DeviceManagerImplTest extends FloodlightTestCase { public class DeviceManagerImplTest extends FloodlightTestCase {
protected OFPacketIn packetIn, anotherPacketIn; protected OFPacketIn packetIn_1, packetIn_2, packetIn_3, packetIn_4, packetIn_5;
protected IPacket testPacket, anotherTestPacket; protected IPacket testARPReplyPacket_1, testARPReplyPacket_2, testARPReplyPacket_3;
protected byte[] testPacketSerialized, anotherTestPacketSerialized; protected IPacket testARPReqPacket_1, testARPReqPacket_2;
private IPacket thirdTestPacket; protected byte[] testARPReplyPacket_1_Serialized, testARPReplyPacket_2_Serialized;
private byte[] thirdTestPacketSerialized; private byte[] testARPReplyPacket_3_Serialized;
private OFPacketIn thirdPacketIn; private byte[] testARPReqPacket_1_Serialized, testARPReqPacket_2_Serialized;
MockFloodlightProvider mockFloodlightProvider; MockFloodlightProvider mockFloodlightProvider;
DeviceManagerImpl deviceManager; DeviceManagerImpl deviceManager;
MemoryStorageSource storageSource; MemoryStorageSource storageSource;
...@@ -98,7 +98,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -98,7 +98,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
deviceManager.startUp(fmc); deviceManager.startUp(fmc);
// Build our test packet // Build our test packet
this.testPacket = new Ethernet() this.testARPReplyPacket_1 = new Ethernet()
.setSourceMACAddress("00:44:33:22:11:00") .setSourceMACAddress("00:44:33:22:11:00")
.setDestinationMACAddress("00:11:22:33:44:55") .setDestinationMACAddress("00:11:22:33:44:55")
.setEtherType(Ethernet.TYPE_ARP) .setEtherType(Ethernet.TYPE_ARP)
...@@ -114,10 +114,10 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -114,10 +114,10 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
.setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.1")) .setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.1"))
.setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55")) .setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
.setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2"))); .setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
this.testPacketSerialized = testPacket.serialize(); this.testARPReplyPacket_1_Serialized = testARPReplyPacket_1.serialize();
// Another test packet with a different source IP // Another test packet with a different source IP
this.anotherTestPacket = new Ethernet() this.testARPReplyPacket_2 = new Ethernet()
.setSourceMACAddress("00:44:33:22:11:01") .setSourceMACAddress("00:44:33:22:11:01")
.setDestinationMACAddress("00:11:22:33:44:55") .setDestinationMACAddress("00:11:22:33:44:55")
.setEtherType(Ethernet.TYPE_ARP) .setEtherType(Ethernet.TYPE_ARP)
...@@ -132,9 +132,9 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -132,9 +132,9 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
.setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.1")) .setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.1"))
.setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55")) .setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
.setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2"))); .setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
this.anotherTestPacketSerialized = anotherTestPacket.serialize(); this.testARPReplyPacket_2_Serialized = testARPReplyPacket_2.serialize();
this.thirdTestPacket = new Ethernet() this.testARPReplyPacket_3 = new Ethernet()
.setSourceMACAddress("00:44:33:22:11:01") .setSourceMACAddress("00:44:33:22:11:01")
.setDestinationMACAddress("00:11:22:33:44:55") .setDestinationMACAddress("00:11:22:33:44:55")
.setEtherType(Ethernet.TYPE_ARP) .setEtherType(Ethernet.TYPE_ARP)
...@@ -149,38 +149,88 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -149,38 +149,88 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
.setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.3")) .setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.3"))
.setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55")) .setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
.setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2"))); .setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
this.thirdTestPacketSerialized = thirdTestPacket.serialize(); this.testARPReplyPacket_3_Serialized = testARPReplyPacket_3.serialize();
this.testARPReqPacket_1 = new Ethernet()
.setSourceMACAddress("00:44:33:22:11:04")
.setDestinationMACAddress("ff:ff:ff:ff:ff:ff")
.setEtherType(Ethernet.TYPE_ARP)
.setPayload(
new ARP()
.setHardwareType(ARP.HW_TYPE_ETHERNET)
.setProtocolType(ARP.PROTO_TYPE_IP)
.setHardwareAddressLength((byte) 6)
.setProtocolAddressLength((byte) 4)
.setOpCode(ARP.OP_REQUEST)
.setSenderHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:04"))
.setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.4"))
.setTargetHardwareAddress(Ethernet.toMACAddress("00:00:00:00:00:00"))
.setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
this.testARPReqPacket_1_Serialized = testARPReqPacket_1.serialize();
this.testARPReqPacket_2 = new Ethernet()
.setSourceMACAddress("00:44:33:22:11:04")
.setDestinationMACAddress("ff:ff:ff:ff:ff:ff")
.setEtherType(Ethernet.TYPE_ARP)
.setPayload(
new ARP()
.setHardwareType(ARP.HW_TYPE_ETHERNET)
.setProtocolType(ARP.PROTO_TYPE_IP)
.setHardwareAddressLength((byte) 6)
.setProtocolAddressLength((byte) 4)
.setOpCode(ARP.OP_REQUEST)
.setSenderHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:04"))
.setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.14"))
.setTargetHardwareAddress(Ethernet.toMACAddress("00:00:00:00:00:00"))
.setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
this.testARPReqPacket_2_Serialized = testARPReqPacket_2.serialize();
// Build the PacketIn
this.packetIn_1 = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(this.testARPReplyPacket_1_Serialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) this.testARPReplyPacket_1_Serialized.length);
// Build the PacketIn
this.packetIn_2 = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(this.testARPReplyPacket_2_Serialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) this.testARPReplyPacket_2_Serialized.length);
// Build the PacketIn // Build the PacketIn
this.packetIn = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN)) this.packetIn_3 = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1) .setBufferId(-1)
.setInPort((short) 1) .setInPort((short) 1)
.setPacketData(this.testPacketSerialized) .setPacketData(this.testARPReplyPacket_3_Serialized)
.setReason(OFPacketInReason.NO_MATCH) .setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) this.testPacketSerialized.length); .setTotalLength((short) this.testARPReplyPacket_3_Serialized.length);
// Build the PacketIn // Build the PacketIn
this.anotherPacketIn = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN)) this.packetIn_4 = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1) .setBufferId(-1)
.setInPort((short) 1) .setInPort((short) 1)
.setPacketData(this.anotherTestPacketSerialized) .setPacketData(this.testARPReqPacket_1_Serialized)
.setReason(OFPacketInReason.NO_MATCH) .setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) this.anotherTestPacketSerialized.length); .setTotalLength((short) this.testARPReqPacket_1_Serialized.length);
// Build the PacketIn // Build the PacketIn
this.thirdPacketIn = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN)) this.packetIn_5 = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1) .setBufferId(-1)
.setInPort((short) 1) .setInPort((short) 1)
.setPacketData(this.thirdTestPacketSerialized) .setPacketData(this.testARPReqPacket_2_Serialized)
.setReason(OFPacketInReason.NO_MATCH) .setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) this.thirdTestPacketSerialized.length); .setTotalLength((short) this.testARPReqPacket_2_Serialized.length);
} }
@Test @Test
public void testAddHostAttachmentPoint() throws Exception { public void testAddHostAttachmentPoint() throws Exception {
IOFSwitch mockSwitch = createMock(IOFSwitch.class); IOFSwitch mockSwitch = createMock(IOFSwitch.class);
Device d = new Device(((Ethernet)this.testPacket).getSourceMACAddress()); Device d = new Device(((Ethernet)this.testARPReplyPacket_1).getSourceMACAddress());
Date cDate = new Date(); Date cDate = new Date();
SwitchPortTuple spt1 = new SwitchPortTuple(mockSwitch, (short)1); SwitchPortTuple spt1 = new SwitchPortTuple(mockSwitch, (short)1);
SwitchPortTuple spt2 = new SwitchPortTuple(mockSwitch, (short)2); SwitchPortTuple spt2 = new SwitchPortTuple(mockSwitch, (short)2);
...@@ -197,7 +247,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -197,7 +247,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
@Test @Test
public void testDeviceDiscover() throws Exception { public void testDeviceDiscover() throws Exception {
byte[] dataLayerSource = ((Ethernet)this.testPacket).getSourceMACAddress(); byte[] dataLayerSource = ((Ethernet)this.testARPReplyPacket_1).getSourceMACAddress();
// Mock up our expected behavior // Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class); IOFSwitch mockSwitch = createMock(IOFSwitch.class);
...@@ -219,7 +269,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -219,7 +269,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
// Start recording the replay on the mocks // Start recording the replay on the mocks
replay(mockSwitch, mockTopology); replay(mockSwitch, mockTopology);
// Get the listener and trigger the packet in // Get the listener and trigger the packet in
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1);
// Verify the replay matched our expectations // Verify the replay matched our expectations
verify(mockSwitch, mockTopology); verify(mockSwitch, mockTopology);
...@@ -245,7 +295,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -245,7 +295,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
// Start recording the replay on the mocks // Start recording the replay on the mocks
replay(mockSwitch, mockTopology); replay(mockSwitch, mockTopology);
// Get the listener and trigger the packet in // Get the listener and trigger the packet in
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)2)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)2));
// Verify the replay matched our expectations // Verify the replay matched our expectations
verify(mockSwitch, mockTopology); verify(mockSwitch, mockTopology);
...@@ -257,9 +307,67 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -257,9 +307,67 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
deviceManager.clearAllDeviceStateFromMemory(); deviceManager.clearAllDeviceStateFromMemory();
} }
@Test
public void testDeviceDiscover_NegTest() throws Exception {
byte[] dataLayerSource = ((Ethernet)this.testARPReqPacket_1).getSourceMACAddress();
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
expect(mockSwitch.getId()).andReturn(1L).anyTimes();
expect(mockSwitch.getStringId()).andReturn("00:00:00:00:00:00:00:01").anyTimes();
ITopologyService mockTopology = createMock(ITopologyService.class);
expect(mockTopology.isInternal(1L, (short)1)).andReturn(false);
deviceManager.setTopology(mockTopology);
Date currentDate = new Date();
// build our expected Device
Device device = new Device();
device.setDataLayerAddress(dataLayerSource);
device.addAttachmentPoint(new SwitchPortTuple(mockSwitch, (short)1), currentDate);
Integer ipaddr = IPv4.toIPv4Address("192.168.1.4");
device.addNetworkAddress(ipaddr, currentDate);
// Start recording the replay on the mocks
replay(mockSwitch, mockTopology);
// Get the listener and trigger the packet in
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_4);
// Verify the replay matched our expectations
verify(mockSwitch, mockTopology);
// Verify the device
Device rdevice = deviceManager.getDeviceByDataLayerAddress(dataLayerSource);
assertEquals(device, rdevice);
reset(mockSwitch, mockTopology);
expect(mockSwitch.getId()).andReturn(1L).anyTimes();
expect(mockSwitch.getStringId()).andReturn("00:00:00:00:00:00:00:01").anyTimes();
expect(mockTopology.isInternal(1L, (short)1)).andReturn(false);
// The device is learnt from the first packetIn with one network address
assertEquals(1, deviceManager.getDeviceByIPv4Address(ipaddr).getNetworkAddresses().size());
// Start recording the replay on the mocks
replay(mockSwitch, mockTopology);
// Get the listener and trigger the packet in
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_5);
// Verify the replay matched our expectations
verify(mockSwitch, mockTopology);
// The new network address should not be learnt from ARP request.
assertNull(deviceManager.getDeviceByIPv4Address(IPv4.toIPv4Address("192.168.1.14")));
assertEquals(1, deviceManager.getDeviceByDataLayerAddress(dataLayerSource).getNetworkAddresses().size());
// Reset the device cache
deviceManager.clearAllDeviceStateFromMemory();
}
@Test @Test
public void testDeviceRecoverFromStorage() throws Exception { public void testDeviceRecoverFromStorage() throws Exception {
byte[] dataLayerSource = ((Ethernet)this.anotherTestPacket).getSourceMACAddress(); byte[] dataLayerSource = ((Ethernet)this.testARPReplyPacket_2).getSourceMACAddress();
// Mock up our expected behavior // Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class); IOFSwitch mockSwitch = createMock(IOFSwitch.class);
...@@ -289,8 +397,8 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -289,8 +397,8 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
device.addNetworkAddress(ipaddr2, currentDate); device.addNetworkAddress(ipaddr2, currentDate);
// Get the listener and trigger the packet ins // Get the listener and trigger the packet ins
mockFloodlightProvider.dispatchMessage(mockSwitch, this.anotherPacketIn); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_2);
mockFloodlightProvider.dispatchMessage(mockSwitch, this.thirdPacketIn); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_3);
// Verify the device // Verify the device
assertEquals(device, deviceManager.getDeviceByDataLayerAddress(dataLayerSource)); assertEquals(device, deviceManager.getDeviceByDataLayerAddress(dataLayerSource));
...@@ -338,7 +446,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -338,7 +446,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
deviceManager.clearAllDeviceStateFromMemory(); deviceManager.clearAllDeviceStateFromMemory();
MockFloodlightProvider mockFloodlightProvider = getMockFloodlightProvider(); MockFloodlightProvider mockFloodlightProvider = getMockFloodlightProvider();
byte[] dataLayerSource = ((Ethernet)this.testPacket).getSourceMACAddress(); byte[] dataLayerSource = ((Ethernet)this.testARPReplyPacket_1).getSourceMACAddress();
// Mock up our expected behavior // Mock up our expected behavior
IOFSwitch mockSwitch = createNiceMock(IOFSwitch.class); IOFSwitch mockSwitch = createNiceMock(IOFSwitch.class);
...@@ -360,12 +468,12 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -360,12 +468,12 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
// Start recording the replay on the mocks // Start recording the replay on the mocks
replay(mockSwitch, mockTopology); replay(mockSwitch, mockTopology);
// Get the listener and trigger the packet in // Get the listener and trigger the packet in
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1);
Thread.sleep(100); Thread.sleep(100);
// Get the listener and trigger the packet in // Get the listener and trigger the packet in
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1);
// Clear the device cache // Clear the device cache
deviceManager.clearAllDeviceStateFromMemory(); deviceManager.clearAllDeviceStateFromMemory();
...@@ -384,7 +492,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -384,7 +492,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
port1.setName("port1"); port1.setName("port1");
port2.setName("port2"); port2.setName("port2");
byte[] dataLayerSource = ((Ethernet)this.testPacket).getSourceMACAddress(); byte[] dataLayerSource = ((Ethernet)this.testARPReplyPacket_1).getSourceMACAddress();
// Mock up our expected behavior // Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class); IOFSwitch mockSwitch = createMock(IOFSwitch.class);
...@@ -403,12 +511,12 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -403,12 +511,12 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
replay(mockSwitch, mockTopology); replay(mockSwitch, mockTopology);
// Get the listener and trigger the packet in // Get the listener and trigger the packet in
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1);
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)2)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)2));
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)1)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)1));
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)2)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)2));
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)1)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)1));
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)2)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)2));
Device device = deviceManager.getDeviceByDataLayerAddress(dataLayerSource); Device device = deviceManager.getDeviceByDataLayerAddress(dataLayerSource);
...@@ -470,7 +578,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -470,7 +578,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
port2.setName("port2"); port2.setName("port2");
setupPortChannel(); setupPortChannel();
byte[] dataLayerSource = ((Ethernet)this.testPacket).getSourceMACAddress(); byte[] dataLayerSource = ((Ethernet)this.testARPReplyPacket_1).getSourceMACAddress();
// Mock up our expected behavior // Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class); IOFSwitch mockSwitch = createMock(IOFSwitch.class);
...@@ -489,12 +597,12 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -489,12 +597,12 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
replay(mockSwitch, mockTopology); replay(mockSwitch, mockTopology);
// Get the listener and trigger the packet in // Get the listener and trigger the packet in
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1);
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)2)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)2));
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)1)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)1));
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)2)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)2));
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)1)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)1));
mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn.setInPort((short)2)); mockFloodlightProvider.dispatchMessage(mockSwitch, this.packetIn_1.setInPort((short)2));
Device device = deviceManager.getDeviceByDataLayerAddress(dataLayerSource); Device device = deviceManager.getDeviceByDataLayerAddress(dataLayerSource);
......
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