WiFiNINA - ARP - GET MAC/IP ADDRESS

Hello hello everyone ! (in advance, sry for my bad english)

I am using MKR Wifi 1010 which is connected to my network. I would like to get the IP address of an other device connected to my network, which often change.

I would like to send through the network, a request to get IP address of that device, based on the MAC address of that device.

How can I do that ??

Once im connected to my network with the MKR 1010, I would like to scan that network, using a MAC address, in order to find my device IP address.

I will try to send some packet through the network using UDP protocol to get that IP address, regarding the MAC address of my device.

Have someone tried this before ? any idea/suggestion ?

Thx in advance :)

Best regards,

isosel.

To get the MAC address of another device in your local network you can used the ARP protocol. Whether this is easily usable and available in the wifi/network library I do not know.

https://en.wikipedia.org/wiki/Address_Resolution_Protocol

To get the IP address of your own device check the examples with your library. It probably looks something like.

IPAddress ip = WiFi.localIP();

Regarding ARP, I think you might want to look into other possibilities. You basically want to hardwire all the devices in your source code together. This has the following disadvantages. - If your receiving device fails you need to reprogram your sending device, once you have installed a replacement receiver. - If your ARP interval is short you are flooding your network with ARP calls. ARP calls are sent to everyone in the network. - If your ARP interval is too long you are sending your data to the wrong devices. - You need memory to store the MAC and IP addresses. So, this is not a scalable solution.

Have a look at some other options. - Give the sender/server a fixed IP address. Some routers allow a device to use a fixed IP address from a select range e.g. 192.168.2.10 to 192.168.2.20 check your routers manual. Other routers can be instructed to give a specific device based on its MAC the same IP address during DHCP. Check your routers DHCP settings. With this your receiver can send a request to the server and this can then send the data. And you can replace and add new receivers easily. If you need to replace the server just give it the same IP address. No reprogramming necessary.

  • Check out the MQTT protocol for a flexible solution which is supported by libraries available for Arduino. It's a publish subscribe network protocol for small amounts of data. It usually runs on top of TCP/IP. The idea is the following, you have a central node called a message broker this can be a Raspberry Pi running a software called mosquitto and you have many other nodes providing data or requiring data. Each node tells the broker what messages it is interested in (subscribe) and other nodes just send messages (publish). The broker makes sure the messages are delivered to anyone who wants them.

https://en.wikipedia.org/wiki/MQTT