libp2p / libp2p/go-libp2p

proposal: expose transport stats

Open
#1,729 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

effort/days exp/intermediate kind/enhancement
Dominant language
Go
Stars
6.9k
Forks
1.3k
Avg merge
13d 21h
Merged PRs (30d)
1

Description

Motivating issue: Get accurate RTT measurement for yamux (https://github.com/libp2p/go-yamux/pull/70).

We could introduce an `transport.StatTransport` (suggestions for a better name appreciated!) interface that transports can (but don't need to) implement:
```go
type StatTransport {
Stat() Stat
}

type Stat struct {
RTT time.Duration
RTTVariance time.Duration
}
```

Both TCP and QUIC should be able to expose these values easily. We already have an implementation for TCP: https://github.com/libp2p/go-libp2p/blob/fcf408c65d99f9a2f45c761a1003d66d3a664f30/p2p/transport/tcp/metrics.go#L240-L249
quic-go could expose these on the `quic.Connection`, the congestion controller is already keeping track of these values.

Open question: In the future, we'll probably want to add more values to `Stat`. Obvious candidates are congestion window, packet loss rate, counters for bytes sent and received, etc. Will every transport be able to determine these values?

cc @vyzo @Stebalien @MarcoPolo @BigLep

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 the proposed transport.StatTransport and Stat interfaces in the issue, then read p2p/transport/tcp/metrics.go around the referenced TCP implementation. Check how quic.Connection exposes congestion-controller values. Done would require agreement on the interface, supported statistics, and transport behavior, which the issue leaves open.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
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.