From https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6704
[obnox/wireshark/wip.git] / doc / text2pcap.pod
1
2 =head1 NAME
3
4 text2pcap - Generate a capture file from an ASCII hexdump of packets
5
6 =head1 SYNOPSIS
7
8 B<text2pcap>
9 S<[ B<-h> ]>
10 S<[ B<-d> ]>
11 S<[ B<-q> ]>
12 S<[ B<-o> hex|oct|dec ]>
13 S<[ B<-l> E<lt>typenumE<gt> ]>
14 S<[ B<-e> E<lt>l3pidE<gt> ]>
15 S<[ B<-i> E<lt>protoE<gt> ]>
16 S<[ B<-m> E<lt>max-packetE<gt> ]>
17 S<[ B<-u> E<lt>srcportE<gt>,E<lt>destportE<gt> ]>
18 S<[ B<-T> E<lt>srcportE<gt>,E<lt>destportE<gt> ]>
19 S<[ B<-s> E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>tagE<gt> ]>
20 S<[ B<-S> E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>ppiE<gt> ]>
21 S<[ B<-t> E<lt>timefmtE<gt> ]>
22 S<[ B<-a> ]>
23 E<lt>I<infile>E<gt>|-
24 E<lt>I<outfile>E<gt>|-
25
26 =head1 DESCRIPTION
27
28 B<Text2pcap> is a program that reads in an ASCII hex dump and writes the
29 data described into a B<libpcap> capture file.  B<text2pcap> can
30 read hexdumps with multiple packets in them, and build a capture file of
31 multiple packets.  B<text2pcap> is also capable of generating dummy
32 Ethernet, IP and UDP, TCP, or SCTP headers, in order to build fully
33 processable packet dumps from hexdumps of application-level data only.
34
35 B<Text2pcap> understands a hexdump of the form generated by I<od -Ax -tx1 -v>.
36 In other words, each byte is individually displayed and
37 surrounded with a space. Each line begins with an offset describing
38 the position in the file. The offset is a hex number (can also be
39 octal or decimal - see B<-o>), of more than two hex digits.
40 Here is a sample dump that B<text2pcap> can recognize:
41
42     000000 00 e0 1e a7 05 6f 00 10 ........
43     000008 5a a0 b9 12 08 00 46 00 ........
44     000010 03 68 00 00 00 00 0a 2e ........
45     000018 ee 33 0f 19 08 7f 0f 19 ........
46     000020 03 80 94 04 00 00 10 01 ........
47     000028 16 a2 0a 00 03 50 00 0c ........
48     000030 01 01 0f 19 03 80 11 01 ........
49
50 There is no limit on the width or number of bytes per line. Also the
51 text dump at the end of the line is ignored. Bytes/hex numbers can be
52 uppercase or lowercase. Any text before the offset is ignored,
53 including email forwarding characters '>'. Any lines of text between
54 the bytestring lines is ignored. The offsets are used to track the
55 bytes, so offsets must be correct. Any line which has only bytes
56 without a leading offset is ignored. An offset is recognized as being
57 a hex number longer than two characters. Any text after the bytes is
58 ignored (e.g. the character dump). Any hex numbers in this text are
59 also ignored. An offset of zero is indicative of starting a new
60 packet, so a single text file with a series of hexdumps can be
61 converted into a packet capture with multiple packets. Packets may be
62 preceded by a timestamp. These are interpreted according to the format
63 given on the command line (see B<-t>). If not, the first packet
64 is timestamped with the current time the conversion takes place. Multiple
65 packets are written with timestamps differing by one microsecond each.
66 In general, short of these restrictions, B<text2pcap> is pretty liberal
67 about reading in hexdumps and has been tested with a variety of
68 mangled outputs (including being forwarded through email multiple
69 times, with limited line wrap etc.)
70
71 There are a couple of other special features to note. Any line where
72 the first non-whitespace character is '#' will be ignored as a
73 comment. Any line beginning with #TEXT2PCAP is a directive and options
74 can be inserted after this command to be processed by
75 B<text2pcap>. Currently there are no directives implemented; in the
76 future, these may be used to give more fine grained control on the
77 dump and the way it should be processed e.g. timestamps, encapsulation
78 type etc.
79
80 B<Text2pcap> also allows the user to read in dumps of
81 application-level data, by inserting dummy L2, L3 and L4 headers
82 before each packet. The user can elect to insert Ethernet headers,
83 Ethernet and IP, or Ethernet, IP and UDP/TCP/SCTP headers before each
84 packet. This allows Wireshark or any other full-packet decoder to
85 handle these dumps.
86
87 =head1 OPTIONS
88
89 =over 4
90
91 =item -h
92
93 Displays a help message.
94
95 =item -d
96
97 Displays debugging information during the process. Can be used
98 multiple times to generate more debugging information.
99
100 =item -q
101
102 Be completely quiet during the process.
103
104 =item -o hex|oct|dec
105
106 Specify the radix for the offsets (hex, octal or decimal). Defaults to
107 hex. This corresponds to the C<-A> option for I<od>.
108
109 =item -l
110
111 Specify the link-layer header type of this packet.  Default is Ethernet
112 (1).  See L<http://www.tcpdump.org/linktypes.html> for the complete list
113 of possible encapsulations.  Note that this option should be used if
114 your dump is a complete hex dump of an encapsulated packet and you wish
115 to specify the exact type of encapsulation.  Example: I<-l 7> for ARCNet
116 packets.
117
118 =item -e E<lt>l3pidE<gt>
119
120 Include a dummy Ethernet header before each packet. Specify the L3PID
121 for the Ethernet header in hex. Use this option if your dump has Layer
122 3 header and payload (e.g. IP header), but no Layer 2
123 encapsulation. Example: I<-e 0x806> to specify an ARP packet.
124
125 For IP packets, instead of generating a fake Ethernet header you can
126 also use I<-l 12> to indicate a raw IP packet to Wireshark. Note that
127 I<-l 12> does not work for any non-IP Layer 3 packet (e.g. ARP),
128 whereas generating a dummy Ethernet header with I<-e> works for any
129 sort of L3 packet.
130
131 =item -i E<lt>protoE<gt>
132
133 Include dummy IP headers before each packet. Specify the IP protocol
134 for the packet in decimal. Use this option if your dump is the payload
135 of an IP packet (i.e. has complete L4 information) but does not have
136 an IP header with each packet. Note that an appropriate Ethernet header
137 is automatically included with each packet as well.
138 Example: I<-i 46> to specify an RSVP packet (IP protocol 46).
139
140 =item -m E<lt>max-packetE<gt>
141
142 Set the maximum packet length, default is 64000.
143 Useful for testing various packet boundaries when only an application
144 level datastream is available.  Example:
145
146 I<od -Ax -tx1 stream | text2pcap -m1460 -T1234,1234 - stream.pcap>
147
148 will convert from plain datastream format to a sequence of Ethernet
149 TCP packets.
150
151 =item -u E<lt>srcportE<gt>,E<lt>destportE<gt>
152
153 Include dummy UDP headers before each packet. Specify the source and
154 destination UDP ports for the packet in decimal. Use this option if
155 your dump is the UDP payload of a packet but does not include any UDP,
156 IP or Ethernet headers. Note that appropriate Ethernet and IP headers
157 are automatically also included with each packet.
158 Example: I<-u1000,69> to make the packets look like TFTP/UDP packets.
159
160 =item -T E<lt>srcportE<gt>,E<lt>destportE<gt>
161
162 Include dummy TCP headers before each packet. Specify the source and
163 destination TCP ports for the packet in decimal. Use this option if
164 your dump is the TCP payload of a packet but does not include any TCP,
165 IP or Ethernet headers. Note that appropriate Ethernet and IP headers
166 are automatically also included with each packet.
167 Sequence numbers will start at 0.
168
169 =item -s E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>tagE<gt>
170
171 Include dummy SCTP headers before each packet.  Specify, in decimal, the
172 source and destination SCTP ports, and verification tag, for the packet.
173 Use this option if your dump is the SCTP payload of a packet but does
174 not include any SCTP, IP or Ethernet headers.  Note that appropriate
175 Ethernet and IP headers are automatically also included with each
176 packet.  A CRC32C checksum will be put into the SCTP header.
177
178 =item -S E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>ppiE<gt>
179
180 Include dummy SCTP headers before each packet.  Specify, in decimal, the
181 source and destination SCTP ports, and a verification tag of 0, for the
182 packet, and prepend a dummy SCTP DATA chunk header with a payload
183 protocol identifier if I<ppi>.  Use this option if your dump is the SCTP
184 payload of a packet but does not include any SCTP, IP or Ethernet
185 headers.  Note that appropriate Ethernet and IP headers are
186 automatically included with each packet.  A CRC32C checksum will be put
187 into the SCTP header.
188
189 =item -t E<lt>timefmtE<gt>
190
191 Treats the text before the packet as a date/time code; I<timefmt> is a
192 format string of the sort supported by strptime(3).
193 Example: The time "10:15:14.5476" has the format code "%H:%M:%S."
194
195 B<NOTE:> The subsecond component delimiter must be specified (.) but no
196 pattern is required; the remaining number is assumed to be fractions of
197 a second.
198
199 B<NOTE:> Date/time fields from the current date/time are
200 used as the default for unspecified fields.
201
202 =item -a
203
204 Enables ASCII text dump identification. It allows to identify the start of
205 the ASCII text dump and not include it in the packet even if it looks like HEX.
206
207 B<NOTE:> Do not enable it if the input file does not contain the ASCII text dump.
208
209 =back
210
211 =head1 SEE ALSO
212
213 od(1), pcap(3), wireshark(1), tshark(1), dumpcap(1), mergecap(1),
214 editcap(1), strptime(3), pcap-filter(7) or tcpdump(8) if it doesn't exist.
215
216 =head1 NOTES
217
218 B<Text2pcap> is part of the B<Wireshark> distribution.  The latest version
219 of B<Wireshark> can be found at L<http://www.wireshark.org>.
220
221 =head1 AUTHORS
222
223   Ashok Narayanan          <ashokn[AT]cisco.com>