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