EDITCAP(1)
π editcap(1) β the capture-file edit/translate era, part 1 π
π NAME π
editcap β edits and/or translates the format of capture files. It's literally the capture-file makeover bestie. π
β¨ SYNOPSIS β¨
editcap [ -a <frame:comment> ] [ -A <start time> ] [ -B <stop time> ]
[ -c <packets per file> ] [ -C [offset:]<choplen> ]
[ -E <error probability> ] [ -F <file format> ]
[ -i <seconds per file> ] [ -o <change offset> ] [ -L ] [ -r ]
[ -R <frame:timestamp> ] [ -s <snaplen> ]
[ -S <strict time adjustment> ] [ -t <time adjustment> ]
[ -T <encapsulation type> ] [ -V ]
[ --inject-secrets <secrets type>,<file> ] [ --discard-all-secrets ]
[ --discard-name-resolution ] [ --discard-process-info ]
[ --capture-comment <comment> ] [ --discard-capture-comment ]
[ --discard-packet-comments ] [ --preserve-packet-comments ] infile
outfile [ packet#[-packet#] ... ]
editcap -d -D <dup window> -w <dup time window> [ -V ]
[ -I <bytes to ignore> ] [ --skip-radiotap-header ] [ --set-unused ]
[ --sctp-split ] infile outfile
editcap --extract-secrets [ -V ] infile outfile
editcap -h|--help
editcap -v|--version
πΈ DESCRIPTION πΈ
Okay so editcap is a program that reads some or all of the captured packets from the infile, optionally converts them in various ways, and writes the resulting packets to the capture outfile (or outfiles). Main character energy: it can be a whole little assembly line. π₯
By default, it reads all packets from infile and writes them to outfile in pcapng file format. Use - for infile or outfile to read from standard input or write to standard output, respectively. π«Ά
The -A and -B options allow you to limit the time range from which packets are read from infile.
An optional list of packet numbers can be specified on the command tail; individual packet numbers separated by whitespace and/or ranges of packet numbers can be specified as start-end, referring to all packets from start to end. By default the selected packets with those numbers will not be written to the capture file. If the -r flag is specified, the whole packet selection is reversed; in that case only the selected packets will be written to the capture file. π¦
editcap can also be used to remove duplicate packets. Several different options (-d, -D and -w) are used to control the packet window or relative time window to be used for duplicate comparison.
editcap can be used to assign comment strings to frame numbers.
editcap is able to detect, read and write the same capture files that are supported by Wireshark. The input file doesnβt need a specific filename extension; the file format and an optional gzip, zstd or lz4 compression will be automatically detected. Near the beginning of the DESCRIPTION section of wireshark(1) or https://www.wireshark.org/docs/man-pages/wireshark.html is a detailed description of the way Wireshark handles this, which is the same way editcap handles this. π§
editcap can write the file in several output formats. The -F flag can be used to specify the format in which to write the capture file; editcap -F provides a list of the available output formats. editcap can also compress the output file. The --compress option can specify the compression type. If that option is not given, then the desired compression method, if any, is deduced from the extension of outfile; e.g., if the output filename has the .gz extension, then the gzip format is used. β¨
editcap can also be used to extract embedded decryption secrets from file formats like pcapng that contain them, in lieu of writing a capture file. π
π OPTIONS π
-a<framenum:comment>β for the specified frame number, assign the given comment string. Can be repeated for multiple frames. Only the last comment string for each unique frame number specified in the command line will be saved. Quotes should be used with comment strings that include spaces.
By default the -a option will replace any and all packet comments for the given frame number. Add the --preserve-packet-comment option to the command line to preserve any pre-existing packet comments.
-A<start time>β reads only the packets whose timestamp is on or after<start time>. The time may be given either in ISO 8601 format or in Unix epoch timestamp format.
ISO 8601 format is either
YYYY-MM-DD HH:MM:SS[.nnnnnnnnn][Z|Β±hh:mm]
or
YYYY-MM-DDTHH:MM:SS[.nnnnnnnnn][Z|Β±hh:mm]
The fractional seconds are optional, as is the time zone offset from UTC (in which case local time is assumed).
Unix epoch format is in seconds since the Unix epoch and nanoseconds, with either a period or a comma separating the seconds and nanoseconds. The nanoseconds are optional. The Unix epoch is 1970-01-01 00:00:00 UTC, so this format is not local time.
-B<stop time>β reads only the packets whose timestamp is before<stop time>. The time may be given either in ISO 8601 format or in Unix epoch timestamp format.
ISO 8601 format is either
YYYY-MM-DD HH:MM:SS[.nnnnnnnnn][Z|Β±hh:mm]
or
YYYY-MM-DDTHH:MM:SS[.nnnnnnnnn][Z|Β±hh:mm]
The fractional seconds are optional, as is the time zone offset from UTC (in which case local time is assumed).
Unix epoch format is in seconds since the Unix epoch and nanoseconds, with either a period or a comma separating the seconds and nanoseconds. The nanoseconds are optional. The Unix epoch is 1970-01-01 00:00:00 UTC, so this format is not local time.
-c<packets per file>β splits the packet output to different files based on uniform packet counts with a maximum of<packets per file>each.
Each output file will be created with an infix _nnnnn[_YYYYmmddHHMMSS] inserted before the file extension (which may be null) of outfile. The infix consists of the ordinal number of the output file, starting with 00000, followed by the timestamp of its first packet. The timestamp is omitted if the input file does not contain timestamp information.
After the specified number of packets is written to the output file, the next output file is opened. The default is to use a single output file. This option conflicts with -i. π
-C[offset:]<choplen>β sets the chop length to use when writing the packet data. Each packet is chopped by<choplen>bytes of data. Positive values chop at the packet beginning while negative values chop at the packet end.
If an optional offset precedes the <choplen>, then the bytes chopped will be offset from that value. Positive offsets are from the packet beginning, while negative offsets are from the packet end.
This is useful for chopping headers for decapsulation of an entire capture, removing tunneling headers, or in the rare case that the conversion between two file formats leaves some random bytes at the end of each packet. Another use is for removing vlan tags.
Note: this option can be used more than once, effectively allowing you to chop bytes from up to two different areas of a packet in a single pass provided that you specify at least one chop length as a positive value and at least one as a negative value. All positive chop lengths are added together as are all negative chop lengths. π
-dβ attempts to remove duplicate packets. The length and MD5 hash of the current packet are compared to the previous four (4) packets. If a match is found, the current packet is skipped. This option is equivalent to using the option-D 5.-D<dup window>β attempts to remove duplicate packets. The length and MD5 hash of the current packet are compared to the previous<dup window>- 1 packets. If a match is found, the current packet is skipped.
The use of the option -D 0 combined with the -V option is useful in that each packetβs Packet number, Len and MD5 Hash will be printed to standard error. This verbose output (specifically the MD5 hash strings) can be useful in scripts to identify duplicate packets across trace files.
The <dup window> is specified as an integer value between 0 and 1000000 (inclusive).
Note: specifying large<dup window>values with large tracefiles can result in very long processing times foreditcap. π
-E<error probability>β sets the probability that bytes in the output file are randomly changed.editcapuses that probability (between0.0and1.0inclusive) to apply errors to each data byte in the file. For instance, a probability of0.02means that each byte has a 2% chance of having an error.
This option is meant to be used for fuzz-testing protocol dissectors.
-F<file format>β sets the file format of the output capture file.editcapcan write the file in several formats,editcap -Fprovides a list of the available output formats. The default is thepcapngformat.-h|--helpβ print the version number and options and exit.-i<seconds per file>β splits the packet output to different files based on uniform time intervals using a maximum interval of<seconds per file>each. Floating point values (e.g.0.5) are allowed.
Each output file will be created with the same _nnnnn[_YYYYmmddHHMMSS] infix deets as -c: inserted before the file extension (which may be null) of outfile, with the ordinal number of the output file starting at 00000, followed by the timestamp of its first packet. The timestamp is omitted if the input file does not contain timestamp information.
After packets for the specified time interval are written to the output file, the next output file is opened. The default is to use a single output file. This option conflicts with -c. π
-I<bytes to ignore>β ignore the specified number of bytes at the beginning of the frame during MD5 hash calculation, unless the frame is too short, then the full frame is used. Useful to remove duplicated packets taken on several routers (different mac addresses for example) e.g.-I 26in case of Ether/IP will ignoreether(14)and IP header(20 - 4(src ip) - 4(dst ip)). The default value is0.-Lβ adjust the original frame length accordingly when chopping and/or snapping (in addition to the captured length, which is always adjusted regardless of whether-Lis specified or not). See also-C <choplen>and-s <snaplen>.-o<change offset>
Okay so when this one's paired with -E, it skips some bytes from the beginning of the packet so they don't get changed π«Ά. That way some headers stay untouched and the fuzzer is hyperfocused on a smaller part of the packet instead of the whole thing. Keeping a part of the packet fixed means the same dissector gets triggered, which makes the fuzzing way more precise. Obsessed.
-rβ Reverses the packet selection, like a little plot twist π. It causes the packets whose packet numbers you specified on the command line to be written to the output capture file, instead of being discarded.-R<framenum:timestamp>β For the specified frame number, assigns the given timestamp β¨. You can repeat this one for multiple frames, so go off.
The time can be given either in ISO 8601 format or in Unix epoch timestamp format.
ISO 8601 format is either
YYYY-MM-DD HH:MM:SS[.nnnnnnnnn][Z|Β±hh:mm]
or
YYYY-MM-DDTHH:MM:SS[.nnnnnnnnn][Z|Β±hh:mm]
The fractional seconds are optional, and so is the time zone offset from UTC (and if you don't give one, local time is assumed π).
Unix epoch format is in seconds since the Unix epoch plus nanoseconds, with either a period or a comma separating the seconds and the nanoseconds. The nanoseconds are optional. And like, the Unix epoch is 1970-01-01 00:00:00 UTC, so this format is not local time β do not come for me on that one π.
-s<snaplen>β Sets the snapshot length to use when writing the data. If the-sflag is used to specify a snapshot length, packets in the input file that have more captured data than the specified snapshot length will get only the amount of data specified by the snapshot length written to the output file. Trimming the fit, basically βοΈ.
This may be useful if the program that's going to read the output file can't handle packets larger than a certain size (for example, the versions of snoop in Solaris 2.5.1 and Solaris 2.6 appear to reject Ethernet packets larger than the standard Ethernet MTU, making them incapable of handling gigabit Ethernet captures if jumbo packets were used). Ancient behaviour, but we respect the lore π«‘.
--seed<seed>β When used in conjunction with-E, sets the seed for the pseudo-random number generator π². It's useful for recreating a particular sequence of errors, so you can summon the exact same chaos again.--skip-radiotap-headerβ Skips the radiotap header of each frame when checking for packet duplicates π . This is useful when you're processing a capture created by combining outputs of multiple capture devices on the same channel in the vicinity of each other. Same channel, same vibe, different headers.-S<strict time adjustment>β Time-adjusts selected packets to ensure strict chronological order β°.
The <strict time adjustment> value represents relative seconds, specified as seconds[.fractional seconds].
As the capture file is processed, each packet's absolute time is possibly adjusted to be equal to or greater than the previous packet's absolute timestamp, depending on the <strict time adjustment> value.
If the <strict time adjustment> value is 0 or greater (e.g. 0.000001) then only packets with a timestamp less than the previous packet will be adjusted. The adjusted timestamp value will be set to be equal to the timestamp value of the previous packet plus the value of the <strict time adjustment> value. A <strict time adjustment> value of 0 will adjust the minimum number of timestamp values necessary to ensure the resulting capture file is in strict chronological order. Iconic minimal-effort behaviour.
If the <strict time adjustment> value is specified as a negative value, then the timestamp values of all packets will be adjusted to be equal to the timestamp value of the previous packet plus the absolute value of the <strict time adjustment> value. A <strict time adjustment> value of -0 will result in all packets having the timestamp value of the first packet π°οΈ.
This feature is useful when the trace file has an occasional packet with a negative delta time relative to the previous packet.
-t<time adjustment>β Sets the time adjustment to use on selected packets. If the-tflag is used to specify a time adjustment, the specified adjustment gets applied to all selected packets in the capture file. The adjustment is specified asseconds[.fractional seconds]. For example,-t 3600advances the timestamp on selected packets by one hour, while-t -0.5reduces the timestamp on selected packets by one-half second β³.
This feature is useful when synchronizing dumps collected on different machines where the time difference between the two machines is known or can be estimated. Clock-syncing besties rise π«Ά.
-T<encapsulation type>β Sets the packet encapsulation type of the output capture file. If the-Tflag is used to specify an encapsulation type, the encapsulation type of the output capture file will be forced to the specified type.editcap -Tprovides a list of the available types π. The default type is the one appropriate to the encapsulation type of the input capture file.
Note: this merely forces the encapsulation type of the output file to be the specified type; the packet headers of the packets will not be translated from the encapsulation type of the input capture file to the specified encapsulation type. So no cap: it will not translate an Ethernet capture to an FDDI capture if an Ethernet capture is read and-T fddiis specified. If you need to remove/add headers from/to a packet, you'll needod(1)/text2pcap(1). It's giving delegation π .
-v,--versionβ Prints the full version information and exits. That's it, that's the whole vibe β¨.-Vβ Causeseditcapto print verbose messages while it's working π£οΈ.
Use of -V with the de-duplication switches of -d, -D or -w will cause all MD5 hashes to be printed, whether the packet is skipped or not. Full transparency, we love to see it.
-w<dup time window>β Attempts to remove duplicate packets π―. The current packet's arrival time is compared with up to 1000000 previous packets. If the packet's relative arrival time is less than or equal to the<dup time window>of a previous packet and the packet length and MD5 hash of the current packet are the same, then the packet is skipped. The duplicate comparison test stops when the current packet's relative arrival time is greater than<dup time window>.
The <dup time window> is specified as seconds[.fractional seconds].
The [.fractional seconds] component can be specified to nine (9) decimal places (billionths of a second), but most typical trace files have resolution to six (6) decimal places (millionths of a second).
Note: specifying large<dup time window>values with large tracefiles can result in very long processing times foreditcap. Like, go make a snack π.
Note: the-woption assumes that the packets are in chronological order. If the packets are NOT in chronological order then the-wduplication removal option may not identify some duplicates. Rude, but that's the deal π.
--inject-secrets<secrets type>,<file>β Inserts the contents of<file>into a Decryption Secrets Block (DSB) within the pcapng output file π. This enables decryption without requiring additional configuration in protocol preferences. Main character energy.
The file format is described by <secrets type>, which can be one of:
opcuaβ OPC UA Key Log, seehttps://ietf-opsawg-wg.github.io/draft-ietf-opsawg-pcap/draft-ietf-opsawg-pcapng.html#name-decryption-secrets-blocksshβ SSH Key Log, seehttps://wiki.wireshark.org/SSH#key-log-formattlsβ TLS Key Log, seehttps://tlswg.org/sslkeylogfile/draft-ietf-tls-keylogfile.htmlwgβ WireGuard Key Log, seehttps://wiki.wireshark.org/WireGuard#key-log-formatespβ ESP SA Key, see theesp_safile in your profile folder andhttps://ietf-opsawg-wg.github.io/draft-ietf-opsawg-pcap/draft-ietf-opsawg-pcapng.html#name-decryption-secrets-block
This option may be specified multiple times π. The available options for <secrets type> can be listed with --inject-secrets help.
--extract-secretsβ Extracts each Decryption Secrets Block (DSB) contained withininfileπ§. If there's only one, it gets written tooutfileinstead of a capture file. If there's more than one, they're each written to unique output files named with an infix_nnnnnbefore the file extension ofoutfile, in a manner similar to the-cflag (unless writing to standard output). So cute, so organized.
Incompatible with other options except for -V π
ββοΈ.
--discard-all-secretsβ Discards all decryption secrets from the input file when writing the output file ποΈ. Does not discard secrets added by--inject-secretsin the same command line. Your secrets are yours.--discard-name-resolutionβ Discards all Name Resolution Block (NRB) entries from the input file when writing the output file π«. This removes all hostname-to-IP address mappings that were embedded in the capture file at capture time. Bye bye, map.--discard-process-infoβ Discards the process information from the input file when writing the output file: the blocks that describe the processes on the capturing host (as recorded bydumpcap --process-info, or by Darwin), and the options of the packets that refer to them π§Ή. Use it before sharing a capture file, because those blocks can hold the names, executable paths, command lines and users of the processes. Protect the people, fr fr π«Ά.--capture-comment<comment>β Adds the given comment to the output file, if supported by the output file format π¬. New comments will be added after any comments present in the input file, unless--discard-capture-commentis also specified.
This option may be specified multiple times. Note that Wireshark currently only displays the first comment of a capture file π β so the rest are lowkey just sitting there.
--discard-capture-commentβ Discards all capture file comments from the input file when writing the output file ποΈ. Does not discard comments added by--capture-commentin the same command line.--set-unusedβ Sets the unused bytes (if any) to zero in SLL link type π§. Useful when checking for duplicates, since those unused bytes can be anything β like when the packet traverses the device stack for bonded interfaces on Linux, for example.--discard-packet-commentsβ Discards all packet comments from the input file when writing the output file ποΈ. Does not discard comments added by-ain the same command line.
This option takes precedence over the --preserve-packet-comments option. She said what she said π
.
--preserve-packet-commentsβ When adding a new packet comment with the-aoption, this preserves from the input file any packet comments for the specified frame when writing the output file π. Without this option, any-aoptions will replace any and all pre-existing packet comments for the given frame number. Choose your fighter.
okay so quick continuation from that last option: it does not allow for the -a option to add multiple packet comments for same frame number in the same command line.
and lowkey the --discard-packet-comments option takes precedence over this option. periodt. π
--compress <type>β Compress the output file using the type compression format.--compresswith no argument provides a list of the compression formats supported for writing. The type given takes precedence over the extension ofoutfile.--sctp-splitβ Split SCTP packets containing multiple bundled DATA chunks into individual packets, one per DATA chunk. Each split packet retains the original Ethernet, IP, and SCTP common headers. A packet comment indicating the original frame number is added to each split packet. Non-SCTP packets and SCTP packets without DATA chunks are passed through unchanged. π¦
π©Ί DIAGNOSTIC OPTIONS π©Ί
--log-level <level>β Set the active log level. Supported levels in lowest to highest order are"noisy","debug","info","message","warning","critical", and"error". Messages at each level and higher will be printed β for example"warning"prints"warning","critical", and"error"messages, and"noisy"prints all messages. Levels are case insensitive.--log-fatal <level>β Abort the program if any messages are logged at the specified level or higher. For example,"warning"aborts on any"warning","critical", or"error"messages.--log-fatal-count <count>β The amount of fatal log messages which may pass before the program is aborted.--log-domains <list>β Only print messages for the specified log domains, e.g."GUI,Epan,sshdump". List of domains must be comma-separated. Can be negated with!as the first character (inverts the match).--log-debug <list>β Force the specified domains to log at the"debug"level. List of domains must be comma-separated. Can be negated with!as the first character (inverts the match).--log-noisy <list>β Force the specified domains to log at the"noisy"level. List of domains must be comma-separated. Can be negated with!as the first character (inverts the match).--log-fatal-domains <list>β Abort the program if any messages are logged for the specified log domains. List of domains must be comma-separated.--log-file <path>β Write log messages and stderr output to the specified file.
π§ͺ EXAMPLES π§ͺ
To see more detailed description of the options use:
editcap -h
To shrink the capture file by truncating the packets at 64 bytes and writing it as Sun snoop file use:
editcap -s 64 -F snoop capture.pcapng shortcapture.snoop
To delete packet 1000 from the capture file use:
editcap capture.pcapng sans1000.pcapng 1000
To limit a capture file to packets from number 200 to 750 (inclusive) use:
editcap -r capture.pcapng small.pcapng 200-750
To get all packets from number 1-500 (inclusive) use:
editcap -r capture.pcapng first500.pcapng 1-500
or
editcap capture.pcapng first500.pcapng 501-9999999
To exclude packets 1, 5, 10 to 20 and 30 to 40 from the new file use:
editcap capture.pcapng exclude.pcapng 1 5 10-20 30-40
To select just packets 1, 5, 10 to 20 and 30 to 40 for the new file use:
editcap -r capture.pcapng select.pcapng 1 5 10-20 30-40
To remove duplicate packets seen within the prior four frames use:
editcap -d capture.pcapng dedup.pcapng
To remove duplicate packets seen within the prior four frames while skipping radiotap headers use:
editcap -d --skip-radiotap-header capture.pcapng dedup.pcapng
To remove duplicate packets seen within the prior 100 frames use:
editcap -D 101 capture.pcapng dedup.pcapng
To remove duplicate packets seen equal to or less than 1/10th of a second:
editcap -w 0.1 capture.pcapng dedup.pcapng
To display the MD5 hash for all of the packets (and NOT generate any real output file):
editcap -V -D 0 capture.pcapng /dev/null
or on Windows systems
editcap -V -D 0 capture.pcapng NUL
To advance the timestamps of each packet forward by 3.0827 seconds:
editcap -t 3.0827 capture.pcapng adjusted.pcapng
To ensure all timestamps are in strict chronological order:
editcap -S 0 capture.pcapng adjusted.pcapng
To introduce 5% random errors in a capture file use:
editcap -E 0.05 capture.pcapng capture_error.pcapng
To remove vlan tags from all packets within an Ethernet-encapsulated capture file, use:
editcap -L -C 12:4 capture_vlan.pcapng capture_no_vlan.pcapng
To chop both the 10 byte and 20 byte regions from the following 75 byte packet in a single pass, use any of the 8 possible methods provided below:
<--------------------------- 75 ---------------------------->
+---+-------+-----------+---------------+-------------------+
| 5 | 10 | 15 | 20 | 25 |
+---+-------+-----------+---------------+-------------------+
1) editcap -C 5:10 -C -25:-20 capture.pcapng chopped.pcapng
2) editcap -C 5:10 -C 50:-20 capture.pcapng chopped.pcapng
3) editcap -C -70:10 -C -25:-20 capture.pcapng chopped.pcapng
4) editcap -C -70:10 -C 50:-20 capture.pcapng chopped.pcapng
5) editcap -C 30:20 -C -60:-10 capture.pcapng chopped.pcapng
6) editcap -C 30:20 -C 15:-10 capture.pcapng chopped.pcapng
7) editcap -C -45:20 -C -60:-10 capture.pcapng chopped.pcapng
8) editcap -C -45:20 -C 15:-10 capture.pcapng chopped.pcapng
To add comment strings to the first 2 input frames, use:
editcap -a "1:1st frame" -a 2:Second capture.pcapng capture-comments.pcapng
To add an additional comment to the first frame, use:
editcap --preserve-packet-comments -a "1:This is another comment" \
capture-comments.pcapng more-capture-comments.pcapng
π SEE ALSO π
pcap(3), wireshark(1), tshark(1), mergecap(1), dumpcap(1), capinfos(1), text2pcap(1), reordercap(1), od(1), pcap-filter(7) or tcpdump(8)
π NOTES π
This is the manual page for Editcap 4.7.4. Editcap is part of the Wireshark distribution. The latest version of Wireshark can be found at https://www.wireshark.org.
HTML versions of the Wireshark project man pages are available at https://www.wireshark.org/docs/man-pages.
π AUTHORS π
- Original Author:
Richard Sharpe <sharpe[AT]ns.aus.com> - Contributors:
Guy Harris <guy[AT]alum.mit.edu>,Ulf Lamping <ulf.lamping[AT]web.de>
mwah π β this page is the Editcap 4.7.4 manual, dated 2026-10-08, source/version EDITCAP(1), and thatβs the whole footer vibe, periodt. π
π¦ where this page comes from
- arch rolling: wireshark-cli 4.7.4-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms