1EDITCAP(1) The Wireshark Network Analyzer EDITCAP(1)
2
3
4
6 editcap - Edit and/or translate the format of capture files
7
9 editcap [ -A <start time> ] [ -B <stop time> ]
10 [ -c <packets per file> ] [ -C <choplen> ] [ -E <error probability> ]
11 [ -F <file format> ] [ -h ] [ -i <seconds per file> ] [ -r ]
12 [ -s <snaplen> ] [ -S <strict time adjustment> ]
13 [ -t <time adjustment> ] [ -T <encapsulation type> ] [ -v ] infile
14 outfile [ packet#[-packet#] ... ]
15
16 editcap -d | -D <dup window> | -w <dup time window> [ -v ] infile
17 outfile
18
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 pcap 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> is a detailed
45 description of the way Wireshark handles this, which is the same way
46 Editcap handles this.
47
48 Editcap can write the file in several output formats. The -F flag can
49 be used to specify the format in which to write the capture file;
50 editcap -F provides a list of the available output formats.
51
53 -A <start time>
54 Saves only the packets whose timestamp is on or after start time.
55 The time is given in the following format YYYY-MM-DD HH:MM:SS
56
57 -B <stop time>
58 Saves only the packets whose timestamp is before stop time. The
59 time is given in the following format YYYY-MM-DD HH:MM:SS
60
61 -c <packets per file>
62 Splits the packet output to different files based on uniform packet
63 counts with a maximum of <packets per file> each. Each output file
64 will be created with a suffix -nnnnn, starting with 00000. If the
65 specified number of packets is written to the output file, the next
66 output file is opened. The default is to use a single output file.
67
68 -C <choplen>
69 Sets the chop length to use when writing the packet data. Each
70 packet is chopped by a few <choplen> bytes of data. Positive values
71 chop at the packet beginning while negative values chop at the
72 packet end.
73
74 This is useful for chopping headers for decapsulation of an entire
75 capture or in the rare case that the conversion between two file
76 formats leaves some random bytes at the end of each packet.
77
78 -d Attempts to remove duplicate packets. The length and MD5 hash of
79 the current packet are compared to the previous four (4) packets.
80 If a match is found, the current packet is skipped. This option is
81 equivalent to using the option -D 5.
82
83 -D <dup window>
84 Attempts to remove duplicate packets. The length and MD5 hash of
85 the current packet are compared to the previous <dup window> - 1
86 packets. If a match is found, the current packet is skipped.
87
88 The use of the option -D 0 combined with the -v option is useful in
89 that each packet's Packet number, Len and MD5 Hash will be printed
90 to standard out. This verbose output (specifically the MD5 hash
91 strings) can be useful in scripts to identify duplicate packets
92 across trace files.
93
94 The <dup window> is specified as an integer value between 0 and
95 1000000 (inclusive).
96
97 NOTE: Specifying large <dup window> values with large tracefiles
98 can result in very long processing times for editcap.
99
100 -E <error probability>
101 Sets the probability that bytes in the output file are randomly
102 changed. Editcap uses that probability (between 0.0 and 1.0
103 inclusive) to apply errors to each data byte in the file. For
104 instance, a probability of 0.02 means that each byte has a 2%
105 chance of having an error.
106
107 This option is meant to be used for fuzz-testing protocol
108 dissectors.
109
110 -F <file format>
111 Sets the file format of the output capture file. Editcap can write
112 the file in several formats, editcap -F provides a list of the
113 available output formats. The default is the pcap format.
114
115 -h Prints the version and options and exits.
116
117 -i <seconds per file>
118 Splits the packet output to different files based on uniform time
119 intervals using a maximum interval of <seconds per file> each. Each
120 output file will be created with a suffix -nnnnn, starting with
121 00000. If packets for the specified time interval are written to
122 the output file, the next output file is opened. The default is to
123 use a single output file.
124
125 -r Reverse the packet selection. Causes the packets whose packet
126 numbers are specified on the command line to be written to the
127 output capture file, instead of discarding them.
128
129 -s <snaplen>
130 Sets the snapshot length to use when writing the data. If the -s
131 flag is used to specify a snapshot length, packets in the input
132 file with more captured data than the specified snapshot length
133 will have only the amount of data specified by the snapshot length
134 written to the output file.
135
136 This may be useful if the program that is to read the output file
137 cannot handle packets larger than a certain size (for example, the
138 versions of snoop in Solaris 2.5.1 and Solaris 2.6 appear to reject
139 Ethernet packets larger than the standard Ethernet MTU, making them
140 incapable of handling gigabit Ethernet captures if jumbo packets
141 were used).
142
143 -S <strict time adjustment>
144 Time adjust selected packets to insure strict chronological order.
145
146 The <strict time adjustment> value represents relative seconds
147 specified as [-]seconds[.fractional seconds].
148
149 As the capture file is processed each packet's absolute time is
150 possibly adjusted to be equal to or greater than the previous
151 packet's absolute timestamp depending on the <strict time
152 adjustment> value.
153
154 If <strict time adjustment> value is 0 or greater (e.g. 0.000001)
155 then only packets with a timestamp less than the previous packet
156 will adjusted. The adjusted timestamp value will be set to be
157 equal to the timestamp value of the previous packet plus the value
158 of the <strict time adjustment> value. A <strict time adjustment>
159 value of 0 will adjust the minimum number of timestamp values
160 necessary to insure that the resulting capture file is in strict
161 chronological order.
162
163 If <strict time adjustment> value is specified as a negative value,
164 then the timestamp values of all packets will be adjusted to be
165 equal to the timestamp value of the previous packet plus the
166 absolute value of the <lt>strict time adjustment<gt> value. A
167 <strict time adjustment> value of -0 will result in all packets
168 having the timestamp value of the first packet.
169
170 This feature is useful when the trace file has an occasional packet
171 with a negative delta time relative to the previous packet.
172
173 -t <time adjustment>
174 Sets the time adjustment to use on selected packets. If the -t
175 flag is used to specify a time adjustment, the specified adjustment
176 will be applied to all selected packets in the capture file. The
177 adjustment is specified as [-]seconds[.fractional seconds]. For
178 example, -t 3600 advances the timestamp on selected packets by one
179 hour while -t -0.5 reduces the timestamp on selected packets by
180 one-half second.
181
182 This feature is useful when synchronizing dumps collected on
183 different machines where the time difference between the two
184 machines is known or can be estimated.
185
186 -T <encapsulation type>
187 Sets the packet encapsulation type of the output capture file. If
188 the -T flag is used to specify an encapsulation type, the
189 encapsulation type of the output capture file will be forced to the
190 specified type. editcap -T provides a list of the available types.
191 The default type is the one appropriate to the encapsulation type
192 of the input capture file.
193
194 Note: this merely forces the encapsulation type of the output file
195 to be the specified type; the packet headers of the packets will
196 not be translated from the encapsulation type of the input capture
197 file to the specified encapsulation type (for example, it will not
198 translate an Ethernet capture to an FDDI capture if an Ethernet
199 capture is read and '-T fddi' is specified). If you need to
200 remove/add headers from/to a packet, you will need
201 od(1)/text2pcap(1).
202
203 -v Causes editcap to print verbose messages while it's working.
204
205 Use of -v with the de-duplication switches of -d, -D or -w will
206 cause all MD5 hashes to be printed whether the packet is skipped or
207 not.
208
209 -w <dup time window>
210 Attempts to remove duplicate packets. The current packet's arrival
211 time is compared with up to 1000000 previous packets. If the
212 packet's relative arrival time is less than or equal to the <dup
213 time window> of a previous packet and the packet length and MD5
214 hash of the current packet are the same then the packet to skipped.
215 The duplicate comparison test stops when the current packet's
216 relative arrival time is greater than <dup time window>.
217
218 The <dup time window> is specified as seconds[.fractional seconds].
219
220 The [.fractional seconds] component can be specified to nine (9)
221 decimal places (billionths of a second) but most typical trace
222 files have resolution to six (6) decimal places (millionths of a
223 second).
224
225 NOTE: Specifying large <dup time window> values with large
226 tracefiles can result in very long processing times for editcap.
227
228 NOTE: The -w option assumes that the packets are in chronological
229 order. If the packets are NOT in chronological order then the -w
230 duplication removal option may not identify some duplicates.
231
233 To see more detailed description of the options use:
234
235 editcap -h
236
237 To shrink the capture file by truncating the packets at 64 bytes and
238 writing it as Sun snoop file use:
239
240 editcap -s 64 -F snoop capture.pcap shortcapture.snoop
241
242 To delete packet 1000 from the capture file use:
243
244 editcap capture.pcap sans1000.pcap 1000
245
246 To limit a capture file to packets from number 200 to 750 (inclusive)
247 use:
248
249 editcap -r capture.pcap small.pcap 200-750
250
251 To get all packets from number 1-500 (inclusive) use:
252
253 editcap -r capture.pcap first500.pcap 1-500
254
255 or
256
257 editcap capture.pcap first500.pcap 501-9999999
258
259 To exclude packets 1, 5, 10 to 20 and 30 to 40 from the new file use:
260
261 editcap capture.pcap exclude.pcap 1 5 10-20 30-40
262
263 To select just packets 1, 5, 10 to 20 and 30 to 40 for the new file
264 use:
265
266 editcap -r capture.pcap select.pcap 1 5 10-20 30-40
267
268 To remove duplicate packets seen within the prior four frames use:
269
270 editcap -d capture.pcap dedup.pcap
271
272 To remove duplicate packets seen within the prior 100 frames use:
273
274 editcap -D 101 capture.pcap dedup.pcap
275
276 To remove duplicate packets seen equal to or less than 1/10th of a
277 second:
278
279 editcap -w 0.1 capture.pcap dedup.pcap
280
281 To display the MD5 hash for all of the packets (and NOT generate any
282 real output file):
283
284 editcap -v -D 0 capture.pcap /dev/null
285
286 or on Windows systems
287
288 editcap -v -D 0 capture.pcap NUL
289
290 To advance the timestamps of each packet forward by 3.0827 seconds:
291
292 editcap -t 3.0827 capture.pcap adjusted.pcap
293
294 To insure all timestamps are in strict chronological order:
295
296 editcap -S 0 capture.pcap adjusted.pcap
297
298 To introduce 5% random errors in a capture file use:
299
300 editcap -E 0.05 capture.pcap capture_error.pcap
301
303 pcap(3), wireshark(1), tshark(1), mergecap(1), dumpcap(1), capinfos(1),
304 text2pcap(1), od(1), pcap-filter(7) or tcpdump(8)
305
307 Editcap is part of the Wireshark distribution. The latest version of
308 Wireshark can be found at <http://www.wireshark.org>.
309
310 HTML versions of the Wireshark project man pages are available at:
311 <http://www.wireshark.org/docs/man-pages>.
312
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.10.14 2015-05-12 EDITCAP(1)