Solved

Winsock -> Obtaining a remote mac address

Posted on 2004-07-30
6
1,186 Views
Last Modified: 2013-12-03
Is it possible to get a remote computer's MAC Address upon recieving a packet VIA a udp socket? I know that the mac address gets sent along with the UDP header, but is there a way to look at it using winsock?

Note that this doesn't involve LANs at all.
0
Comment
Question by:Pogo187
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:mxjijo
ID: 11695118

No you cannot find it from the UDP packet because by the time your applications get the
packet, the IP/UDP etc headers are already removed.

To map between IP and MAC address, you may use ARP (Address resolution Protocol)

Take a look at SendARP (). I think that function would serve your purpose.

~j
0
 
LVL 8

Expert Comment

by:adg080898
ID: 11759047
This is somewhat cheesy, (use mxjijo's suggestion if you can, it's way better!), but an extremely simple alternative is to system() out to "arp -a", kind of like this:

system("arp -a > c:\\full\\path\\to\\my\\outputfile.txt");

Then open that output file and parse out the ARP information. Go into a command prompt and type

arp -a

and look at the output. Yes, I know, "UNIX style", but it should work if you start ripping your hair out trying to use SendARP.

I'm pretty sure you can't get the MAC address of a machine outside your local (hardwired) network. In other words, you won't see "past" a router.
0
 
LVL 8

Expert Comment

by:adg080898
ID: 11759052
How does it not involve LANs? In that case, you will probably only get the "mac address" for your modem. I know, it's not really a MAC address, but it pretends to have one.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 8

Assisted Solution

by:mxjijo
mxjijo earned 200 total points
ID: 11774361

adg,
     
>> I know, it's not really a MAC address, but it pretends to have one.
      Yes, any network interface (eithernet card / satellite link etc) will expose a unique MAC address, just like the IP address.
In fact you have to subcribe the MAC address before you use it.

>> I'm pretty sure you can't get the MAC address of a machine outside your local (hardwired) network
      Yes, that is the whole point of your default gateway. If the source machine could not find the MAC address in the network, it will forward it to the default gateway.

>> Yes, I know, "UNIX style", but it should work if you start ripping your hair out trying to use SendARP.
      Making a single call (system call in unix terms) is much better than parsing a txt file :)

0
 
LVL 8

Accepted Solution

by:
adg080898 earned 300 total points
ID: 11774500
SendARP requires windows 2000 Professional or XP.

I just noticed something in your question:
>  ...I know that the mac address gets sent along with the UDP header...

Actually, no. It doesn't get sent with the UDP header. The UDP datagram is wrapped in an ethernet frame that is addressed to YOUR mac address. Long before you get it (in winsock), the ethernet header is long gone.

If you did somehow manage to get a source mac address, it would be the mac address of the last router that touched your packet, useless.
0
 

Author Comment

by:Pogo187
ID: 11803887
Ah, I see. Thanks for the information.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question