Search in sources :

Example 16 with DefaultInboundPacket

use of org.onosproject.net.packet.DefaultInboundPacket in project dhcpl2relay by opencord.

the class DhcpL2RelayTestBase method sendPacket.

/**
 * Sends an Ethernet packet to the process method of the Packet Processor.
 *
 * @param pkt Ethernet packet
 */
void sendPacket(Ethernet pkt, ConnectPoint cp) {
    final ByteBuffer byteBuffer = ByteBuffer.wrap(pkt.serialize());
    InboundPacket inPacket = new DefaultInboundPacket(cp, pkt, byteBuffer);
    PacketContext context = new TestPacketContext(127L, inPacket, null, false);
    packetProcessor.process(context);
}
Also used : DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) InboundPacket(org.onosproject.net.packet.InboundPacket) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) DefaultPacketContext(org.onosproject.net.packet.DefaultPacketContext) PacketContext(org.onosproject.net.packet.PacketContext) ByteBuffer(java.nio.ByteBuffer)

Example 17 with DefaultInboundPacket

use of org.onosproject.net.packet.DefaultInboundPacket in project aaa by opencord.

the class AaaStatisticsTest method testRequestRetransmittedCount.

/*
     * Tests the retransmitted packet and malformed packet count
     *
     * @throws DeserializationException
     *  if packed deserialization fails.
     */
@Test
public void testRequestRetransmittedCount() throws Exception {
    // (1) Supplicant start up
    Ethernet startPacket = constructSupplicantStartPacket();
    sendPacket(startPacket);
    assertAfter(ASSERTION_DELAY, ASSERTION_LENGTH, () -> {
        // (2) Supplicant identify
        Ethernet identifyPacket = null;
        try {
            identifyPacket = constructSupplicantIdentifyPacket(null, EAP.ATTR_IDENTITY, (byte) 1, null);
            sendPacket(identifyPacket);
            RADIUS radiusIdentifyPacket = (RADIUS) fetchPacket(1);
            checkRadiusPacketFromSupplicant(radiusIdentifyPacket);
            // again creating pending state for same packet
            constructSupplicantIdentifyPacket(null, EAP.ATTR_IDENTITY, (byte) 1, null);
            sendPacket(identifyPacket);
        } catch (Exception e) {
            log.error(e.getMessage());
            fail();
        }
    });
    assertAfter(ASSERTION_DELAY, ASSERTION_LENGTH, () -> {
        aaaManager.impl.handlePacketFromServer(null);
        aaaManager.aaaStatisticsManager.calculatePacketRoundtripTime();
        // creating malformed packet
        final ByteBuffer byteBuffer = ByteBuffer.wrap(startPacket.serialize());
        InboundPacket inPacket = new DefaultInboundPacket(connectPoint("1", 1), startPacket, byteBuffer);
        PacketContext context = new TestPacketContext(127L, inPacket, null, false);
        aaaManager.impl.handlePacketFromServer(context);
        // Check for increase of Stats
        assertNotEquals(aaaStatisticsManager.getAaaStats().getEapolResIdentityMsgTrans(), ZERO);
        assertNotEquals(aaaStatisticsManager.getAaaStats().getEapolStartReqRx(), ZERO);
        assertNotEquals(aaaStatisticsManager.getAaaStats().getRadiusAccessRequestsTx(), ZERO);
        assertNotEquals(aaaStatisticsManager.getAaaStats().getDroppedResponsesRx(), ZERO);
        assertNotEquals(aaaStatisticsManager.getAaaStats().getRadiusPendingRequests(), ZERO);
        assertNotEquals(aaaStatisticsManager.getAaaStats().getMalformedResponsesRx(), ZERO);
        assertNotEquals(aaaStatisticsManager.getAaaStats().getRequestReTx(), ZERO);
        assertNotEquals(aaaStatisticsManager.getAaaStats().getUnknownTypeRx(), ZERO);
        assertNotEquals(aaaStatisticsManager.getAaaStats().getUnknownServerRx(), ZERO);
        countAaaStatistics();
    });
}
Also used : RADIUS(org.onlab.packet.RADIUS) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) Ethernet(org.onlab.packet.Ethernet) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) ByteBuffer(java.nio.ByteBuffer) DeserializationException(org.onlab.packet.DeserializationException) UnknownHostException(java.net.UnknownHostException) Test(org.junit.Test)

Example 18 with DefaultInboundPacket

use of org.onosproject.net.packet.DefaultInboundPacket in project aaa by opencord.

the class AaaTestBase method sendPacket.

/**
 * Sends an Ethernet packet to the process method of the Packet Processor.
 *
 * @param reply Ethernet packet
 */
void sendPacket(Ethernet reply) {
    final ByteBuffer byteBuffer = ByteBuffer.wrap(reply.serialize());
    InboundPacket inPacket = new DefaultInboundPacket(connectPoint("1", 1), reply, byteBuffer);
    PacketContext context = new TestPacketContext(127L, inPacket, null, false);
    packetProcessor.process(context);
}
Also used : DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) InboundPacket(org.onosproject.net.packet.InboundPacket) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) DefaultPacketContext(org.onosproject.net.packet.DefaultPacketContext) PacketContext(org.onosproject.net.packet.PacketContext) ByteBuffer(java.nio.ByteBuffer)

Example 19 with DefaultInboundPacket

use of org.onosproject.net.packet.DefaultInboundPacket in project fabric-tna by stratum.

the class FabricInterpreterTest method testMapInboundPacketWithShortMetadata.

@Test
public void testMapInboundPacketWithShortMetadata() throws ImmutableByteSequence.ByteSequenceTrimException, PiPipelineInterpreter.PiInterpreterException {
    PortNumber inputPort = PortNumber.portNumber(1);
    PiPacketMetadata pktInMetadata = PiPacketMetadata.builder().withId(P4InfoConstants.INGRESS_PORT).withValue(// deliberately smaller
    ImmutableByteSequence.copyFrom(inputPort.toLong()).fit(8)).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 20 with DefaultInboundPacket

use of org.onosproject.net.packet.DefaultInboundPacket in project fabric-tna by stratum.

the class FabricInterpreterTest method testMapInboundPacketWithCpuPort.

@Test
public void testMapInboundPacketWithCpuPort() throws ImmutableByteSequence.ByteSequenceTrimException, PiPipelineInterpreter.PiInterpreterException {
    PortNumber inputPort = PortNumber.portNumber(Constants.PORT_CPU);
    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)

Aggregations

DefaultInboundPacket (org.onosproject.net.packet.DefaultInboundPacket)20 InboundPacket (org.onosproject.net.packet.InboundPacket)19 ByteBuffer (java.nio.ByteBuffer)12 Ethernet (org.onlab.packet.Ethernet)12 ConnectPoint (org.onosproject.net.ConnectPoint)11 PortNumber (org.onosproject.net.PortNumber)9 PiPacketMetadata (org.onosproject.net.pi.runtime.PiPacketMetadata)9 PiPacketOperation (org.onosproject.net.pi.runtime.PiPacketOperation)9 PacketContext (org.onosproject.net.packet.PacketContext)7 Test (org.junit.Test)6 DeserializationException (org.onlab.packet.DeserializationException)6 DeviceId (org.onosproject.net.DeviceId)6 Port (org.onosproject.net.Port)6 DefaultPacketContext (org.onosproject.net.packet.DefaultPacketContext)6 OutboundPacket (org.onosproject.net.packet.OutboundPacket)6 ImmutableList (com.google.common.collect.ImmutableList)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 String.format (java.lang.String.format)5 Collection (java.util.Collection)5 List (java.util.List)5