Page 1 of 1
Obtain sender's MAC address for a UDP packet
Posted: Wed Nov 11, 2020 10:16 am
by valery
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?
Re: Obtain sender's MAC address for a UDP packet
Posted: Wed Nov 11, 2020 9:00 pm
by Scott.Bonomi
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.
Re: Obtain sender's MAC address for a UDP packet
Posted: Thu Nov 12, 2020 1:16 am
by ESP_Sprite
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.
Re: Obtain sender's MAC address for a UDP packet
Posted: Thu Nov 12, 2020 9:23 am
by valery
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