1MERGECAP(1) The Wireshark Network Analyzer MERGECAP(1)
2
3
4
6 mergecap - Merges two or more capture files into one
7
9 mergecap [ -a ] [ -F <file format> ] [ -h ] [ -I <IDB merge mode> ]
10 [ -s <snaplen> ] [ -v ] [ -V ] -w <outfile>|- <infile> [<infile> ...]
11
13 Mergecap is a program that combines multiple saved capture files into a
14 single output file specified by the -w argument. Mergecap knows how to
15 read pcap and pcapng capture files, including those of tcpdump,
16 Wireshark and other tools that write captures in those formats.
17
18 By default, Mergecap writes the capture file in pcapng format, and
19 writes all of the packets from the input capture files to the output
20 file.
21
22 Mergecap is able to detect, read and write the same capture files that
23 are supported by Wireshark. The input files don't need a specific
24 filename extension; the file format and an optional gzip compression
25 will be automatically detected. Near the beginning of the DESCRIPTION
26 section of wireshark(1) or
27 <https://www.wireshark.org/docs/man-pages/wireshark.html> is a detailed
28 description of the way Wireshark handles this, which is the same way
29 Mergecap handles this.
30
31 Mergecap can write the file in several output formats. The -F flag can
32 be used to specify the format in which to write the capture file,
33 mergecap -F provides a list of the available output formats.
34
35 Packets from the input files are merged in chronological order based on
36 each frame's timestamp, unless the -a flag is specified. Mergecap
37 assumes that frames within a single capture file are already stored in
38 chronological order. When the -a flag is specified, packets are copied
39 directly from each input file to the output file, independent of each
40 frame's timestamp.
41
42 The output file frame encapsulation type is set to the type of the
43 input files if all input files have the same type. If not all of the
44 input files have the same frame encapsulation type, the output file
45 type is set to WTAP_ENCAP_PER_PACKET. Note that some capture file
46 formats, most notably pcap, do not currently support
47 WTAP_ENCAP_PER_PACKET. This combination will cause the output file
48 creation to fail.
49
51 -a Causes the frame timestamps to be ignored, writing all packets from
52 the first input file followed by all packets from the second input
53 file. By default, when -a is not specified, the contents of the
54 input files are merged in chronological order based on each frame's
55 timestamp.
56
57 Note: when merging, mergecap assumes that packets within a capture
58 file are already in chronological order.
59
60 -F <file format>
61 Sets the file format of the output capture file. Mergecap can write
62 the file in several formats; mergecap -F provides a list of the
63 available output formats. By default this is the pcapng format.
64
65 -h Prints the version and options and exits.
66
67 -I <IDB merge mode>
68 Sets the Interface Description Block (IDB) merge mode to use during
69 merging. mergecap -I provides a list of the available IDB merge
70 modes.
71
72 Every input file has one or more IDBs, which describe the
73 interface(s) the capture was performed on originally. This includes
74 encapsulation type, interface name, etc. When mergecap merges
75 multiple input files, it has to merge these IDBs somehow for the
76 new merged output file. This flag controls how that is
77 accomplished. The currently available modes are:
78
79 none: No merging of IDBs is performed, and instead all IDBs are
80 copied to the merged output file.
81
82 all: IDBs are merged only if all input files have the same
83 number of IDBs, and each IDB matches their respective entry in
84 the other files. This is the default mode.
85
86 any: Any and all duplicate IDBs are merged into one IDB,
87 regardless of what file they are in.
88
89 Note that an IDB is only considered a matching duplicate if it has
90 the same encapsulation type, name, speed, time precision, comments,
91 description, etc.
92
93 -s <snaplen>
94 Sets the snapshot length to use when writing the data. If the -s
95 flag is used to specify a snapshot length, frames in the input file
96 with more captured data than the specified snapshot length will
97 have only the amount of data specified by the snapshot length
98 written to the output file. This may be useful if the program that
99 is to read the output file cannot handle packets larger than a
100 certain size (for example, the versions of snoop in Solaris 2.5.1
101 and Solaris 2.6 appear to reject Ethernet frames larger than the
102 standard Ethernet MTU, making them incapable of handling gigabit
103 Ethernet captures if jumbo frames were used).
104
105 -v Causes mergecap to print a number of messages while it's working.
106
107 -V Print the version and exit.
108
109 -w <outfile>|-
110 Sets the output filename. If the name is '-', stdout will be used.
111 This setting is mandatory.
112
114 To merge two capture files together, 100 seconds apart use:
115
116 capinfos -aeS a.pcap b.pcap
117
118 (Let's suppose a.pcap starts at 1009932757 and b.pcap ends at
119 873660281. 1009932757 - 873660281 - 100 = 136272376 seconds.)
120
121 editcap -t 136272376 b.pcap b-shifted.pcap
122 mergecap -w compare.pcap a.pcap b-shifted.pcap
123
125 pcap(3), wireshark(1), tshark(1), dumpcap(1), editcap(1), text2pcap(1),
126 pcap-filter(7) or tcpdump(8)
127
129 Mergecap is based heavily upon editcap by Richard Sharpe
130 <sharpe[AT]ns.aus.com> and Guy Harris <guy[AT]alum.mit.edu>.
131
132 Mergecap is part of the Wireshark distribution. The latest version of
133 Wireshark can be found at <https://www.wireshark.org>.
134
135 HTML versions of the Wireshark project man pages are available at:
136 <https://www.wireshark.org/docs/man-pages>.
137
139 Original Author
140 -------- ------
141 Scott Renfro <scott[AT]renfro.org>
142
143
144 Contributors
145 ------------
146 Bill Guyton <guyton[AT]bguyton.com>
147
148
149
1503.4.4 2021-03-16 MERGECAP(1)