I'm running tshark to dump wireless traffic. I am currently running in multiple files mode, splitting output into 50MB chunks. Is there any way to also have these 50MB chunks compressed with something like gzip or lzma?

I'm aware that in single file mode I could pipe the output from tshark to gzip and then onto split, but I'd like each pcap file to be readable on it's own, without needing to decompress every part of the compressed file.


I was looking into the same problem just now .. I don't know if you found your solution, but I end up using a linux bash script to solve this problem ..

below is the script ..

while [  $COUNTER -lt $FILENO ]; do
    sudo tshark -i any -a duration:300 -a filesize:500000 -w - | gzip -9 -f > TRACE/trace_$COUNTER.gzip

Wireshark can be compiled with zlib support, so both the Wireshark graphical app and tshark commandline app can read gzip files.

Here is me capturing traffic:

# tcpdump -n -i br0 -w tcpdump.pcap
tcpdump: listening on br0, link-type EN10MB (Ethernet), capture size 65535 bytes
^C281 packets captured
281 packets received by filter
0 packets dropped by kernel

then compressing it:

$ gzip tcpdump.pcap 
$ ls -lgo
total 88
-rw-r--r--. 1 89875 Jul 24 22:11 tcpdump.pcap.gz

and reading directly from the compressed file:

$ tshark -nr tcpdump.pcap.gz | head -n5
1   0.000000 41342  53 DNS 75 Standard query 0x1716  A plus.google.com
2   0.004990 53 41342 DNS 251 Standard query response 0x1716  A A A A A A A A A A A
3   0.005274 54794 443 TCP 74 54794 > 443 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=612252515 TSecr=0 WS=128
4   0.024052 443 54794 TCP 74 443 > 54794 [SYN, ACK] Seq=0 Ack=1 Win=42540 Len=0 MSS=1376 SACK_PERM=1 TSval=639245311 TSecr=612252515 WS=64
5   0.024078 54794 443 TCP 66 54794 > 443 [ACK] Seq=1 Ack=1 Win=29312 Len=0 TSval=612252534 TSecr=639245311
  • I'm aware that wireshark and tshark can read gzipped files. My question was in reference to the ability of tshark to split it's captures using the Multiple Files modes. I want each capture to be a self contained file that is also compressed, rather than compressing one large capture. – Daniel Murphy Jul 28 '14 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.