@Test public void testPassToTransportLayer() { TransportLayer transportLayer = mock(TransportLayer.class); SourceRoutingSwitch device = new SourceRoutingSwitch(4, transportLayer, 5, new IdentityFlowletIntermediary()); device.addConnection(topology.getPort(4, 2)); device.addConnection(topology.getPort(4, 3)); SourceRoutingPath path = new SourceRoutingPath(); path.add(1); path.add(3); path.add(4); when(packet.getDestinationId()).thenReturn(4); SourceRoutingEncapsulation encapsulation = new SourceRoutingEncapsulation(packet, path); encapsulation.nextHop(); encapsulation.nextHop(); device.receive(encapsulation); verify(transportLayer, times(1)).receive(packet); verify(topology.getPort(4, 2), times(0)).enqueue(encapsulation); verify(topology.getPort(4, 3), times(0)).enqueue(encapsulation); }
@Override public void receive(Packet genericPacket) { SourceRoutingEncapsulation encapsulation = (SourceRoutingEncapsulation) genericPacket; if (encapsulation.getDestinationId() == this.identifier) { this.passToIntermediary(encapsulation.getPacket()); } else { this.targetIdToOutputPort.get(encapsulation.nextHop()).enqueue(encapsulation); } }
SourceRoutingSwitch extends NetworkDevice { @Override public void receive(Packet genericPacket) { SourceRoutingEncapsulation encapsulation = (SourceRoutingEncapsulation) genericPacket; if (encapsulation.getDestinationId() == this.identifier) { this.passToIntermediary(encapsulation.getPacket()); } else { this.targetIdToOutputPort.get(encapsulation.nextHop()).enqueue(encapsulation); } } }
SourceRoutingSwitch extends NetworkDevice { @Override public void receive(Packet genericPacket) { SourceRoutingEncapsulation encapsulation = (SourceRoutingEncapsulation) genericPacket; if (encapsulation.getDestinationId() == this.identifier) { this.passToIntermediary(encapsulation.getPacket()); } else { this.targetIdToOutputPort.get(encapsulation.nextHop()).enqueue(encapsulation); } } SourceRoutingSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); }
SourceRoutingSwitch extends NetworkDevice { @Override public void receive(Packet genericPacket) { SourceRoutingEncapsulation encapsulation = (SourceRoutingEncapsulation) genericPacket; if (encapsulation.getDestinationId() == this.identifier) { this.passToIntermediary(encapsulation.getPacket()); } else { this.targetIdToOutputPort.get(encapsulation.nextHop()).enqueue(encapsulation); } } SourceRoutingSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); @Override void receive(Packet genericPacket); List<List<SourceRoutingPath>> getPathsList(); @Override void receiveFromIntermediary(Packet genericPacket); @Override String toString(); }
SourceRoutingSwitch extends NetworkDevice { @Override public void receive(Packet genericPacket) { SourceRoutingEncapsulation encapsulation = (SourceRoutingEncapsulation) genericPacket; if (encapsulation.getDestinationId() == this.identifier) { this.passToIntermediary(encapsulation.getPacket()); } else { this.targetIdToOutputPort.get(encapsulation.nextHop()).enqueue(encapsulation); } } SourceRoutingSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); @Override void receive(Packet genericPacket); List<List<SourceRoutingPath>> getPathsList(); @Override void receiveFromIntermediary(Packet genericPacket); @Override String toString();  }