4 mergecap - Merges two or more capture files into one
10 S<[ B<-F> E<lt>I<file format>E<gt> ]>
12 S<[ B<-s> E<lt>I<snaplen>E<gt> ]>
13 S<[ B<-T> E<lt>I<encapsulation type>E<gt> ]>
15 S<B<-w> E<lt>I<outfile>E<gt>|->
21 B<Mergecap> is a program that combines multiple saved capture files into
22 a single output file specified by the B<-w> argument. B<Mergecap> knows
23 how to read B<libpcap> capture files, including those of B<tcpdump>,
24 B<Wireshark>, and other tools that write captures in that format.
26 By default, B<Mergecap> writes the capture file in B<libpcap> format, and writes
27 all of the packets from the input capture files to the output file.
29 B<Mergecap> is able to detect, read and write the same capture files that
30 are supported by B<Wireshark>.
31 The input files don't need a specific filename extension; the file
32 format and an optional gzip compression will be automatically detected.
33 Near the beginning of the DESCRIPTION section of wireshark(1) or
34 L<http://www.wireshark.org/docs/man-pages/wireshark.html>
35 is a detailed description of the way B<Wireshark> handles this, which is
36 the same way B<Mergecap> handles this.
38 B<Mergecap> can write the file in several output formats.
39 The B<-F> flag can be used to specify the format in which to write the
40 capture file, B<mergecap -F> provides a list of the available output
43 Packets from the input files are merged in chronological order based on
44 each frame's timestamp, unless the B<-a> flag is specified. B<Mergecap>
45 assumes that frames within a single capture file are already stored in
46 chronological order. When the B<-a> flag is specified, packets are
47 copied directly from each input file to the output file, independent of
48 each frame's timestamp.
50 The output file frame encapsulation type is set to the type of the input
51 files if all input files have the same type. If not all of the input
52 files have the same frame encapsulation type, the output file type is
53 set to WTAP_ENCAP_PER_PACKET. Note that some capture file formats, most
54 notably B<libpcap>, do not currently support WTAP_ENCAP_PER_PACKET.
55 This combination will cause the output file creation to fail.
63 Causes the frame timestamps to be ignored, writing all packets from the
64 first input file followed by all packets from the second input file. By
65 default, when B<-a> is not specified, the contents of the input files
66 are merged in chronological order based on each frame's timestamp.
68 Note: when merging, B<mergecap> assumes that packets within a capture
69 file are already in chronological order.
71 =item -F E<lt>file formatE<gt>
73 Sets the file format of the output capture file. B<Mergecap> can write
74 the file in several formats; B<mergecap -F> provides a list of the
75 available output formats. The default is to use the file format of the
80 Prints the version and options and exits.
82 =item -s E<lt>snaplenE<gt>
84 Sets the snapshot length to use when writing the data.
85 If the B<-s> flag is used to specify a snapshot length, frames in the
86 input file with more captured data than the specified snapshot length
87 will have only the amount of data specified by the snapshot length
88 written to the output file. This may be useful if the program that is
89 to read the output file cannot handle packets larger than a certain size
90 (for example, the versions of snoop in Solaris 2.5.1 and Solaris 2.6
91 appear to reject Ethernet frames larger than the standard Ethernet MTU,
92 making them incapable of handling gigabit Ethernet captures if jumbo
97 Causes B<mergecap> to print a number of messages while it's working.
99 =item -w E<lt>outfileE<gt>|-
101 Sets the output filename. If the name is 'B<->', stdout will be used.
102 This setting is mandatory.
104 =item -T E<lt>encapsulation typeE<gt>
106 Sets the packet encapsulation type of the output capture file.
107 If the B<-T> flag is used to specify a frame encapsulation type, the
108 encapsulation type of the output capture file will be forced to the
109 specified type, rather than being the type appropriate to the
110 encapsulation type of the input capture files.
112 Note that this merely
113 forces the encapsulation type of the output file to be the specified
114 type; the packet headers of the packets will not be translated from the
115 encapsulation type of the input capture file to the specified
116 encapsulation type (for example, it will not translate an Ethernet
117 capture to an FDDI capture if an Ethernet capture is read and 'B<-T
118 fddi>' is specified).
124 To merge two capture files together, 100 seconds apart use:
126 capinfos -aeS a.pcap b.pcap
128 (Let's suppose a.pcap starts at 1009932757 and b.pcap ends
129 at 873660281. 1009932757 - 873660281 - 100 = 136272376
132 editcap -t 136272376 b.pcap b-shifted.pcap
133 mergecap -w compare.pcap a.pcap b-shifted.pcap
137 tcpdump(8), pcap(3), wireshark(1), tshark(1), dumpcap(1), editcap(1),
142 B<Mergecap> is based heavily upon B<editcap> by Richard Sharpe
143 <sharpe[AT]ns.aus.com> and Guy Harris <guy[AT]alum.mit.edu>.
145 B<Mergecap> is part of the B<Wireshark> distribution. The latest version
146 of B<Wireshark> can be found at L<http://www.wireshark.org>.
148 HTML versions of the Wireshark project man pages are available at:
149 L<http://www.wireshark.org/docs/man-pages>.
155 Scott Renfro <scott[AT]renfro.org>
160 Bill Guyton <guyton[AT]bguyton.com>