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');
| [reply] |
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. | [reply] |
Where do I find the PcapUtils for Windows? | [reply] |
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
| [reply] |