Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to do an analysis on pcap files, but tshark seems rather heavy for the simple analysis I want, such as:

  • number of packets
  • capture duration
  • total bytes

Is there an easier way to get these statistics?

share|improve this question

1 Answer 1

Using lovely python in a lazy way:

# apt-get install python-pypcap

>>> import pcap
>>> p = pcap.pcap(name="hs22v-boot.pcap")
>>> packets = [x for x in p]
>>> duration = packets[-1][0] - packets[0][0]
>>> totalbytes = sum([len(x[1]) for x in packets])
>>> numpackets = len(packets)
>>> duration, totalbytes, numpackets
(113.37264108657837, 193812281, 227491)
share|improve this answer
    
Turning this into properly efficient code is left as an exercise for the reader. –  MikeyB Jul 25 '12 at 15:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.