@Test public void floodArpTest() throws PacketException { ArpSender arpSender = new ArpSender(packetService); MacAddress senderMac = new MacAddress("00:00:00:00:00:01"); Ipv4Address senderAddress = new Ipv4Address("192.168.0.1"); Ipv4Address targetAddress = new Ipv4Address("192.168.0.2"); InstanceIdentifier<Node> nodeIid = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("node1"))).build(); ArpMessageAddress arpAddress = new ArpMessageAddress(senderMac, senderAddress); arpSender.floodArp(arpAddress, targetAddress, nodeIid); ArgumentCaptor<TransmitPacketInput> argument = ArgumentCaptor.forClass(TransmitPacketInput.class); Mockito.verify(packetService).transmitPacket(argument.capture()); Assert.assertEquals(nodeIid, argument.getValue().getNode().getValue()); Packet ethernet = new Ethernet().deserialize(argument.getValue().getPayload(), 0, argument.getValue().getPayload().length); Packet potentialArp = ethernet.getPayload(); Assume.assumeNotNull(potentialArp); Assert.assertTrue(potentialArp instanceof Arp); Arp arp = (Arp) potentialArp; Assert.assertArrayEquals(ArpUtils.ipToBytes(senderAddress), arp.getSenderProtocolAddress()); Assert.assertArrayEquals(ArpUtils.ipToBytes(targetAddress), arp.getTargetProtocolAddress()); Assert.assertArrayEquals(ArpUtils.macToBytes(senderMac), arp.getSenderHardwareAddress()); }
public ListenableFuture<RpcResult<Void>> floodArp(ArpMessageAddress senderAddress, Ipv4Address tpa, InstanceIdentifier<Node> nodeIid) { checkNotNull(senderAddress); checkNotNull(tpa); checkNotNull(nodeIid); NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(createNodeConnectorId(OFPP_ALL, nodeIid.firstKeyOf(Node.class, NodeKey.class).getId())); InstanceIdentifier<NodeConnector> egressNc = nodeIid.child(NodeConnector.class, nodeConnectorKey); return sendArp(senderAddress, tpa, egressNc); }
ArpSender { public ListenableFuture<RpcResult<Void>> floodArp(ArpMessageAddress senderAddress, Ipv4Address tpa, InstanceIdentifier<Node> nodeIid) { checkNotNull(senderAddress); checkNotNull(tpa); checkNotNull(nodeIid); NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(createNodeConnectorId(OFPP_ALL, nodeIid.firstKeyOf(Node.class, NodeKey.class).getId())); InstanceIdentifier<NodeConnector> egressNc = nodeIid.child(NodeConnector.class, nodeConnectorKey); return sendArp(senderAddress, tpa, egressNc); } }
ArpSender { public ListenableFuture<RpcResult<Void>> floodArp(ArpMessageAddress senderAddress, Ipv4Address tpa, InstanceIdentifier<Node> nodeIid) { checkNotNull(senderAddress); checkNotNull(tpa); checkNotNull(nodeIid); NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(createNodeConnectorId(OFPP_ALL, nodeIid.firstKeyOf(Node.class, NodeKey.class).getId())); InstanceIdentifier<NodeConnector> egressNc = nodeIid.child(NodeConnector.class, nodeConnectorKey); return sendArp(senderAddress, tpa, egressNc); } ArpSender(PacketProcessingService packetProcessingService); }
ArpSender { public ListenableFuture<RpcResult<Void>> floodArp(ArpMessageAddress senderAddress, Ipv4Address tpa, InstanceIdentifier<Node> nodeIid) { checkNotNull(senderAddress); checkNotNull(tpa); checkNotNull(nodeIid); NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(createNodeConnectorId(OFPP_ALL, nodeIid.firstKeyOf(Node.class, NodeKey.class).getId())); InstanceIdentifier<NodeConnector> egressNc = nodeIid.child(NodeConnector.class, nodeConnectorKey); return sendArp(senderAddress, tpa, egressNc); } 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); }
ArpSender { public ListenableFuture<RpcResult<Void>> floodArp(ArpMessageAddress senderAddress, Ipv4Address tpa, InstanceIdentifier<Node> nodeIid) { checkNotNull(senderAddress); checkNotNull(tpa); checkNotNull(nodeIid); NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(createNodeConnectorId(OFPP_ALL, nodeIid.firstKeyOf(Node.class, NodeKey.class).getId())); InstanceIdentifier<NodeConnector> egressNc = nodeIid.child(NodeConnector.class, nodeConnectorKey); return sendArp(senderAddress, tpa, egressNc); } 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);  }