If you’ve developed systems that communicate over the network (for example, a remote RT system) you’ve probably run into this issue: Clients need to know the remote program’s IP address in order to connect to it. If you have complete control over the local network, the simplest solution is to just set a static IP address on your system and call it a day. Often times, especially in corporate environments, you don’t have this luxury. Corporate IT is not always willing to set aside IP addresses specifically for your system. When faced with this situation, you’ll have to keep your system in DHCP mode and it’s IP address won’t be known ahead of time. This is where using UDP broadcast messages to make your systems “discoverable” can save the day.
The image below shows how this works. The client that’s looking for the remote system sends out a UDP broadcast message containing it’s own IP address to all devices on the network. Your remote system will be looking for this message, and when it sees it, it will respond directly to the client (since it now know’s the client’s IP address) with a direct UDP message containing it’s own IP address. Once the client receives that response message, it will have the remote system’s IP and can now connect properly. As a side effect, all of the other devices on the network will also receive the UDP broadcast message, but they will simply ignore it.
Here’s what this looks like in LabVIEW (Download Example Code):
Client:
Remote:
The remote system continuously listens for an incoming UDP packet. Most of the time, it will timeout and return an error, but when it receives a packet it sends it’s IP address back to the client (in the “No Error” case). The client simply sends out a broadcast message containing it’s IP address by sending out the packet to 255.255.255.255, and then listens for the response message containing the remote system’s IP address.
Making your remote systems discoverable using this technique can not only get around IT infrastructure constraints, it can also give your systems that “professional touch” that can make all the difference. Thoughts or suggestions? Please comment below to let me know what you think!