I need a program which prints the number of packets in a capture file which uses the pcap format. This number does not seem available in the pcap header (probably because it is written before the capture starts) and it does not seem there is a "footer" in the file, with this information.
So, I believe the only algorithm is to loop over all the packets and sum them. It is in O(N) and, for large traces, quite long.
I post here to see if someone has a cleverer idea?
I tagged with "C" because it is the language I currently use but I believe it is a language-independant issue.