This is a static, read-only archive of Wireshark Q&A. Older questions and answers from October 2017 and earlier can be found at osqa-ask.wireshark.org.
0

How to get random packets from a .pcap file?

asked Nov 02 '17

updated Nov 02 '17

I am trying to get a random subset of packets from a .pcap file. To do so, I have written the following shell script:

large_number=150000
smaller_number=10000
selected_packet_numbers=$(shuf -i 0-"$large_number" -n "$smaller_number")
editcap -r capture.pcap capture-selected.pcap $selected_packet_numbers

However, editcap is giving me the following error:

Out of room for packet selections

Using a shell loop would take an unreasonably long time.

What can I do to select a random subset of packets from a .pcap file?

1 Answer

1

answered Nov 02 '17

Unless something has changed, there will be a limit to the number of packets or ranges you can specify in a single run of editcap https://www.wireshark.org/lists/wires... (it might be still 100 or could have been increased to 512)

So you might need to work with that.

Comments

1

In Wireshark 2.x this is set to 512.

User 39986 ( Nov 02 '17 )
cc-by-sa Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.