byte[] icmpPacket1Serialized, icmpPacket2Serialized;
OFPacketIn arpRequestPacketIn1;
OFPacketIn icmpPacketIn1, icmpPacketIn2;
OFPacketOut arpReplyPacketOut1;
Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
Capture<FloodlightContext> bc1 =
new Capture<FloodlightContext>(CaptureType.ALL);
int fastWildcards =
OFMatch.OFPFW_IN_PORT |
OFMatch.OFPFW_NW_PROTO |
OFMatch.OFPFW_TP_SRC |
OFMatch.OFPFW_TP_DST |
OFMatch.OFPFW_NW_SRC_ALL |
OFMatch.OFPFW_NW_DST_ALL |
OFMatch.OFPFW_NW_TOS;
sw1 = EasyMock.createNiceMock(IOFSwitch.class);
expect(sw1.getId()).andReturn(1L).anyTimes();
expect(sw1.getStringId()).andReturn("00:00:00:00:00:01").anyTimes();
expect(sw1.getAttribute(IOFSwitch.PROP_FASTWILDCARDS)).andReturn(fastWildcards).anyTimes();
expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
sw1.writeThrottled(capture(wc1), capture(bc1));
expectLastCall().anyTimes();
sw1.flush();
expectLastCall().anyTimes();
replay(sw1);
sfp.switchAdded(1L);
verify(sw1);
/* Test plan:
* - two clients and two servers on sw1 port 1, 2, 3, 4
* - mock arp request received towards vip1 from (1L, 1)
* - proxy arp got pushed out to (1L, 1)- check sw1 getting the packetout
* - mock icmp request received towards vip1 from (1L, 1)
* - device manager list of devices queried to identify source and dest devices
* - routing engine queried to get inbound and outbound routes
* - check getRoute calls and responses
* - sfp called to install flows
* - check sfp calls
*/
// Build topology
reset(topology);
expect(topology.isIncomingBroadcastAllowed(anyLong(), anyShort())).andReturn(true).anyTimes();
expect(topology.getL2DomainId(1L)).andReturn(1L).anyTimes();
expect(topology.isAttachmentPointPort(1L, (short)1)).andReturn(true).anyTimes();
expect(topology.isAttachmentPointPort(1L, (short)2)).andReturn(true).anyTimes();
expect(topology.isAttachmentPointPort(1L, (short)3)).andReturn(true).anyTimes();
expect(topology.isAttachmentPointPort(1L, (short)4)).andReturn(true).anyTimes();
replay(topology);
// Build arp packets
arpRequest1 = new Ethernet()
.setSourceMACAddress("00:00:00:00:00:01")
.setDestinationMACAddress("ff:ff:ff:ff:ff:ff")
.setEtherType(Ethernet.TYPE_ARP)
.setVlanID((short) 0)
.setPriorityCode((byte) 0)
.setPayload(
new ARP()
.setHardwareType(ARP.HW_TYPE_ETHERNET)
.setProtocolType(ARP.PROTO_TYPE_IP)
.setHardwareAddressLength((byte) 6)
.setProtocolAddressLength((byte) 4)
.setOpCode(ARP.OP_REQUEST)
.setSenderHardwareAddress(HexString.fromHexString("00:00:00:00:00:01"))
.setSenderProtocolAddress(IPv4.toIPv4AddressBytes("10.0.0.1"))
.setTargetHardwareAddress(HexString.fromHexString("00:00:00:00:00:00"))
.setTargetProtocolAddress(IPv4.toIPv4AddressBytes("10.0.0.100")));
arpRequest1Serialized = arpRequest1.serialize();
arpRequestPacketIn1 =
((OFPacketIn) getMockFloodlightProvider().getOFMessageFactory().
getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(arpRequest1Serialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) arpRequest1Serialized.length);
IFloodlightProviderService.bcStore.put(cntx,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
(Ethernet) arpRequest1);
// Mock proxy arp packet-out
arpReply1 = new Ethernet()
.setSourceMACAddress(LBVip.LB_PROXY_MAC)
.setDestinationMACAddress(HexString.fromHexString("00:00:00:00:00:01"))
.setEtherType(Ethernet.TYPE_ARP)
.setVlanID((short) 0)
.setPriorityCode((byte) 0)
.setPayload(
new ARP()
.setHardwareType(ARP.HW_TYPE_ETHERNET)
.setProtocolType(ARP.PROTO_TYPE_IP)
.setHardwareAddressLength((byte) 6)
.setProtocolAddressLength((byte) 4)
.setOpCode(ARP.OP_REPLY)
.setSenderHardwareAddress(HexString.fromHexString(LBVip.LB_PROXY_MAC))
.setSenderProtocolAddress(IPv4.toIPv4AddressBytes("10.0.0.100"))
.setTargetHardwareAddress(HexString.fromHexString("00:00:00:00:00:01"))
.setTargetProtocolAddress(IPv4.toIPv4AddressBytes("10.0.0.1")));
arpReply1Serialized = arpReply1.serialize();
arpReplyPacketOut1 =
(OFPacketOut) getMockFloodlightProvider().getOFMessageFactory().
getMessage(OFType.PACKET_OUT);
arpReplyPacketOut1.setBufferId(OFPacketOut.BUFFER_ID_NONE)
.setInPort(OFPort.OFPP_NONE.getValue());
List<OFAction> poactions = new ArrayList<OFAction>();
poactions.add(new OFActionOutput(arpRequestPacketIn1.getInPort(), (short) 0xffff));
arpReplyPacketOut1.setActions(poactions)
.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
.setPacketData(arpReply1Serialized)
.setLengthU(OFPacketOut.MINIMUM_LENGTH+
arpReplyPacketOut1.getActionsLength()+
arpReply1Serialized.length);
lb.receive(sw1, arpRequestPacketIn1, cntx);
verify(sw1, topology);