use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapInputFormat method initPcapRecordReader.
public static PcapRecordReader initPcapRecordReader(Path path, long start, long length, TaskAttemptContext context) throws IOException {
Configuration conf = context.getConfiguration();
FileSystem fs = path.getFileSystem(conf);
FSDataInputStream baseStream = fs.open(path);
DataInputStream stream = baseStream;
CompressionCodecFactory compressionCodecs = new CompressionCodecFactory(conf);
final CompressionCodec codec = compressionCodecs.getCodec(path);
if (codec != null)
stream = new DataInputStream(codec.createInputStream(stream));
PcapReader reader = initPcapReader(stream, conf);
return new PcapRecordReader(reader, start, length, baseStream, stream, context);
}
use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapInputFormat method initPcapRecordReader.
public static PcapRecordReader initPcapRecordReader(Path path, long start, long length, Reporter reporter, Configuration conf) throws IOException {
FileSystem fs = path.getFileSystem(conf);
FSDataInputStream baseStream = fs.open(path);
DataInputStream stream = baseStream;
CompressionCodecFactory compressionCodecs = new CompressionCodecFactory(conf);
final CompressionCodec codec = compressionCodecs.getCodec(path);
if (codec != null)
stream = new DataInputStream(codec.createInputStream(stream));
PcapReader reader = initPcapReader(stream, conf);
return new PcapRecordReader(reader, start, length, baseStream, stream, reporter);
}
use of net.ripe.hadoop.pcap.PcapReader in project hadoop-pcap by RIPE-NCC.
the class PcapReaderTest method findIPStartNULL.
@Test
public void findIPStartNULL() {
PcapReader xreader = new PcapReader(PcapReader.LinkType.NULL);
assertEquals(4, xreader.findIPStart(null));
}
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 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));
}
Aggregations