Fix grammaro, indent example code.
[obnox/wireshark/wip.git] / doc / mergecap.pod
1
2 =head1 NAME
3
4 mergecap - Merges two or more capture files into one
5
6 =head1 SYNOPSIS
7
8 B<mergecap>
9 S<[ B<-a> ]>
10 S<[ B<-F> E<lt>I<file format>E<gt> ]>
11 S<[ B<-h> ]>
12 S<[ B<-s> E<lt>I<snaplen>E<gt> ]>
13 S<[ B<-T> E<lt>I<encapsulation type>E<gt> ]>
14 S<[ B<-v> ]>
15 S<B<-w> E<lt>I<outfile>E<gt>|->
16 E<lt>I<infile>E<gt>
17 I<...>
18
19 =head1 DESCRIPTION
20
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.  
25
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.  
28
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.
37
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 
41 formats.
42
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.
49
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.
56
57 =head1 OPTIONS
58
59 =over 4
60
61 =item -a
62
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.
67
68 Note: when merging, B<mergecap> assumes that packets within a capture
69 file are already in chronological order.
70
71 =item -F  E<lt>file formatE<gt>
72
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 
76 first input file.
77
78 =item -h
79
80 Prints the version and options and exits.
81
82 =item -s  E<lt>snaplenE<gt>
83
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
93 frames were used).
94
95 =item -v
96
97 Causes B<mergecap> to print a number of messages while it's working.
98
99 =item -w  E<lt>outfileE<gt>|-
100
101 Sets the output filename. If the name is 'B<->', stdout will be used.
102 This setting is mandatory.
103
104 =item -T  E<lt>encapsulation typeE<gt>
105
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.  
111
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).
119
120 =back
121
122 =head1 EXAMPLES
123
124 To merge two capture files together, 100 seconds apart use:
125
126     capinfos -aeS a.pcap b.pcap
127     
128 (Let's suppose a.pcap starts at 1009932757 and b.pcap ends
129 at 873660281. 1009932757 - 873660281 - 100 = 136272376
130 seconds.)
131
132     editcap -t 136272376 b.pcap b-shifted.pcap
133     mergecap -w compare.pcap a.pcap b-shifted.pcap
134
135 =head1 SEE ALSO
136
137 tcpdump(8), pcap(3), wireshark(1), tshark(1), dumpcap(1), editcap(1),
138 text2pcap(1)
139
140 =head1 NOTES
141
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>.
144
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>.
147
148 HTML versions of the Wireshark project man pages are available at:
149 L<http://www.wireshark.org/docs/man-pages>.
150
151 =head1 AUTHORS
152
153   Original Author
154   -------- ------
155   Scott Renfro             <scott[AT]renfro.org>
156
157
158   Contributors
159   ------------
160   Bill Guyton              <guyton[AT]bguyton.com>