Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to implement device discovery on a LAN

I have little experience in network programming and I am writing a multi platform system which requires each device to be able to find other devices within the same LAN. I am looking for the right approach to do that, and hope that people here can give a good advise. Here are my design requirements:

  1. I am using C++ and the solution needs to be cross platform, which is at least able to run on iOS, Windows, Android.

  2. The system should be pretty light weight, and work under no special setup or network requirements, if possible.

Here are different approaches I am considering:

  1. Using uPnP protocol, but I am not very familiar with it, and it doesn't seems that there are many examples with code on the subject.

  2. Using the traditional socket approach, creating both Server/Client on each device and send the data packet to every IP in the LAN. And do everything manually afterwards. Correct me if I am wrong, if I send a packet to the broadcast address, does that mean that the system automatically sends my packet to every IP within the subnet?

  3. Using an external server all clients will register to, and then getting information about other(already registered) clients from that server. However, I am not sure with what information each client should connect in order to determine they are in the same LAN.

Let me know if what I am thinking makes any senses. Any advice is greatly appreciated.

like image 812
NachoChip Avatar asked Apr 25 '13 22:04

NachoChip


People also ask

What is LAN discovery?

When connected over a local network, network discovery enables network devices to connect and communicate between the other devices connected to the same network. This allows system administrators to locate devices with ease.

Which allows discovery of new devices to connect in the network?

Network discovery is what allows computers and other devices to be discovered on a network. With network discovery, a system will send out messages over the network looking for devices that are discoverable.


1 Answers

One option you have not listed is ZeroConf's DNS-SD protocol.

It is used heavily by Apple - who market it as Bonjour (née Rendezvous). There is tight integration into iOS and MacOSX.
Apple also provides a Windows implementation, an SDK and has open sourced the mDNS service.

Android appears to support it out of the box.

There's also robust and mature support for Linux in the form of Avahi, included in most desktop distros.

It seems the only platform where a user would need to install anything is Windows, and even then, it is installed with iTunes (used for music library sharing) and the setup software for any of Apple's wireless access points.

like image 183
marko Avatar answered Sep 27 '22 18:09

marko