upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / test / tcpdumpscii.txt
1
2 From marcs@znep.com Fri Apr 17 15:16:16 1998
3 Date: Sat, 22 Nov 1997 20:44:10 -0700 (MST)
4 From: Marc Slemko <marcs@znep.com>
5 To: TLOSAP <new-httpd@apache.org>
6 Subject: Re: Getting ethernet packets content under FreeBSD?  (fwd)
7 Reply-To: new-httpd@apache.org
8
9 Anyone too lazy to hack tcpdump (eg. my tcpdump has a -X option to display
10 the data in ASCII) can use something like the below to grab HTTP headers
11 when debugging broken clients.
12
13 Nothing complicated, but handy.
14
15 ---------- Forwarded message ----------
16 Date: Sat, 22 Nov 1997 14:35:23 PST
17 From: Bill Fenner <fenner@parc.xerox.com>
18 To: Nate Williams <nate@mt.sri.com>
19 Cc: bmah@ca.sandia.gov, hackers@FreeBSD.ORG
20 Subject: Re: Getting ethernet packets content under FreeBSD? 
21
22 I usually just use this perl script, which I call "tcpdumpscii".
23 Then run "tcpdumpscii -s 1500 -x [other tcpdump args]".
24
25   Bill
26
27 #!/import/misc/bin/perl
28 #
29 #
30 open(TCPDUMP,"tcpdump -l @ARGV|");
31 while (<TCPDUMP>) {
32         if (/^\s+(\S\S)+/) {
33                 $sav = $_;
34                 $asc = "";
35                 while (s/\s*(\S\S)\s*//) {
36                         $i = hex($1);
37                         if ($i < 32 || $i > 126) {
38                                 $asc .= ".";
39                         } else {
40                                 $asc .= pack(C,hex($1));
41                         }
42                 }
43                 $foo = "." x length($asc);
44                 $_ = $sav;
45                 s/\t/        /g;
46                 s/^$foo/$asc/;
47         }
48         print;
49 }
50