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