ArpSender { public ListenableFuture<RpcResult<Void>> sendArpResponse(ArpMessageAddress senderAddress, ArpMessageAddress receiverAddress, InstanceIdentifier<NodeConnector> egressNc, Header8021q vlan) { checkNotNull(senderAddress); checkNotNull(receiverAddress); checkNotNull(egressNc); final Ethernet arpFrame = createArpFrame(senderAddress, receiverAddress, vlan); byte[] arpFrameAsBytes; try { arpFrameAsBytes = arpFrame.serialize(); } catch (PacketException e) { LOG.warn("Serializition of ARP packet is not successful.", e); if (LOG.isDebugEnabled()) { LOG.debug("ARP packet: {}", ArpUtils.getArpFrameToStringFormat(arpFrame)); } return Futures.immediateFailedFuture(e); } LOG.debug("Egress for ARP packetOut: " + new NodeConnectorRef(egressNc).toString()); TransmitPacketInput packet = new TransmitPacketInputBuilder().setEgress(new NodeConnectorRef(egressNc)) .setNode(new NodeRef(egressNc.firstIdentifierOf(Node.class))).setPayload(arpFrameAsBytes).build(); if (LOG.isTraceEnabled()) { LOG.trace("Sending ARP RESPONSE \n{}", ArpUtils.getArpFrameToStringFormat(arpFrame)); } Future<RpcResult<Void>> futureTransmitPacketResult = packetProcessingService.transmitPacket(packet); return JdkFutureAdapters.listenInPoolThread(futureTransmitPacketResult); } ArpSender(PacketProcessingService packetProcessingService); ListenableFuture<RpcResult<Void>> floodArp(ArpMessageAddress senderAddress, Ipv4Address tpa,
			InstanceIdentifier<Node> nodeIid); ListenableFuture<RpcResult<Void>> sendArp(ArpMessageAddress senderAddress, Ipv4Address tpa,
			InstanceIdentifier<NodeConnector> egressNc); ListenableFuture<RpcResult<Void>> sendArpResponse(ArpMessageAddress senderAddress,
			ArpMessageAddress receiverAddress, InstanceIdentifier<NodeConnector> egressNc, Header8021q vlan);  }
@Test public void testSendArpResponse() { Ipv4Address srcIpv4Address = Ipv4Address.getDefaultInstance("192.168.20.1"); Ipv4Address dstIpv4Address = Ipv4Address.getDefaultInstance("192.168.10.1"); MacAddress srcMacAddress = new MacAddress("aa:bb:cc:dd:ee:00"); MacAddress dstMacAddress = new MacAddress("aa:bb:cc:dd:ee:ff"); ArpMessageAddress senderAddress = new ArpMessageAddress(srcMacAddress, srcIpv4Address); ArpMessageAddress receiverAddress = new ArpMessageAddress(dstMacAddress, dstIpv4Address); InstanceIdentifier<Node> instanceId = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(new NodeId("node_001"))).toInstance(); NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(new NodeConnectorId("node_001:0xfffffffc")); InstanceIdentifier<NodeConnector> egressNc = instanceId.child(NodeConnector.class, nodeConnectorKey); Future<RpcResult<Void>> futureTransmitPacketResult = mock(Future.class); when(packetProcessingService.transmitPacket(any(TransmitPacketInput.class))) .thenReturn(futureTransmitPacketResult); arpSender.sendArpResponse(senderAddress, receiverAddress, egressNc, null); verify(packetProcessingService, times(1)).transmitPacket(any(TransmitPacketInput.class)); }