On this URL: https://coin.dance/nodes
It says how many public Bitcoin nodes are currently active in the world, and how many Bitcoin Core ones.
While it's good that I can grab these numbers from that webpage, I'd like to know how exactly they determine this, and if it's simple, I'd like to calculate it myself rather than relying on a third party which could disappear tomorrow or lie to me or have a bug or anything.
Is this simple to determine? What steps have they likely taken to calculate this? Does it involve scanning every public IP address in the world repeatedly and checking for listening Bitcoin ports? If so, I'll probably leave it to them as I don't need to emit that kind of insane amount of traffic from my home... not to mention it would probably require me to use tons of IP addresses lest I want to get banned from various network and thus get inaccurate statistics.
Or does Bitcoin Core itself have this information baked in? Does the Bitcoin network send around an integer saying how many nodes there are to each other as part of the protocol, and I can just use the RPC API to my local Bitcoin Core to get this info?
getaddr
, make new connections and repeat.