Obtain sender's MAC address for a UDP packet

valery
Posts: 5
Joined: Sun May 03, 2020 12:20 pm

Obtain sender's MAC address for a UDP packet

Postby valery » Wed Nov 11, 2020 10:16 am

When I receive a UDP packet from a remote computer, I need to determine the MAC address of the (remote) interface card from which it was sent. Is there any way to do this?

Scott.Bonomi
Posts: 73
Joined: Mon Mar 09, 2020 7:36 pm

Re: Obtain sender's MAC address for a UDP packet

Postby Scott.Bonomi » Wed Nov 11, 2020 9:00 pm

It should be bytes 6..11 in the datagram.
I suggest you get wireshark and capture some of your actual packets to ensure they are being built correctly.

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: Obtain sender's MAC address for a UDP packet

Postby ESP_Sprite » Thu Nov 12, 2020 1:16 am

Scott.Bonomi: You don't get the Ethernet-level packet if you use the sockets interface, which valery likely is doing.

Valery: The IP you're receiving from is associated with the MAC through arp. You might be able to use the LWIP call etharp_find_addr() or etharp_get_entry() to convert the IP back to the MAC.

valery
Posts: 5
Joined: Sun May 03, 2020 12:20 pm

Re: Obtain sender's MAC address for a UDP packet

Postby valery » Thu Nov 12, 2020 9:23 am

ESP_Sprite wrote:
Thu Nov 12, 2020 1:16 am
Valery: The IP you're receiving from is associated with the MAC through arp. You might be able to use the LWIP call etharp_find_addr() or etharp_get_entry() to convert the IP back to the MAC.
Thank You :)

Who is online

Users browsing this forum: No registered users and 182 guests