-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[transports/webrtc] Record total number of bytes sent / received in UDPMuxNewAddr #3157
Comments
Also I don't think it's possible to wrap Transport which does multiplexing (webrtc / quic) with https://docs.rs/libp2p/latest/libp2p/bandwidth/struct.BandwidthLogging.html. Solution seems to be return it along with Seems like we'll need a new type |
Yes. Additionally, both of these are UDP-based which means we don't have a stream that we can wrap. All data that is sent is sent as datagrams. I wish we would be able to do this but it requires specialization: #[cfg(feature = "webrtc")]
impl Transport for BandwidthLogging<libp2p_webrtc::tokio::Transport> { } |
I think I found a solution. See #3161. |
When tracking ingress and egress, one has to count on a specific level, e.g. on the IP layer, the transport layer, the application layer, ... I would boldly state that none of them are correct (as you can always drill deeper), but some are useful / intuitive. #3161 and #3162 count at the Transport layer, i.e. bytes sent and received on a TCP or UDP socket. Though #3162 makes some exceptions:
With all of the above, I want to propose an alternative approach. How about counting at the application level? How about counting the goodput? In other words, how about counting at the stream layer? Unless I am missing something, this would only require a @melekes @thomaseizinger what do you think? (@melekes I know this would be a mildly breaking change on the Substrate side. Though in my eyes, a change worth considering.) |
From the perspective of libp2p user, I don't have a strong opinion. If counting only the goodput results in a good abstraction, I think we should go for it! From the perspective of webrtc-rs dev, it would be good to measure / know the overhead of webrtc proto, but that's a different topic (and doesn't belong to this repo anyway). |
I don't mind much where we attach the logging. If it works for users that we only log application traffic, then this will obviously make our life easier because we get away with a single abstraction. |
An alternative approach to libp2p#3161 suggested in libp2p#3157 (comment) Closes libp2p#3157
@tomaka any thoughts on #3157 (comment)? |
It's what I've mentioned in another issue or PR: I think that building the bandwidth measurement on top of the And from a point of view of libp2p user I don't care that much about missing some bytes. I would have a different opinion if the bandwidth measurement of TCP was exact, because that would make us switch from "exact measurement" to "approximate measurement", but as mentioned it's not. |
Previously, the `with_bandwidth_logging` extension to `Transport` would track the bytes sent and received on a socket level. This however only works in conjunction with `Transport` upgrades where a separate multiplexer is negotiated on top of a regular stream. With QUIC and WebRTC landing, this no longer works as those `Transport`s bring their own multiplexing stack. To still allow for tracking of bandwidth, we refactor the `with_bandwidth_logging` extension to count the bytes send on all substreams opened through a `StreamMuxer`. This works, regardless of the underlying transport technology. It does omit certain layers. However, there isn't necessarily a "correct" layer to count bandwidth on because you can always go down another layer (IP, Ethernet, etc). Closes #3157.
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
BandwidthSinks
struct in SubstrateAre you planning to do it yourself in a pull request?
Yes
The text was updated successfully, but these errors were encountered: