'\" t .\" Title: mergecap .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 .\" Date: 2024-02-04 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" .TH "MERGECAP" "1" "2024-02-04" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" mergecap \- Merges two or more capture files into one .SH "SYNOPSIS" .sp \fBmergecap\fP [\~\fB\-a\fP\~] [\~\fB\-F\fP\~<\fIfile\~format\fP>\~] [\~\fB\-I\fP\~<\fIIDB\~merge\~mode\fP>\~] [\~\fB\-s\fP\~<\fIsnaplen\fP>\~] [\~\fB\-V\fP\~] \fB\-w\fP\~<\fIoutfile\fP>|\- <\fIinfile\fP>\~[<\fIinfile\fP>\~\fI...\fP] .sp \fBmergecap\fP \fB\-h|\-\-help\fP .sp \fBmergecap\fP \fB\-v|\-\-version\fP .SH "DESCRIPTION" .sp \fBMergecap\fP is a program that combines multiple saved capture files into a single output file specified by the \fB\-w\fP argument. \fBMergecap\fP knows how to read \fBpcap\fP and \fBpcapng\fP capture files, including those of \fBtcpdump\fP, \fBWireshark\fP and other tools that write captures in those formats. .sp By default, \fBMergecap\fP writes the capture file in \fBpcapng\fP format, and writes all of the packets from the input capture files to the output file. .sp \fBMergecap\fP is able to detect, read and write the same capture files that are supported by \fBWireshark\fP. The input files don\(cqt need a specific filename extension; the file format and an optional gzip, zstd or lz4 compression will be automatically detected. Near the beginning of the DESCRIPTION section of wireshark(1) or \c .URL "https://www.wireshark.org/docs/man\-pages/wireshark.html" "" is a detailed description of the way \fBWireshark\fP handles this, which is the same way \fBMergecap\fP handles this. .sp \fBMergecap\fP can write the file in several output formats. The \fB\-F\fP flag can be used to specify the format in which to write the capture file, \fBmergecap \-F\fP provides a list of the available output formats. .sp Packets from the input files are merged in chronological order based on each frame\(cqs timestamp, unless the \fB\-a\fP flag is specified. \fBMergecap\fP assumes that frames within a single capture file are already stored in chronological order. When the \fB\-a\fP flag is specified, packets are copied directly from each input file to the output file, independent of each frame\(cqs timestamp. .sp 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. Note that some capture file formats, most notably \fBpcap\fP, do not currently support WTAP_ENCAP_PER_PACKET. This combination will cause the output file creation to fail. .SH "OPTIONS" .sp \-a .RS 4 .sp 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 \fB\-a\fP is not specified, the contents of the input files are merged in chronological order based on each frame\(cqs timestamp. .sp Note: when merging, \fBmergecap\fP assumes that packets within a capture file are already in chronological order. .RE .sp \-F .RS 4 .sp Sets the file format of the output capture file. \fBMergecap\fP can write the file in several formats; \fBmergecap \-F\fP provides a list of the available output formats. By default this is the \fBpcapng\fP format. .RE .sp \-h|\-\-help .RS 4 Print the version number and options and exit. .RE .sp \-I .RS 4 .sp Sets the Interface Description Block (IDB) merge mode to use during merging. \fBmergecap \-I\fP provides a list of the available IDB merge modes. .sp 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. When mergecap merges multiple input files, it has to merge these IDBs somehow for the new merged output file. This flag controls how that is accomplished. The currently available modes are: .sp \fBnone\fP: No merging of IDBs is performed, and instead all IDBs are copied to the merged output file. .sp \fBall\fP: 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. .sp \fBany\fP: Any and all duplicate IDBs are merged into one IDB, regardless of what file they are in. .sp Note that an IDB is only considered a matching duplicate if it has the same encapsulation type, name, speed, time precision, comments, description, etc. .RE .sp \-s .RS 4 .sp Sets the snapshot length to use when writing the data. If the \fB\-s\fP flag 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 of snoop in 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). .RE .sp \-v|\-\-version .RS 4 Print the full version information and exit. .RE .sp \-V .RS 4 Causes \fBmergecap\fP to print a number of messages while it\(cqs working. .RE .sp \-w |\- .RS 4 Sets the output filename. If the name is \*(Aq\fB\-\fP\*(Aq, stdout will be used. This setting is mandatory. .RE .SH "DIAGNOSTIC OPTIONS" .sp \-\-log\-level .RS 4 Set the active log level. Supported levels in lowest to highest order are "noisy", "debug", "info", "message", "warning", "critical", and "error". Messages at each level and higher will be printed, for example "warning" prints "warning", "critical", and "error" messages and "noisy" prints all messages. Levels are case insensitive. .RE .sp \-\-log\-fatal .RS 4 Abort the program if any messages are logged at the specified level or higher. For example, "warning" aborts on any "warning", "critical", or "error" messages. .RE .sp \-\-log\-domains .RS 4 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). .RE .sp \-\-log\-debug .RS 4 Force the specified domains to log at the "debug" level. List of domains must be comma\-separated. Can be negated with "!" as the first character (inverts the match). .RE .sp \-\-log\-noisy .RS 4 Force the specified domains to log at the "noisy" level. List of domains must be comma\-separated. Can be negated with "!" as the first character (inverts the match). .RE .sp \-\-log\-fatal\-domains .RS 4 Abort the program if any messages are logged for the specified log domains. List of domains must be comma\-separated. .RE .sp \-\-log\-file .RS 4 Write log messages and stderr output to the specified file. .RE .SH "EXAMPLES" .sp To merge two capture files together into a third capture file, in which the last packet of one file arrives 100 seconds before the first packet of another file, use the following sequence of commands. .sp First, use: .sp .if n .RS 4 .nf .fam C capinfos \-aeS a.pcap b.pcap .fam .fi .if n .RE .sp to determine the start and end times of the two capture files, as seconds since January 1, 1970, 00:00:00 UTC. .sp 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. .sp Thus, the next step would be to use: .sp .if n .RS 4 .nf .fam C editcap \-t 136272376 b.pcap b\-shifted.pcap .fam .fi .if n .RE .sp to generate a version of b.pcap with its time stamps shifted 136272376 ahead. .sp Then the final step would be to use : .sp .if n .RS 4 .nf .fam C mergecap \-w compare.pcap a.pcap b\-shifted.pcap .fam .fi .if n .RE .sp to merge a.pcap and the shifted b.pcap into compare.pcap. .SH "SEE ALSO" .sp pcap(3), wireshark(1), tshark(1), dumpcap(1), editcap(1), text2pcap(1), pcap\-filter(7) or tcpdump(8) .SH "NOTES" .sp \fBMergecap\fP is based heavily upon \fBeditcap\fP by Richard Sharpe and Guy Harris . .sp This is the manual page for \fBMergecap\fP 4.2.2. \fBMergecap\fP is part of the \fBWireshark\fP distribution. The latest version of \fBWireshark\fP can be found at \c .URL "https://www.wireshark.org" "" "." .sp HTML versions of the Wireshark project man pages are available at .URL "https://www.wireshark.org/docs/man\-pages" "" "." .SH "AUTHORS" .sp .B Original Author .br Scott Renfro .sp .B Contributors .br Bill Guyton