@Test public void testTwoSubsequentIcmpRequests() throws Exception { testCreateVip(); testCreatePool(); testCreateMember(); IOFSwitch sw1; IPacket arpRequest1, arpReply1, icmpPacket1, icmpPacket2; byte[] arpRequest1Serialized; byte[] arpReply1Serialized; 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); 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); 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); 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()); List<OFMessage> msglist1 = wc1.getValues(); for (OFMessage m: msglist1) { if (m instanceof OFPacketOut) assertEquals(arpReplyPacketOut1, m); else assertTrue(false); } 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) .setPayload( new IPv4() .setSourceAddress("10.0.0.2") .setDestinationAddress("10.0.0.100") .setProtocol(IPv4.PROTOCOL_ICMP) .setPayload(new ICMP() .setIcmpCode((byte) 0) .setIcmpType((byte) 0))); icmpPacket2Serialized = icmpPacket2.serialize(); icmpPacketIn2 = ((OFPacketIn) getMockFloodlightProvider().getOFMessageFactory(). getMessage(OFType.PACKET_IN)) .setBufferId(-1) .setInPort((short) 2) .setPacketData(icmpPacket2Serialized) .setReason(OFPacketInReason.NO_MATCH) .setTotalLength((short) icmpPacket2Serialized.length); byte[] dataLayerSource1 = ((Ethernet)icmpPacket1).getSourceMACAddress(); int networkSource1 = ((IPv4)((Ethernet)icmpPacket1).getPayload()).getSourceAddress(); byte[] dataLayerDest1 = HexString.fromHexString("00:00:00:00:00:03"); int networkDest1 = IPv4.toIPv4Address("10.0.0.3"); byte[] dataLayerSource2 = ((Ethernet)icmpPacket2).getSourceMACAddress(); int networkSource2 = ((IPv4)((Ethernet)icmpPacket2).getPayload()).getSourceAddress(); byte[] dataLayerDest2 = HexString.fromHexString("00:00:00:00:00:04"); int networkDest2 = IPv4.toIPv4Address("10.0.0.4"); deviceManager.learnEntity(Ethernet.toLong(dataLayerSource1), null, networkSource1, 1L, 1); deviceManager.learnEntity(Ethernet.toLong(dataLayerSource2), null, networkSource2, 1L, 2); deviceManager.learnEntity(Ethernet.toLong(dataLayerDest1), null, networkDest1, 1L, 3); deviceManager.learnEntity(Ethernet.toLong(dataLayerDest2), null, networkDest2, 1L, 4); Route route1 = new Route(1L, 1L); List<NodePortTuple> nptList1 = new ArrayList<NodePortTuple>(); nptList1.add(new NodePortTuple(1L, (short)1)); nptList1.add(new NodePortTuple(1L, (short)3)); route1.setPath(nptList1); expect(routingEngine.getRoute(1L, (short)1, 1L, (short)3, 0)).andReturn(route1).atLeastOnce(); Route route2 = new Route(1L, 1L); List<NodePortTuple> nptList2 = new ArrayList<NodePortTuple>(); nptList2.add(new NodePortTuple(1L, (short)3)); nptList2.add(new NodePortTuple(1L, (short)1)); route2.setPath(nptList2); expect(routingEngine.getRoute(1L, (short)3, 1L, (short)1, 0)).andReturn(route2).atLeastOnce(); Route route3 = new Route(1L, 1L); List<NodePortTuple> nptList3 = new ArrayList<NodePortTuple>(); nptList3.add(new NodePortTuple(1L, (short)2)); nptList3.add(new NodePortTuple(1L, (short)4)); route3.setPath(nptList3); expect(routingEngine.getRoute(1L, (short)2, 1L, (short)4, 0)).andReturn(route3).atLeastOnce(); Route route4 = new Route(1L, 1L); List<NodePortTuple> nptList4 = new ArrayList<NodePortTuple>(); nptList4.add(new NodePortTuple(1L, (short)4)); nptList4.add(new NodePortTuple(1L, (short)2)); route4.setPath(nptList3); expect(routingEngine.getRoute(1L, (short)4, 1L, (short)2, 0)).andReturn(route4).atLeastOnce(); replay(routingEngine); wc1.reset(); IFloodlightProviderService.bcStore.put(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet) icmpPacket1); lb.receive(sw1, icmpPacketIn1, cntx); IFloodlightProviderService.bcStore.put(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet) icmpPacket2); lb.receive(sw1, icmpPacketIn2, cntx); assertTrue(wc1.hasCaptured()); List<OFMessage> msglist2 = wc1.getValues(); assertTrue(msglist2.size()==2); Map<String, OFFlowMod> map = sfp.getFlows("00:00:00:00:00:00:00:01"); assertTrue(map.size()==4); }
@Override public net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) { switch (msg.getType()) { case PACKET_IN: return processPacketIn(sw, (OFPacketIn)msg, cntx); default: break; } log.warn("Received unexpected message {}", msg); return Command.CONTINUE; }
LoadBalancer implements IFloodlightModule,
    ILoadBalancerService, IOFMessageListener { @Override public net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) { switch (msg.getType()) { case PACKET_IN: return processPacketIn(sw, (OFPacketIn)msg, cntx); default: break; } log.warn("Received unexpected message {}", msg); return Command.CONTINUE; } }
LoadBalancer implements IFloodlightModule,
    ILoadBalancerService, IOFMessageListener { @Override public net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) { switch (msg.getType()) { case PACKET_IN: return processPacketIn(sw, (OFPacketIn)msg, cntx); default: break; } log.warn("Received unexpected message {}", msg); return Command.CONTINUE; }  }
LoadBalancer implements IFloodlightModule,
    ILoadBalancerService, IOFMessageListener { @Override public net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) { switch (msg.getType()) { case PACKET_IN: return processPacketIn(sw, (OFPacketIn)msg, cntx); default: break; } log.warn("Received unexpected message {}", msg); return Command.CONTINUE; }  @Override String getName(); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); void pushPacket(IPacket packet, 
                           IOFSwitch sw,
                           int bufferId,
                           short inPort,
                           short outPort, 
                           FloodlightContext cntx,
                           boolean flush); void pushStaticVipRoute(boolean inBound, Route route, IPClient client, LBMember member, long pinSwitch); @Override Collection<LBVip> listVips(); @Override Collection<LBVip> listVip(String vipId); @Override LBVip createVip(LBVip vip); @Override LBVip updateVip(LBVip vip); @Override int removeVip(String vipId); @Override Collection<LBPool> listPools(); @Override Collection<LBPool> listPool(String poolId); @Override LBPool createPool(LBPool pool); @Override LBPool updatePool(LBPool pool); @Override int removePool(String poolId); @Override Collection<LBMember> listMembers(); @Override Collection<LBMember> listMember(String memberId); @Override Collection<LBMember> listMembersByPool(String poolId); @Override LBMember createMember(LBMember member); @Override LBMember updateMember(LBMember member); @Override int removeMember(String memberId); @Override Collection<LBMonitor> listMonitors(); @Override Collection<LBMonitor> listMonitor(String monitorId); @Override LBMonitor createMonitor(LBMonitor monitor); @Override LBMonitor updateMonitor(LBMonitor monitor); @Override int removeMonitor(String monitorId); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); static void parseActionString(OFFlowMod flowMod, String actionstr, Logger log); }
LoadBalancer implements IFloodlightModule,
    ILoadBalancerService, IOFMessageListener { @Override public net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) { switch (msg.getType()) { case PACKET_IN: return processPacketIn(sw, (OFPacketIn)msg, cntx); default: break; } log.warn("Received unexpected message {}", msg); return Command.CONTINUE; }  @Override String getName(); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); void pushPacket(IPacket packet, 
                           IOFSwitch sw,
                           int bufferId,
                           short inPort,
                           short outPort, 
                           FloodlightContext cntx,
                           boolean flush); void pushStaticVipRoute(boolean inBound, Route route, IPClient client, LBMember member, long pinSwitch); @Override Collection<LBVip> listVips(); @Override Collection<LBVip> listVip(String vipId); @Override LBVip createVip(LBVip vip); @Override LBVip updateVip(LBVip vip); @Override int removeVip(String vipId); @Override Collection<LBPool> listPools(); @Override Collection<LBPool> listPool(String poolId); @Override LBPool createPool(LBPool pool); @Override LBPool updatePool(LBPool pool); @Override int removePool(String poolId); @Override Collection<LBMember> listMembers(); @Override Collection<LBMember> listMember(String memberId); @Override Collection<LBMember> listMembersByPool(String poolId); @Override LBMember createMember(LBMember member); @Override LBMember updateMember(LBMember member); @Override int removeMember(String memberId); @Override Collection<LBMonitor> listMonitors(); @Override Collection<LBMonitor> listMonitor(String monitorId); @Override LBMonitor createMonitor(LBMonitor monitor); @Override LBMonitor updateMonitor(LBMonitor monitor); @Override int removeMonitor(String monitorId); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); static void parseActionString(OFFlowMod flowMod, String actionstr, Logger log); public Comparator<SwitchPort> clusterIdComparator; }