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
Are you planning to do it yourself in a pull request?
Yes
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::writereports "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
ChunkPayloadDatathe 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
BandwidthSinksstruct in SubstrateAre you planning to do it yourself in a pull request?
Yes