Search code examples
google-cast

Why does Google Cast Chrome extension only search for link-local devices via mDNS?


Chromecast v2 devices announce their presence using mDNS, and they are discoverable when performing mDNS queries for _googlecast._tcp.

DNS-SD / Bonjour also support the concept of "wide-area discovery", which makes use of standard unicast DNS queries to find devices. This can be useful for more complex networking scenarios - i.e your Chromecast devices may be in one VLAN but your sender devices are in another.

However, when trawling Chromium source I found this code in mdns_api.cc which seems to indicate that the Chrome extension will only search for _googlecast._tcp.local - completely preventing wide-area DNS discovery of other Chromecast devices. Based on anecdotal testing, it seems the Chromecast iOS app and SDK also have this behaviour.

Why does the official discovery mechanism for the Chromecast Chrome extension explicitly only discover link-local Chromecast devices?


Solution

  • They probably didn't do "wide-area discovery" because there are a lot of gotchas in implementing it and there isn't much gain to be had.

    Let's suppose that they did implement it (from looking at the spec, it doesn't seem to be technically difficult; seems like it is mostly an edge-case problem).

    You'd need:

    1. A domain under your control. Could be a local-only domain.
      • Not many people do this.
    2. Multiple VLANs that you want to use.
      • Most homes only have a single VLAN.
    3. A DNS-SD server that supports Wide-Area Discovery.
      • This is probably the easiest thing to have. Even then, most people wouldn't do it.
    4. A UX flow to input the various WAD servers that you want to ping for devices.
      • This is the hard part for Google since it needs to be consistent across all SDKs and using a WAD-discovered Chromecast would cause all local-media-server Apps to not work (e.g. Plex).

    (1) - (3) are why Google wouldn't make this a priority. Chromecast is, after all, a consumer device and consumers tend to have simple networking situations. (4) is why it isn't low-hanging fruit.

    You'd also need to solve a few problems:

    1. What happens when you are connected to a Chromecast on a separate VLAN and then remove it's WAD server?
      • What if the WAD server goes offline?
    2. What happens when you have multiple Chromecasts with the same name?
      • What if they also have the same IP address (possible since VLANs can have overlapping IP spaces)?
    3. What happens when a Chromecast is discoverable using WAD but not reachable?
      • Should they attempt a connection to every single Chromecast you discover to test that it is reachable?
        • How would you scale this out to work with 100s of Chromecasts in VLANs that could be "far" away?

    It is these problems that I think would prevent Google from implementing WAD even if they wanted to.