Solved

Winsock -> Obtaining a remote mac address

Posted on 2004-07-30
6
1,177 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

732 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