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 [ -a <frame:comment> ] [ -A <start time> ] [ -B <stop time> ]
10       [ -c <packets per file> ] [ -C [offset:]<choplen> ]
11       [ -E <error probability> ] [ -F <file format> ] [ -h ]
12       [ -i <seconds per file> ] [ -o <change offset> ] [ -L ] [ -r ]
13       [ -s <snaplen> ] [ -S <strict time adjustment> ]
14       [ -t <time adjustment> ] [ -T <encapsulation type> ] [ -v ] infile
15       outfile [ packet#[-packet#] ... ]
16
17       editcap  -d  |  -D <dup window>  |  -w <dup time window>  [ -v ]
18       [ -I <bytes to ignore> ] infile outfile
19
20       editcap [ -V ]
21

DESCRIPTION

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

OPTIONS

58       -a  <framenum:comment>
59           For the specificed frame number, assign the given comment string.
60           Can be repeated for multiple frames.  Quotes should be used with
61           comment strings that include spaces.
62
63       -A  <start time>
64           Saves only the packets whose timestamp is on or after start time.
65           The time is given in the following format YYYY-MM-DD HH:MM:SS
66
67       -B  <stop time>
68           Saves only the packets whose timestamp is before stop time.  The
69           time is given in the following format YYYY-MM-DD HH:MM:SS
70
71       -c  <packets per file>
72           Splits the packet output to different files based on uniform packet
73           counts with a maximum of <packets per file> each. Each output file
74           will be created with a suffix -nnnnn, starting with 00000. If the
75           specified number of packets is written to the output file, the next
76           output file is opened. The default is to use a single output file.
77
78       -C  [offset:]<choplen>
79           Sets the chop length to use when writing the packet data. Each
80           packet is chopped by <choplen> bytes of data. Positive values chop
81           at the packet beginning while negative values chop at the packet
82           end.
83
84           If an optional offset precedes the <choplen>, then the bytes
85           chopped will be offset from that value. Positive offsets are from
86           the packet beginning, while negative offsets are from the packet
87           end.
88
89           This is useful for chopping headers for decapsulation of an entire
90           capture, removing tunneling headers, or in the rare case that the
91           conversion between two file formats leaves some random bytes at the
92           end of each packet. Another use is for removing vlan tags.
93
94           NOTE: This option can be used more than once, effectively allowing
95           you to chop bytes from up to two different areas of a packet in a
96           single pass provided that you specify at least one chop length as a
97           positive value and at least one as a negative value.  All positive
98           chop lengths are added together as are all negative chop lengths.
99
100       -d  Attempts to remove duplicate packets.  The length and MD5 hash of
101           the current packet are compared to the previous four (4) packets.
102           If a match is found, the current packet is skipped.  This option is
103           equivalent to using the option -D 5.
104
105       -D  <dup window>
106           Attempts to remove duplicate packets.  The length and MD5 hash of
107           the current packet are compared to the previous <dup window> - 1
108           packets.  If a match is found, the current packet is skipped.
109
110           The use of the option -D 0 combined with the -v option is useful in
111           that each packet's Packet number, Len and MD5 Hash will be printed
112           to standard out.  This verbose output (specifically the MD5 hash
113           strings) can be useful in scripts to identify duplicate packets
114           across trace files.
115
116           The <dup window> is specified as an integer value between 0 and
117           1000000 (inclusive).
118
119           NOTE: Specifying large <dup window> values with large tracefiles
120           can result in very long processing times for editcap.
121
122       -E  <error probability>
123           Sets the probability that bytes in the output file are randomly
124           changed.  Editcap uses that probability (between 0.0 and 1.0
125           inclusive) to apply errors to each data byte in the file.  For
126           instance, a probability of 0.02 means that each byte has a 2%
127           chance of having an error.
128
129           This option is meant to be used for fuzz-testing protocol
130           dissectors.
131
132       -F  <file format>
133           Sets the file format of the output capture file.  Editcap can write
134           the file in several formats, editcap -F provides a list of the
135           available output formats. The default is the pcap format.
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       -I  <bytes to ignore>
148           Ignore the specified number of bytes at the beginning of the frame
149           during MD5 hash calculation, unless the frame is too short, then
150           the full frame is used.  Useful to remove duplicated packets taken
151           on several routers (different mac addresses for example) e.g. -I 26
152           in case of Ether/IP will ignore ether(14) and IP header(20 - 4(src
153           ip) - 4(dst ip)).  The default value is 0.
154
155       -L  Adjust the original frame length accordingly when chopping and/or
156           snapping (in addition to the captured length, which is always
157           adjusted regardless of whether -L is specified or not).  See also
158           -C <choplen> and -s <snaplen>.
159
160       -o  <change offset>
161           When used in conjunction with -E, skip some bytes from the
162           beginning of the packet from being changed. In this way some
163           headers don't get changed, and the fuzzer is more focused on a
164           smaller part of the packet. Keeping a part of the packet fixed the
165           same dissector is triggered, that make the fuzzing more precise.
166
167       -r  Reverse the packet selection.  Causes the packets whose packet
168           numbers are specified on the command line to be written to the
169           output capture file, instead of discarding them.
170
171       -s  <snaplen>
172           Sets the snapshot length to use when writing the data.  If the -s
173           flag is used to specify a snapshot length, packets in the input
174           file with more captured data than the specified snapshot length
175           will have only the amount of data specified by the snapshot length
176           written to the output file.
177
178           This may be useful if the program that is to read the output file
179           cannot handle packets larger than a certain size (for example, the
180           versions of snoop in Solaris 2.5.1 and Solaris 2.6 appear to reject
181           Ethernet packets larger than the standard Ethernet MTU, making them
182           incapable of handling gigabit Ethernet captures if jumbo packets
183           were used).
184
185       -S  <strict time adjustment>
186           Time adjust selected packets to ensure strict chronological order.
187
188           The <strict time adjustment> value represents relative seconds
189           specified as [-]seconds[.fractional seconds].
190
191           As the capture file is processed each packet's absolute time is
192           possibly adjusted to be equal to or greater than the previous
193           packet's absolute timestamp depending on the <strict time
194           adjustment> value.
195
196           If <strict time adjustment> value is 0 or greater (e.g. 0.000001)
197           then only packets with a timestamp less than the previous packet
198           will adjusted.  The adjusted timestamp value will be set to be
199           equal to the timestamp value of the previous packet plus the value
200           of the <strict time adjustment> value.  A <strict time adjustment>
201           value of 0 will adjust the minimum number of timestamp values
202           necessary to ensure that the resulting capture file is in strict
203           chronological order.
204
205           If <strict time adjustment> value is specified as a negative value,
206           then the timestamp values of all packets will be adjusted to be
207           equal to the timestamp value of the previous packet plus the
208           absolute value of the <lt>strict time adjustment<gt> value. A
209           <strict time adjustment> value of -0 will result in all packets
210           having the timestamp value of the first packet.
211
212           This feature is useful when the trace file has an occasional packet
213           with a negative delta time relative to the previous packet.
214
215       -t  <time adjustment>
216           Sets the time adjustment to use on selected packets.  If the -t
217           flag is used to specify a time adjustment, the specified adjustment
218           will be applied to all selected packets in the capture file.  The
219           adjustment is specified as [-]seconds[.fractional seconds].  For
220           example, -t 3600 advances the timestamp on selected packets by one
221           hour while -t -0.5 reduces the timestamp on selected packets by
222           one-half second.
223
224           This feature is useful when synchronizing dumps collected on
225           different machines where the time difference between the two
226           machines is known or can be estimated.
227
228       -T  <encapsulation type>
229           Sets the packet encapsulation type of the output capture file.  If
230           the -T flag is used to specify an encapsulation type, the
231           encapsulation type of the output capture file will be forced to the
232           specified type.  editcap -T provides a list of the available types.
233           The default type is the one appropriate to the encapsulation type
234           of the input capture file.
235
236           Note: this merely forces the encapsulation type of the output file
237           to be the specified type; the packet headers of the packets will
238           not be translated from the encapsulation type of the input capture
239           file to the specified encapsulation type (for example, it will not
240           translate an Ethernet capture to an FDDI capture if an Ethernet
241           capture is read and '-T fddi' is specified). If you need to
242           remove/add headers from/to a packet, you will need
243           od(1)/text2pcap(1).
244
245       -v  Causes editcap to print verbose messages while it's working.
246
247           Use of -v with the de-duplication switches of -d, -D or -w will
248           cause all MD5 hashes to be printed whether the packet is skipped or
249           not.
250
251       -V  Print the version and exit.
252
253       -w  <dup time window>
254           Attempts to remove duplicate packets.  The current packet's arrival
255           time is compared with up to 1000000 previous packets.  If the
256           packet's relative arrival time is less than or equal to the <dup
257           time window> of a previous packet and the packet length and MD5
258           hash of the current packet are the same then the packet to skipped.
259           The duplicate comparison test stops when the current packet's
260           relative arrival time is greater than <dup time window>.
261
262           The <dup time window> is specified as seconds[.fractional seconds].
263
264           The [.fractional seconds] component can be specified to nine (9)
265           decimal places (billionths of a second) but most typical trace
266           files have resolution to six (6) decimal places (millionths of a
267           second).
268
269           NOTE: Specifying large <dup time window> values with large
270           tracefiles can result in very long processing times for editcap.
271
272           NOTE: The -w option assumes that the packets are in chronological
273           order.  If the packets are NOT in chronological order then the -w
274           duplication removal option may not identify some duplicates.
275

EXAMPLES

277       To see more detailed description of the options use:
278
279           editcap -h
280
281       To shrink the capture file by truncating the packets at 64 bytes and
282       writing it as Sun snoop file use:
283
284           editcap -s 64 -F snoop capture.pcap shortcapture.snoop
285
286       To delete packet 1000 from the capture file use:
287
288           editcap capture.pcap sans1000.pcap 1000
289
290       To limit a capture file to packets from number 200 to 750 (inclusive)
291       use:
292
293           editcap -r capture.pcap small.pcap 200-750
294
295       To get all packets from number 1-500 (inclusive) use:
296
297           editcap -r capture.pcap first500.pcap 1-500
298
299       or
300
301           editcap capture.pcap first500.pcap 501-9999999
302
303       To exclude packets 1, 5, 10 to 20 and 30 to 40 from the new file use:
304
305           editcap capture.pcap exclude.pcap 1 5 10-20 30-40
306
307       To select just packets 1, 5, 10 to 20 and 30 to 40 for the new file
308       use:
309
310           editcap -r capture.pcap select.pcap 1 5 10-20 30-40
311
312       To remove duplicate packets seen within the prior four frames use:
313
314           editcap -d capture.pcap dedup.pcap
315
316       To remove duplicate packets seen within the prior 100 frames use:
317
318           editcap -D 101 capture.pcap dedup.pcap
319
320       To remove duplicate packets seen equal to or less than 1/10th of a
321       second:
322
323           editcap -w 0.1 capture.pcap dedup.pcap
324
325       To display the MD5 hash for all of the packets (and NOT generate any
326       real output file):
327
328           editcap -v -D 0 capture.pcap /dev/null
329
330       or on Windows systems
331
332           editcap -v -D 0 capture.pcap NUL
333
334       To advance the timestamps of each packet forward by 3.0827 seconds:
335
336           editcap -t 3.0827 capture.pcap adjusted.pcap
337
338       To ensure all timestamps are in strict chronological order:
339
340           editcap -S 0 capture.pcap adjusted.pcap
341
342       To introduce 5% random errors in a capture file use:
343
344           editcap -E 0.05 capture.pcap capture_error.pcap
345
346       To remove vlan tags from all packets within an Ethernet-encapsulated
347       capture file, use:
348
349           editcap -L -C 12:4 capture_vlan.pcap capture_no_vlan.pcap
350
351       To chop both the 10 byte and 20 byte regions from the following 75 byte
352       packet in a single pass, use any of the 8 possible methods provided
353       below:
354
355           <--------------------------- 75 ---------------------------->
356
357           +---+-------+-----------+---------------+-------------------+
358           | 5 |   10  |     15    |       20      |         25        |
359           +---+-------+-----------+---------------+-------------------+
360
361           1) editcap -C 5:10 -C -25:-20 capture.pcap chopped.pcap
362           2) editcap -C 5:10 -C 50:-20 capture.pcap chopped.pcap
363           3) editcap -C -70:10 -C -25:-20 capture.pcap chopped.pcap
364           4) editcap -C -70:10 -C 50:-20 capture.pcap chopped.pcap
365           5) editcap -C 30:20 -C -60:-10 capture.pcap chopped.pcap
366           6) editcap -C 30:20 -C 15:-10 capture.pcap chopped.pcap
367           7) editcap -C -45:20 -C -60:-10 capture.pcap chopped.pcap
368           8) editcap -C -45:20 -C 15:-10 capture.pcap chopped.pcap
369
370       To add comment strings to the first 2 input frames, use:
371
372           editcap -a "1:1st frame" -a 2:Second capture.pcap capture-comments.pcap
373

SEE ALSO

375       pcap(3), wireshark(1), tshark(1), mergecap(1), dumpcap(1), capinfos(1),
376       text2pcap(1), od(1), pcap-filter(7) or tcpdump(8)
377

NOTES

379       Editcap is part of the Wireshark distribution.  The latest version of
380       Wireshark can be found at <https://www.wireshark.org>.
381
382       HTML versions of the Wireshark project man pages are available at:
383       <https://www.wireshark.org/docs/man-pages>.
384

AUTHORS

386         Original Author
387         -------- ------
388         Richard Sharpe           <sharpe[AT]ns.aus.com>
389
390
391         Contributors
392         ------------
393         Guy Harris               <guy[AT]alum.mit.edu>
394         Ulf Lamping              <ulf.lamping[AT]web.de>
395
396
397
3982.6.2                             2018-07-18                        EDITCAP(1)
Impressum