quinn-rs / quinn

Async-friendly QUIC implementation in Rust
Apache License 2.0
3.57k stars 363 forks source link

stream sending buffer size and how much left #1838

Closed szguoxz closed 1 month ago

szguoxz commented 1 month ago

for bistream or unistream, is there anyway to know how big is the sending buffer, and how many bytes left in the buffer?

Ralith commented 1 month ago

There are multiple limits on the amount of data you can send at any particular point in time. Some are under the sender's control, some the receiver's (flow control). Flow control limits aren't currently exposed directly. They could be, but that information might become out of date immediately. What are you trying to achieve, specifically?

szguoxz commented 1 month ago

I am creating a VPN between China and USA. but the connection is not stable. I have a relay node in HK. So I created two connections between my China and USA nodes. One direct, another one relay by the HK nodes.

When I send data from USA to China, I want to intelligently pick which connection to use. If one is seriously delayed, I will use another one.

On the receiving side, my node is intelligent enough to drop duplicate data ... etc.

So, my main problem is: How to determine which connection is in relatively bad shape? Which one should I use at the moment?

Thanks.

Ralith commented 1 month ago

Hmm, I know I typed up a response to this, but I must have forgotten to send it...

"bad shape" and "not stable" are vague. Are you trying to use the connection with the lowest latency? The highest throughput? The least packet loss? Some weighted combination of those? Most likely you should be looking at PathStats (via Connection::stats), rather than anything to do with stream buffer state.