Skip to content
Tutorials Center
My learning

Topics

Lesson 33 of 37 ยท Advanced Techniques

Handling Large Captures: Ring Buffers, editcap and mergecap

Work with huge capture files: ring buffers, capture filters and snap length, splitting, merging and trimming with editcap and mergecap, and performance tips.

A busy 10 Gbit/s link can fill a hard drive in minutes, and a multi-gigabyte file can freeze the Wireshark GUI. Professional analysis is as much about capturing less and cutting files down as it is about reading packets. This lesson shows the tools and habits for that.

Everything here is command line or settings, shown read-only because capture tools are not available in the browser. Python stand-ins illustrate the size arithmetic and splitting logic. Capture only on networks you are authorized to monitor.

Plan the capture

Before you start, decide what you need and how long you need it.

Capture less, learn more

Capture filter Keep only relevant hosts and ports.
Snap length Save headers, not full payloads.
1 / 2
  • Capture filter (BPF) reduces the volume at the source: host 10.0.0.5 and tcp port 443, or not port 22 to exclude your own SSH session, which otherwise captures itself.
  • Snap length (-s 96 in tcpdump, or -s in dumpcap) stores only the first N bytes of each packet. 96 bytes keeps Ethernet, IP and TCP headers, which is enough for most troubleshooting, and cuts file size drastically. Do not use it when you need payloads.
  • Time and size limits stop a runaway capture.

Estimate the size first.

Python How big will the capture be?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Ring buffers

A ring buffer writes to a series of files and, once the limit is reached, deletes the oldest. It lets you leave a capture running for days and keep the most recent data, ready for when the problem occurs.

Terminal
# dumpcap is the capture engine behind Wireshark and tshark (efficient, low privileges)
dumpcap -i eth0 -f "not port 22" -b filesize:200000 -b files:20 -w /data/cap/ring.pcapng

That keeps up to twenty files of about 200 MB each (sizes are in kilobytes). The files are named with a number and a timestamp, so you can find the period around an incident. Other options: -b duration:3600 starts a new file every hour; -b interval:300 every 5 minutes.

Python Simulate which ring-buffer files survive

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

editcap: trim and split

editcap edits capture files without opening Wireshark:

Terminal
# Keep packets 1000-2000
editcap -r big.pcapng part.pcapng 1000-2000

# Split into files of 100,000 packets
editcap -c 100000 big.pcapng chunk.pcapng

# Split every 5 minutes
editcap -i 300 big.pcapng chunk.pcapng

# Keep only a time window
editcap -A "2025-03-01 10:00:00" -B "2025-03-01 10:15:00" big.pcapng window.pcapng

# Remove duplicate packets (seen twice because of a span port plus a tap)
editcap -d big.pcapng deduped.pcapng

# Convert format
editcap -F pcap big.pcapng old-format.pcap

You can also use a display filter with tshark to write a smaller file:

Terminal
tshark -r big.pcapng -Y "ip.addr == 10.0.0.42" -w host42.pcapng

mergecap: combine

When you captured at both ends of a path, merge the files into one timeline:

Terminal
mergecap -w combined.pcapng client.pcapng server.pcapng   # merged by timestamp
mergecap -a -w appended.pcapng part1.pcapng part2.pcapng  # appended in order

Timestamps from different machines must be synchronized (NTP). If the clocks differ by 80 ms, packets look as if they travel faster or slower than they do. Use editcap -t to shift a file by a number of seconds, and treat cross-host timing with care.

Making Wireshark cope

  • Turn off name resolution (View, Name Resolution) so it does not do thousands of DNS lookups.
  • Disable heavy options: "Allow subdissectors to reassemble TCP streams" and colorization only when you need them.
  • Use filters first: apply a display filter before scrolling, and avoid sorting a million rows.
  • Split, then work on slices. Filter with tshark to extract only the host or time window you need.
  • More memory and an SSD help; Wireshark loads packet lists into RAM.
  • Capture with dumpcap or tcpdump, not the GUI, for high-rate links; the GUI can drop packets under load.

Detecting capture drops

If the capture machine cannot keep up, the operating system drops packets and the file has gaps that look like network loss. Check:

  • Wireshark or dumpcap statistics ("dropped by kernel").
  • Gaps in the TCP sequence numbers in both directions at the same time, without matching retransmissions.
  • A SPAN port oversubscribed above its capacity; physical taps avoid that.
Python Merge two sorted packet lists by timestamp

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a ring buffer do?

    It limits disk use while always keeping the most recent traffic.
  2. 2. Which tool splits one big capture into smaller files?

    editcap can split by packet count or time interval with -c and -i.
  3. 3. Why exclude your own SSH session from a remote capture?

    Watching a server over SSH creates traffic that the capture then records, so exclude it with a capture filter.
  4. 4. What is a risk of merging captures from two machines?

    Packet order and delay calculations depend on timestamps, so clocks should be synchronized.

Summary

  • Reduce data at capture time: capture filters, snap length, and autostop.
  • Ring buffers keep a rolling window with fixed disk use.
  • editcap trims, splits and de-duplicates; mergecap merges by timestamp.
  • Keep the GUI fast by splitting files, disabling name resolution, and watching for capture drops.

Next: Project: Baseline Your Home Network