Split pcap to multiple files based on number of packets

Here is a script that can use tshark to split a large pcap to multiple small pcaps



max=$(tshark  -r $inpcap -n -T fields -e frame.number|tail -1)

# This is the number of packets in each split pcap

# Save all new pcaps to out, if it does not exist, create it.
[[ ! -d out ]] && mkdir out

for i in $(seq 1 $max $c)
        tshark  -r $inpcap  -n -c $c "frame.number==$i" -w out/$i.pcap
        #Do other stuff, if required
        read -p "Send the next packet? "

A very simple 3-4 line script that has saved my day so may times.

This site uses Akismet to reduce spam. Learn how your comment data is processed.