use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapReaderTest method findIPStartSLL.
@Test
public void findIPStartSLL() {
byte[] packet = new byte[20];
PcapReader xreader = new PcapReader(PcapReader.LinkType.LINUX_SLL);
byte[] sllAddressSourceLength = PcapReaderUtil.convertShort(6);
packet[4] = sllAddressSourceLength[0];
packet[5] = sllAddressSourceLength[1];
byte[] ethernetTypeIp = PcapReaderUtil.convertShort(PcapReader.ETHERNET_TYPE_IP);
packet[16] = ethernetTypeIp[0];
packet[17] = ethernetTypeIp[1];
assertEquals(16, xreader.findIPStart(packet));
}
use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapReaderTest method findIPStartEN10MB.
@Test
public void findIPStartEN10MB() {
byte[] packet = new byte[20];
PcapReader xreader = new PcapReader(PcapReader.LinkType.EN10MB);
byte[] ethernetType = PcapReaderUtil.convertShort(PcapReader.ETHERNET_TYPE_IP);
packet[12] = ethernetType[0];
packet[13] = ethernetType[1];
assertEquals(14, xreader.findIPStart(packet));
}
use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapReaderTest method findIPStartEN10MB_8021Q.
@Test
public void findIPStartEN10MB_8021Q() {
byte[] packet = new byte[20];
PcapReader xreader = new PcapReader(PcapReader.LinkType.EN10MB);
byte[] ethernetType8021Q = PcapReaderUtil.convertShort(PcapReader.ETHERNET_TYPE_8021Q);
packet[12] = ethernetType8021Q[0];
packet[13] = ethernetType8021Q[1];
byte[] ethernetTypeIp = PcapReaderUtil.convertShort(PcapReader.ETHERNET_TYPE_IP);
packet[16] = ethernetTypeIp[0];
packet[17] = ethernetTypeIp[1];
assertEquals(18, xreader.findIPStart(packet));
}
use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapReaderTest method assembled.
@Test
public void assembled() throws IOException {
for (String file : new String[] { "src/test/resources/tcp-stream-v4.pcap", "src/test/resources/tcp-stream-v6.pcap" }) {
PcapReader reader = new PcapReader(new DataInputStream(new FileInputStream(file))) {
@Override
protected void processPacketPayload(Packet packet, byte[] payload) {
Integer fragments = (Integer) packet.get(Packet.REASSEMBLED_TCP_FRAGMENTS);
if (fragments != null) {
assertTrue(2 == fragments);
assertEquals("part1\npart2\n", new String(payload));
}
}
@Override
protected boolean isReassembleTcp() {
return true;
}
@Override
protected boolean isPush() {
return false;
}
};
assertEquals(10, Iterables.size(reader));
}
}
use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapIPv6RecordReaderTest method startup.
@Before
public void startup() throws IOException {
JobConf config = new JobConf();
FileSystem fs = FileSystem.get(config);
FSDataInputStream is = fs.open(new Path(TEST_FILE.getParent(), TEST_FILE.getName()));
recordReader = new PcapRecordReader(new PcapReader(is), 0L, TEST_FILE.length(), is, is, new TestableTaskAttemptContext(config));
}
Aggregations