libp2p / libp2p/go-libp2p

Transport-level bandwidth reporter

Open
#1,008 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.