1

I am using WireShark to analyse the network traffic. After saving traffic in a .pcap file and I need to analyse it using JNetPCAP API.

There is some way to know the numbers of packets contained in the pcap file?

Sample Code:

final String FILENAME = "/home/pcap1.pcap";  
final StringBuilder errbuf = new StringBuilder();  
final Pcap pcap = Pcap.openOffline(FILENAME, errbuf);

if (pcap == null) {  
            System.err.println(errbuf); 
            return;  
        }  
pcap.loop(/*I WANT TO KNOW NUMBER OF PACKETS HERE!!!!*/ 10, new JPacketHandler<StringBuilder>() { 
//SOME CODE
 }
}
Alberto Crespo
  • 2,429
  • 5
  • 28
  • 51

1 Answers1

0

I think i have found the answer by myself.

Pcap.LOOP_INFINITE

pcap.loop(Pcap.LOOP_INFINITE, new JPacketHandler<StringBuilder>() { 
//SOME CODE 
} 
Alberto Crespo
  • 2,429
  • 5
  • 28
  • 51