title: Continuously read pcap file in python that being written continuously
body: <p>Using <code>Python</code> I want to continuously read the packets one-by-one in the same order they are written into, from a <code>pcap</code> file that is being continuously written by <code>tshark</code> (or a piece of code written in <code>libpcap</code> or <code>pfring</code>) live capture.</p>
  <p>To test this I used <code>tshark</code> and <code>scapy</code> in Python in the following way.</p>
  <p>@terminal1:  <code>ping -i 5 192.168.1.10</code></p>
  <p>@terminal2:   <code>tshark -f &quot;icmp&quot; -a filesize:1000 -w ping_live.pcap</code></p>
  <p>Packet reader in Python intended to read each unread packet at every 5 seconds (not the whole set of packets every time). But it will not wait for the next set of packets that are about to  written after 5 second, and it exits.</p>
  <pre><code>from scapy.all import *
  
  def process_packet(packet):
      print(packet.summary())
  
  sniff(offline=&quot;ping_live.pcap&quot;, prn=process_packet, store=0)
  print(&quot;sniff complete, exiting&quot;)
  </code></pre>
  <p>Then I tried to put <code>while True:</code> loop around the <code>sniff</code> method, but it is not reading only the next unread packet, instead reading whole file again and again.</p>
  <p>What is the solution for my requirement (not limited to <code>scapy</code>)?</p>
  <p>Thank you</p>