Question

Let's say I have a desktop software called super-dupper-app. I want it to be able to detect all computers on this local network with super-dupper-app running.

General pointers really appreciated. Bonus points for Python pointers or snippets.

Was it helpful?

Solution

The short answer is you use multicast packets in python. I believe there are also python bindings for avahi, which implements "ZeroConf" aka mDNS/DNS-SD, which is implemented on top of multicast and would save you having to reinvent the wheel as well as being more standard.

Multicast sits somewhere in between unicast (packets going to one host) and broadcast (packets going to all hosts) in that it allows host (via applications running on them usually) to register an interest in certain multicast groups. Multicast traffic can cross routers as well as switches, with appropriate support and the idea is that a minimum spanning tree gets built for sending packets to all subscribed hosts. In IPv4 multicast uses the 224/4 subnet. For IPv6 this is ff00::/8. In ethernet multicast addresses are mapped onto MAC addresses (i.e. have the multicast bit set to 1 in the MAC address), which makes efficient filtering of multicast streams possible.

Routers running RIPv2 for example use multicast to discover other neighbouring routers and share their routes without bothering hosts which have no interest in RIP.

mDNS/Bonjour/Rendevouz is an approach to automatic service discovery that uses one multicast group to share DNS style messages listing available services on a LAN.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top