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