Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Windows Wireless and PCAP library functions.

by Simbha (Initiate)
on Jan 02, 2013 at 08:28 UTC ( #1011227=perlquestion: print w/ replies, xml ) Need Help??
Simbha has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to learn how to use PCAP libraries. So started on my windows Vista Enterprise laptop with wireless connection. No wired connection on the PC. To start with i want to get the network IPAddress and subnet mask. Eventually able to build the programme by cut&paste from all the perl experts articles:
use Net::Pcap; my $dev = Net::Pcap::lookupdev( \$err ); if ( defined $err ) { die "Unable to determine network device for monitoring - ", $err; } @devs = Net::Pcap::findalldevs(\$err); foreach (@devs) { $dev= $_ ; print "$_ \n"; my ( $addr, $net, $mask ); if ( Net::Pcap::lookupnet( $dev, \$net, \$mask, \$err ) ) {die "Unable to look up device information for ", $dev, " - " +, $err; } print "Device : $dev, Network Address : $net, NetMask : $mask \n" +; }
And the output is: ------------------
C:\Perl\Data>..\bin\perl Pcap-102.pl \Device\NPF_{A6DECF92-8A65-40B8-BFDC-214D19DA6F37} Device : \Device\NPF_{A6DECF92-8A65-40B8-BFDC-214D19DA6F37}, Network A +ddress : 2604000768, NetMask : 4294967040 \Device\NPF_{8A8505C7-56D7-4D83-B18E-85957B77C060} Device : \Device\NPF_{8A8505C7-56D7-4D83-B18E-85957B77C060}, Network A +ddress : 3232238080, NetMask : 4294967040 \Device\NPF_{B44D4BF3-170A-4772-BF08-B03EB1739C5C} Device : \Device\NPF_{B44D4BF3-170A-4772-BF08-B03EB1739C5C}, Network A +ddress : 0, NetMask : 0 \Device\NPF_{691970A7-D403-46AD-BC01-1628915ED58A} Device : \Device\NPF_{691970A7-D403-46AD-BC01-1628915ED58A}, Network A +ddress : 0, NetMask : 4278190080 C:\Perl\Data>
----------------- While my actual Wireless network adapter settings on the PC are:
Wireless LAN adapter Wireless Network Connection: Connection-specific DNS Suffix . : hsd1.ca.comcast.net. Description . . . . . . . . . . . : Intel(R) WiFi Link 5300 AGN Physical Address. . . . . . . . . : 00-21-6A-17-F1-56 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::11f2:d913:3057:da24%13(Pr +eferred) IPv4 Address. . . . . . . . . . . : 192.168.10.103(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : Tuesday, January 01, 2013 8:20: +58 PM Lease Expires . . . . . . . . . . : Wednesday, January 02, 2013 2:3 +3:19 AM Default Gateway . . . . . . . . . : 192.168.10.1 DHCP Server . . . . . . . . . . . : 192.168.10.1 DHCPv6 IAID . . . . . . . . . . . : 234889578 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-11-D6-E3-9D-00-25-B +3-2E-25-5A DNS Servers . . . . . . . . . . . : 202.148.200.3 NetBIOS over Tcpip. . . . . . . . : Enabled
---------------

Is not the function call "lookupdev" supposed to find the active Network adapter?

Is not the wireless adapter, part of the "findalldevs()" ?

Does windows OS need different PCAP functions?

I did read couple of similar questions but answers not in full. Thought may be i should post the question again.

Thanks Simbha

Comment on Windows Wireless and PCAP library functions.
Select or Download Code
Re: Windows Wireless and PCAP library functions.
by Anonymous Monk on Jan 02, 2013 at 09:21 UTC

    Thought may be i should post the question again.

    There was no need :) some network card (wifi card) drivers don't allow packet capture, its still very common on windoes, nothing you can do about it, pcap won't work with it

      I tried with Wired ethernet connection instead of wireless. I see the same results as WiFi referred earlier. I could not retrieve network/mask numbers for Ethernet adapter too. The wireshark is working fine on both Ethernet and WiFi connections. Able to sniff packets just by selecting. Wireshark Interface details match with the output of findalldevs(). Where as lookupdev() incase of Net::Pcap returns the first \Device\... and not the active device. Irrespective of the output of lookupdev(), the $net & $mask should read all devices network numbers and netmasks. Thanks Simbha

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2014-09-18 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (124 votes), past polls