Skip to content

[transports/webrtc] Record total number of bytes sent / received in UDPMuxNewAddr #3157

@melekes

Description

@melekes

Description

so the last thing which stops me from releasing webrtc in Substrate (blockchain framework) is bandwidth calculation. The way it's commonly done for other libp2p transports is wrapping Transport with https://docs.rs/libp2p/latest/libp2p/bandwidth/struct.BandwidthLogging.html, which basically records number of bytes written / read across all streams.

BUT the problem with webrtc Transport is that a call to DataChannel::write reports "invalid" number of bytes.
by "invalid" I mean a call write([1,2,3]) will return n=3, but the actual number of bytes will be higher since [1,2,3] is wrapped into ChunkPayloadData

the correct amount is recorded by Association (https://github.com/webrtc-rs/webrtc/blob/cbfd3033c7605eff97988eef7257694fc3dcd717/sctp/src/association/mod.rs#L471)
but it's neither exposed nor present in stats.

One possible solution is to record total bytes sent / received in UDPMuxNewAddr, where the actual writing / reading from UDP socket happens. Then expose this info in ListenStream.

Motivation

Being able to accurately measure WebRTC connection's bandwidth.

Open questions

  • check that it will be possible to return a trait instead of BandwidthSinks struct in Substrate

Are you planning to do it yourself in a pull request?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions