cloudflare / quiche

🥧 Savoury implementation of the QUIC transport protocol and HTTP/3
https://docs.quic.tech/quiche/
BSD 2-Clause "Simplified" License
9.14k stars 686 forks source link

C API "quiche_conn_stream_send" The actual data size sent is inconsistent with the expected #603

Open 510056223 opened 3 years ago

510056223 commented 3 years ago
ssize_t ret = quiche_conn_stream_send(conn, stream_id, *buf, buf_len, fin);

Autually: ret > 0 && ret !=buf_len And call this function next time failed

The following is log

received an IP packet from kernel, packet len:1295!
############################### forward start
send the tcp packet to server, len: 1134
############################### forward stop
############################### send start
sent 1134 bytes
done writing
timeout: 0.032532
############################### send stop
received an IP packet from kernel, packet len:1324!
############################### forward start
failed to send HTTP request
############################### forward stop

expect 1295 actul 1134

510056223 commented 3 years ago
quiche: 07b04abcaa6a37f13bd08ca6afb14e8d rx pkt Short dcid=07b04abcaa6a37f13bd08ca6afb14e8d key_phase=false len=24 pn=306
quiche: 07b04abcaa6a37f13bd08ca6afb14e8d rx frm ACK delay=14 blocks=[359..374]
quiche::recovery: 07b04abcaa6a37f13bd08ca6afb14e8d packet newly acked 374
quiche::recovery: 07b04abcaa6a37f13bd08ca6afb14e8d timer=49.389879ms latest_rtt=10.765052ms srtt=Some(11.277481ms) min_rtt=507.294µs rttvar=3.344963ms loss_time=[None, None, None] loss_probes=[0, 0, 0] cwnd=14520 ssthresh=18446744073709551615 bytes_in_flight=13841 app_limited=true congestion_recovery_start_time=None delivered=195493 delivered_time=68.33µs recent_delivered_packet_sent_time=11.269293ms app_limited_at_pkt=207927  hystart=window_end=Some(0) last_round_min_rtt=None current_round_min_rtt=None rtt_sample_count=0 lss_start_time=None  

"cwnd" - "bytes_in_flight" = 679. So the next packet could only be sent 679 bytes if the next packet size is greater than 679 bytes.

LPardue commented 3 years ago

It is not clear to me what your problem is. stream_send() is documented here: https://docs.quic.tech/quiche/struct.Connection.html#method.stream_send. It is expected that the number of bytes returned from this method is totally in control of quiche, the application does not have awareness of flow control, packetization etc.

510056223 commented 3 years ago

It is not clear to me what your problem is. stream_send() is documented here: https://docs.quic.tech/quiche/struct.Connection.html#method.stream_send. It is expected that the number of bytes returned from this method is totally in control of quiche, the application does not have awareness of flow control, packetization etc.

I found that it was because bytes_in_fight ran out of cwnd.

And I found a new problem.When the timeout time obtained by "quiche_conn_timeout_as_nanos" is 0, the timer in the C language example is set to 0, which causes the timer to be deleted and the timeout processing function is not executed.