Reputation: 6227
So I used tcpdump to capture my UDP packets into a file. I now have my pcap file with my packets. Now I need:
A Java program to open this file, parse it and place the packet contents, one at a time, into a ByteBuffer so my protocol parser can process each packet as it was getting them from the network. My protocol parser must not care whether it is being called by the network reader or by the pcap processor.
Is there a library or a standard way in Java to do that? Can you give me or point me out to some source code example? Thanks!
Upvotes: 0
Views: 2158
Reputation: 533500
To read from a file and place it into a ByteBuffer you can use
FileChannel in = new FileInputStream(filename).getChannel();
// read into a ByteBuffer from a file.
in.read(byteBuffer);
Upvotes: 0