Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: babagindra on November 03, 2021, 08:30:45 PM



Title: Measuring bandwidth between two full nodes
Post by: babagindra on November 03, 2021, 08:30:45 PM
Can Bitcoin API measure the bandwidth between the full nodes?
For example, can I connect to some 8 peers and measure the bandwidth between myself and each of the peers (in some manner similar to iperf)?


Title: Re: Measuring bandwidth between two full nodes
Post by: BlackHatCoiner on November 03, 2021, 08:43:56 PM
Not sure if the Bitcoin API allows you to view this, but I highly doubt it. You can't obviously do this with softwares such as iperf, because the other nodes won't have them installed. So, it has to be written in the source code of Bitcoin Core.

Here's a disappointing API search: https://developer.bitcoin.org/search.html?q=bandwidth&check_keywords=yes&area=default

I hope another user knows more than I do.


Title: Re: Measuring bandwidth between two full nodes
Post by: PrimeNumber7 on November 03, 2021, 09:29:40 PM
You can use the getpeerinfo (https://developer.bitcoin.org/reference/rpc/getpeerinfo.html) RPC command to get the IP address of each of the nodes you are connected to.

Once you have the above information, you can use a tool to monitor traffic between you and that IP address. There are a number of tools that can help you do this. a google search found one tool (https://www.techadvisor.com/how-to/network-wifi/how-monitor-traffic-from-ip-address-3581880/) called wireshark, and another tool called utop (https://unix.stackexchange.com/questions/36815/find-out-network-traffic-per-ip). I have never used either of these tools, and have done no research on them beyond a basic google search looking for them, so use at your own risk. Note that this is measuring the actual amount of bandwidth being used, not necessarily the capacity to transfer data between your node and the nodes you are connected to.


Title: Re: Measuring bandwidth between two full nodes
Post by: nc50lc on November 04, 2021, 07:38:25 AM
-snip-
For example, can I connect to some 8 peers and measure the bandwidth between myself and each of the peers (in some manner similar to iperf)?
Yes, you can use the suggested command above.
The "bytessent" and "bytesrecv" results of getpeerinfo already has the info you're looking for (but in total).

If you're looking for real-time result like in iperf, follow his suggestion.