1 <!-- WSUG Appendix Tools -->
4 <appendix id="AppTools">
5 <title>Related command line tools</title>
7 <section id="AppToolsIntroduction">
8 <title>Introduction</title>
10 Besides the Wireshark GUI application, there are some command line tools
11 which can be helpful for doing some more specialized things. These tools
12 will be described in this chapter.
16 <section id="AppToolstshark">
17 <title><command>tshark</command>: Terminal-based Wireshark</title>
19 <application>TShark</application> is a terminal oriented version
20 of Wireshark designed for capturing and displaying packets when an
21 interactive user interface isn't necessary or available. It supports
22 the same options as <command>wireshark</command>. For more
23 information on <command>tshark</command>, see the manual pages
24 (<command>man tshark</command>).
27 <example id="AppToolstsharkEx">
28 <title>Help information available from tshark</title>
30 TShark 1.11.0 (SVN Rev 52564 from /trunk)
31 Dump and analyze network traffic.
32 See http://www.wireshark.org for more information.
34 Copyright 1998-2013 Gerald Combs <gerald@wireshark.org> and contributors.
35 This is free software; see the source for copying conditions. There is NO
36 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
38 Usage: tshark [options] ...
41 -i <interface> name or idx of interface (def: first non-loopback)
42 -f <capture filter> packet filter in libpcap filter syntax
43 -s <snaplen> packet snapshot length (def: 65535)
44 -p don't capture in promiscuous mode
45 -I capture in monitor mode, if available
46 -B <buffer size> size of kernel buffer (def: 1MB)
47 -y <link type> link layer type (def: first appropriate)
48 -D print list of interfaces and exit
49 -L print list of link-layer types of iface and exit
51 Capture stop conditions:
52 -c <packet count> stop after n packets (def: infinite)
53 -a <autostop cond.> ... duration:NUM - stop after NUM seconds
54 filesize:NUM - stop this file after NUM KB
55 files:NUM - stop after NUM files
57 -b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs
58 filesize:NUM - switch to next file after NUM KB
59 files:NUM - ringbuffer: replace after NUM files
61 -A <user>:<password> use RPCAP password authentication
63 -r <infile> set the filename to read from (no pipes or stdin!)
66 -2 perform a two-pass analysis
67 -R <read filter> packet Read filter in Wireshark display filter syntax
68 -Y <display filter> packet displaY filter in Wireshark display filter syntax
69 -n disable all name resolutions (def: all enabled)
70 -N <name resolve flags> enable specific name resolution(s): "mntC"
71 -d <layer_type>==<selector>,<decode_as_protocol> ...
72 "Decode As", see the man page for details
73 Example: tcp.port==8888,http
74 -H <hosts file> read a list of entries from a hosts file, which will
75 then be written to a capture file. (Implies -W n)
77 -w <outfile|-> write packets to a pcap-format file named "outfile"
78 (or to the standard output for "-")
79 -C <config profile> start with specified configuration profile
80 -F <output file type> set the output file type, default is libpcap
81 an empty "-F" option will list the file types
82 -V add output of packet tree (Packet Details)
83 -O <protocols> Only show packet details of these protocols, comma
85 -P print packet summary even when writing to a file
86 -S <separator> the line separator to print between packets
87 -x add output of hex and ASCII dump (Packet Bytes)
88 -T pdml|ps|psml|text|fields
89 format of text output (def: text)
90 -e <field> field to print if -Tfields selected (e.g. tcp.port, _ws.col.Info);
91 this option can be repeated to print multiple fields
92 -E<fieldsoption>=<value> set options for output when -Tfields selected:
93 header=y|n switch headers on and off
94 separator=/t|/s|<char> select tab, space, printable character as separator
95 occurrence=f|l|a print first, last or all occurrences of each field
96 aggregator=,|/s|<char> select comma, space, printable character as
98 quote=d|s|n select double, single, no quotes for values
99 -t a|ad|d|dd|e|r|u|ud output format of time stamps (def: r: rel. to first)
100 -u s|hms output format of seconds (def: s: seconds)
101 -l flush standard output after each packet
102 -q be more quiet on stdout (e.g. when using statistics)
103 -Q only log true errors to stderr (quieter than -q)
104 -g enable group read access on the output file(s)
105 -W n Save extra information in the file, if supported.
106 n = write network address resolution information
107 -X <key>:<value> eXtension options, see the man page for details
108 -z <statistics> various statistics, see the man page for details
109 --capture-comment <comment>
110 add a capture comment to the newly created
111 output file (only for pcapng)
114 -h display this help and exit
115 -v display version info and exit
116 -o <name>:<value> ... override preference setting
117 -K <keytab> keytab file to use for kerberos decryption
118 -G [report] dump one of several available reports and exit
119 default report="fields"
120 use "-G ?" for more help
126 <section id="AppToolstcpdump">
127 <title><command>tcpdump</command>: Capturing with tcpdump for viewing
128 with Wireshark</title>
130 There are occasions when you want to capture packets using
131 <command>tcpdump</command> rather than <command>wireshark</command>,
132 especially when you want to do a remote capture and do not want the
133 network load associated with running Wireshark remotely (not to
134 mention all the X traffic polluting your capture).
137 However, the default <command>tcpdump</command> parameters result in a
138 capture file where each packet is truncated, because most versions of
139 <command>tcpdump</command>, will, by default, only capture the first
140 68 or 96 bytes of each packet.
143 To ensure that you capture complete packets, use the following command:
145 tcpdump -i <interface> -s 65535 -w <some-file>
147 You will have to specify the correct <command>interface</command> and
148 the name of a <command>file</command> to save into. In addition,
149 you will have to terminate the capture with ^C when you believe you
150 have captured enough packets.
152 <note><title>Note!</title>
154 tcpdump is not part of the Wireshark distribution. You can get it from:
155 <ulink url="&TcpdumpWebsite;">&TcpdumpWebsite;</ulink> for various
161 <section id="AppToolsdumpcap">
162 <title><command>dumpcap</command>: Capturing with dumpcap for viewing
163 with Wireshark</title>
165 <application>Dumpcap</application> is a network traffic dump tool.
166 It captures packet data from a live network and writes the
168 Dumpcap's native capture file format is libpcap format, which is also
169 the format used by Wireshark, tcpdump and various other tools.
172 Without any options set it will use the pcap library to capture traffic
173 from the first available network interface and write the received raw
174 packet data, along with the packets' time stamps into a libpcap file.
177 Packet capturing is performed with the pcap library.
178 The capture filter syntax follows the rules of the pcap library.
181 <example id="AppToolsdumpcapEx">
182 <title>Help information available from dumpcap</title>
184 Dumpcap 1.11.0 (SVN Rev 52564 from /trunk)
185 Capture network packets and dump them into a pcapng file.
186 See http://www.wireshark.org for more information.
188 Usage: dumpcap [options] ...
191 -i <interface> name or idx of interface (def: first non-loopback)
192 or for remote capturing, use one of these formats:
193 rpcap://<host>/<interface>
194 TCP@<host>:<port>
195 -f <capture filter> packet filter in libpcap filter syntax
196 -s <snaplen> packet snapshot length (def: 65535)
197 -p don't capture in promiscuous mode
198 -I capture in monitor mode, if available
199 -B <buffer size> size of kernel buffer in MB (def: 2MB)
200 -y <link type> link layer type (def: first appropriate)
201 -D print list of interfaces and exit
202 -L print list of link-layer types of iface and exit
203 -d print generated BPF code for capture filter
204 -k set channel on wifi interface <freq>,[<type>]
205 -S print statistics for each interface once per second
206 -M for -D, -L, and -S, produce machine-readable output
209 -r don't ignore own RPCAP traffic in capture
210 -u use UDP for RPCAP data transfer
211 -A <user>:<password> use RPCAP password authentication
212 -m <sampling type> use packet sampling
213 count:NUM - capture one packet of every NUM
214 timer:NUM - capture no more than 1 packet in NUM ms
216 -c <packet count> stop after n packets (def: infinite)
217 -a <autostop cond.> ... duration:NUM - stop after NUM seconds
218 filesize:NUM - stop this file after NUM KB
219 files:NUM - stop after NUM files
221 -w <filename> name of file to save (def: tempfile)
222 -g enable group read access on the output file(s)
223 -b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs
224 filesize:NUM - switch to next file after NUM KB
225 files:NUM - ringbuffer: replace after NUM files
226 -n use pcapng format instead of pcap (default)
227 -P use libpcap format instead of pcapng
228 --capture-comment <comment>
229 add a capture comment to the output file
233 -N <packet_limit> maximum number of packets buffered within dumpcap
234 -C <byte_limit> maximum number of bytes used for buffering packets
236 -t use a separate thread per interface
237 -q don't report packet capture counts
238 -v print version information and exit
239 -h display this help and exit
241 Example: dumpcap -i eth0 -a duration:60 -w output.pcapng
242 "Capture packets from interface eth0 until 60s passed into output.pcapng"
244 Use Ctrl-C to stop capturing at any time.
250 <section id="AppToolscapinfos">
251 <title><command>capinfos</command>: Print information about capture files
254 Included with Wireshark is a small utility called
255 <command>capinfos</command>, which is a command-line utility to
256 print information about binary capture files.
259 <example id="AppToolscapinfosEx">
260 <title>Help information available from capinfos</title>
262 Capinfos 1.11.0 (SVN Rev 52564 from /trunk)
263 Prints various information (infos) about capture files.
264 See http://www.wireshark.org for more information.
266 Usage: capinfos [options] <infile> ...
269 -t display the capture file type
270 -E display the capture file encapsulation
271 -H display the SHA1, RMD160, and MD5 hashes of the file
272 -k display the capture comment
275 -c display the number of packets
276 -s display the size of the file (in bytes)
277 -d display the total length of all packets (in bytes)
278 -l display the packet size limit (snapshot length)
281 -u display the capture duration (in seconds)
282 -a display the capture start time
283 -e display the capture end time
284 -o display the capture file chronological status (True/False)
285 -S display start and end times as seconds
288 -y display average data rate (in bytes/sec)
289 -i display average data rate (in bits/sec)
290 -z display average packet size (in bytes)
291 -x display average packet rate (in packets/sec)
294 -L generate long report (default)
295 -T generate table report
296 -M display machine-readable values in long reports
298 Table report options:
299 -R generate header record (default)
300 -r do not generate header record
302 -B separate infos with TAB character (default)
303 -m separate infos with comma (,) character
304 -b separate infos with SPACE character
306 -N do not quote infos (default)
307 -q quote infos with single quotes (')
308 -Q quote infos with double quotes (")
311 -h display this help and exit
312 -C cancel processing if file open fails (default is to continue)
313 -A generate all infos (default)
315 Options are processed from left to right order with later options superceding
316 or adding to earlier options.
318 If no options are given the default is to display all infos in long report
325 <section id="AppToolsrawshark" >
326 <title><command>rawshark</command>: Dump and analyze network traffic.
329 Rawshark reads a stream of packets from a file or pipe, and prints
330 a line describing its output, followed by a set of matching fields
331 for each packet on stdout.
333 <example id="AppToolsrawsharkEx">
334 <title>Help information available from rawshark</title>
336 Rawshark 1.11.0 (SVN Rev 52564 from /trunk)
337 Dump and analyze network traffic.
338 See http://www.wireshark.org for more information.
340 Copyright 1998-2013 Gerald Combs <gerald@wireshark.org> and contributors.
341 This is free software; see the source for copying conditions. There is NO
342 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
344 Usage: rawshark [options] ...
347 -r <infile> set the pipe or file name to read from
350 -d <encap:linktype>|<proto:protoname>
351 packet encapsulation or protocol
352 -F <field> field to display
353 -n disable all name resolution (def: all enabled)
354 -N <name resolve flags> enable specific name resolution(s): "mntC"
355 -p use the system's packet header format
356 (which may have 64-bit timestamps)
357 -R <read filter> packet filter in Wireshark display filter syntax
358 -s skip PCAP header on input
361 -l flush output after each packet
362 -S format string for fields
363 (%D - name, %S - stringval, %N numval)
364 -t ad|a|r|d|dd|e output format of time stamps (def: r: rel. to first)
367 -h display this help and exit
368 -o <name>:<value> ... override preference setting
369 -v display version info and exit
374 <section id="AppToolseditcap">
375 <title><command>editcap</command>: Edit capture files</title>
377 Included with Wireshark is a small utility called
378 <command>editcap</command>, which is a command-line utility for
379 working with capture files. Its main function is to remove
380 packets from capture files, but it can also be used to convert
381 capture files from one format to another, as well as to print
382 information about capture files.
386 <example id="AppToolseditcapEx">
387 <title>Help information available from editcap</title>
390 Editcap 1.11.0 (SVN Rev 52564 from /trunk)
391 Edit and/or translate the format of capture files.
392 See http://www.wireshark.org for more information.
394 Usage: editcap [options] ... <infile> <outfile> [ <packet#>[-<packet#>] ... ]
396 <infile> and <outfile> must both be present.
397 A single packet or a range of packets can be selected.
400 -r keep the selected packets; default is to delete them.
401 -A <start time> only output packets whose timestamp is after (or equal
402 to) the given time (format as YYYY-MM-DD hh:mm:ss).
403 -B <stop time> only output packets whose timestamp is before the
404 given time (format as YYYY-MM-DD hh:mm:ss).
406 Duplicate packet removal:
407 -d remove packet if duplicate (window == 5).
408 -D <dup window> remove packet if duplicate; configurable <dup window>
409 Valid <dup window> values are 0 to 1000000.
410 NOTE: A <dup window> of 0 with -v (verbose option) is
411 useful to print MD5 hashes.
412 -w <dup time window> remove packet if duplicate packet is found EQUAL TO OR
413 LESS THAN <dup time window> prior to current packet.
414 A <dup time window> is specified in relative seconds
417 NOTE: The use of the 'Duplicate packet removal' options with
418 other editcap options except -v may not always work as expected.
419 Specifically the -r, -t or -S options will very likely NOT have the
420 desired effect if combined with the -d, -D or -w.
423 -s <snaplen> truncate each packet to max. <snaplen> bytes of data.
424 -C [offset:]<choplen> chop each packet by <choplen> bytes. Positive values
425 chop at the packet beginning, negative values at the
426 packet end. If an optional offset precedes the length,
427 then the bytes chopped will be offset from that value.
428 Positive offsets are from the packet beginning,
429 negative offsets are from the packet end. You can use
430 this option more than once, allowing up to 2 chopping
431 regions within a packet provided that at least 1
432 choplen is positive and at least 1 is negative.
433 -L adjust the frame length when chopping and/or snapping
434 -t <time adjustment> adjust the timestamp of each packet;
435 <time adjustment> is in relative seconds (e.g. -0.5).
436 -S <strict adjustment> adjust timestamp of packets if necessary to insure
437 strict chronological increasing order. The <strict
438 adjustment> is specified in relative seconds with
439 values of 0 or 0.000001 being the most reasonable.
440 A negative adjustment value will modify timestamps so
441 that each packet's delta time is the absolute value
442 of the adjustment specified. A value of -0 will set
443 all packets to the timestamp of the first packet.
444 -E <error probability> set the probability (between 0.0 and 1.0 incl.) that
445 a particular packet byte will be randomly changed.
448 -c <packets per file> split the packet output to different files based on
449 uniform packet counts with a maximum of
450 <packets per file> each.
451 -i <seconds per file> split the packet output to different files based on
452 uniform time intervals with a maximum of
453 <seconds per file> each.
454 -F <capture type> set the output file type; default is pcapng. An empty
455 "-F" option will list the file types.
456 -T <encap type> set the output file encapsulation type; default is the
457 same as the input file. An empty "-T" option will
458 list the encapsulation types.
461 -h display this help and exit.
463 If -v is used with any of the 'Duplicate Packet
464 Removal' options (-d, -D or -w) then Packet lengths
465 and MD5 hashes are printed to standard-out.
469 <example id="AppToolseditcapEx1">
470 <title>Capture file types available from editcap</title>
474 editcap: option requires an argument -- 'F'
475 editcap: The available capture file types for the "-F" flag are:
476 5views - InfoVista 5View capture
477 btsnoop - Symbian OS btsnoop
478 commview - TamoSoft CommView
479 dct2000 - Catapult DCT2000 trace (.out format)
480 erf - Endace ERF capture
481 eyesdn - EyeSDN USB S0/E1 ISDN trace format
482 k12text - K12 text file
483 lanalyzer - Novell LANalyzer
484 modlibpcap - Modified tcpdump - libpcap
485 netmon1 - Microsoft NetMon 1.x
486 netmon2 - Microsoft NetMon 2.x
487 nettl - HP-UX nettl trace
488 ngsniffer - Sniffer (DOS)
489 ngwsniffer_1_1 - NetXray, Sniffer (Windows) 1.1
490 ngwsniffer_2_0 - Sniffer (Windows) 2.00x
491 niobserver - Network Instruments Observer
492 nokialibpcap - Nokia tcpdump - libpcap
493 nseclibpcap - Wireshark - nanosecond libpcap
494 nstrace10 - NetScaler Trace (Version 1.0)
495 nstrace20 - NetScaler Trace (Version 2.0)
496 pcap - Wireshark/tcpdump/... - pcap
497 pcapng - Wireshark/... - pcapng
498 rf5 - Tektronix K12xx 32-bit .rf5 format
499 rh6_1libpcap - RedHat 6.1 tcpdump - libpcap
501 suse6_3libpcap - SuSE 6.3 tcpdump - libpcap
502 visual - Visual Networks traffic capture
506 <example id="AppToolseditcapEx2">
507 <title>Encapsulation types available from editcap</title>
510 <!-- This kludge is needed since example doesn't break across PDF pages -->
515 editcap: option requires an argument -- 'T'
516 editcap: The available encapsulation types for the "-T" flag are:
517 ap1394 - Apple IP-over-IEEE 1394
519 arcnet_linux - Linux ARCNET
520 ascend - Lucent/Ascend access equipment
522 atm-pdus-untruncated - ATM PDUs - untruncated
523 atm-rfc1483 - RFC 1483 ATM
524 ax25 - Amateur Radio AX.25
525 ax25-kiss - AX.25 with KISS header
526 bacnet-ms-tp - BACnet MS/TP
527 bacnet-ms-tp-with-direction - BACnet MS/TP with Directional Info
528 ber - ASN.1 Basic Encoding Rules
529 bluetooth-h4 - Bluetooth H4
530 bluetooth-h4-linux - Bluetooth H4 with linux header
531 bluetooth-hci - Bluetooth without transport layer
532 bluetooth-le-ll - Bluetooth Low Energy Link Layer
533 can20b - Controller Area Network 2.0B
535 chdlc-with-direction - Cisco HDLC with Directional Info
536 cosine - CoSine L2 debug log
538 dct2000 - Catapult DCT2000
539 docsis - Data Over Cable Service Interface Specification
540 dpnss_link - Digital Private Signalling System No 1 Link Layer
541 dvbci - DVB-CI (Common Interface)
542 enc - OpenBSD enc(4) encapsulating interface
543 erf - Extensible Record Format
545 ether-nettl - Ethernet with nettl headers
546 fc2 - Fibre Channel FC-2
547 fc2sof - Fibre Channel FC-2 With Frame Delimiter
549 fddi-nettl - FDDI with nettl headers
550 fddi-swapped - FDDI with bit-swapped MAC addresses
553 frelay-with-direction - Frame Relay with Directional Info
554 gcom-serial - GCOM Serial
555 gcom-tie1 - GCOM TIE1
557 gsm_um - GSM Um Interface
560 ieee-802-11 - IEEE 802.11 Wireless LAN
561 ieee-802-11-airopeek - IEEE 802.11 plus AiroPeek radio header
562 ieee-802-11-avs - IEEE 802.11 plus AVS radio header
563 ieee-802-11-netmon - IEEE 802.11 plus Network Monitor radio header
564 ieee-802-11-prism - IEEE 802.11 plus Prism II monitor mode radio header
565 ieee-802-11-radio - IEEE 802.11 Wireless LAN with radio information
566 ieee-802-11-radiotap - IEEE 802.11 plus radiotap radio header
567 ieee-802-16-mac-cps - IEEE 802.16 MAC Common Part Sublayer
568 infiniband - InfiniBand
569 ios - Cisco IOS internal
570 ip-over-fc - RFC 2625 IP-over-Fibre Channel
571 ip-over-ib - IP over Infiniband
573 ipmb - Intelligent Platform Management Bus
574 ipnet - Solaris IPNET
577 ixveriwave - IxVeriWave header and stats block
579 juniper-atm1 - Juniper ATM1
580 juniper-atm2 - Juniper ATM2
581 juniper-chdlc - Juniper C-HDLC
582 juniper-ether - Juniper Ethernet
583 juniper-frelay - Juniper Frame-Relay
584 juniper-ggsn - Juniper GGSN
585 juniper-mlfr - Juniper MLFR
586 juniper-mlppp - Juniper MLPPP
587 juniper-ppp - Juniper PPP
588 juniper-pppoe - Juniper PPPoE
589 juniper-svcs - Juniper Services
590 juniper-vp - Juniper Voice PIC
591 k12 - K12 protocol analyzer
594 layer1-event - EyeSDN Layer 1 event
595 lin - Local Interconnect Network
596 linux-atm-clip - Linux ATM CLIP
597 linux-lapd - LAPD with Linux pseudo-header
598 linux-sll - Linux cooked-mode capture
601 most - Media Oriented Systems Transport
602 mp2ts - ISO/IEC 13818-1 MPEG2-TS
605 mtp2-with-phdr - MTP2 with pseudoheader
608 netanalyzer - netANALYZER
609 netanalyzer-transparent - netANALYZER-Transparent
612 nstrace10 - NetScaler Encapsulation 1.0 of Ethernet
613 nstrace20 - NetScaler Encapsulation 2.0 of Ethernet
615 packetlogger - PacketLogger
616 pflog - OpenBSD PF Firewall logs
617 pflog-old - OpenBSD PF Firewall logs, pre-3.4
618 ppi - Per-Packet Information header
620 ppp-with-direction - PPP with Directional Info
621 pppoes - PPP-over-Ethernet session
622 raw-icmp-nettl - Raw ICMP with nettl headers
623 raw-icmpv6-nettl - Raw ICMPv6 with nettl headers
624 raw-telnet-nettl - Raw telnet with nettl headers
626 rawip-nettl - Raw IP with nettl headers
629 redback - Redback SmartEdge
630 rtac-serial - RTAC serial-line
635 sita-wan - SITA WAN packets
637 socketcan - SocketCAN
638 symantec - Symantec Enterprise Firewall
639 tnef - Transport-Neutral Encapsulation Format
641 tr-nettl - Token Ring with nettl headers
642 tzsp - Tazmen sniffer protocol
644 unknown-nettl - Unknown link-layer type with nettl headers
645 usb - Raw USB packets
646 usb-linux - USB packets with Linux header
647 usb-linux-mmap - USB packets with Linux header and padding
648 usb-usbpcap - USB packets with USBPcap header
665 v5-ef - V5 Envelope Function
666 whdlc - Wellfleet HDLC
667 wireshark-upper-pdu - Wireshark Upper PDU export
668 wpan - IEEE 802.15.4 Wireless PAN
669 wpan-nofcs - IEEE 802.15.4 Wireless PAN with FCS not present
670 wpan-nonask-phy - IEEE 802.15.4 Wireless PAN non-ASK PHY
671 x2e-serial - X2E serial line capture
672 x2e-xoraya - X2E Xoraya
679 <section id="AppToolsmergecap">
680 <title><command>mergecap</command>:
681 Merging multiple capture files into one
684 Mergecap is a program that combines multiple saved capture files
685 into a single output file specified by the -w argument. Mergecap
686 knows how to read libpcap capture files, including those of tcpdump.
687 In addition, Mergecap can read capture files from snoop (including
688 Shomiti) and atmsnoop, LanAlyzer, Sniffer (compressed or
689 uncompressed), Microsoft Network Monitor, AIX's iptrace, NetXray,
690 Sniffer Pro, RADCOM's WAN/LAN analyzer, Lucent/Ascend router debug
691 output, HP-UX's nettl, and the dump output from Toshiba's ISDN
692 routers. There is no need to tell Mergecap what type of file you are
693 reading; it will determine the file type by itself. Mergecap is also
694 capable of reading any of these file formats if they are compressed
695 using gzip. Mergecap recognizes this directly from the file; the '.gz'
696 extension is not required for this purpose.
699 By default, it writes the capture file in libpcap format, and writes
700 all of the packets in the input capture files to the output file.
701 The -F flag can be used to specify the format in which to write the
702 capture file; it can write the file in libpcap format (standard
703 libpcap format, a modified format used by some patched versions of
704 libpcap, the format used by Red Hat Linux 6.1, or the format used
705 by SuSE Linux 6.3), snoop format, uncompressed Sniffer format,
706 Microsoft Network Monitor 1.x format, and the format used by
707 Windows-based versions of the Sniffer software.
710 Packets from the input files are merged in chronological order based
711 on each frame's timestamp, unless the -a flag is specified. Mergecap
712 assumes that frames within a single capture file are already stored
713 in chronological order. When the -a flag is specified, packets are
714 copied directly from each input file to the output file, independent
715 of each frame's timestamp.
718 If the -s flag is used to specify a snapshot length, frames in the
719 input file with more captured data than the specified snapshot length
720 will have only the amount of data specified by the snapshot length
721 written to the output file. This may be useful if the program that
722 is to read the output file cannot handle packets larger than a
723 certain size (for example, the versions of snoop in Solaris 2.5.1 and
724 Solaris 2.6 appear to reject Ethernet frames larger than the standard
725 Ethernet MTU, making them incapable of handling gigabit Ethernet
726 captures if jumbo frames were used).
730 If the -T flag is used to specify an encapsulation type, the
731 encapsulation type of the output capture file will be forced to
732 the specified type, rather than being the type appropriate to the
733 encapsulation type of the input capture file. Note that this merely
734 forces the encapsulation type of the output file to be the specified
735 type; the packet headers of the packets will not be translated from the
736 encapsulation type of the input capture file to the specified
737 encapsulation type (for example, it will not translate an Ethernet
738 capture to an FDDI capture if an Ethernet capture is read
739 and '-T fddi' is specified).
741 <example id="AppToolsmergecapEx">
742 <title>Help information available from mergecap</title>
744 Mergecap 1.11.0 (SVN Rev 52564 from /trunk)
745 Merge two or more capture files into one.
746 See http://www.wireshark.org for more information.
748 Usage: mergecap [options] -w <outfile>|- <infile> [<infile> ...]
751 -a concatenate rather than merge files.
752 default is to merge based on frame timestamps.
753 -s <snaplen> truncate packets to <snaplen> bytes of data.
754 -w <outfile>|- set the output filename to <outfile> or '-' for stdout.
755 -F <capture type> set the output file type; default is pcapng.
756 an empty "-F" option will list the file types.
757 -T <encap type> set the output file encapsulation type;
758 default is the same as the first input file.
759 an empty "-T" option will list the encapsulation types.
762 -h display this help and exit.
767 A simple example merging <filename>dhcp-capture.libpcap</filename>
768 and <filename>imap-1.libpcap</filename> into
769 <filename>outfile.libpcap</filename> is shown below.
771 <example id="AppToolsmergecapExSimple">
772 <title>Simple example of using mergecap</title>
773 <programlisting>$ mergecap -w outfile.libpcap dhcp-capture.libpcap imap-1.libpcap
778 <section id="AppToolstext2pcap" >
779 <title><command>text2pcap</command>: Converting ASCII hexdumps to network
783 There may be some occasions when you wish to convert a hex dump of some
784 network traffic into a libpcap file.</para>
786 <command>Text2pcap</command> is a program that reads in an ASCII hex
787 dump and writes the data described into a libpcap-style capture file.
788 text2pcap can read hexdumps with multiple packets in them, and build a
789 capture file of multiple packets. text2pcap is also capable of
790 generating dummy Ethernet, IP and UDP headers, in order to build fully
791 processable packet dumps from hexdumps of application-level data only.
794 Text2pcap understands a hexdump of the form generated by od -A x -t x1. In
795 other words, each byte is individually displayed and surrounded with a
796 space. Each line begins with an offset describing the position in the
797 file. The offset is a hex number (can also be octal - see -o), of
798 more than two hex digits. Here is a sample dump that text2pcap can
802 000000 00 e0 1e a7 05 6f 00 10 ........
803 000008 5a a0 b9 12 08 00 46 00 ........
804 000010 03 68 00 00 00 00 0a 2e ........
805 000018 ee 33 0f 19 08 7f 0f 19 ........
806 000020 03 80 94 04 00 00 10 01 ........
807 000028 16 a2 0a 00 03 50 00 0c ........
808 000030 01 01 0f 19 03 80 11 01 ........
811 There is no limit on the width or number of bytes per line. Also the
812 text dump at the end of the line is ignored. Bytes/hex numbers can be
813 uppercase or lowercase. Any text before the offset is ignored,
814 including email forwarding characters '>'. Any lines of text
815 between the bytestring lines is ignored. The offsets are used to
816 track the bytes, so offsets must be correct. Any line which has only
817 bytes without a leading offset is ignored. An offset is recognized
818 as being a hex number longer than two characters. Any text after the
819 bytes is ignored (e.g. the character dump). Any hex numbers in this
820 text are also ignored. An offset of zero is indicative of starting a
821 new packet, so a single text file with a series of hexdumps can be
822 converted into a packet capture with multiple packets. Multiple
823 packets are read in with timestamps differing by one second each.
824 In general, short of these restrictions, text2pcap is pretty liberal
825 about reading in hexdumps and has been tested with a variety of mangled
826 outputs (including being forwarded through email multiple times,
827 with limited line wrap etc.)
830 There are a couple of other special features to note. Any line where
831 the first non-whitespace character is '#' will be ignored as a
832 comment. Any line beginning with #TEXT2PCAP is a directive and options
833 can be inserted after this command to be processed by text2pcap.
834 Currently there are no directives implemented; in the future, these
835 may be used to give more fine grained control on the dump and the
836 way it should be processed e.g. timestamps, encapsulation type etc.
839 Text2pcap also allows the user to read in dumps of application-level
840 data, by inserting dummy L2, L3 and L4 headers before each packet.
841 Possibilities include inserting headers such as Ethernet, Ethernet + IP,
842 Ethernet + IP + UDP, or Ethernet + Ip + TCP before each packet.
843 This allows Wireshark or any other full-packet decoder to handle these dumps.
845 <example id="AppToolstext2pcapEx">
846 <title>Help information available from text2pcap</title>
848 Text2pcap 1.11.0 (SVN Rev 52564 from /trunk)
849 Generate a capture file from an ASCII hexdump of packets.
850 See http://www.wireshark.org for more information.
852 Usage: text2pcap [options] <infile> <outfile>
854 where <infile> specifies input filename (use - for standard input)
855 <outfile> specifies output filename (use - for standard output)
858 -o hex|oct|dec parse offsets as (h)ex, (o)ctal or (d)ecimal;
860 -t <timefmt> treat the text before the packet as a date/time code;
861 the specified argument is a format string of the sort
862 supported by strptime.
863 Example: The time "10:15:14.5476" has the format code
865 NOTE: The subsecond component delimiter, '.', must be
866 given, but no pattern is required; the remaining
867 number is assumed to be fractions of a second.
868 NOTE: Date/time fields from the current date/time are
869 used as the default for unspecified fields.
870 -D the text before the packet starts with an I or an O,
871 indicating that the packet is inbound or outbound.
872 This is only stored if the output format is PCAP-NG.
873 -a enable ASCII text dump identification.
874 The start of the ASCII text dump can be identified
875 and excluded from the packet data, even if it looks
877 NOTE: Do not enable it if the input file does not
878 contain the ASCII text dump.
881 -l <typenum> link-layer type number; default is 1 (Ethernet). See
882 http://www.tcpdump.org/linktypes.html for a list of
883 numbers. Use this option if your dump is a complete
884 hex dump of an encapsulated packet and you wish to
885 specify the exact type of encapsulation.
886 Example: -l 7 for ARCNet packets.
887 -m <max-packet> max packet length in output; default is 65535
889 Prepend dummy header:
890 -e <l3pid> prepend dummy Ethernet II header with specified L3PID
892 Example: -e 0x806 to specify an ARP packet.
893 -i <proto> prepend dummy IP header with specified IP protocol
895 Automatically prepends Ethernet header as well.
897 -4 <srcip>,<destip> prepend dummy IPv4 header with specified
898 dest and source address.
899 Example: -4 10.0.0.1,10.0.0.2
900 -6 <srcip>,<destip> replace IPv6 header with specified
901 dest and source address.
902 Example: -6 fe80:0:0:0:202:b3ff:fe1e:8329, 2001:0db8:85a3:0000:0000:8a2e:0370:7334
903 -u <srcp>,<destp> prepend dummy UDP header with specified
904 source and destination ports (in DECIMAL).
905 Automatically prepends Ethernet & IP headers as well.
906 Example: -u 1000,69 to make the packets look like
908 -T <srcp>,<destp> prepend dummy TCP header with specified
909 source and destination ports (in DECIMAL).
910 Automatically prepends Ethernet & IP headers as well.
912 -s <srcp>,<dstp>,<tag> prepend dummy SCTP header with specified
913 source/dest ports and verification tag (in DECIMAL).
914 Automatically prepends Ethernet & IP headers as well.
916 -S <srcp>,<dstp>,<ppi> prepend dummy SCTP header with specified
917 source/dest ports and verification tag 0.
918 Automatically prepends a dummy SCTP DATA
919 chunk header with payload protocol identifier ppi.
923 -h display this help and exit.
924 -d show detailed debug of parser states.
925 -q generate no output at all (automatically disables -d).
926 -n use PCAP-NG instead of PCAP as output format.
931 <section id="AppToolsidl2wrs" >
932 <title><command>idl2wrs</command>:
933 Creating dissectors from CORBA IDL files
936 In an ideal world idl2wrs would be mentioned in the users guide
937 in passing and documented in the developers guide. As the
939 has not yet been completed it will be documented here.
942 <title>What is it?</title>
944 As you have probably guessed from the name,
945 <command>idl2wrs</command> takes a
946 user specified IDL file and attempts to build a dissector that
947 can decode the IDL traffic over GIOP. The resulting file is
948 "C" code, that should compile okay as a Wireshark dissector.
951 <command>idl2wrs</command> basically parses the data struct given to
952 it by the omniidl compiler, and using the GIOP API available in
953 packet-giop.[ch], generates get_CDR_xxx calls to decode the
954 CORBA traffic on the wire.
956 <para>It consists of 4 main files.</para>
958 <varlistentry><term><filename>README.idl2wrs</filename></term>
960 <para>This document</para>
963 <varlistentry><term><filename>wireshark_be.py</filename></term>
965 <para>The main compiler backend</para>
968 <varlistentry><term><filename>wireshark_gen.py</filename></term>
970 <para>A helper class, that generates the C code.</para>
973 <varlistentry><term><filename>idl2wrs</filename></term>
975 <para> A simple shell script wrapper that the end user should
976 use to generate the dissector from the IDL file(s).</para>
982 <title>Why do this?</title>
984 It is important to understand what CORBA traffic looks
985 like over GIOP/IIOP, and to help build a tool that can assist
986 in troubleshooting CORBA interworking. This was especially the
987 case after seeing a lot of discussions about how particular
988 IDL types are represented inside an octet stream.
991 I have also had comments/feedback that this tool would be good for say
992 a CORBA class when teaching students what CORBA traffic looks like
996 It is also COOL to work on a great Open Source project such as
997 the case with "Wireshark" (
998 <ulink url="&WiresharkWebSite;">&WiresharkWebSite;</ulink>
1002 <section><title>How to use idl2wrs</title>
1004 To use the idl2wrs to generate Wireshark dissectors, you
1008 <title>Prerequisites to using idl2wrs</title>
1011 Python must be installed. See
1012 <ulink url="http://python.org/"/>
1017 omniidl from the omniORB package must be available. See
1018 <ulink url="http://omniorb.sourceforge.net/"/>
1023 Of course you need Wireshark installed to compile the
1024 code and tweak it if required. idl2wrs is part of the
1025 standard Wireshark distribution
1030 To use idl2wrs to generate an Wireshark dissector from an idl file
1031 use the following procedure:
1035 Procedure for converting a CORBA idl file into a Wireshark
1040 To write the C code to stdout.
1041 <programlisting>idl2wrs <your_file.idl></programlisting>
1042 e.g.: <programlisting>idl2wrs echo.idl</programlisting>
1047 To write to a file, just redirect the output.
1048 <programlisting>idl2wrs echo.idl > packet-test-idl.c</programlisting>
1049 You may wish to comment out the register_giop_user_module() code
1050 and that will leave you with heuristic dissection.
1055 If you don't want to use the shell script wrapper, then try
1056 steps 3 or 4 instead.</para>
1057 <orderedlist continuation="continues">
1059 <para>To write the C code to stdout.
1060 <programlisting>Usage: omniidl -p ./ -b wireshark_be <your file.idl></programlisting>
1062 <programlisting>omniidl -p ./ -b wireshark_be echo.idl</programlisting>
1067 To write to a file, just redirect the output.
1068 <programlisting>omniidl -p ./ -b wireshark_be echo.idl > packet-test-idl.c</programlisting>
1069 You may wish to comment out the register_giop_user_module() code
1070 and that will leave you with heuristic dissection.
1075 Copy the resulting C code to subdirectory epan/dissectors/ inside your
1076 Wireshark source directory.
1077 <programlisting>cp packet-test-idl.c /dir/where/wireshark/lives/epan/dissectors/</programlisting>
1078 The new dissector has to be added to Makefile.common in the same
1079 directory. Look for the declaration CLEAN_DISSECTOR_SRC and add
1080 the new dissector there. For example,
1082 CLEAN_DISSECTOR_SRC = \
1083 packet-2dparityfec.c \
1084 packet-3com-njack.c \
1089 CLEAN_DISSECTOR_SRC = \
1091 packet-2dparityfec.c \
1092 packet-3com-njack.c \
1097 For the next steps, go up to the top of your Wireshark source directory.
1102 <programlisting>./configure (or ./autogen.sh)</programlisting>
1106 <para> Compile the code
1107 <programlisting>make</programlisting>
1111 <para>Good Luck !!</para>
1115 <section><title>TODO</title>
1119 Exception code not generated (yet), but can be added manually.
1124 Enums not converted to symbolic values (yet), but can be added
1129 <para>Add command line options etc</para>
1132 <para>More I am sure :-)</para>
1136 <section><title>Limitations</title>
1138 See the TODO list inside <filename>packet-giop.c</filename>
1141 <section><title>Notes</title>
1145 The "-p ./" option passed to omniidl indicates that the
1146 wireshark_be.py and wireshark_gen.py are residing in the
1147 current directory. This may need
1148 tweaking if you place these files somewhere else.
1153 If it complains about being unable to find some modules
1155 you may want to check if PYTHONPATH is set correctly.
1156 On my Linux box, it is PYTHONPATH=/usr/lib/python2.4/
1162 <section id="AppToolsreordercap" >
1163 <title><command>reordercap</command>: Reorder a capture file
1166 Reordercap allows to reorder a capture file according to the packets timestamp.
1168 <example id="AppToolsreordercapEx">
1169 <title>Help information available from reordercap</title>
1172 Reorder timestamps of input file frames into output file.
1173 See http://www.wireshark.org for more information.
1175 Usage: reordercap [options] <infile> <outfile>
1178 -n don't write to output file if the input file is ordered.
1183 <!-- End of WSUG Appendix Tools -->