ded0f5b6851a0881838d550ecd4d939db429f1da
[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 SYNOPSYS
7
8 B<text2pcap>
9 S<[ B<-h> ]>
10 S<[ B<-d> ]>
11 S<[ B<-q> ]>
12 S<[ B<-o> hex|oct ]>
13 S<[ B<-l> typenum ]>
14 S<[ B<-e> l3pid ]>
15 S<[ B<-i> proto ]>
16 S<[ B<-u> srcport,destport ]>
17 S<[ B<-s> srcport,destport,tag ]>
18 S<[ B<-S> srcport,destport,ppi ]>
19 S<[ B<-t> timefmt ]>
20 I<infile>
21 I<outfile>
22
23 =head1 DESCRIPTION
24
25 B<Text2pcap> is a program that reads in an ASCII hex dump and writes
26 the data described into a B<libpcap>-style capture file. B<text2pcap>
27 can read hexdumps with multiple packets in them, and build a capture
28 file of multiple packets. B<text2pcap> is also capable of generating
29 dummy Ethernet, IP and UDP headers, in order to build fully
30 processable packet dumps from hexdumps of application-level data
31 only. 
32
33 B<Text2pcap> understands a hexdump of the form generated by I<od -t
34 x1>. In other words, each byte is individually displayed and
35 surrounded with a space. Each line begins with an offset describing
36 the position in the file. The offset is a hex number (can also be
37 octal - see B<-o>), of more than two hex digits. Here is a sample dump
38 that B<text2pcap> can recognize:
39
40     000000 00 e0 1e a7 05 6f 00 10 ........
41     000008 5a a0 b9 12 08 00 46 00 ........
42     000010 03 68 00 00 00 00 0a 2e ........
43     000018 ee 33 0f 19 08 7f 0f 19 ........
44     000020 03 80 94 04 00 00 10 01 ........
45     000028 16 a2 0a 00 03 50 00 0c ........
46     000030 01 01 0f 19 03 80 11 01 ........
47
48 There is no limit on the width or number of bytes per line. Also the
49 text dump at the end of the line is ignored. Bytes/hex numbers can be
50 uppercase or lowercase. Any text before the offset is ignored,
51 including email forwarding characters '>'. Any lines of text between
52 the bytestring lines is ignored. The offsets are used to track the
53 bytes, so offsets must be correct. Any line which has only bytes
54 without a leading offset is ignored. An offset is recognized as being
55 a hex number longer than two characters. Any text after the bytes is
56 ignored (e.g. the character dump). Any hex numbers in this text are
57 also ignored. An offset of zero is indicative of starting a new
58 packet, so a single text file with a series of hexdumps can be
59 converted into a packet capture with multiple packets. Multiple
60 packets are read in with timestamps differing by one second each. In
61 general, short of these restrictions, B<text2pcap> is pretty liberal
62 about reading in hexdumps and has been tested with a variety of
63 mangled outputs (including being forwarded through email multiple
64 times, with limited line wrap etc.)
65
66 There are a couple of other special features to note. Any line where
67 the first non-whitespace character is '#' will be ignored as a
68 comment. Any line beginning with #TEXT2PCAP is a directive and options
69 can be inserted after this command to be processed by
70 B<text2pcap>. Currently there are no directives implemented; in the
71 future, these may be used to give more fine grained control on the
72 dump and the way it should be processed e.g. timestamps, encapsulation
73 type etc.
74
75 B<Text2pcap> also allows the user to read in dumps of
76 application-level data, by inserting dummy L2, L3 and L4 headers
77 before each packet. The user can elect to insert Ethernet headers,
78 Ethernet and IP, or Ethernet, IP and UDP headers before each
79 packet. This allows Ethereal or any other full-packet decoder to
80 handle these dumps.
81
82 =head1 OPTIONS
83
84 =over 4
85
86 =item -h
87
88 Displays a help message.
89
90 =item -d
91
92 Displays debugging information during the process. Can be used
93 multiple times to generate more debugging information.
94
95 =item -q
96
97 Be completely quiet during the process.
98
99 =item -o hex|oct
100
101 Specify the radix for the offsets (hex or octal). Defaults to
102 hex. This corresponds to the C<-A> option for I<od>.
103
104 =item -l
105
106 Specify the link-layer type of this packet. Default is Ethernet
107 (1). See I<net/bpf.h> for the complete list of possible
108 encapsulations. Note that this option should be used if your dump is a
109 complete hex dump of an encapsulated packet and you wish to specify
110 the exact type of encapsulation. Example: I<-l 7> for ARCNet packets.
111
112 =item -e l3pid
113
114 Include a dummy Ethernet header before each packet. Specify the L3PID
115 for the Ethernet header in hex. Use this option if your dump has Layer
116 3 header and payload (e.g. IP header), but no Layer 2
117 encapsulation. Example: I<-e 0x806> to specify an ARP packet. 
118
119 For IP packets, instead of generating a fake Ethernet header you can
120 also use I<-l 12> to indicate a raw IP packet to Ethereal. Note that
121 I<-l 12> does not work for any non-IP Layer 3 packet (e.g. ARP),
122 whereas generating a dummy Ethernet header with I<-e> works for any
123 sort of L3 packet.
124
125 =item -i proto
126
127 Include dummy IP headers before each packet. Specify the IP protocol
128 for the packet in decimal. Use this option if your dump is the payload
129 of an IP packet (i.e. has complete L4 information) but does not have
130 an IP header. Note that this automatically includes an appropriate
131 Ethernet header as well. Example: I<-i 46> to specify an RSVP packet
132 (IP protocol 46).
133
134 =item -u srcport,destport
135
136 Include dummy UDP headers before each packet. Specify the source and
137 destination UDP ports for the packet in decimal. Use this option if
138 your dump is the UDP payload of a packet but does not include any UDP,
139 IP or Ethernet headers. Note that this automatically includes
140 appropriate Ethernet and IP headers with each packet. Example: I<-u
141 1000,69> to make the packets look like TFTP/UDP packets.
142
143 =item -s srcport,destport,tag
144
145 Include dummy SCTP headers before each packet.  Specify, in decimal, the
146 source and destination SCTP ports, and verification tag, for the packet. 
147 Use this option if your dump is the SCTP payload of a packet but does
148 not include any SCTP, IP or Ethernet headers.  Note that this
149 automatically includes appropriate Ethernet and IP headers with each
150 packet.  A CRC32C checksum will be put into the SCTP header.
151
152 =item -S srcport,destport,ppi
153
154 Include dummy SCTP headers before each packet.  Specify, in decimal, the
155 source and destination SCTP ports, and a verification tag of 0, for the
156 packet, and prepend a dummy SCTP DATA chunk header with a payload
157 protocol identifier if I<ppi>.  Use this option if your dump is the SCTP
158 payload of a packet but does not include any SCTP, IP or Ethernet
159 headers.  Note that this automatically includes appropriate Ethernet and
160 IP headers with each packet.  A CRC32C checksum will be put into the
161 SCTP header.
162
163 =item -t timefmt
164
165 Treats the text before the packet as a date/time code; I<timefmt> is a
166 format string of the sort supported by B<strptime(3)>.
167 Example: The time "10:15:14.5476" has the format code "%H:%M:%S."
168
169 B<NOTE:> The subsecond component delimiter must be specified (.) but no
170 pattern is required; the remaining number is assumed to be fractions of
171 a second.
172
173 =head1 SEE ALSO
174
175 I<tcpdump(8)>, I<pcap(3)>, I<ethereal(1)>, I<editcap(1)>, I<strptime(3)>.
176
177 =head1 NOTES
178
179 B<Text2pcap> is part of the B<Ethereal> distribution.  The latest version
180 of B<Ethereal> can be found at B<http://www.ethereal.com>.
181
182 =head1 AUTHORS
183
184   Ashok Narayanan          <ashokn@cisco.com>