title: Packet capture buffering
body: <p>I'm having some issues with my network which I can't figure out and currently I'm focusing on the IoT part.</p>
  <p>So what I'd like to check is what happens before we're experiencing a connectivity loss and a bit after.</p>
  <p>What I was thinking about is launching <code>tcpdump</code> stream and retain 10 past seconds from now, whenever I'm experiencing an issue (connectivity loss reported by the app) I'd like to record 10 more seconds (20 total, 10 before the error and 10 after) and save it as a <code>pcap</code> (or <code>pcapng</code>).</p>
  <p>I was thinking about implementing this solution with Python but I have 2 problems:</p>
  <ol>
  <li>I can't figure how to buffer a CLI output stream so I'll only save 10 seconds.</li>
  <li>Capturing the CLI output won't help me when I'll try to save it to pcap(ng).</li>
  </ol>
  <p>I saw a partial non-coding solution here:
  <a href="https://stackoverflow.com/questions/58442622/network-capture-toolset-that-store-a-buffer-and-saves-on-a-trigger">Network capture toolset that store a buffer and saves on a trigger</a></p>
  <p>The problem is that the process is killed and I need it to be ready for the next error but if it didn't have this limitation it could be pretty good, probably signal handling or so.</p>
  <p>Thanks.</p>