Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(674)

Unified Diff: net/quic/quic_connection.cc

Issue 555653002: Send an ack when it 20 packets have been received since the last ack was (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection.cc
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
index f84d08c9eace955fffe66eb7cb543f0d9a53025c..33c489a479e9bf9d3d485f8600f62e3dbe4b7be2 100644
--- a/net/quic/quic_connection.cc
+++ b/net/quic/quic_connection.cc
@@ -56,6 +56,9 @@ const size_t kMaxFecGroups = 2;
// expectation of the CHLO/SHLO arriving.
const size_t kMaxUndecryptablePackets = 10;
+// Maximum number of acks received before sending an ack in response.
+const size_t kMaxPacketsReceivedBeforeAckSend = 20;
+
bool Near(QuicPacketSequenceNumber a, QuicPacketSequenceNumber b) {
QuicPacketSequenceNumber delta = (a > b) ? a - b : b - a;
return delta <= kMaxPacketGap;
@@ -192,6 +195,7 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id,
pending_version_negotiation_packet_(false),
received_packet_manager_(&stats_),
ack_queued_(false),
+ num_packets_received_since_last_ack_sent_(0),
stop_waiting_count_(0),
ack_alarm_(helper->CreateAlarm(new AckAlarm(this))),
retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))),
@@ -781,6 +785,8 @@ void QuicConnection::OnPacketComplete() {
<< last_close_frames_.size() << " closes, "
<< "for " << last_header_.public_header.connection_id;
+ ++num_packets_received_since_last_ack_sent_;
+
// Call MaybeQueueAck() before recording the received packet, since we want
// to trigger an ack if the newly received packet was previously missing.
MaybeQueueAck();
@@ -914,6 +920,12 @@ bool QuicConnection::ShouldLastPacketInstigateAck() const {
if (!last_ack_frames_.empty() && last_ack_frames_.back().is_truncated) {
return true;
}
+ // Always send an ack every 20 packets in order to allow the peer to discard
+ // information from the SentPacketManager and provide an RTT measurement.
+ if (num_packets_received_since_last_ack_sent_ >=
+ kMaxPacketsReceivedBeforeAckSend) {
+ return true;
+ }
return false;
}
@@ -1554,6 +1566,7 @@ void QuicConnection::SendPing() {
void QuicConnection::SendAck() {
ack_alarm_->Cancel();
stop_waiting_count_ = 0;
+ num_packets_received_since_last_ack_sent_ = 0;
bool send_feedback = false;
// Deprecating the Congestion Feedback Frame after QUIC_VERSION_22.
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698