2 Comments

Using UDP Broadcast Messages to Discover Local Clients

On my current project, we have a group of networked devices that will be assigning their own IP address semi-randomly based on a serial number burned into the CPU. This leaves us with a problem: we need to be able to quickly determine who’s on the network.

We’ve chosen to have each device listen on the network’s broadcast address using a UDP socket. We can then have our control device join the network and send a “Who’s there?” message to the broadcast address. When the devices on the network get the broadcast message, they respond with an “I’m here” message. Based on these responses, we can enumerate who all we should concern ourselves with in later operations.

There are a few special things to remember when configuring a system like this. I’ve built a pair of reference applications that define a listening broadcast “server” and a broadcast “client” that can discover who’s available.

I’ve made these sample applications available on Github.