use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class DirectHostManager method send.
private void send(Ethernet eth, ConnectPoint cp) {
OutboundPacket packet = new DefaultOutboundPacket(cp.deviceId(), DefaultTrafficTreatment.builder().setOutput(cp.port()).build(), ByteBuffer.wrap(eth.serialize()));
packetService.emit(packet);
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class SdnIpReactiveRouting method forwardPacketToDst.
/**
* Emits the specified packet onto the network.
*
* @param context the packet context
* @param connectPoint the connect point where the packet should be
* sent out
*/
private void forwardPacketToDst(PacketContext context, ConnectPoint connectPoint) {
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(connectPoint.port()).build();
OutboundPacket packet = new DefaultOutboundPacket(connectPoint.deviceId(), treatment, context.inPacket().unparsed());
packetService.emit(packet);
log.trace("sending packet: {}", packet);
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class DefaultVirtualPacketProvider method devirtualize.
/**
* Translate the requested virtual outbound packet into
* a set of physical OutboundPacket.
* See {@link org.onosproject.net.packet.OutboundPacket}
*
* @param packet an OutboundPacket to be translated
* @return a set of de-virtualized (physical) OutboundPacket
*/
private Set<OutboundPacket> devirtualize(NetworkId networkId, OutboundPacket packet) {
Set<OutboundPacket> outboundPackets = new HashSet<>();
Set<VirtualPort> vPorts = vnaService.getVirtualPorts(networkId, packet.sendThrough());
TrafficTreatment.Builder commonTreatmentBuilder = DefaultTrafficTreatment.builder();
packet.treatment().allInstructions().stream().filter(i -> i.type() != Instruction.Type.OUTPUT).forEach(i -> commonTreatmentBuilder.add(i));
TrafficTreatment commonTreatment = commonTreatmentBuilder.build();
PortNumber vOutPortNum = packet.treatment().allInstructions().stream().filter(i -> i.type() == Instruction.Type.OUTPUT).map(i -> ((Instructions.OutputInstruction) i).port()).findFirst().get();
if (!vOutPortNum.isLogical()) {
Optional<ConnectPoint> optionalCpOut = vPorts.stream().filter(v -> v.number().equals(vOutPortNum)).map(v -> v.realizedBy()).findFirst();
if (!optionalCpOut.isPresent()) {
log.warn("Port {} is not realized yet, in Network {}, Device {}", vOutPortNum, networkId, packet.sendThrough());
return outboundPackets;
}
ConnectPoint egressPoint = optionalCpOut.get();
TrafficTreatment treatment = DefaultTrafficTreatment.builder(commonTreatment).setOutput(egressPoint.port()).build();
OutboundPacket outboundPacket = new DefaultOutboundPacket(egressPoint.deviceId(), treatment, packet.data());
outboundPackets.add(outboundPacket);
} else {
if (vOutPortNum == PortNumber.FLOOD) {
for (VirtualPort outPort : vPorts) {
ConnectPoint cpOut = outPort.realizedBy();
if (cpOut != null) {
TrafficTreatment treatment = DefaultTrafficTreatment.builder(commonTreatment).setOutput(cpOut.port()).build();
OutboundPacket outboundPacket = new DefaultOutboundPacket(cpOut.deviceId(), treatment, packet.data());
outboundPackets.add(outboundPacket);
} else {
log.warn("Port {} is not realized yet, in Network {}, Device {}", outPort.number(), networkId, packet.sendThrough());
}
}
}
}
return outboundPackets;
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class VirtualNetworkPacketManagerWithDistStoreTest method emit2Test.
/**
* Tests the correct usage of emit() for a outbound packet - master of packet's
* sendThrough is not local node.
*/
@Test
@Ignore("Ignore until there is MastershipService support for virtual devices")
public void emit2Test() {
OutboundPacket packet = new DefaultOutboundPacket(VDID2, DefaultTrafficTreatment.emptyTreatment(), ByteBuffer.allocate(5));
packetManager1.emit(packet);
assertNull("Packet should not have been emmitted", emittedPacket);
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class VirtualNetworkPacketManagerTest method emitTest.
/**
* Tests the correct usage of emit() for a outbound packet.
*/
@Test
public void emitTest() {
OutboundPacket packet = new DefaultOutboundPacket(VDID1, DefaultTrafficTreatment.emptyTreatment(), ByteBuffer.allocate(5));
packetManager1.emit(packet);
assertEquals("Packet not emitted correctly", packet, emittedPacket);
}
Aggregations