1EDITCAP(1)              The Wireshark Network Analyzer              EDITCAP(1)
2
3
4

NAME

6       editcap - Edit and/or translate the format of capture files
7

SYNOPSIS

9       editcap [ -c <packets per file> ] [ -C <choplen> ]
10       [ -E <error probability> ] [ -F <file format> ] [ -A <start time> ]
11       [ -B <stop time> ] [ -h ] [ -i <seconds per file> ] [ -r ]
12       [ -s <snaplen> ] [ -t <time adjustment> ]
13       [ -S <strict time adjustment> ] [ -T <encapsulation type> ] [ -v ]
14       infile outfile [ packet#[-packet#] ... ]
15
16       editcap  -d  |  -D <dup window>  |  -w <dup time window>  [ -v ] infile
17       outfile
18

DESCRIPTION

20       Editcap is a program that reads some or all of the captured packets
21       from the infile, optionally converts them in various ways and writes
22       the resulting packets to the capture outfile (or outfiles).
23
24       By default, it reads all packets from the infile and writes them to the
25       outfile in libpcap file format.
26
27       An optional list of packet numbers can be specified on the command
28       tail; individual packet numbers separated by whitespace and/or ranges
29       of packet numbers can be specified as start-end, referring to all
30       packets from start to end.  By default the selected packets with those
31       numbers will not be written to the capture file.  If the -r flag is
32       specified, the whole packet selection is reversed; in that case only
33       the selected packets will be written to the capture file.
34
35       Editcap can also be used to remove duplicate packets.  Several
36       different options (-d, -D and -w) are used to control the packet window
37       or relative time window to be used for duplicate comparison.
38
39       Editcap is able to detect, read and write the same capture files that
40       are supported by Wireshark.  The input file doesn't need a specific
41       filename extension; the file format and an optional gzip compression
42       will be automatically detected.  Near the beginning of the DESCRIPTION
43       section of wireshark(1) or
44       http://www.wireshark.org/docs/man-pages/wireshark.html
45       <http://www.wireshark.org/docs/man-pages/wireshark.html> is a detailed
46       description of the way Wireshark handles this, which is the same way
47       Editcap handles this.
48
49       Editcap can write the file in several output formats. The -F flag can
50       be used to specify the format in which to write the capture file;
51       editcap -F provides a list of the available output formats.
52

OPTIONS

54       -c  <packets per file>
55           Splits the packet output to different files based on uniform packet
56           counts with a maximum of <packets per file> each. Each output file
57           will be created with a suffix -nnnnn, starting with 00000. If the
58           specified number of packets is written to the output file, the next
59           output file is opened. The default is to use a single output file.
60
61       -C  <choplen>
62           Sets the chop length to use when writing the packet data.  Each
63           packet is chopped at the packet end by a few <choplen> bytes of
64           data.
65
66           This is useful in the rare case that the conversion between two
67           file formats leaves some random bytes at the end of each packet.
68
69       -d  Attempts to remove duplicate packets.  The length and MD5 hash of
70           the current packet are compared to the previous four (4) packets.
71           If a match is found, the current packet is skipped.  This option is
72           equivalent to using the option -D 5.
73
74       -D  <dup window>
75           Attempts to remove duplicate packets.  The length and MD5 hash of
76           the current packet are compared to the previous <dup window> - 1
77           packets.  If a match is found, the current packet is skipped.
78
79           The use of the option -D 0 combined with the -v option is useful in
80           that each packet's Packet number, Len and MD5 Hash will be printed
81           to standard out.  This verbose output (specifically the MD5 hash
82           strings) can be useful in scripts to identify duplicate packets
83           across trace files.
84
85           The <dup window> is specifed as an integer value between 0 and
86           1000000 (inclusive).
87
88           NOTE: Specifying large <dup window> values with large tracefiles
89           can result in very long processing times for editcap.
90
91       -w  <dup time window>
92           Attempts to remove duplicate packets.  The current packet's arrival
93           time is compared with up to 1000000 previous packets.  If the
94           packet's relative arrival time is less than or equal to the <dup
95           time window> of a previous packet and the packet length and MD5
96           hash of the current packet are the same then the packet to skipped.
97           The duplicate comparison test stops when the current packet's
98           relative arrival time is greater than <dup time window>.
99
100           The <dup time window> is specifed as seconds[.fractional seconds].
101
102           The [.fractional seconds] component can be specified to nine (9)
103           decimal places (billionths of a second) but most typical trace
104           files have resolution to six (6) decimal places (millionths of a
105           second).
106
107           NOTE: Specifying large <dup time window> values with large
108           tracefiles can result in very long processing times for editcap.
109
110           NOTE: The -w option assumes that the packets are in chronological
111           order.  If the packets are NOT in chronological order then the -w
112           duplication removal option may not identify some duplicates.
113
114       -E  <error probability>
115           Sets the probabilty that bytes in the output file are randomly
116           changed.  Editcap uses that probability (between 0.0 and 1.0
117           inclusive) to apply errors to each data byte in the file.  For
118           instance, a probability of 0.02 means that each byte has a 2%
119           chance of having an error.
120
121           This option is meant to be used for fuzz-testing protocol
122           dissectors.
123
124       -F  <file format>
125           Sets the file format of the output capture file.  Editcap can write
126           the file in several formats, editcap -F provides a list of the
127           available output formats. The default is the libpcap format.
128
129       -A  <start time>
130           Saves only the packets whose timestamp is on or after start time.
131           The time is given in the following format YYYY-MM-DD HH:MM:SS
132
133       -B  <stop time>
134           Saves only the packets whose timestamp is on or before stop time.
135           The time is given in the following format YYYY-MM-DD HH:MM:SS
136
137       -h  Prints the version and options and exits.
138
139       -i  <seconds per file>
140           Splits the packet output to different files based on uniform time
141           intervals using a maximum interval of <seconds per file> each. Each
142           output file will be created with a suffix -nnnnn, starting with
143           00000. If packets for the specified time interval are written to
144           the output file, the next output file is opened. The default is to
145           use a single output file.
146
147       -r  Reverse the packet selection.  Causes the packets whose packet
148           numbers are specified on the command line to be written to the
149           output capture file, instead of discarding them.
150
151       -s  <snaplen>
152           Sets the snapshot length to use when writing the data.  If the -s
153           flag is used to specify a snapshot length, packets in the input
154           file with more captured data than the specified snapshot length
155           will have only the amount of data specified by the snapshot length
156           written to the output file.
157
158           This may be useful if the program that is to read the output file
159           cannot handle packets larger than a certain size (for example, the
160           versions of snoop in Solaris 2.5.1 and Solaris 2.6 appear to reject
161           Ethernet packets larger than the standard Ethernet MTU, making them
162           incapable of handling gigabit Ethernet captures if jumbo packets
163           were used).
164
165       -t  <time adjustment>
166           Sets the time adjustment to use on selected packets.  If the -t
167           flag is used to specify a time adjustment, the specified adjustment
168           will be applied to all selected packets in the capture file.  The
169           adjustment is specified as [-]seconds[.fractional seconds].  For
170           example, -t 3600 advances the timestamp on selected packets by one
171           hour while -t -0.5 reduces the timestamp on selected packets by
172           one-half second.
173
174           This feature is useful when synchronizing dumps collected on
175           different machines where the time difference between the two
176           machines is known or can be estimated.
177
178       -S  <strict time adjustment>
179           Time adjust selected packets to insure strict chronological order.
180
181           The <strict time adjustment> value represents relative seconds
182           specified as [-]seconds[.fractional seconds].
183
184           As the capture file is processed each packet's absolute time is
185           possibly adjusted to be equal to or greater than the previous
186           packet's absolute timestamp depending on the <strict time
187           adjustment> value.
188
189           If <strict time adjustment> value is 0 or greater (e.g. 0.000001)
190           then only packets with a timestamp less than the previous packet
191           will adjusted.  The adjusted timestamp value will be set to be
192           equal to the timestamp value of the previous packet plus the value
193           of the <strict time adjustment> value.  A <strict time adjustment>
194           value of 0 will adjust the minimum number of timestamp values
195           necessary to insure that the resulting capture file is in strict
196           chronological order.
197
198           If <strict time adjustment> value is specified as a negative value,
199           then the timestamp values of all packets will be adjusted to be
200           equal to the timestamp value of the previous packet plus the
201           absolute value of the <lt>strict time adjustment<gt> value. A
202           <strict time adjustment> value of -0 will result in all packets
203           having the timestamp value of the first packet.
204
205           This feature is useful when the trace file has an occasional packet
206           with a negative delta time relative to the previous packet.
207
208       -T  <encapsulation type>
209           Sets the packet encapsulation type of the output capture file.  If
210           the -T flag is used to specify an encapsulation type, the
211           encapsulation type of the output capture file will be forced to the
212           specified type.  editcap -T provides a list of the available types.
213           The default type is the one appropriate to the encapsulation type
214           of the input capture file.
215
216           Note: this merely forces the encapsulation type of the output file
217           to be the specified type; the packet headers of the packets will
218           not be translated from the encapsulation type of the input capture
219           file to the specified encapsulation type (for example, it will not
220           translate an Ethernet capture to an FDDI capture if an Ethernet
221           capture is read and '-T fddi' is specified). If you need to
222           remove/add headers from/to a packet, you will need
223           od(1)/text2pcap(1).
224
225       -v  Causes editcap to print verbose messages while it's working.
226
227           Use of -v with the de-duplication switches of -d, -D or -w will
228           cause all MD5 hashes to be printed whether the packet is skipped or
229           not.
230

EXAMPLES

232       To see more detailed description of the options use:
233
234           editcap -h
235
236       To shrink the capture file by truncating the packets at 64 bytes and
237       writing it as Sun snoop file use:
238
239           editcap -s 64 -F snoop capture.pcap shortcapture.snoop
240
241       To delete packet 1000 from the capture file use:
242
243           editcap capture.pcap sans1000.pcap 1000
244
245       To limit a capture file to packets from number 200 to 750 (inclusive)
246       use:
247
248           editcap -r capture.pcap small.pcap 200-750
249
250       To get all packets from number 1-500 (inclusive) use:
251
252           editcap -r capture.pcap first500.pcap 1-500
253
254       or
255
256           editcap capture.pcap first500.pcap 501-9999999
257
258       To exclude packets 1, 5, 10 to 20 and 30 to 40 from the new file use:
259
260           editcap capture.pcap exclude.pcap 1 5 10-20 30-40
261
262       To select just packets 1, 5, 10 to 20 and 30 to 40 for the new file
263       use:
264
265           editcap -r capture.pcap select.pcap 1 5 10-20 30-40
266
267       To remove duplicate packets seen within the prior four frames use:
268
269           editcap -d capture.pcap dedup.pcap
270
271       To remove duplicate packets seen within the prior 100 frames use:
272
273           editcap -D 101 capture.pcap dedup.pcap
274
275       To remove duplicate packets seen equal to or less than 1/10th of a
276       second:
277
278           editcap -w 0.1 capture.pcap dedup.pcap
279
280       To display the MD5 hash for all of the packets (and NOT generate any
281       real output file):
282
283           editcap -v -D 0 capture.pcap /dev/null
284
285       or on Windows systems
286
287           editcap -v -D 0 capture.pcap NUL
288
289       To advance the timestamps of each packet forward by 3.0827 seconds:
290
291           editcap -t 3.0827 capture.pcap adjusted.pcap
292
293       To insure all timestamps are in strict chronological order:
294
295           editcap -S 0 capture.pcap adjusted.pcap
296
297       To introduce 5% random errors in a capture file use:
298
299         editcap -E 0.05 capture.pcap capture_error.pcap
300

SEE ALSO

302       tcpdump(8), pcap(3), wireshark(1), tshark(1), mergecap(1), dumpcap(1),
303       capinfos(1), text2pcap(1), od(1)
304

NOTES

306       Editcap is part of the Wireshark distribution.  The latest version of
307       Wireshark can be found at <http://www.wireshark.org>.
308
309       HTML versions of the Wireshark project man pages are available at:
310       http://www.wireshark.org/docs/man-pages
311       <http://www.wireshark.org/docs/man-pages>.
312

AUTHORS

314         Original Author
315         -------- ------
316         Richard Sharpe           <sharpe[AT]ns.aus.com>
317
318
319         Contributors
320         ------------
321         Guy Harris               <guy[AT]alum.mit.edu>
322         Ulf Lamping              <ulf.lamping[AT]web.de>
323
324
325
3261.4.10                            2011-11-01                        EDITCAP(1)
Impressum