user109327: 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?

user-1: Every crawler may use its own method and bitnodes uses GETADDR for it:

The current methodology involves sending getaddr messages recursively to find all the reachable nodes in the network, starting from a set of seed nodes.

Webpage and crawler used by Luke Dashjr shows more nodes compared to others: https://luke.dashjr.org/programs/bitcoin/files/charts/software.html
If you monitor the traffic of your network while trying to connect to Bitcoin Network using Bitcoin Core, you will notice it sends below information in the first request and gets similar response from another node:
User-Agent: //
Version: XXXXX
Lastblock: XXXXXX
I have filtered the results in Wireshark to show only "Bitcoin" protocol related requests and response

Below is the response my node got from other node:

I don't have my own code or tools to monitor the internet traffic and filter it for Bitcoin nodes however I tried searching using Shodan and it returned few results:

Some crawlers might also use ways to filter machines connected to the internet and get information about nodes.

user13866: 
Does the Bitcoin network send around an integer saying how many nodes there are to each other as part of the protocol,

No.
See https://en.bitcoin.it/wiki/Protocol_documentation
So far as I can see, total counts of active nodes are not part of any message but there are potentially useful messages such as:

getaddr
The getaddr message sends a request to a node asking for information about known active peers to help with finding potential nodes in the network.

By sending this message to all known but previously uncontacted nodes, it is possible to discover more previously uncontacted nodes you can send this message to until the responses only contain previously contacted nodes and all the nodes you know of are either contacted nodes or unresponsive nodes.


I'd like to know how exactly they determine this,

CoinDance don't say.

As Davidson Souza's later answer reports, at least one website (Bitnodes) uses the getaddr message to approximate the number of all currently accessible nodes.

109327: <p>On this URL: <a href="https://coin.dance/nodes" rel="nofollow noreferrer">https://coin.dance/nodes</a></p>
<p>It says how many public Bitcoin nodes are currently active in the world, and how many Bitcoin Core ones.</p>
<p>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.</p>
<p>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.</p>
<p>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?</p>
 -1: <p>Every crawler may use its own method and <a href="https://bitnodes.io/" rel="nofollow noreferrer">bitnodes</a> uses <code>GETADDR</code> for it:</p>
<blockquote>
<p>The current methodology involves sending getaddr messages recursively to find all the reachable nodes in the network, starting from a set of seed nodes.</p>
</blockquote>
<p>Webpage and crawler used by Luke Dashjr shows more nodes compared to others: <a href="https://luke.dashjr.org/programs/bitcoin/files/charts/software.html" rel="nofollow noreferrer">https://luke.dashjr.org/programs/bitcoin/files/charts/software.html</a></p>
<p>If you monitor the traffic of your network while trying to connect to Bitcoin Network using Bitcoin Core, you will notice it sends below information in the first request and gets similar response from another node:</p>
<pre><code>User-Agent: //
Version: XXXXX
Lastblock: XXXXXX</pre></code>
<p>I have filtered the results in <a href="https://www.wireshark.org/" rel="nofollow noreferrer">Wireshark</a> to show only &quot;Bitcoin&quot; protocol related requests and response</p>
<p><a href="https://i.stack.imgur.com/Shf0j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Shf0j.png" alt="Screenshot-Wireshark-BitcoinCore1" /></a></p>
<p>Below is the response my node got from other node:</p>
<p><a href="https://i.stack.imgur.com/IzgVC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IzgVC.png" alt="Screenshot-Wireshark-BitcoinCore2" /></a></p>
<p>I don't have my own code or tools to monitor the internet traffic and filter it for Bitcoin nodes however I tried searching using <a href="https://www.shodan.io/" rel="nofollow noreferrer">Shodan</a> and it returned few results:</p>
<p><a href="https://i.stack.imgur.com/lF3cO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lF3cO.png" alt="Shodan-Bitcoin" /></a></p>
<p>Some crawlers might also use ways to filter machines connected to the internet and get information about nodes.</p>
 13866: <blockquote>
<p><strong>Does the Bitcoin network send around an integer saying how many nodes there are to each other as part of the protocol,</strong></p>
</blockquote>
<p>No.</p>
<p>See <a href="https://en.bitcoin.it/wiki/Protocol_documentation" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Protocol_documentation</a></p>
<p>So far as I can see, total counts of active nodes are not part of any message but there are potentially useful messages such as:</p>
<blockquote>
<p><strong>getaddr</strong><br />
The getaddr message sends a request to a node asking for information about known active peers to help with finding potential nodes in the network.</p>
</blockquote>
<p>By sending this message to all known but previously uncontacted nodes, it is possible to discover more previously uncontacted nodes you can send this message to until the responses only contain previously contacted nodes and all the nodes you know of are either contacted nodes or unresponsive nodes.</p>
<hr />
<blockquote>
<p><strong>I'd like to know how exactly they determine this,</strong></p>
</blockquote>
<p>CoinDance don't say.</p>
<hr />
<p>As <a href="https://bitcoin.stackexchange.com/a/98850/13866">Davidson Souza's later answer</a> reports, at least one website (<a href="https://bitcoin.stackexchange.com/a/98850/13866">Bitnodes</a>) uses the <code>getaddr</code> message to approximate the number of all currently accessible nodes.</p>
