This is not a question, but more an oddity and simple solution. I was bringing some old network monitoring code up-to-date, I attempted to install both Net::Pcap and Net::PcapUtils on my Ubuntu 10.04 Virtualbox. Both installs failed, hanging in a test 01-loop.t. I was creating plenty of traffic on my only Ethernet interface, which is needed to finish this test.

Since the interface was eth3, I thought there might be some assumptions that were failing or other defaults in selecting the device. I had installed Net::Pcap through apt-get because it had hung in the very same test. So I used the sample code from the Net::Pcap manual page and added printouts of all of the possible devices:

use Net::Pcap; my $err = '';# storsge string fille by sub error my %devinfo; my @devs = Net::Pcap::pcap_findalldevs(\%devinfo, \$err); for my $dev (@devs) { print "$dev : $devinfo{$dev}\n"; } exit;
The surprising result was:
tuser@desktop:~/Pcap$ sudo perl testNetPcap-2.pl usbmon1 : USB bus number 1 usbmon2 : USB bus number 2 eth3 : No description available any : Pseudo-device that captures on all interfaces lo : Loopback device tuser@desktop:~/Pcap$
The '01-loop' test program simply does:
my $result = Net::PcapUtils::loop(\&process_pkt); if (!$result eq "") { print("$result\n"); }
Net::PcapUtils::loop calls Net::Pcap::lookupdev, which, in the absence of a specific device returns the first entry in the list ('usbmon1'). If This means it was reading the 'Uusbon1' interface, and not the Ethernet interface.

This may be a reason that both of these packages install failed. They weren't accessing the correct interface. Why the USB interfaces are on the list is a deeper problem that I can handle. I am dropping PcapUtils because it won't pass it's test, and have installed Pcap through the 'apt-get' packages. Then I modified the test program:

my $eth; my @devs = Net::Pcap::pcap_findalldevs(\%devinfo, \$err); for my $dev (@devs) { print "$dev : $devinfo{$dev}\n"; if ( ! $eth && $dev=~/eth/){ $eth=$dev;} } print " eth=<$eth>\n";
And it ran fine.

It is always better to have seen your target for yourself, rather than depend upon someone else's description.


In reply to pcap_findalldevs picks .... by Wiggins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.