[Winpcap-users] how to find active ports
Mark Pizzolato - WinPCap-Users
winpcap-users-20040408 at subscriptions.pizzolato.net
Tue Jul 12 20:00:52 PDT 2011
Hi there Rajath,
Winpcap doesn't contain a single API which provides the specific answer you are looking for.
However, you could determine the answer you are looking for with a little coding on your part. The following steps will achieve the desired result:
1) Use pcap_findalldevs to enumerate the set of 'ports' as you say.
2) For each enumerated port, use pcap_openlive to open a promiscuous mode pcap handle to the port.
3) For each enumerated port, Craft a packet which says "Sending on Port #N" and use any source MAC address (without Bi1#1 set (i.e. the Broadcast/multicast bit sent), use a destination MAC address of FF:FF:FF:FF:FF:FF. Send the packet on the pcap handle using pcap_sendpacket. Read arriving packets on each of the pcap handles looking for the crafted packet. Each time you find a packet you sent, you've found a 'loopbacked' port (the loopbacks here could also indicate multiple ports connected to the same switch, which is equivalent to a set of ports connected with a crossover cable).
- Mark Pizzolato
On Monday, July 04, 2011 5:44 AM, rajath kumara wrote:
> Thanks for the reply.
> However guess, its better to restate my problem, so that i can make you
> people clear about my query.
> I am using some 3 NICS ( network interface cards), which together get me 10
> 2 NICs are are from D-Link NIC cards which have 4 ports each in them, and
> another is NETGEAR NIC, which has 2 ports in it.
> with the help of pcap_findalldevs() , i can obtain the list of all ports ,
> along with details of NIC cards, their MAC_ addresses and others.
> But my question is , pcap_findalldevs( ), gives me list of all 10 ports i am
> assume i use a cross-cable and connect any 2 ports to form a loopback
> condition,then is their any function in wpcap, which tells me
> which 2 ports are in loopback state among the 10 ports i am using.
> or any other function is their apart from wpcap, which helps me to do this.
> please help me to figure out this problem.
More information about the Winpcap-users