Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Printing IP packets

by Anonymous Monk
on Mar 07, 2003 at 20:25 UTC ( #241251=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there a method to print incoming IP packets (maybe display TCP/IP contents) for ActivePerl on windows?

Comment on Printing IP packets
Re: Printing IP packets
by tadman (Prior) on Mar 07, 2003 at 21:07 UTC
    While I'm not sure how easy it is to get running on Windows, the standard way to do this is with PCAP, usually using Net::PCAP.
Re: Printing IP packets
by phydeauxarff (Priest) on Mar 07, 2003 at 21:17 UTC
    To take the Net::Pcap suggestion even further, I think you want to actually print packets.
    The following example from NetPacket::IP prints the IP frames by IP Address and Protocal to standard output
     #!/usr/bin/perl -w
    
      use strict;
      use Net::PcapUtils;
      use NetPacket::Ethernet qw(:strip);
      use NetPacket::IP;
    
      sub process_pkt {
          my ($user, $hdr, $pkt) = @_;
    
          my $ip_obj = NetPacket::IP->decode(eth_strip($pkt));
          print("$ip_obj->{src_ip}:$ip_obj->{dest_ip} $ip_obj->{proto}\n");
      }
    
      Net::PcapUtils::loop(\&process_pkt, FILTER => 'ip');
    
Re: Printing IP packets
by Anonymous Monk on Mar 07, 2003 at 21:33 UTC
    Where do I find the PcapUtils for Windows?
      First, you need pcap from The WinPcap Website. This does not include the Net::Pcap module, but it is the origin of pcap for Win32. You also need Net::PcapUtils. Unfortunately, I have not seen the compiled .xs file for Net::Pcap for Win32. It might compile straightaway, but I don't have a C compiler for my Win32 systems. Maybe some kind Win32-savvy monk could build and test it.

      HTH, --traveler

      Update: You might also try the winpacp mailing list. See http://winpcap.polito.it/contact.htm.

      Update2: I think I have located the compiled Net::Pcap and have e-mailed the author. I am not sure about its current status...More info when I get it

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://241251]
Approved by rozallin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2014-12-27 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls