Search in sources :

Example 26 with DefaultOutboundPacket

use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.

the class NeighbourResolutionManagerTest method context.

/**
 * Creates a packet context for the given packet coming in the given port.
 *
 * @param packet packet to wrap in a packet context
 * @param inPort input port of the packet
 * @return packet context
 */
private static PacketContext context(Ethernet packet, ConnectPoint inPort) {
    InboundPacket inboundPacket = new DefaultInboundPacket(inPort, packet, null);
    OutboundPacket outboundPacket = new DefaultOutboundPacket(null, null, null);
    return new PacketContextAdapter(0, inboundPacket, outboundPacket, false);
}
Also used : DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContextAdapter(org.onosproject.net.packet.PacketContextAdapter) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) OutboundPacket(org.onosproject.net.packet.OutboundPacket) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket)

Example 27 with DefaultOutboundPacket

use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.

the class PacketManagerTest method packetProviderfallbackBasics.

/**
 * Tests the correct usage of fallback driver provider for packets.
 */
@Test
public void packetProviderfallbackBasics() {
    OutboundPacket packet = new DefaultOutboundPacket(FOO_DID, DefaultTrafficTreatment.emptyTreatment(), ByteBuffer.allocate(5));
    mgr.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)

Example 28 with DefaultOutboundPacket

use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.

the class LinkDiscovery method createOutBoundLldp.

/**
 * Creates packet_out LLDP for specified output port.
 *
 * @param portNumber the port
 * @param portDesc the port description
 * @return Packet_out message with LLDP data
 */
private OutboundPacket createOutBoundLldp(Long portNumber, String portDesc) {
    if (portNumber == null) {
        return null;
    }
    ONOSLLDP lldp = getLinkProbe(portNumber, portDesc);
    if (lldp == null) {
        log.warn("Cannot get link probe with portNumber {} and portDesc {} for {} at LLDP packet creation.", portNumber, portDesc, deviceId);
        return null;
    }
    ethPacket.setSourceMACAddress(context.fingerprint()).setPayload(lldp);
    return new DefaultOutboundPacket(deviceId, builder().setOutput(portNumber(portNumber)).build(), ByteBuffer.wrap(ethPacket.serialize()));
}
Also used : ONOSLLDP(org.onlab.packet.ONOSLLDP) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket)

Example 29 with DefaultOutboundPacket

use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.

the class DefaultOutboundPacketSerializer method read.

@Override
public DefaultOutboundPacket read(Kryo kryo, Input input, Class<DefaultOutboundPacket> type) {
    DeviceId sendThrough = (DeviceId) kryo.readClassAndObject(input);
    TrafficTreatment treatment = (TrafficTreatment) kryo.readClassAndObject(input);
    byte[] data = (byte[]) kryo.readClassAndObject(input);
    return new DefaultOutboundPacket(sendThrough, treatment, ByteBuffer.wrap(data));
}
Also used : DeviceId(org.onosproject.net.DeviceId) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 30 with DefaultOutboundPacket

use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.

the class DefaultVirtualPacketProviderTest method devirtualizePacket.

/**
 * Test the virtual outbound packet is delivered to a proper (physical)
 *  device.
 */
@Test
public void devirtualizePacket() {
    TrafficTreatment tr = DefaultTrafficTreatment.builder().setOutput(VPORT_NUM1).build();
    ByteBuffer data = ByteBuffer.wrap("abc".getBytes());
    OutboundPacket vOutPacket = new DefaultOutboundPacket(VDID, tr, data);
    virtualProvider.emit(VNET_ID, vOutPacket);
    assertEquals("The count should be 1", 1, testPacketService.getRequestedPacketCount());
    OutboundPacket pOutPacket = testPacketService.getRequestedPacket(0);
    assertEquals("The packet should be requested on DEV1", DID1, pOutPacket.sendThrough());
    PortNumber outPort = pOutPacket.treatment().allInstructions().stream().filter(i -> i.type() == Instruction.Type.OUTPUT).map(i -> (Instructions.OutputInstruction) i).map(i -> i.port()).findFirst().get();
    assertEquals("The packet should be out at PORT1 of DEV1", PORT_NUM1, outPort);
}
Also used : DefaultApplicationId(org.onosproject.core.DefaultApplicationId) AbstractVirtualProviderService(org.onosproject.incubator.net.virtual.provider.AbstractVirtualProviderService) DefaultPacketContext(org.onosproject.net.packet.DefaultPacketContext) PortNumber(org.onosproject.net.PortNumber) DefaultDevice(org.onosproject.net.DefaultDevice) Link(org.onosproject.net.Link) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Ethernet(org.onlab.packet.Ethernet) Port(org.onosproject.net.Port) After(org.junit.After) ApplicationId(org.onosproject.core.ApplicationId) DefaultLink(org.onosproject.net.DefaultLink) ImmutableSet(com.google.common.collect.ImmutableSet) DefaultPort(org.onosproject.net.DefaultPort) Device(org.onosproject.net.Device) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Set(java.util.Set) VirtualPacketProvider(org.onosproject.incubator.net.virtual.provider.VirtualPacketProvider) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) DefaultVirtualDevice(org.onosproject.incubator.net.virtual.DefaultVirtualDevice) CoreServiceAdapter(org.onosproject.core.CoreServiceAdapter) DeviceId(org.onosproject.net.DeviceId) VirtualPort(org.onosproject.incubator.net.virtual.VirtualPort) DefaultVirtualPort(org.onosproject.incubator.net.virtual.DefaultVirtualPort) VirtualPacketProviderService(org.onosproject.incubator.net.virtual.provider.VirtualPacketProviderService) VirtualNetworkAdminServiceAdapter(org.onosproject.incubator.net.virtual.VirtualNetworkAdminServiceAdapter) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OutboundPacket(org.onosproject.net.packet.OutboundPacket) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) PacketServiceAdapter(org.onosproject.net.packet.PacketServiceAdapter) LinkedList(java.util.LinkedList) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Before(org.junit.Before) TenantId(org.onosproject.net.TenantId) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Instructions(org.onosproject.net.flow.instructions.Instructions) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) Instruction(org.onosproject.net.flow.instructions.Instruction) VlanId(org.onlab.packet.VlanId) Test(org.junit.Test) ProviderId(org.onosproject.net.provider.ProviderId) DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) Assert.assertEquals(org.junit.Assert.assertEquals) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PortNumber(org.onosproject.net.PortNumber) ByteBuffer(java.nio.ByteBuffer) OutboundPacket(org.onosproject.net.packet.OutboundPacket) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) Test(org.junit.Test)

Aggregations

DefaultOutboundPacket (org.onosproject.net.packet.DefaultOutboundPacket)53 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)42 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)41 OutboundPacket (org.onosproject.net.packet.OutboundPacket)32 Ethernet (org.onlab.packet.Ethernet)23 ByteBuffer (java.nio.ByteBuffer)12 ConnectPoint (org.onosproject.net.ConnectPoint)12 PortNumber (org.onosproject.net.PortNumber)11 IpAddress (org.onlab.packet.IpAddress)9 Test (org.junit.Test)8 DeviceId (org.onosproject.net.DeviceId)8 InboundPacket (org.onosproject.net.packet.InboundPacket)7 PacketContext (org.onosproject.net.packet.PacketContext)7 Set (java.util.Set)6 MacAddress (org.onlab.packet.MacAddress)6 ApplicationId (org.onosproject.core.ApplicationId)6 PacketProcessor (org.onosproject.net.packet.PacketProcessor)6 DefaultInboundPacket (org.onosproject.net.packet.DefaultInboundPacket)5 PacketService (org.onosproject.net.packet.PacketService)5 PiPacketOperation (org.onosproject.net.pi.runtime.PiPacketOperation)5