final JPacket packet = new PcapPacket(Type.POINTER);
final JScanner scanner = new JScanner();
long start = System.currentTimeMillis();
final TextFormatter out = new TextFormatter();
pcap.loop(Pcap.LOOP_INFINATE, new ByteBufferHandler<String>() {
int i = 0;
public void nextPacket(PcapHeader header, ByteBuffer buffer, String user) {
if (i == 200) {
pcap.breakloop();
return;
}
System.out.println("\nPacket #" + i);
try {
packet.peer(buffer);
} catch (PeeringException e) {
e.printStackTrace();
}
scanner.scan(packet, JProtocol.ETHERNET_ID);
// try {
out.setFrameIndex(i++);
// out.format(packet);
// System.out.println(packet.toString());
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();