1

I would like to ask a question about mDNS.
I am trying to create a Linux process which can discover some services (e.g. _airplay._tcp., _raop._tcp) from the other device when the device joins the Linux AP.

I can get the notification through mDNS, and use the dns-sd command,

dns-sd -B _xxxx._tcp

I can see:

Browsing for _xxx._tcp

Timestamp     A/R   Flags if    Domain    Service Type    Instance Name
18:06:15.281  Add   3     8     local.    _xxxx._tcp.     xxxx_name

However, when I move the device out of the WiFi range, I can not get the removed notification through mDNS and no removed event is seen by dns-sd command. I was wondering if it is expected that mDNS can not know the device is removed in this case?

Or maybe mDNS can know the device is removed through the network interface changed? I can not get the removed event, it is because my Linux network configuration is wrong?

Kurt Pfeifle
  • 1,796
  • 2
  • 12
  • 19
steven
  • 11
  • 1

1 Answers1

0

Yes, it is expected that mDNS cannot know that a device has disconnected from the network. A device that is not on the network cannot say that it is no longer on the network, and there is no central registry of devices or service registrations in mDNS -- it is entirely and explicitly designed to be decentralised. You can trade off accuracy for network traffic and query latency, by setting the mDNS record TTL to be quite low, but you can't solve the problem entirely.

Given that essentially the same problem can happen even using regular DNS (and dynamic updates), or practically speaking any service discovery system, the solution to whatever problem you're actually trying to solve is "don't rely on service discovery data being up-to-date, because it often won't be". That means doing your own "liveness" checking on services, properly handling all manner of errors (including using sensibly low connection timeouts), and generally assuming that SD data is, at best, a vague hint in the right direction, and not some sort of absolute guarantee that a particular service is available for you to use at any given moment.

womble
  • 96,255
  • 29
  • 175
  • 230