MERGECAP(1)
π mergecap, but make it a vibe π
Okay so this page is MERGECAP(1), the manual page for mergecap, and bestie she is iconic. Let's get into it. π«Ά
β¨ NAME β¨
mergecap β merges two or more capture files into one. That's the whole job and she does it beautifully. π
π¦ SYNOPSIS π¦
mergecap [ -a ] [ -F <file format> ] [ -I <IDB merge mode> ]
[ -s <snaplen> ] [ -V ] [ --no-merging-comment ] -w <outfile>|-
<infile> [<infile> ...]
mergecap -h|--help
mergecap -v|--version
π DESCRIPTION π
So mergecap is a program that combines multiple saved capture files into a single output file, and you tell her where to put it with the -w argument. She knows how to read pcap and pcapng capture files, including those from tcpdump, Wireshark, and other tools that write captures in those formats. Lowkey a polyglot. π
By default, mergecap writes the capture file in pcapng format, and writes all of the packets from the input capture files to the output file. No packet left behind. Periodt.
Here's the thing: mergecap can detect, read, and write the same capture files that Wireshark supports. The input files don't need a specific filename extension β the file format and any optional gzip, zstd or lz4 compression are automatically detected. Near the beginning of the DESCRIPTION section of wireshark(1) or at https://www.wireshark.org/docs/man-pages/wireshark.html there's a detailed description of the way Wireshark handles this, and that's exactly the same way mergecap handles it. So if you want the deep lore, it's right there. π
She can write the file in several output formats, too. The -F flag specifies the format for the output capture file, and mergecap -F gives you a list of all the available output formats. Nobad options, bestie.
Packets from the input files are merged in chronological order based on each frame's timestamp β unless you specify the -a flag. mergecap assumes that frames within a single capture file are already stored in chronological order. When you do specify -a, packets are copied directly from each input file to the output file, independent of each frame's timestamp. So she's not even looking at the clock. π
The output file frame encapsulation type is set to the type of the input files if all input files have the same type. If not all of the input files have the same frame encapsulation type, the output file type is set to WTAP_ENCAP_PER_PACKET. But heads up: some capture file formats, most notably pcap, do not currently support WTAP_ENCAP_PER_PACKET, and that combination will cause the output file creation to fail. So likeβ¦ check that before you come for her. π
π OPTIONS π
-aβ Causes the frame timestamps to be ignored, writing all packets from the first input file followed by all packets from the second input file. By default, when-ais not specified, the contents of the input files are merged in chronological order based on each frame's timestamp. Note: when merging,mergecapassumes that packets within a capture file are already in chronological order. She's trusting you on that one. π-F <file format>β Sets the file format of the output capture file.mergecapcan write the file in several formats;mergecap -Fprovides a list of the available output formats. By default this is the pcapng format. π-h|--helpβ Print the version number and options and exit. A little "hey bestie, here's everything" moment. βοΈ-I <IDB merge mode>β Sets the Interface Description Block (IDB) merge mode to use during merging.mergecap -Iprovides a list of the available IDB merge modes. Okay so here's the tea: every input file has one or more IDBs, which describe the interface(s) the capture was performed on originally. This includes encapsulation type, interface name, etc. Whenmergecapmerges multiple input files, she has to merge these IDBs somehow for the new merged output file, and this flag controls how that is accomplished. The currently available modes are:noneβ No merging of IDBs is performed, and instead all IDBs are copied to the merged output file.allβ IDBs are merged only if all input files have the same number of IDBs, and each IDB matches their respective entry in the other files. (Only the IDBs that occur at the beginning of the files, before any packet blocks, are compared. IDBs that occur later in the files are merged with duplicates iff the initial IDBs were merged.) This is the default mode. πanyβ Any and all duplicate IDBs are merged into one IDB, regardless of what file they are in.
Note that an IDB is only considered a matching duplicate if it has the same encapsulation type, name, speed, time precision, comments, description, etc. She's picky and we love that for her. π
-s <snaplen>β Sets the snapshot length to use when writing the data. If the-sflag is used to specify a snapshot length, frames in the input file with more captured data than the specified snapshot length will have only the amount of data specified by the snapshot length written to the output file. This may be useful if the program that is to read the output file cannot handle packets larger than a certain size β for example, the versions ofsnoopin Solaris 2.5.1 and Solaris 2.6 appear to reject Ethernet frames larger than the standard Ethernet MTU, making them incapable of handling gigabit Ethernet captures if jumbo frames were used. Tragic, honestly. π-v|--versionβ Print the full version information and exit. Just the receipts. βοΈ-Vβ Causesmergecapto print a number of messages while she's working. Chatty queen. π£οΈ-w <outfile>|-β Sets the output filename. If the name is-, stdout will be used. If the--compressoption is not given, then the filename extension is used to deduce the desired compression method, if any; e.g., if the name has the extension.gz, then the output file is compressed to a gzip archive. This setting is mandatory. You literally cannot skip it, bestie. π--compress <type>β Compress the output file using the type compression format.--compresswith no argument provides a list of the compression formats supported for writing. The type given takes precedence over the extension of outfile. So she listens to the flag first. π--no-merging-commentβ Inhibit generating the capture commentFile created by merging:...to the output file. By default, a multiline capture comment is generated to the output (merged) file that lists all of the files being merged. However, if the generated capture comment is longer than 65535 bytes it is silently dropped. No warning, no nothing. Just gone. π«₯
π DIAGNOSTIC OPTIONS π
--log-level <level>β Set the active log level. Supported levels in lowest to highest order arenoisy,debug,info,message,warning,critical, anderror. Messages at each level and higher will be printed β for example,warningprintswarning,critical, anderrormessages, andnoisyprints all messages. Levels are case insensitive, so don't stress about caps. π--log-fatal <level>β Abort the program if any messages are logged at the specified level or higher. For example,warningaborts on anywarning,critical, orerrormessages. Dramatic? Maybe. Effective? Yes. π--log-fatal-count <count>β The amount of fatal log messages which may pass before the program is aborted. Like a little buffer of chaos. π--log-domains <list>β Only print messages for the specified log domains, e.g.GUI,Epan,sshdump. List of domains must be comma-separated. Can be negated with!as the first character (inverts the match). π--log-debug <list>β Force the specified domains to log at thedebuglevel. List of domains must be comma-separated. Can be negated with!as the first character (inverts the match). π--log-noisy <list>β Force the specified domains to log at thenoisylevel. List of domains must be comma-separated. Can be negated with!as the first character (inverts the match). π--log-fatal-domains <list>β Abort the program if any messages are logged for the specified log domains. List of domains must be comma-separated. No chill whatsoever. π--log-file <path>β Write log messages and stderr output to the specified file. Keep the receipts, bestie. π
πΈ EXAMPLES πΈ
Okay so say you want to merge two capture files together into a third capture file, where the last packet of one file arrives 100 seconds before the first packet of another file. Here's the sequence of commands, step by step.
First, use:
capinfos -aeS a.pcap b.pcap
to determine the start and end times of the two capture files, as seconds since January 1, 1970, 00:00:00 UTC. Time math, but make it cute. π°οΈ
If a.pcap starts at 1009932757 and b.pcap ends at 873660281, then the time adjustment to b.pcap that would make it end 100 seconds before a.pcap begins would be 1009932757 - 873660281 - 100 = 136272376 seconds. Yes, we're doing arithmetic in public. π
So the next step would be to use:
editcap -t 136272376 b.pcap b-shifted.pcap
to generate a version of b.pcap with its time stamps shifted 136272376 ahead.
Then the final step would be to use:
mergecap -w compare.pcap a.pcap b-shifted.pcap
to merge a.pcap and the shifted b.pcap into compare.pcap. And that's it! You did that. π
π SEE ALSO π
Go read those too, iykyk. π
π NOTES π
mergecap is based heavily upon editcap by Richard Sharpe <sharpe[AT]ns.aus.com> and Guy Harris <guy[AT]alum.mit.edu>. Shoutout to the OGs. π«Ά
This is the manual page for Mergecap 4.7.4. Mergecap is part of the Wireshark distribution. The latest version of Wireshark can be found at https://www.wireshark.org. π
HTML versions of the Wireshark project man pages are available at https://www.wireshark.org/docs/man-pages. So if you're a browser gremlin, they got you. π¦
π AUTHORS π
Original Author
- Scott Renfro
<scott[AT]renfro.org>
Contributors
- Bill Guyton
<guyton[AT]bguyton.com>
And that's the whole page, bestie! This is the manual page for Mergecap 4.7.4, dated 2026-10-08, and it lives at MERGECAP(1) β now go merge some captures and absolutely slay. π
β¨π
π¦ where this page comes from
- arch rolling: wireshark-cli 4.7.4-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms