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();
});
}
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);
}
Aggregations