Search in sources :

Example 16 with Packet

use of com.att.aro.core.packetreader.pojo.Packet in project VideoOptimzer by attdevsupport.

the class PacketServiceImplTest method createPacketTest.

@Test
public void createPacketTest() {
    service = (PacketServiceImpl) context.getBean(IPacketService.class);
    ReflectionTestUtils.setField(service, "pcapngHelper", helper);
    byte[] data = new byte[64];
    data[0] = 0;
    data[1] = 0;
    data[2] = 0;
    data[3] = 0;
    ByteBuffer buffer = ByteBuffer.allocate(2);
    // IPV4
    short network = 0x0800;
    buffer.putShort(network);
    buffer.flip();
    byte[] netarr = buffer.array();
    data[12] = netarr[0];
    data[13] = netarr[1];
    data[14] = netarr[0];
    data[15] = netarr[1];
    ByteBuffer datawrap = ByteBuffer.wrap(data);
    short value = datawrap.getShort(12);
    assertEquals(network, value);
    Packet packet = service.createPacketFromPcap(12, 1, 1, 1, data, null);
    packet = service.createPacketFromPcap(1, 1, 1, 1, data, null);
    packet = service.createPacketFromPcap(113, 1, 1, 1, data, null);
    packet = service.createPacketFromPcap(0, 1, 1, 1, data, file.getAbsolutePath());
    packet = service.createPacketFromNetmon(0xe000, 1, 1, 1, data);
    packet = service.createPacketFromNetmon(9, 1, 1, 1, data);
    packet = service.createPacketFromNetmon(8, 1, 1, 1, data);
    packet = service.createPacketFromNetmon(1, 1, 1, 1, data);
    packet = service.createPacketFromNetmon(6, 1, 1, 1, data);
    data[1] = 0x2;
    data[2] = 0x8;
    packet = service.createPacketFromNetmon(6, 1, 1, 1, data);
    // IPV6
    data[6] = 0x6;
    packet = service.createPacket((short) 0x86DD, 1, 1, 1, 0, data);
    boolean ok = false;
    if (packet instanceof TCPPacket) {
        ok = true;
    }
    assertEquals(true, ok);
    data[6] = 0x11;
    packet = service.createPacket((short) 0x86DD, 1, 1, 1, 0, data);
    if (packet instanceof UDPPacket) {
        ok = true;
    }
    assertEquals(true, ok);
    data[6] = 0x8;
    packet = service.createPacket((short) 0x86DD, 1, 1, 1, 0, data);
    // IPV4
    data[9] = 0x6;
    packet = service.createPacket((short) 0x0800, 1, 1, 1, 0, data);
    data[9] = 0x11;
    packet = service.createPacket((short) 0x0800, 1, 1, 1, 0, data);
    data[9] = 0x8;
    packet = service.createPacket((short) 0x0800, 1, 1, 1, 0, data);
    assertNotNull(packet);
}
Also used : UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) Packet(com.att.aro.core.packetreader.pojo.Packet) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) ByteBuffer(java.nio.ByteBuffer) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Aggregations

Packet (com.att.aro.core.packetreader.pojo.Packet)16 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)10 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)8 BaseTest (com.att.aro.core.BaseTest)7 UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 InetAddress (java.net.InetAddress)6 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)5 Session (com.att.aro.core.packetanalysis.pojo.Session)5 IPPacket (com.att.aro.core.packetreader.pojo.IPPacket)5 BestPracticeType (com.att.aro.core.bestpractice.pojo.BestPracticeType)3 Burst (com.att.aro.core.packetanalysis.pojo.Burst)3 AROTraceData (com.att.aro.core.pojo.AROTraceData)3 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)2 PeriodicTransferResult (com.att.aro.core.bestpractice.pojo.PeriodicTransferResult)2 Profile (com.att.aro.core.configuration.pojo.Profile)2 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)2 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)2 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)2