Search in sources :

Example 1 with Data

use of org.onlab.packet.Data in project onos by opennetworkinglab.

the class BaseOptionsTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    data = new Data();
    data.setData("testSerialize".getBytes());
    udp = new UDP();
    udp.setPayload(data);
    byte[] bytePayload = udp.serialize();
    byte[] byteHeader = { (byte) 0x11, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00 };
    bytePacket = new byte[byteHeader.length + bytePayload.length];
    System.arraycopy(byteHeader, 0, bytePacket, 0, byteHeader.length);
    System.arraycopy(bytePayload, 0, bytePacket, byteHeader.length, bytePayload.length);
}
Also used : UDP(org.onlab.packet.UDP) Data(org.onlab.packet.Data) BeforeClass(org.junit.BeforeClass)

Example 2 with Data

use of org.onlab.packet.Data in project onos by opennetworkinglab.

the class FragmentTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    data = new Data();
    data.setData("testSerialize".getBytes());
    udp = new UDP();
    udp.setPayload(data);
    byte[] bytePayload = udp.serialize();
    byte[] byteHeader = { (byte) 0x11, (byte) 0x00, (byte) 0x00, (byte) 0xf9, (byte) 0x00, (byte) 0x00, (byte) 0x13, (byte) 0x57 };
    bytePacket = new byte[byteHeader.length + bytePayload.length];
    System.arraycopy(byteHeader, 0, bytePacket, 0, byteHeader.length);
    System.arraycopy(bytePayload, 0, bytePacket, byteHeader.length, bytePayload.length);
}
Also used : UDP(org.onlab.packet.UDP) Data(org.onlab.packet.Data) BeforeClass(org.junit.BeforeClass)

Example 3 with Data

use of org.onlab.packet.Data in project onos by opennetworkinglab.

the class RoutingTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    data = new Data();
    data.setData("testSerialize".getBytes());
    udp = new UDP();
    udp.setPayload(data);
    byte[] bytePayload = udp.serialize();
    byte[] byteHeader = { (byte) 0x11, (byte) 0x02, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x20, (byte) 0x01, (byte) 0x0f, (byte) 0x18, (byte) 0x01, (byte) 0x13, (byte) 0x02, (byte) 0x15, (byte) 0xca, (byte) 0x2a, (byte) 0x14, (byte) 0xff, (byte) 0xfe, (byte) 0x35, (byte) 0x26, (byte) 0xce };
    bytePacket = new byte[byteHeader.length + bytePayload.length];
    System.arraycopy(byteHeader, 0, bytePacket, 0, byteHeader.length);
    System.arraycopy(bytePayload, 0, bytePacket, byteHeader.length, bytePayload.length);
}
Also used : UDP(org.onlab.packet.UDP) Data(org.onlab.packet.Data) BeforeClass(org.junit.BeforeClass)

Example 4 with Data

use of org.onlab.packet.Data in project fabric-tna by stratum.

the class FabricInterpreterTest method testMapInboundPacket.

@Test
public void testMapInboundPacket() throws ImmutableByteSequence.ByteSequenceTrimException, PiPipelineInterpreter.PiInterpreterException {
    PortNumber inputPort = PortNumber.portNumber(1);
    PiPacketMetadata pktInMetadata = PiPacketMetadata.builder().withId(P4InfoConstants.INGRESS_PORT).withValue(ImmutableByteSequence.copyFrom(inputPort.toLong()).fit(P4InfoConstants.INGRESS_PORT_BITWIDTH)).build();
    Ethernet packet = new Ethernet();
    packet.setDestinationMACAddress(SRC_MAC);
    packet.setSourceMACAddress(DST_MAC);
    packet.setEtherType((short) 0xBA00);
    packet.setPayload(new Data());
    PiPacketOperation pktInOp = PiPacketOperation.builder().withMetadata(pktInMetadata).withData(ImmutableByteSequence.copyFrom(packet.serialize())).withType(PiPacketOperationType.PACKET_IN).build();
    InboundPacket result = interpreter.mapInboundPacket(pktInOp, DEVICE_ID);
    ConnectPoint receiveFrom = new ConnectPoint(DEVICE_ID, inputPort);
    InboundPacket expectedInboundPacket = new DefaultInboundPacket(receiveFrom, packet, ByteBuffer.wrap(packet.serialize()));
    assertEquals(result.receivedFrom(), expectedInboundPacket.receivedFrom());
    assertEquals(result.parsed(), expectedInboundPacket.parsed());
    assertEquals(result.cookie(), expectedInboundPacket.cookie());
    assertEquals(result.unparsed(), expectedInboundPacket.unparsed());
}
Also used : DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) PiPacketMetadata(org.onosproject.net.pi.runtime.PiPacketMetadata) Ethernet(org.onlab.packet.Ethernet) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) InboundPacket(org.onosproject.net.packet.InboundPacket) PiPacketOperation(org.onosproject.net.pi.runtime.PiPacketOperation) DriverData(org.onosproject.net.driver.DriverData) Data(org.onlab.packet.Data) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 5 with Data

use of org.onlab.packet.Data in project fabric-tna by stratum.

the class FabricInterpreterTest method testMapInboundPacketWithPortTranslation.

@Test
public void testMapInboundPacketWithPortTranslation() throws ImmutableByteSequence.ByteSequenceTrimException, PiPipelineInterpreter.PiInterpreterException {
    PortNumber inputPort = PortNumber.portNumber(1, "ONE");
    ConnectPoint receiveFrom = new ConnectPoint(DEVICE_ID, inputPort);
    Port port = createNiceMock(Port.class);
    expect(port.number()).andReturn(inputPort).anyTimes();
    replay(port);
    expect(deviceService.getPort(receiveFrom)).andReturn(port).anyTimes();
    replay(deviceService);
    PiPacketMetadata pktInMetadata = PiPacketMetadata.builder().withId(P4InfoConstants.INGRESS_PORT).withValue(ImmutableByteSequence.copyFrom(inputPort.toLong()).fit(P4InfoConstants.INGRESS_PORT_BITWIDTH)).build();
    Ethernet packet = new Ethernet();
    packet.setDestinationMACAddress(SRC_MAC);
    packet.setSourceMACAddress(DST_MAC);
    packet.setEtherType((short) 0xBA00);
    packet.setPayload(new Data());
    PiPacketOperation pktInOp = PiPacketOperation.builder().withMetadata(pktInMetadata).withData(ImmutableByteSequence.copyFrom(packet.serialize())).withType(PiPacketOperationType.PACKET_IN).build();
    InboundPacket result = interpreter.mapInboundPacket(pktInOp, DEVICE_ID);
    InboundPacket expectedInboundPacket = new DefaultInboundPacket(receiveFrom, packet, ByteBuffer.wrap(packet.serialize()));
    assertEquals(result.receivedFrom(), expectedInboundPacket.receivedFrom());
    assertEquals(result.receivedFrom().port().name(), expectedInboundPacket.receivedFrom().port().name());
    assertEquals(result.parsed(), expectedInboundPacket.parsed());
    assertEquals(result.cookie(), expectedInboundPacket.cookie());
    assertEquals(result.unparsed(), expectedInboundPacket.unparsed());
}
Also used : DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) PiPacketMetadata(org.onosproject.net.pi.runtime.PiPacketMetadata) Port(org.onosproject.net.Port) Ethernet(org.onlab.packet.Ethernet) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) InboundPacket(org.onosproject.net.packet.InboundPacket) PiPacketOperation(org.onosproject.net.pi.runtime.PiPacketOperation) DriverData(org.onosproject.net.driver.DriverData) Data(org.onlab.packet.Data) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Aggregations

Data (org.onlab.packet.Data)8 BeforeClass (org.junit.BeforeClass)4 Test (org.junit.Test)4 Ethernet (org.onlab.packet.Ethernet)4 UDP (org.onlab.packet.UDP)4 ConnectPoint (org.onosproject.net.ConnectPoint)4 PortNumber (org.onosproject.net.PortNumber)4 DriverData (org.onosproject.net.driver.DriverData)4 DefaultInboundPacket (org.onosproject.net.packet.DefaultInboundPacket)4 InboundPacket (org.onosproject.net.packet.InboundPacket)4 PiPacketMetadata (org.onosproject.net.pi.runtime.PiPacketMetadata)4 PiPacketOperation (org.onosproject.net.pi.runtime.PiPacketOperation)4 Port (org.onosproject.net.Port)1