I have external hardware that continuously sends UDP data segments over a specified port. I would like to continuously store the last few received packets in a file (could also be time-based).
If I use
-C, then either a new file is created, or the old one overwritten after the limit is reached. However, this is not what I need. I would like to have a single file that rotates continuously: as a new packet comes in, the oldest packet should be removed to make space for the new one.
This way I know I will always (after the buffer fills, of course) have a large enough sample (and not of a random size between 0 and N packets/bytes/seconds).
After some web searching, I've found that there used to be a tool called pcapture that used a circular buffer to achieve something similar, but it was short-lived and not even supported under Linux.
What would be the best approach with modern tools to achieve such circularity?