@Test public void testValiantPassEnPassantWithServerExtension() { when(packet.getDestinationId()).thenReturn(4); ValiantEncapsulation encapsulation = new ValiantEncapsulation(packet, 2); device0identity.receive(encapsulation); verify(topology.getPort(0, 1), times(0)).enqueue(encapsulation); verify(topology.getPort(0, 2), times(0)).enqueue(encapsulation); verify(topology.getPort(0, 4), times(1)).enqueue(encapsulation); verify(topology.getPort(0, 5), times(0)).enqueue(encapsulation); verify(layer1, times(0)).receive(packet); }
@Override public void receive(Packet genericPacket) { ValiantEncapsulationHeader encapsulation = (ValiantEncapsulationHeader) genericPacket; int actualDestination = encapsulation.getPacket().getDestinationId(); int valiantDestination = encapsulation.getValiantDestination(); int destinationToGoTo = encapsulation.passedValiant() ? actualDestination : valiantDestination; if (!encapsulation.passedValiant() && valiantDestination == this.identifier) { encapsulation.markPassedValiant(); destinationToGoTo = actualDestination; } if (actualDestination == this.identifier) { this.passToIntermediary(encapsulation.getPacket()); } else { if (isWithinExtendedTopology && this.connectedTo.contains(actualDestination)) { destinationToGoTo = actualDestination; } List<Integer> possibilities = destinationToNextSwitch.get(destinationToGoTo); this.targetIdToOutputPort.get(possibilities.get(encapsulation.getPacket().getHash(this.identifier) % possibilities.size())).enqueue(genericPacket); } }
ValiantEcmpSwitch extends EcmpSwitch { @Override public void receive(Packet genericPacket) { ValiantEncapsulationHeader encapsulation = (ValiantEncapsulationHeader) genericPacket; int actualDestination = encapsulation.getPacket().getDestinationId(); int valiantDestination = encapsulation.getValiantDestination(); int destinationToGoTo = encapsulation.passedValiant() ? actualDestination : valiantDestination; if (!encapsulation.passedValiant() && valiantDestination == this.identifier) { encapsulation.markPassedValiant(); destinationToGoTo = actualDestination; } if (actualDestination == this.identifier) { this.passToIntermediary(encapsulation.getPacket()); } else { if (isWithinExtendedTopology && this.connectedTo.contains(actualDestination)) { destinationToGoTo = actualDestination; } List<Integer> possibilities = destinationToNextSwitch.get(destinationToGoTo); this.targetIdToOutputPort.get(possibilities.get(encapsulation.getPacket().getHash(this.identifier) % possibilities.size())).enqueue(genericPacket); } } }
ValiantEcmpSwitch extends EcmpSwitch { @Override public void receive(Packet genericPacket) { ValiantEncapsulationHeader encapsulation = (ValiantEncapsulationHeader) genericPacket; int actualDestination = encapsulation.getPacket().getDestinationId(); int valiantDestination = encapsulation.getValiantDestination(); int destinationToGoTo = encapsulation.passedValiant() ? actualDestination : valiantDestination; if (!encapsulation.passedValiant() && valiantDestination == this.identifier) { encapsulation.markPassedValiant(); destinationToGoTo = actualDestination; } if (actualDestination == this.identifier) { this.passToIntermediary(encapsulation.getPacket()); } else { if (isWithinExtendedTopology && this.connectedTo.contains(actualDestination)) { destinationToGoTo = actualDestination; } List<Integer> possibilities = destinationToNextSwitch.get(destinationToGoTo); this.targetIdToOutputPort.get(possibilities.get(encapsulation.getPacket().getHash(this.identifier) % possibilities.size())).enqueue(genericPacket); } } ValiantEcmpSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); }
ValiantEcmpSwitch extends EcmpSwitch { @Override public void receive(Packet genericPacket) { ValiantEncapsulationHeader encapsulation = (ValiantEncapsulationHeader) genericPacket; int actualDestination = encapsulation.getPacket().getDestinationId(); int valiantDestination = encapsulation.getValiantDestination(); int destinationToGoTo = encapsulation.passedValiant() ? actualDestination : valiantDestination; if (!encapsulation.passedValiant() && valiantDestination == this.identifier) { encapsulation.markPassedValiant(); destinationToGoTo = actualDestination; } if (actualDestination == this.identifier) { this.passToIntermediary(encapsulation.getPacket()); } else { if (isWithinExtendedTopology && this.connectedTo.contains(actualDestination)) { destinationToGoTo = actualDestination; } List<Integer> possibilities = destinationToNextSwitch.get(destinationToGoTo); this.targetIdToOutputPort.get(possibilities.get(encapsulation.getPacket().getHash(this.identifier) % possibilities.size())).enqueue(genericPacket); } } ValiantEcmpSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); @Override void receive(Packet genericPacket); }
ValiantEcmpSwitch extends EcmpSwitch { @Override public void receive(Packet genericPacket) { ValiantEncapsulationHeader encapsulation = (ValiantEncapsulationHeader) genericPacket; int actualDestination = encapsulation.getPacket().getDestinationId(); int valiantDestination = encapsulation.getValiantDestination(); int destinationToGoTo = encapsulation.passedValiant() ? actualDestination : valiantDestination; if (!encapsulation.passedValiant() && valiantDestination == this.identifier) { encapsulation.markPassedValiant(); destinationToGoTo = actualDestination; } if (actualDestination == this.identifier) { this.passToIntermediary(encapsulation.getPacket()); } else { if (isWithinExtendedTopology && this.connectedTo.contains(actualDestination)) { destinationToGoTo = actualDestination; } List<Integer> possibilities = destinationToNextSwitch.get(destinationToGoTo); this.targetIdToOutputPort.get(possibilities.get(encapsulation.getPacket().getHash(this.identifier) % possibilities.size())).enqueue(genericPacket); } } ValiantEcmpSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); @Override void receive(Packet genericPacket);  }