0

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?

1
  • My guess would use getaddr, make new connections and repeat.
    – sanket1729
    Commented Sep 2, 2020 at 6:49

3 Answers 3

2

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.

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

Screenshot-Wireshark-BitcoinCore1

Below is the response my node got from other node:

Screenshot-Wireshark-BitcoinCore2

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:

Shodan-Bitcoin

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

0

They use a crawler that connect to every single reachable node into the network recursively.
Basically connect to a node, send a getaddr request, and try to connect to the received addresses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.