@Test public void testSingleConsumptionDirect() { when(packet.getDestinationId()).thenReturn(4); device4.receiveFromTransportLayer(packet); verify(topology.getPort(4, 2), times(0)).enqueue(packet); verify(topology.getPort(4, 3), times(0)).enqueue(packet); verify(layer4, times(1)).receive(packet); }
@Override public void receive(Packet genericPacket) { TcpHeader tcpHeader = (TcpHeader) genericPacket; if (tcpHeader.getDestinationId() == this.identifier) { this.passToIntermediary(genericPacket); } else { List<Integer> possibilities = destinationToNextSwitch.get(tcpHeader.getDestinationId()); this.targetIdToOutputPort.get(possibilities.get(tcpHeader.getHash(this.identifier) % possibilities.size())).enqueue(genericPacket); } }
EcmpSwitch extends NetworkDevice implements EcmpSwitchRoutingInterface { @Override public void receive(Packet genericPacket) { TcpHeader tcpHeader = (TcpHeader) genericPacket; if (tcpHeader.getDestinationId() == this.identifier) { this.passToIntermediary(genericPacket); } else { List<Integer> possibilities = destinationToNextSwitch.get(tcpHeader.getDestinationId()); this.targetIdToOutputPort.get(possibilities.get(tcpHeader.getHash(this.identifier) % possibilities.size())).enqueue(genericPacket); } } }
EcmpSwitch extends NetworkDevice implements EcmpSwitchRoutingInterface { @Override public void receive(Packet genericPacket) { TcpHeader tcpHeader = (TcpHeader) genericPacket; if (tcpHeader.getDestinationId() == this.identifier) { this.passToIntermediary(genericPacket); } else { List<Integer> possibilities = destinationToNextSwitch.get(tcpHeader.getDestinationId()); this.targetIdToOutputPort.get(possibilities.get(tcpHeader.getHash(this.identifier) % possibilities.size())).enqueue(genericPacket); } } EcmpSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); }
EcmpSwitch extends NetworkDevice implements EcmpSwitchRoutingInterface { @Override public void receive(Packet genericPacket) { TcpHeader tcpHeader = (TcpHeader) genericPacket; if (tcpHeader.getDestinationId() == this.identifier) { this.passToIntermediary(genericPacket); } else { List<Integer> possibilities = destinationToNextSwitch.get(tcpHeader.getDestinationId()); this.targetIdToOutputPort.get(possibilities.get(tcpHeader.getHash(this.identifier) % possibilities.size())).enqueue(genericPacket); } } EcmpSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); @Override void receive(Packet genericPacket); @Override void receiveFromIntermediary(Packet genericPacket); @Override void addDestinationToNextSwitch(int destinationId, int nextHopId); @Override String toString(); }
EcmpSwitch extends NetworkDevice implements EcmpSwitchRoutingInterface { @Override public void receive(Packet genericPacket) { TcpHeader tcpHeader = (TcpHeader) genericPacket; if (tcpHeader.getDestinationId() == this.identifier) { this.passToIntermediary(genericPacket); } else { List<Integer> possibilities = destinationToNextSwitch.get(tcpHeader.getDestinationId()); this.targetIdToOutputPort.get(possibilities.get(tcpHeader.getHash(this.identifier) % possibilities.size())).enqueue(genericPacket); } } EcmpSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); @Override void receive(Packet genericPacket); @Override void receiveFromIntermediary(Packet genericPacket); @Override void addDestinationToNextSwitch(int destinationId, int nextHopId); @Override String toString();  }