Transport-level bandwidth reporter
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.9k
- Forks
- 1.3k
- Avg merge
- 13d 21h
- Merged PRs (30d)
- 1
Description
Adding this here as it was discussed off-band. Right now libp2p isn't capable of giving the amount of total raw data exchanged between two nodes (after the muxer and crypto framings). The only bandwidth measurement available is at a stream level through `go-libp2p-core/metrics/bandwidth.go: TotalBandwidth()`. A wire-level measurement could come pretty handy, especially when debugging implementations after the muxer.
> @raulk: To achieve this we may want to implement a transport wrapper that wraps connections and reports physical bytes read and written to the `Reporter`. For this we’d need to enhance the `Reporter` interface (or add a secondary `Reporter` interface that we can type assert against to know if the implementation has that feature).
Thus we will have two levels of bandwidth measurements in libp2p:
>* The transport would tell us how many bytes were written/read off the wire (disregarding the L3/L4 protocol framing), per connection (which we can then map to the peer).
>* The higher-up component can tell us how many bytes were written/read per protocol and per stream.
We probably want a single sink for these stats, with various reporting sources.
cc @aarshkshah1992
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with go-libp2p-core/metrics/bandwidth.go and the existing TotalBandwidth() and Reporter interfaces. Trace how transport connections and stream-level metrics are reported, then determine how a transport wrapper could record physical bytes while sharing a sink with protocol and stream measurements. Done means the design and implementation expose per-connection wire-level read and write totals without losing the existing stream-level metrics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking, observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100