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);
assertTrue(wc1.hasCaptured()); // wc1 should get packetout
List<OFMessage> msglist1 = wc1.getValues();
for (OFMessage m: msglist1) {
if (m instanceof OFPacketOut)
assertEquals(arpReplyPacketOut1, m);
else
assertTrue(false); // unexpected message
}
//
// Skip arpRequest2 test - in reality this will happen, but for unit test the same logic
// is already validated with arpRequest1 test above
//
// Build icmp packets
icmpPacket1 = new Ethernet()
.setSourceMACAddress("00:00:00:00:00:01")
.setDestinationMACAddress(LBVip.LB_PROXY_MAC)
.setEtherType(Ethernet.TYPE_IPv4)
.setVlanID((short) 0)
.setPriorityCode((byte) 0)
.setPayload(
new IPv4()
.setSourceAddress("10.0.0.1")
.setDestinationAddress("10.0.0.100")
.setProtocol(IPv4.PROTOCOL_ICMP)
.setPayload(new ICMP()
.setIcmpCode((byte) 0)
.setIcmpType((byte) 0)));
icmpPacket1Serialized = icmpPacket1.serialize();
icmpPacketIn1 =
((OFPacketIn) getMockFloodlightProvider().getOFMessageFactory().
getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(icmpPacket1Serialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) icmpPacket1Serialized.length);
icmpPacket2 = new Ethernet()
.setSourceMACAddress("00:00:00:00:00:02")
.setDestinationMACAddress(LBVip.LB_PROXY_MAC)
.setEtherType(Ethernet.TYPE_IPv4)
.setVlanID((short) 0)
.setPriorityCode((byte) 0)