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