Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: networking over the loopback

by rob_au (Abbot)
on May 22, 2002 at 04:21 UTC ( [id://168345]=note: print w/replies, xml ) Need Help??


in reply to Re: networking over the loopback
in thread networking over the loopback

And in the spirit of using Perl for reinventing wheels, a TCP packet dumper using Net::PcapUtils ... :-)

use Net::PcapUtils; use NetPacket::IP; use NetPacket::TCP; use NetPacket::Ethernet qw/:types/; use strict; Net::PcapUtils::loop( sub { my ($arg, $header, $packet) = @_; my $ethernet = NetPacket::Ethernet->decode($packet); if ($ethernet->{'type'} == ETH_TYPE_IP) { my $ip = NetPacket::IP->decode($ethernet->{'data'}, $ether +net); my $tcp = NetPacket::TCP->decode($ip->{'data'}); print $ip->{'src_ip'}, ":", $tcp->{'src_port'}, " -> ", $ip->{'dest_ip'}, ":", $tcp->{'dest_port'}, "\n\n"; my @data = split //, $tcp->{'data'}; while (@data) { print "\t"; for (0..7) { print sprintf("%02x", shift(@data)), " "; } print "\n"; } print "\n"; } }, 'DEV' => 'lo' );

 

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://168345]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-28 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found