use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapReversedHeaderRecordReaderTest 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));
}
use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapReaderTest method findIPStartEN10MBUnknownType.
@Test
public void findIPStartEN10MBUnknownType() {
byte[] packet = new byte[20];
PcapReader xreader = new PcapReader(PcapReader.LinkType.EN10MB);
packet[12] = -1;
packet[13] = -1;
assertEquals(-1, xreader.findIPStart(packet));
}
use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapReaderTest method findIPStartRAW.
@Test
public void findIPStartRAW() {
PcapReader xreader = new PcapReader(PcapReader.LinkType.RAW);
assertEquals(0, xreader.findIPStart(null));
}
use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapReaderTest method findIPStartLOOP.
@Test
public void findIPStartLOOP() {
PcapReader xreader = new PcapReader(PcapReader.LinkType.LOOP);
assertEquals(4, xreader.findIPStart(null));
}
use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapReaderTest method assembledWithPush.
@Test
public void assembledWithPush() 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))) {
public int counter = 1;
@Override
protected void processPacketPayload(Packet packet, byte[] payload) {
Integer fragments = (Integer) packet.get(Packet.REASSEMBLED_TCP_FRAGMENTS);
if (fragments != null) {
assertTrue(1 == fragments);
switch(counter) {
case 1:
assertEquals("part1\n", new String(payload));
break;
case 2:
assertEquals("part2\n", new String(payload));
break;
}
counter++;
}
}
@Override
protected boolean isReassembleTcp() {
return true;
}
@Override
protected boolean isPush() {
return true;
}
};
assertEquals(10, Iterables.size(reader));
}
}
Aggregations