org.onosproject.net.pi.runtime.PiPacketMetadata Java Examples

The following examples show how to use org.onosproject.net.pi.runtime.PiPacketMetadata. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PacketMetadataCodec.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
protected PiPacketMetadata decode(
        P4RuntimeOuterClass.PacketMetadata message,
        P4InfoOuterClass.Preamble ctrlPktMetaPreamble,
        PiPipeconf pipeconf, P4InfoBrowser browser)
        throws P4InfoBrowser.NotFoundException {
    final String packetMetadataName = browser
            .packetMetadatas(ctrlPktMetaPreamble.getId())
            .getById(message.getMetadataId()).getName();
    final PiPacketMetadataId metadataId = PiPacketMetadataId
            .of(packetMetadataName);
    return PiPacketMetadata.builder()
            .withId(metadataId)
            .withValue(copyFrom(message.getValue().asReadOnlyByteBuffer()))
            .build();
}
 
Example #2
Source File: PacketInEventTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Setup method for packetOperation and packetOperation2.
 * @throws ImmutableByteSequence.ByteSequenceTrimException if byte sequence cannot be trimmed
 */
@Before
public void setup() throws ImmutableByteSequence.ByteSequenceTrimException {

    packetOperation = PiPacketOperation.builder()
            .withData(ImmutableByteSequence.ofOnes(512))
            .withType(PACKET_OUT)
            .withMetadata(PiPacketMetadata.builder()
                                  .withId(PiPacketMetadataId.of("egress_port"))
                                  .withValue(copyFrom(DEFAULT_ORIGINAL_VALUE).fit(DEFAULT_BIT_WIDTH))
                                  .build())
            .build();

    packetOperation2 = PiPacketOperation.builder()
            .withData(ImmutableByteSequence.ofOnes(512))
            .withType(PACKET_IN)
            .withMetadata(PiPacketMetadata.builder()
                                  .withId(PiPacketMetadataId.of("ingress_port"))
                                  .withValue(copyFrom(DEFAULT_ORIGINAL_VALUE).fit(DEFAULT_BIT_WIDTH))
                                  .build())
            .build();

    packetIn = new org.onosproject.p4runtime.ctl.controller.PacketInEvent(deviceId, packetOperation);
    sameAsPacketIn = new org.onosproject.p4runtime.ctl.controller.PacketInEvent(sameDeviceId, packetOperation);
    packetIn2 = new org.onosproject.p4runtime.ctl.controller.PacketInEvent(deviceId2, packetOperation);
    packetIn3 = new org.onosproject.p4runtime.ctl.controller.PacketInEvent(deviceId, packetOperation2);
}
 
Example #3
Source File: PipelineInterpreterImpl.java    From onos with Apache License 2.0 5 votes vote down vote up
private PiPacketMetadata createPacketMetadata(long portNumber)
        throws PiInterpreterException {
    try {
        return PiPacketMetadata.builder()
                .withId(PiPacketMetadataId.of(EGRESS_PORT))
                .withValue(copyFrom(portNumber).fit(PORT_FIELD_BITWIDTH))
                .build();
    } catch (ImmutableByteSequence.ByteSequenceTrimException e) {
        throw new PiInterpreterException(format(
                "Port number %d too big, %s", portNumber, e.getMessage()));
    }
}
 
Example #4
Source File: PipelineInterpreterImpl.java    From onos with Apache License 2.0 5 votes vote down vote up
private PiPacketOperation createPiPacketOp(ByteBuffer data, long portNumber)
        throws PiInterpreterException {
    PiPacketMetadata metadata = createPacketMetadata(portNumber);
    return PiPacketOperation.builder()
            .withType(PACKET_OUT)
            .withData(copyFrom(data))
            .withMetadatas(ImmutableList.of(metadata))
            .build();
}
 
Example #5
Source File: PipelineInterpreterImpl.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId)
        throws PiInterpreterException {
    // We assume that the packet is ethernet, which is fine since mytunnel.p4
    // can deparse only ethernet packets.
    Ethernet ethPkt;

    try {
        ethPkt = Ethernet.deserializer().deserialize(
                packetIn.data().asArray(), 0, packetIn.data().size());
    } catch (DeserializationException dex) {
        throw new PiInterpreterException(dex.getMessage());
    }

    // Returns the ingress port packet metadata.
    Optional<PiPacketMetadata> packetMetadata = packetIn.metadatas().stream()
            .filter(metadata -> metadata.id().toString().equals(INGRESS_PORT))
            .findFirst();

    if (packetMetadata.isPresent()) {
        short s = packetMetadata.get().value().asReadOnlyBuffer().getShort();
        ConnectPoint receivedFrom = new ConnectPoint(
                deviceId, PortNumber.portNumber(s));
        return new DefaultInboundPacket(
                receivedFrom, ethPkt, packetIn.data().asReadOnlyBuffer());
    } else {
        throw new PiInterpreterException(format(
                "Missing metadata '%s' in packet-in received from '%s': %s",
                INGRESS_PORT, deviceId, packetIn));
    }
}
 
Example #6
Source File: BasicInterpreterImpl.java    From onos with Apache License 2.0 5 votes vote down vote up
private PiPacketMetadata createPacketMetadata(long portNumber) throws PiInterpreterException {
    try {
        return PiPacketMetadata.builder()
                .withId(EGRESS_PORT)
                .withValue(copyFrom(portNumber).fit(PORT_BITWIDTH))
                .build();
    } catch (ImmutableByteSequence.ByteSequenceTrimException e) {
        throw new PiInterpreterException(format(
                "Port number %d too big, %s", portNumber, e.getMessage()));
    }
}
 
Example #7
Source File: BasicInterpreterImpl.java    From onos with Apache License 2.0 5 votes vote down vote up
private PiPacketOperation createPiPacketOperation(ByteBuffer data, long portNumber)
        throws PiInterpreterException {
    PiPacketMetadata metadata = createPacketMetadata(portNumber);
    return PiPacketOperation.builder()
            .withType(PACKET_OUT)
            .withData(copyFrom(data))
            .withMetadatas(ImmutableList.of(metadata))
            .build();
}
 
Example #8
Source File: BasicInterpreterImpl.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId)
        throws PiInterpreterException {
    // Assuming that the packet is ethernet, which is fine since basic.p4
    // can deparse only ethernet packets.
    Ethernet ethPkt;
    try {
        ethPkt = Ethernet.deserializer().deserialize(packetIn.data().asArray(), 0,
                                                     packetIn.data().size());
    } catch (DeserializationException dex) {
        throw new PiInterpreterException(dex.getMessage());
    }

    // Returns the ingress port packet metadata.
    Optional<PiPacketMetadata> packetMetadata = packetIn.metadatas()
            .stream().filter(m -> m.id().equals(INGRESS_PORT))
            .findFirst();

    if (packetMetadata.isPresent()) {
        ImmutableByteSequence portByteSequence = packetMetadata.get().value();
        short s = portByteSequence.asReadOnlyBuffer().getShort();
        ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(s));
        ByteBuffer rawData = ByteBuffer.wrap(packetIn.data().asArray());
        return new DefaultInboundPacket(receivedFrom, ethPkt, rawData);
    } else {
        throw new PiInterpreterException(format(
                "Missing metadata '%s' in packet-in received from '%s': %s",
                INGRESS_PORT, deviceId, packetIn));
    }
}
 
Example #9
Source File: FabricInterpreter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId) throws PiInterpreterException {
    // Assuming that the packet is ethernet, which is fine since fabric.p4
    // can deparse only ethernet packets.
    Ethernet ethPkt;
    try {
        ethPkt = Ethernet.deserializer().deserialize(packetIn.data().asArray(), 0,
                                                     packetIn.data().size());
    } catch (DeserializationException dex) {
        throw new PiInterpreterException(dex.getMessage());
    }

    // Returns the ingress port packet metadata.
    Optional<PiPacketMetadata> packetMetadata = packetIn.metadatas()
            .stream().filter(m -> m.id().equals(FabricConstants.INGRESS_PORT))
            .findFirst();

    if (packetMetadata.isPresent()) {
        ImmutableByteSequence portByteSequence = packetMetadata.get().value();
        short s = portByteSequence.asReadOnlyBuffer().getShort();
        ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(s));
        ByteBuffer rawData = ByteBuffer.wrap(packetIn.data().asArray());
        return new DefaultInboundPacket(receivedFrom, ethPkt, rawData);
    } else {
        throw new PiInterpreterException(format(
                "Missing metadata '%s' in packet-in received from '%s': %s",
                FabricConstants.INGRESS_PORT, deviceId, packetIn));
    }
}
 
Example #10
Source File: FabricInterpreter.java    From onos with Apache License 2.0 5 votes vote down vote up
private PiPacketMetadata createPacketMetadata(long portNumber)
        throws PiInterpreterException {
    try {
        return PiPacketMetadata.builder()
                .withId(FabricConstants.EGRESS_PORT)
                .withValue(copyFrom(portNumber).fit(PORT_BITWIDTH))
                .build();
    } catch (ImmutableByteSequence.ByteSequenceTrimException e) {
        throw new PiInterpreterException(format(
                "Port number '%d' too big, %s", portNumber, e.getMessage()));
    }
}
 
Example #11
Source File: FabricInterpreter.java    From onos with Apache License 2.0 5 votes vote down vote up
private PiPacketOperation createPiPacketOperation(
        DeviceId deviceId, ByteBuffer data, long portNumber)
        throws PiInterpreterException {
    PiPacketMetadata metadata = createPacketMetadata(portNumber);
    return PiPacketOperation.builder()
            .withType(PACKET_OUT)
            .withData(copyFrom(data))
            .withMetadatas(ImmutableList.of(metadata))
            .build();
}
 
Example #12
Source File: InterpreterImpl.java    From ngsdn-tutorial with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a pipeconf-specific packet-out instance with the given payload and
 * egress port.
 *
 * @param pktData    packet payload
 * @param portNumber egress port
 * @return packet-out
 * @throws PiInterpreterException if packet-out cannot be built
 */
private PiPacketOperation buildPacketOut(ByteBuffer pktData, long portNumber)
        throws PiInterpreterException {

    // Make sure port number can fit in v1model port metadata bitwidth.
    final ImmutableByteSequence portBytes;
    try {
        portBytes = copyFrom(portNumber).fit(V1MODEL_PORT_BITWIDTH);
    } catch (ImmutableByteSequence.ByteSequenceTrimException e) {
        throw new PiInterpreterException(format(
                "Port number %d too big, %s", portNumber, e.getMessage()));
    }

    // Create metadata instance for egress port.
    // TODO EXERCISE 3: modify metadata names to match P4 program
    // ---- START SOLUTION ----
    final String outPortMetadataName = "egress_port";
    // ---- END SOLUTION ----
    final PiPacketMetadata outPortMetadata = PiPacketMetadata.builder()
            .withId(PiPacketMetadataId.of(outPortMetadataName))
            .withValue(portBytes)
            .build();

    // Build packet out.
    return PiPacketOperation.builder()
            .withType(PACKET_OUT)
            .withData(copyFrom(pktData))
            .withMetadata(outPortMetadata)
            .build();
}
 
Example #13
Source File: PacketMetadataCodec.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected P4RuntimeOuterClass.PacketMetadata encode(
        PiPacketMetadata piEntity, P4InfoOuterClass.Preamble ctrlPktMetaPreamble,
        PiPipeconf pipeconf, P4InfoBrowser browser)
        throws P4InfoBrowser.NotFoundException {
    final int metadataId = browser
            .packetMetadatas(ctrlPktMetaPreamble.getId())
            .getByName(piEntity.id().id()).getId();
    return P4RuntimeOuterClass.PacketMetadata.newBuilder()
            .setMetadataId(metadataId)
            .setValue(ByteString.copyFrom(piEntity.value().asReadOnlyBuffer()))
            .build();
}
 
Example #14
Source File: InterpreterImpl.java    From onos-p4-tutorial with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a pipeconf-specific packet-out instance with the given payload and
 * egress port.
 *
 * @param pktData    packet payload
 * @param portNumber egress port
 * @return packet-out
 * @throws PiInterpreterException if packet-out cannot be built
 */
private PiPacketOperation buildPacketOut(ByteBuffer pktData, long portNumber)
        throws PiInterpreterException {

    // Make sure port number can fit in v1model port metadata bitwidth.
    final ImmutableByteSequence portBytes;
    try {
        portBytes = copyFrom(portNumber).fit(V1MODEL_PORT_BITWIDTH);
    } catch (ImmutableByteSequence.ByteSequenceTrimException e) {
        throw new PiInterpreterException(format(
                "Port number %d too big, %s", portNumber, e.getMessage()));
    }

    // Create metadata instance for egress port.
    // TODO EXERCISE 1: modify metadata names to match P4 program
    // ---- START SOLUTION ----
    final String outPortMetadataName = "MODIFY ME";
    // ---- END SOLUTION ----
    final PiPacketMetadata outPortMetadata = PiPacketMetadata.builder()
            .withId(PiPacketMetadataId.of(outPortMetadataName))
            .withValue(portBytes)
            .build();

    // Build packet out.
    return PiPacketOperation.builder()
            .withType(PACKET_OUT)
            .withData(copyFrom(pktData))
            .withMetadata(outPortMetadata)
            .build();
}
 
Example #15
Source File: InterpreterImpl.java    From onos-p4-tutorial with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a pipeconf-specific packet-out instance with the given payload and
 * egress port.
 *
 * @param pktData    packet payload
 * @param portNumber egress port
 * @return packet-out
 * @throws PiInterpreterException if packet-out cannot be built
 */
private PiPacketOperation buildPacketOut(ByteBuffer pktData, long portNumber)
        throws PiInterpreterException {

    // Make sure port number can fit in v1model port metadata bitwidth.
    final ImmutableByteSequence portBytes;
    try {
        portBytes = copyFrom(portNumber).fit(V1MODEL_PORT_BITWIDTH);
    } catch (ImmutableByteSequence.ByteSequenceTrimException e) {
        throw new PiInterpreterException(format(
                "Port number %d too big, %s", portNumber, e.getMessage()));
    }

    // Create metadata instance for egress port.
    // TODO EXERCISE 1: modify metadata names to match P4 program
    // ---- START SOLUTION ----
    final String outPortMetadataName = "egress_port";
    // ---- END SOLUTION ----
    final PiPacketMetadata outPortMetadata = PiPacketMetadata.builder()
            .withId(PiPacketMetadataId.of(outPortMetadataName))
            .withValue(portBytes)
            .build();

    // Build packet out.
    return PiPacketOperation.builder()
            .withType(PACKET_OUT)
            .withData(copyFrom(pktData))
            .withMetadata(outPortMetadata)
            .build();
}
 
Example #16
Source File: InterpreterImpl.java    From ngsdn-tutorial with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a pipeconf-specific packet-out instance with the given payload and
 * egress port.
 *
 * @param pktData    packet payload
 * @param portNumber egress port
 * @return packet-out
 * @throws PiInterpreterException if packet-out cannot be built
 */
private PiPacketOperation buildPacketOut(ByteBuffer pktData, long portNumber)
        throws PiInterpreterException {

    // Make sure port number can fit in v1model port metadata bitwidth.
    final ImmutableByteSequence portBytes;
    try {
        portBytes = copyFrom(portNumber).fit(V1MODEL_PORT_BITWIDTH);
    } catch (ImmutableByteSequence.ByteSequenceTrimException e) {
        throw new PiInterpreterException(format(
                "Port number %d too big, %s", portNumber, e.getMessage()));
    }

    // Create metadata instance for egress port.
    // *** TODO EXERCISE 3: modify metadata names to match P4 program
    // ---- START SOLUTION ----
    final String outPortMetadataName = "<ADD HERE METADATA NAME FOR THE EGRESS PORT>";
    // ---- END SOLUTION ----
    final PiPacketMetadata outPortMetadata = PiPacketMetadata.builder()
            .withId(PiPacketMetadataId.of(outPortMetadataName))
            .withValue(portBytes)
            .build();

    // Build packet out.
    return PiPacketOperation.builder()
            .withType(PACKET_OUT)
            .withData(copyFrom(pktData))
            .withMetadata(outPortMetadata)
            .build();
}
 
Example #17
Source File: InterpreterImpl.java    From onos-p4-tutorial with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an ONS InboundPacket equivalent to the given pipeconf-specific
 * packet-in operation.
 *
 * @param packetIn packet operation
 * @param deviceId ID of the device that originated the packet-in
 * @return inbound packet
 * @throws PiInterpreterException if the packet operation cannot be mapped
 *                                to an inbound packet
 */
@Override
public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId)
        throws PiInterpreterException {

    // Find the ingress_port metadata.
    // TODO EXERCISE 1: modify metadata names to match P4 program
    // ---- START SOLUTION ----
    final String inportMetadataName = "MODIFY ME";
    // ---- END SOLUTION ----
    Optional<PiPacketMetadata> inportMetadata = packetIn.metadatas()
            .stream()
            .filter(meta -> meta.id().id().equals(inportMetadataName))
            .findFirst();

    if (!inportMetadata.isPresent()) {
        throw new PiInterpreterException(format(
                "Missing metadata '%s' in packet-in received from '%s': %s",
                inportMetadataName, deviceId, packetIn));
    }

    // Build ONOS InboundPacket instance with the given ingress port.

    // 1. Parse packet-in object into Ethernet packet instance.
    final byte[] payloadBytes = packetIn.data().asArray();
    final ByteBuffer rawData = ByteBuffer.wrap(payloadBytes);
    final Ethernet ethPkt;
    try {
        ethPkt = Ethernet.deserializer().deserialize(
                payloadBytes, 0, packetIn.data().size());
    } catch (DeserializationException dex) {
        throw new PiInterpreterException(dex.getMessage());
    }

    // 2. Get ingress port
    final ImmutableByteSequence portBytes = inportMetadata.get().value();
    final short portNum = portBytes.asReadOnlyBuffer().getShort();
    final ConnectPoint receivedFrom = new ConnectPoint(
            deviceId, PortNumber.portNumber(portNum));

    return new DefaultInboundPacket(receivedFrom, ethPkt, rawData);
}
 
Example #18
Source File: InterpreterImpl.java    From onos-p4-tutorial with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an ONS InboundPacket equivalent to the given pipeconf-specific
 * packet-in operation.
 *
 * @param packetIn packet operation
 * @param deviceId ID of the device that originated the packet-in
 * @return inbound packet
 * @throws PiInterpreterException if the packet operation cannot be mapped
 *                                to an inbound packet
 */
@Override
public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId)
        throws PiInterpreterException {

    // Find the ingress_port metadata.
    // TODO EXERCISE 1: modify metadata names to match P4 program
    // ---- START SOLUTION ----
    final String inportMetadataName = "ingress_port";
    // ---- END SOLUTION ----
    Optional<PiPacketMetadata> inportMetadata = packetIn.metadatas()
            .stream()
            .filter(meta -> meta.id().id().equals(inportMetadataName))
            .findFirst();

    if (!inportMetadata.isPresent()) {
        throw new PiInterpreterException(format(
                "Missing metadata '%s' in packet-in received from '%s': %s",
                inportMetadataName, deviceId, packetIn));
    }

    // Build ONOS InboundPacket instance with the given ingress port.

    // 1. Parse packet-in object into Ethernet packet instance.
    final byte[] payloadBytes = packetIn.data().asArray();
    final ByteBuffer rawData = ByteBuffer.wrap(payloadBytes);
    final Ethernet ethPkt;
    try {
        ethPkt = Ethernet.deserializer().deserialize(
                payloadBytes, 0, packetIn.data().size());
    } catch (DeserializationException dex) {
        throw new PiInterpreterException(dex.getMessage());
    }

    // 2. Get ingress port
    final ImmutableByteSequence portBytes = inportMetadata.get().value();
    final short portNum = portBytes.asReadOnlyBuffer().getShort();
    final ConnectPoint receivedFrom = new ConnectPoint(
            deviceId, PortNumber.portNumber(portNum));

    return new DefaultInboundPacket(receivedFrom, ethPkt, rawData);
}
 
Example #19
Source File: InterpreterImpl.java    From ngsdn-tutorial with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an ONS InboundPacket equivalent to the given pipeconf-specific
 * packet-in operation.
 *
 * @param packetIn packet operation
 * @param deviceId ID of the device that originated the packet-in
 * @return inbound packet
 * @throws PiInterpreterException if the packet operation cannot be mapped
 *                                to an inbound packet
 */
@Override
public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId)
        throws PiInterpreterException {

    // Find the ingress_port metadata.
    // *** TODO EXERCISE 3: modify metadata names to match P4Info
    // ---- START SOLUTION ----
    final String inportMetadataName = "<ADD HERE METADATA NAME FOR THE INGRESS PORT>";
    // ---- END SOLUTION ----
    Optional<PiPacketMetadata> inportMetadata = packetIn.metadatas()
            .stream()
            .filter(meta -> meta.id().id().equals(inportMetadataName))
            .findFirst();

    if (!inportMetadata.isPresent()) {
        throw new PiInterpreterException(format(
                "Missing metadata '%s' in packet-in received from '%s': %s",
                inportMetadataName, deviceId, packetIn));
    }

    // Build ONOS InboundPacket instance with the given ingress port.

    // 1. Parse packet-in object into Ethernet packet instance.
    final byte[] payloadBytes = packetIn.data().asArray();
    final ByteBuffer rawData = ByteBuffer.wrap(payloadBytes);
    final Ethernet ethPkt;
    try {
        ethPkt = Ethernet.deserializer().deserialize(
                payloadBytes, 0, packetIn.data().size());
    } catch (DeserializationException dex) {
        throw new PiInterpreterException(dex.getMessage());
    }

    // 2. Get ingress port
    final ImmutableByteSequence portBytes = inportMetadata.get().value();
    final short portNum = portBytes.asReadOnlyBuffer().getShort();
    final ConnectPoint receivedFrom = new ConnectPoint(
            deviceId, PortNumber.portNumber(portNum));

    return new DefaultInboundPacket(receivedFrom, ethPkt, rawData);
}
 
Example #20
Source File: InterpreterImpl.java    From ngsdn-tutorial with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an ONS InboundPacket equivalent to the given pipeconf-specific
 * packet-in operation.
 *
 * @param packetIn packet operation
 * @param deviceId ID of the device that originated the packet-in
 * @return inbound packet
 * @throws PiInterpreterException if the packet operation cannot be mapped
 *                                to an inbound packet
 */
@Override
public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId)
        throws PiInterpreterException {

    // Find the ingress_port metadata.
    // TODO EXERCISE 3: modify metadata names to match P4 program
    // ---- START SOLUTION ----
    final String inportMetadataName = "ingress_port";
    // ---- END SOLUTION ----
    Optional<PiPacketMetadata> inportMetadata = packetIn.metadatas()
            .stream()
            .filter(meta -> meta.id().id().equals(inportMetadataName))
            .findFirst();

    if (!inportMetadata.isPresent()) {
        throw new PiInterpreterException(format(
                "Missing metadata '%s' in packet-in received from '%s': %s",
                inportMetadataName, deviceId, packetIn));
    }

    // Build ONOS InboundPacket instance with the given ingress port.

    // 1. Parse packet-in object into Ethernet packet instance.
    final byte[] payloadBytes = packetIn.data().asArray();
    final ByteBuffer rawData = ByteBuffer.wrap(payloadBytes);
    final Ethernet ethPkt;
    try {
        ethPkt = Ethernet.deserializer().deserialize(
                payloadBytes, 0, packetIn.data().size());
    } catch (DeserializationException dex) {
        throw new PiInterpreterException(dex.getMessage());
    }

    // 2. Get ingress port
    final ImmutableByteSequence portBytes = inportMetadata.get().value();
    final short portNum = portBytes.asReadOnlyBuffer().getShort();
    final ConnectPoint receivedFrom = new ConnectPoint(
            deviceId, PortNumber.portNumber(portNum));

    return new DefaultInboundPacket(receivedFrom, ethPkt, rawData);
}