Search in sources :

Example 1 with OutboundPacket

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);
}
Also used : DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) OutboundPacket(org.onosproject.net.packet.OutboundPacket) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket)

Example 2 with OutboundPacket

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);
}
Also used : DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) OutboundPacket(org.onosproject.net.packet.OutboundPacket) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket)

Example 3 with OutboundPacket

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;
}
Also used : VirtualPort(org.onosproject.incubator.net.virtual.VirtualPort) VirtualNetworkEvent(org.onosproject.incubator.net.virtual.VirtualNetworkEvent) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) ComponentContext(org.osgi.service.component.ComponentContext) VirtualPacketProviderService(org.onosproject.incubator.net.virtual.provider.VirtualPacketProviderService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) HashSet(java.util.HashSet) Ethernet(org.onlab.packet.Ethernet) Component(org.osgi.service.component.annotations.Component) VirtualPacketContext(org.onosproject.incubator.net.virtual.VirtualPacketContext) OutboundPacket(org.onosproject.net.packet.OutboundPacket) ApplicationId(org.onosproject.core.ApplicationId) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) Activate(org.osgi.service.component.annotations.Activate) VirtualProviderRegistryService(org.onosproject.incubator.net.virtual.provider.VirtualProviderRegistryService) TenantId(org.onosproject.net.TenantId) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Instructions(org.onosproject.net.flow.instructions.Instructions) Logger(org.slf4j.Logger) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) Deactivate(org.osgi.service.component.annotations.Deactivate) Instruction(org.onosproject.net.flow.instructions.Instruction) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Set(java.util.Set) PacketService(org.onosproject.net.packet.PacketService) ProviderId(org.onosproject.net.provider.ProviderId) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) VirtualPacketProvider(org.onosproject.incubator.net.virtual.provider.VirtualPacketProvider) VirtualNetworkListener(org.onosproject.incubator.net.virtual.VirtualNetworkListener) AbstractVirtualProvider(org.onosproject.incubator.net.virtual.provider.AbstractVirtualProvider) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) VirtualNetworkAdminService(org.onosproject.incubator.net.virtual.VirtualNetworkAdminService) Optional(java.util.Optional) PacketPriority(org.onosproject.net.packet.PacketPriority) Reference(org.osgi.service.component.annotations.Reference) DeviceId(org.onosproject.net.DeviceId) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualPort(org.onosproject.incubator.net.virtual.VirtualPort) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) Dictionary(java.util.Dictionary) Instructions(org.onosproject.net.flow.instructions.Instructions) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) OutboundPacket(org.onosproject.net.packet.OutboundPacket) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) PortNumber(org.onosproject.net.PortNumber) HashSet(java.util.HashSet)

Example 4 with OutboundPacket

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);
}
Also used : DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) OutboundPacket(org.onosproject.net.packet.OutboundPacket) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with OutboundPacket

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);
}
Also used : DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) OutboundPacket(org.onosproject.net.packet.OutboundPacket) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) Test(org.junit.Test)

Aggregations

OutboundPacket (org.onosproject.net.packet.OutboundPacket)37 DefaultOutboundPacket (org.onosproject.net.packet.DefaultOutboundPacket)28 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)21 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)19 Ethernet (org.onlab.packet.Ethernet)18 Test (org.junit.Test)15 ConnectPoint (org.onosproject.net.ConnectPoint)13 PortNumber (org.onosproject.net.PortNumber)11 DeviceId (org.onosproject.net.DeviceId)10 Instruction (org.onosproject.net.flow.instructions.Instruction)8 ByteBuffer (java.nio.ByteBuffer)7 Device (org.onosproject.net.Device)7 Port (org.onosproject.net.Port)7 InboundPacket (org.onosproject.net.packet.InboundPacket)7 Interface (org.onosproject.net.intf.Interface)6 DefaultInboundPacket (org.onosproject.net.packet.DefaultInboundPacket)6 Optional (java.util.Optional)5 Set (java.util.Set)5 InterfaceService (org.onosproject.net.intf.InterfaceService)5 PacketContext (org.onosproject.net.packet.PacketContext)5