@Override
public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
super.initialize(split, context);
IpDecoder ipDecoder = new IpDecoder() {
@Override
public void process(EthernetFrame frame) {
ipPacket = Ipv4Packet.parse(frame.getBuffer());
ipData = copyData(ipPacket.getData());
super.process(frame);
}
};
TcpDecoder tcpDecoder = new TcpDecoder(new TcpPortProtocolMapper()) {
@Override
public void process(Ipv4Packet packet) {
tcpPacket = TcpPacket.parse(packet);
tcpData = copyData(tcpPacket.getData());
}
};
UdpProcessor udpProcessor = new UdpProcessor() {
@Override
public void process(UdpPacket p) {
udpPacket = p;
udpData = copyData(p.getData());
}
};
UdpDecoder udpDecoder = new UdpDecoder(new UdpPortProtocolMapper()) {
@Override
public void process(Ipv4Packet packet) {
// nothing really
super.process(packet);
}
};
udpDecoder.registerUdpProcessor(udpProcessor);
eth.register(EthernetType.IPV4, ipDecoder);
ipDecoder.register(InternetProtocol.TCP, tcpDecoder);
ipDecoder.register(InternetProtocol.UDP, udpDecoder);
byteKey = new UnsignedByte[n];
for (int i = 0; i < n; i++)
byteKey[i] = new UnsignedByte(0);
}