Is your feature request related to a problem? Please describe.
It is not possible to get per message stats accumulated since the node has started. This would make analyzing network traffic in details easier.
Describe the solution you’d like
Extend getnettotals
with a data similar to what is present in getpeerinfo
per peer.
Describe alternatives you’ve considered
Looking at getpeerinfo
gives some approximation, but it is only for currently connected peers and the stats are lost when a peer disconnects. It is possible to derive/interpolate from that and the time the peer has been connected, but that is cumbersome and prone to errors due to temporary traffic glitches (if the traffic is not uniform over time). E.g. if this peer has been connected for 10 seconds and transferred 5 bytes for INV messages and bitcoind
is up for 1000 seconds, then 500 * number_of_peers bytes have been transferred for INV messages since startup, assuming number of connected peers does not change.
Additional context
Suggested additions to getnettotals
:
0{
1 "totalbytesrecv": 304173500,
2 "totalbytessent": 291919674,
3+ "bytessent_per_msg": {
4+ "addrv2": 8215,
5+ "feefilter": 32,
6+ "getaddr": 24,
7+ "getdata": 9542,
8+ "getheaders": 1053,
9+ "headers": 1696,
10+ "inv": 1536387,
11+ "notfound": 61,
12+ "ping": 3584,
13+ "pong": 3616,
14+ "sendaddrv2": 24,
15+ "sendcmpct": 33,
16+ "sendheaders": 24,
17+ "tx": 1446525,
18+ "verack": 24,
19+ "version": 127,
20+ "wtxidrelay": 24
21+ },
22+ "bytesrecv_per_msg": {
23+ "addrv2": 52611,
24+ "feefilter": 32,
25+ "getdata": 15413,
26+ "getheaders": 1053,
27+ "headers": 3604,
28+ "inv": 444758,
29+ "notfound": 183,
30+ "ping": 3616,
31+ "pong": 3584,
32+ "sendaddrv2": 24,
33+ "sendcmpct": 66,
34+ "sendheaders": 24,
35+ "tx": 506127,
36+ "verack": 24,
37+ "version": 126,
38+ "wtxidrelay": 24
39+ },
40 "timemillis": 1666181842031,
41 "uploadtarget": {
42 "timeframe": 86400,
43 "target": 0,
44 "target_reached": false,
45 "serve_historical_blocks": true,
46 "bytes_left_in_cycle": 0,
47 "time_left_in_cycle": 0
48 }
49}