Search in sources :

Example 26 with PacketContext

use of org.onosproject.net.packet.PacketContext 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 27 with PacketContext

use of org.onosproject.net.packet.PacketContext 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)

Aggregations

PacketContext (org.onosproject.net.packet.PacketContext)27 ByteBuffer (java.nio.ByteBuffer)14 Ethernet (org.onlab.packet.Ethernet)12 DeviceId (org.onosproject.net.DeviceId)11 InboundPacket (org.onosproject.net.packet.InboundPacket)11 Test (org.junit.Test)10 Logger (org.slf4j.Logger)10 Set (java.util.Set)9 IpAddress (org.onlab.packet.IpAddress)9 DefaultOutboundPacket (org.onosproject.net.packet.DefaultOutboundPacket)9 MacAddress (org.onlab.packet.MacAddress)8 ApplicationId (org.onosproject.core.ApplicationId)8 ConnectPoint (org.onosproject.net.ConnectPoint)8 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)8 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)8 TrafficSelector (org.onosproject.net.flow.TrafficSelector)8 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)8 PacketService (org.onosproject.net.packet.PacketService)8 Executors.newSingleThreadExecutor (java.util.concurrent.Executors.newSingleThreadExecutor)7 Tools.groupedThreads (org.onlab.util.Tools.groupedThreads)7