alibaba / xquic

XQUIC Library released by Alibaba is a cross-platform implementation of QUIC and HTTP/3 protocol.
Apache License 2.0
1.65k stars 326 forks source link

[Bug]: XQC_kGranularity usage #299

Closed cooldazdingo closed 12 months ago

cooldazdingo commented 1 year ago

What happened?

both client and server stuck in call chain xqc_process_ack_frame->xqc_send_ctl_on_ack_received->xqc_send_ctl_detect_lost->xqc_send_ctl_indirectly_ack_po

Steps To Reproduce

simulate a bad network env on server side, such as: tc qdisc add dev eth0 root netem delay 100ms 10ms 30% loss 1% 30% duplicate 1%

test_client get a big file from server

Relevant log output

diff --git a/src/transport/xqc_send_ctl.c b/src/transport/xqc_send_ctl.c
index 7adf85c..20a1915 100644
--- a/src/transport/xqc_send_ctl.c
+++ b/src/transport/xqc_send_ctl.c
@@ -1185,7 +1185,7 @@ xqc_send_ctl_detect_lost(xqc_send_ctl_t *send_ctl, xqc_send_queue_t *send_queue,
     loss_delay += loss_delay >> send_ctl->ctl_reordering_time_threshold_shift;

     /* Minimum time of kGranularity before packets are deemed lost. */
-    loss_delay = xqc_max(loss_delay, XQC_kGranularity);
+    loss_delay = xqc_max(loss_delay, XQC_kGranularity * 1000);

     /* Packets sent before this time are deemed lost. */
     xqc_usec_t lost_send_time = now - loss_delay;
@@ -1315,7 +1315,7 @@ xqc_bool_t
 xqc_send_ctl_in_persistent_congestion(xqc_send_ctl_t *send_ctl, xqc_packet_out_t *largest_lost, xqc_usec_t now)
 {
     if (send_ctl->ctl_pto_count >= XQC_CONSECUTIVE_PTO_THRESH) {
-        xqc_usec_t duration = (send_ctl->ctl_srtt + xqc_max(send_ctl->ctl_rttvar << 2, XQC_kGranularity)
+        xqc_usec_t duration = (send_ctl->ctl_srtt + xqc_max(send_ctl->ctl_rttvar << 2, XQC_kGranularity * 1000)
             + send_ctl->ctl_conn->remote_settings.max_ack_delay * 1000) * XQC_kPersistentCongestionThreshold;
         if (now - largest_lost->po_sent_time > duration) {
             return XQC_TRUE;
@@ -1915,4 +1915,4 @@ xqc_sent_record_log(xqc_send_ctl_t *send_ctl, xqc_packet_out_t *packet_out)
     xqc_log(send_ctl->ctl_conn->log, XQC_LOG_DEBUG, "|path:%ui|pkt_num:%ui|record_smallest_pn:%ui|record_largest_pn:%ui|",
             send_ctl->ctl_path->path_id, packet_out->po_pkt.pkt_num, first_node->pkt_num, last_node->pkt_num);
 }