Summary: it only takes about 2 hours to set up a Chromecast ... if your network has IPv6.

The Chromecast set up is meant to work like this:

1. Chromecast when powered on runs a wireless access point with SSID ChromecastXXXX
2. Chromecast setup app. connects Android device to Chromecast
3. User inputs real wi-fi details to setup app.
4. Chromecast setup app. configures Chromecast with real wi-fi details
5. Chromecast setup app. instructs Chromecast to connect to real wi-fi
6. Chromecast setup app. disconnects Android device from Chromecast, connects to real wi-fi and discovers Chromecast (using multicast)

In my case, at step 5 above, the setup app. reports failure to communicate with the Chromecast, and offers to cancel or to retry. Retry causes the app. to re-run steps 3 through 6 above. Cancel takes you back to step 2 (and then will run steps 3 through 6 again).

What happens at the network level for steps 5 and 6 above is this:

11. Chromecast connects to real access point
12. Chromecast obtains IP (v4) address using DHCP
13. Chromecast advertises itself using IP (v4) multicast
21. Android device connects to real access point
22. Android device obtains IP (v4 and/or v6) addresses
23. Android discovers Chromecast(s) using IP (v4 and/or v6) multicast

The problem I hit was in steps 22 and 23. The Android device obtained an IPv6 address first. It then tried to discover the Chromecast using IPv6 multicast and reported that the Chromecast was not responding. It didn't receive an IPv4 address until after it had given up on the Chromecast.

The first flaw here is that the IPv4 stack wasn't configured until after the app. had decided that the Chromecast wasn't responding. The second flaw is that retry involves reconfiguring the Chromecast and then trying to discover it, which involves reconnecting the Android device to the real network and the setting up of IP (v4 and v6) addresses. It shouldn't be a surprise to learn, that retry always failed to find the Chromecast.

In my network, IPv6 addresses are obtained via stateless autoconfiguration and router advertisements (RA's). This means that IPv6 stack set up is quick. For the IPv4 stack, the Android device first tries to re-use the address that the Chromecast gave it via DHCP (192.168.255.251) with the real DHCP server. When this fails, it falls back to requesting a DHCP address normally.

As mentioned in the summary, it took about 2 hours of searching the Internet (via Google, of course) then using a packet sniffer (tcpdump watching the ethernet addresses of both Chromecast and Android device) to realise what was happening. The "fix" only took a few seconds - I disabled Router Advertisements on my router, selected Retry on the Android device, and the Chromecast was discovered first time. A real fix would be for the setup app. to not attempt to discover the Chromecast until the correct network protocol (IPv4) is available.


-^- More notes -^-