diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-15 19:42:24 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-15 19:42:24 +0000 |
commit | 48697d8a33d2b98f7401a3b1e657c86cf3dba981 (patch) | |
tree | 254ea035abc7758a85ec4328d68ae8b7d7a9ea29 /net | |
parent | 018c9908c69c8e5ab04a0f7878da276b27f6fc2d (diff) | |
download | chromium_src-48697d8a33d2b98f7401a3b1e657c86cf3dba981.zip chromium_src-48697d8a33d2b98f7401a3b1e657c86cf3dba981.tar.gz chromium_src-48697d8a33d2b98f7401a3b1e657c86cf3dba981.tar.bz2 |
Largest received -> largest observed.
This fixes a bug in our QUIC ack/nack logic where if we got a truncated ack with large contiguous blocks, we'd likely never resend-due-to-nacks because we used largest_received as an upper bound and it could be lower than all the missing packets.
Merge internal change: 40678081
TBR=jar@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11820005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176955 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/quic/congestion_control/quic_send_scheduler.cc | 4 | ||||
-rw-r--r-- | net/quic/congestion_control/quic_send_scheduler_test.cc | 4 | ||||
-rw-r--r-- | net/quic/quic_connection.cc | 14 | ||||
-rw-r--r-- | net/quic/quic_connection_test.cc | 28 | ||||
-rw-r--r-- | net/quic/quic_framer.cc | 38 | ||||
-rw-r--r-- | net/quic/quic_framer.h | 4 | ||||
-rw-r--r-- | net/quic/quic_framer_test.cc | 76 | ||||
-rw-r--r-- | net/quic/quic_protocol.cc | 24 | ||||
-rw-r--r-- | net/quic/quic_protocol.h | 17 |
9 files changed, 86 insertions, 123 deletions
diff --git a/net/quic/congestion_control/quic_send_scheduler.cc b/net/quic/congestion_control/quic_send_scheduler.cc index 17c4a2f..7b30ee0 100644 --- a/net/quic/congestion_control/quic_send_scheduler.cc +++ b/net/quic/congestion_control/quic_send_scheduler.cc @@ -86,7 +86,7 @@ void QuicSendScheduler::OnIncomingQuicCongestionFeedbackFrame( void QuicSendScheduler::OnIncomingAckFrame(const QuicAckFrame& ack_frame) { // We want to. - // * Get all packets lower(including) than largest_received + // * Get all packets lower(including) than largest_observed // from pending_packets_. // * Remove all missing packets. // * Send each ACK in the list to send_algorithm_. @@ -96,7 +96,7 @@ void QuicSendScheduler::OnIncomingAckFrame(const QuicAckFrame& ack_frame) { PendingPacketsMap::iterator it, it_upper; it = pending_packets_.begin(); it_upper = pending_packets_.upper_bound( - ack_frame.received_info.largest_received); + ack_frame.received_info.largest_observed); while (it != it_upper) { QuicPacketSequenceNumber sequence_number = it->first; diff --git a/net/quic/congestion_control/quic_send_scheduler_test.cc b/net/quic/congestion_control/quic_send_scheduler_test.cc index 0df0d92..f28a6db 100644 --- a/net/quic/congestion_control/quic_send_scheduler_test.cc +++ b/net/quic/congestion_control/quic_send_scheduler_test.cc @@ -46,7 +46,7 @@ TEST_F(QuicSendSchedulerTest, FixedRateSenderAPI) { TEST_F(QuicSendSchedulerTest, FixedRatePacing) { SetUpCongestionType(kFixRate); QuicAckFrame ack; - ack.received_info.largest_received = 0; + ack.received_info.largest_observed = 0; sender_->OnIncomingAckFrame(ack); QuicCongestionFeedbackFrame feedback; @@ -165,7 +165,7 @@ TEST_F(QuicSendSchedulerTest, BandwidthWith3SecondGap) { TEST_F(QuicSendSchedulerTest, Pacing) { SetUpCongestionType(kFixRate); QuicAckFrame ack; - ack.received_info.largest_received = 0; + ack.received_info.largest_observed = 0; sender_->OnIncomingAckFrame(ack); QuicCongestionFeedbackFrame feedback; diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc index 629863d..e937810 100644 --- a/net/quic/quic_connection.cc +++ b/net/quic/quic_connection.cc @@ -92,7 +92,7 @@ QuicConnection::QuicConnection(QuicGuid guid, framer_.set_visitor(this); memset(&last_header_, 0, sizeof(last_header_)); outgoing_ack_.sent_info.least_unacked = 0; - outgoing_ack_.received_info.largest_received = 0; + outgoing_ack_.received_info.largest_observed = 0; /* if (FLAGS_fake_packet_loss_percentage > 0) { @@ -207,10 +207,10 @@ void QuicConnection::OnCongestionFeedbackFrame( } bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { - if (incoming_ack.received_info.largest_received > + if (incoming_ack.received_info.largest_observed > packet_creator_.sequence_number()) { - DLOG(ERROR) << "Client acked unsent packet:" - << incoming_ack.received_info.largest_received << " vs " + DLOG(ERROR) << "Client observed unsent packet:" + << incoming_ack.received_info.largest_observed << " vs " << packet_creator_.sequence_number(); // We got an error for data we have not sent. Error out. return false; @@ -246,10 +246,10 @@ void QuicConnection::UpdatePacketInformationReceivedByPeer( QuicConnectionVisitorInterface::AckedPackets acked_packets; // Initialize the lowest unacked packet to the lower of the next outgoing - // sequence number and the largest received packed in the incoming ack. + // sequence number and the largest observed packet in the incoming ack. QuicPacketSequenceNumber lowest_unacked = min( packet_creator_.sequence_number() + 1, - incoming_ack.received_info.largest_received + 1); + incoming_ack.received_info.largest_observed + 1); int resent_packets = 0; @@ -286,7 +286,7 @@ void QuicConnection::UpdatePacketInformationReceivedByPeer( // Determine if this packet is being explicitly nacked and, if so, if it // is worth resending. QuicPacketSequenceNumber resend_number = 0; - if (it->first < incoming_ack.received_info.largest_received) { + if (it->first < incoming_ack.received_info.largest_observed) { // The peer got packets after this sequence number. This is an explicit // nack. ++(it->second.number_nacks); diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc index a4ce7fe..9bff3ec 100644 --- a/net/quic/quic_connection_test.cc +++ b/net/quic/quic_connection_test.cc @@ -352,73 +352,73 @@ class QuicConnectionTest : public ::testing::Test { TEST_F(QuicConnectionTest, PacketsInOrder) { ProcessPacket(1); - EXPECT_EQ(1u, last_ack()->received_info.largest_received); + EXPECT_EQ(1u, last_ack()->received_info.largest_observed); EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size()); ProcessPacket(2); - EXPECT_EQ(2u, last_ack()->received_info.largest_received); + EXPECT_EQ(2u, last_ack()->received_info.largest_observed); EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size()); ProcessPacket(3); - EXPECT_EQ(3u, last_ack()->received_info.largest_received); + EXPECT_EQ(3u, last_ack()->received_info.largest_observed); EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size()); } TEST_F(QuicConnectionTest, PacketsRejected) { ProcessPacket(1); - EXPECT_EQ(1u, last_ack()->received_info.largest_received); + EXPECT_EQ(1u, last_ack()->received_info.largest_observed); EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size()); accept_packet_ = false; ProcessPacket(2); // We should not have an ack for two. - EXPECT_EQ(1u, last_ack()->received_info.largest_received); + EXPECT_EQ(1u, last_ack()->received_info.largest_observed); EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size()); } TEST_F(QuicConnectionTest, PacketsOutOfOrder) { ProcessPacket(3); - EXPECT_EQ(3u, last_ack()->received_info.largest_received); + EXPECT_EQ(3u, last_ack()->received_info.largest_observed); EXPECT_TRUE(IsMissing(2)); EXPECT_TRUE(IsMissing(1)); ProcessPacket(2); - EXPECT_EQ(3u, last_ack()->received_info.largest_received); + EXPECT_EQ(3u, last_ack()->received_info.largest_observed); EXPECT_FALSE(IsMissing(2)); EXPECT_TRUE(IsMissing(1)); ProcessPacket(1); - EXPECT_EQ(3u, last_ack()->received_info.largest_received); + EXPECT_EQ(3u, last_ack()->received_info.largest_observed); EXPECT_FALSE(IsMissing(2)); EXPECT_FALSE(IsMissing(1)); } TEST_F(QuicConnectionTest, DuplicatePacket) { ProcessPacket(3); - EXPECT_EQ(3u, last_ack()->received_info.largest_received); + EXPECT_EQ(3u, last_ack()->received_info.largest_observed); EXPECT_TRUE(IsMissing(2)); EXPECT_TRUE(IsMissing(1)); // Send packet 3 again, but do not set the expectation that // the visitor OnPacket() will be called. ProcessDataPacket(3, 0); - EXPECT_EQ(3u, last_ack()->received_info.largest_received); + EXPECT_EQ(3u, last_ack()->received_info.largest_observed); EXPECT_TRUE(IsMissing(2)); EXPECT_TRUE(IsMissing(1)); } TEST_F(QuicConnectionTest, PacketsOutOfOrderWithAdditionsAndLeastAwaiting) { ProcessPacket(3); - EXPECT_EQ(3u, last_ack()->received_info.largest_received); + EXPECT_EQ(3u, last_ack()->received_info.largest_observed); EXPECT_TRUE(IsMissing(2)); EXPECT_TRUE(IsMissing(1)); ProcessPacket(2); - EXPECT_EQ(3u, last_ack()->received_info.largest_received); + EXPECT_EQ(3u, last_ack()->received_info.largest_observed); EXPECT_TRUE(IsMissing(1)); ProcessPacket(5); - EXPECT_EQ(5u, last_ack()->received_info.largest_received); + EXPECT_EQ(5u, last_ack()->received_info.largest_observed); EXPECT_TRUE(IsMissing(1)); EXPECT_TRUE(IsMissing(4)); @@ -441,7 +441,7 @@ TEST_F(QuicConnectionTest, RejectPacketTooFarOut) { ProcessDataPacket(6000, 0); SendAckPacketToPeer(); // Packet 2 - EXPECT_EQ(0u, last_ack()->received_info.largest_received); + EXPECT_EQ(0u, last_ack()->received_info.largest_observed); } TEST_F(QuicConnectionTest, TruncatedAck) { diff --git a/net/quic/quic_framer.cc b/net/quic/quic_framer.cc index d60cb70..f5ec5e1 100644 --- a/net/quic/quic_framer.cc +++ b/net/quic/quic_framer.cc @@ -425,8 +425,8 @@ bool QuicFramer::ProcessAckFrame(QuicAckFrame* frame) { } bool QuicFramer::ProcessReceivedInfo(ReceivedPacketInfo* received_info) { - if (!reader_->ReadUInt48(&received_info->largest_received)) { - set_detailed_error("Unable to read largest received."); + if (!reader_->ReadUInt48(&received_info->largest_observed)) { + set_detailed_error("Unable to read largest observed."); return false; } @@ -671,7 +671,7 @@ size_t QuicFramer::ComputeFramePayloadLength(const QuicFrame& frame) { break; // Need to support this eventually :> case ACK_FRAME: { const QuicAckFrame& ack = *frame.ack_frame; - len += 6; // largest received packet sequence number + len += 6; // largest observed packet sequence number len += 1; // num missing packets len += 6 * ack.received_info.missing_packets.size(); len += 6; // least packet sequence number awaiting an ack @@ -753,8 +753,7 @@ bool QuicFramer::AppendStreamFramePayload( return true; } -// TODO(alyssar): revisit the complexity here to rch's satisfaction -QuicPacketSequenceNumber QuicFramer::CalculateLargestReceived( +QuicPacketSequenceNumber QuicFramer::CalculateLargestObserved( const SequenceSet& missing_packets, SequenceSet::const_iterator largest_written) { SequenceSet::const_iterator it = largest_written; @@ -767,21 +766,8 @@ QuicPacketSequenceNumber QuicFramer::CalculateLargestReceived( return *it - 1; } - // If we've hit the end of the list, and we're not missing any packets, try - // finding a gap between the largest written and the beginning of the set. - it = largest_written++; - previous_missing = *it; - do { - --it; - if (previous_missing - 1 != *it) { - return previous_missing - 1; - } - previous_missing = *it; - } while (it != missing_packets.begin()); - - // The missing packets are entirely contiguous. Return the value of the first - // missing packet - 1, as that must have been seen. - return *missing_packets.begin() - 1; + // Otherwise return the largest missing packet, as indirectly observed. + return *largest_written; } // TODO(ianswett): Use varints or another more compact approach for all deltas. @@ -792,8 +778,8 @@ bool QuicFramer::AppendAckFramePayload( return false; } - size_t largest_received_offset = writer->length(); - if (!writer->WriteUInt48(frame.received_info.largest_received)) { + size_t largest_observed_offset = writer->length(); + if (!writer->WriteUInt48(frame.received_info.largest_observed)) { return false; } @@ -809,10 +795,10 @@ bool QuicFramer::AppendAckFramePayload( int num_missing_packets_written = 0; for (; it != frame.received_info.missing_packets.end(); ++it) { if (!writer->WriteUInt48(*it)) { - // We are truncating. Overwrite largest_received. - QuicPacketSequenceNumber largest_received = - CalculateLargestReceived(frame.received_info.missing_packets, --it); - writer->WriteUInt48ToOffset(largest_received, largest_received_offset); + // We are truncating. Overwrite largest_observed. + QuicPacketSequenceNumber largest_observed = + CalculateLargestObserved(frame.received_info.missing_packets, --it); + writer->WriteUInt48ToOffset(largest_observed, largest_observed_offset); writer->WriteUInt8ToOffset(num_missing_packets_written, num_missing_packets_offset); return true; diff --git a/net/quic/quic_framer.h b/net/quic/quic_framer.h index 4cda9dc..f403e14 100644 --- a/net/quic/quic_framer.h +++ b/net/quic/quic_framer.h @@ -95,10 +95,10 @@ class NET_EXPORT_PRIVATE QuicFramer { virtual ~QuicFramer(); - // Calculates the largest received packet to advertise in the case an Ack + // Calculates the largest observed packet to advertise in the case an Ack // Frame was truncated. last_written in this case is the iterator for the // last missing packet which fit in the outgoing ack. - static QuicPacketSequenceNumber CalculateLargestReceived( + static QuicPacketSequenceNumber CalculateLargestObserved( const SequenceSet& missing_packets, SequenceSet::const_iterator last_written); diff --git a/net/quic/quic_framer_test.cc b/net/quic/quic_framer_test.cc index 82fabae..2b8832c 100644 --- a/net/quic/quic_framer_test.cc +++ b/net/quic/quic_framer_test.cc @@ -225,13 +225,11 @@ class QuicFramerTest : public ::testing::Test { EXPECT_EQ(error_code, framer_.error()) << "len: " << len; } - void ValidateTruncatedAck(const QuicAckFrame* ack, int keys) { - for (int i = 1; i < keys; ++i) { + void ValidateTruncatedAck(const QuicAckFrame* ack, size_t keys) { + for (size_t i = 1; i < keys; ++i) { EXPECT_TRUE(ContainsKey(ack->received_info.missing_packets, i)) << i; } - // With no gaps in the missing packets, we can't admit to having received - // anything. - EXPECT_EQ(0u, ack->received_info.largest_received); + EXPECT_EQ(keys, ack->received_info.largest_observed); } test::TestEncrypter* encrypter_; @@ -559,7 +557,7 @@ TEST_F(QuicFramerTest, AckFrame) { // least packet sequence number awaiting an ack 0xA0, 0x9A, 0x78, 0x56, 0x34, 0x12, - // largest received packet sequence number + // largest observed packet sequence number 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, // num missing packets @@ -579,7 +577,7 @@ TEST_F(QuicFramerTest, AckFrame) { EXPECT_EQ(0u, visitor_.stream_frames_.size()); ASSERT_EQ(1u, visitor_.ack_frames_.size()); const QuicAckFrame& frame = *visitor_.ack_frames_[0]; - EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame.received_info.largest_received); + EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame.received_info.largest_observed); ASSERT_EQ(1u, frame.received_info.missing_packets.size()); SequenceSet::const_iterator missing_iter = frame.received_info.missing_packets.begin(); @@ -596,7 +594,7 @@ TEST_F(QuicFramerTest, AckFrame) { } else if (i < 8) { expected_error = "Unable to read least unacked."; } else if (i < 14) { - expected_error = "Unable to read largest received."; + expected_error = "Unable to read largest observed."; } else if (i < 15) { expected_error = "Unable to read num missing packets."; } else if (i < 21) { @@ -946,7 +944,7 @@ TEST_F(QuicFramerTest, ConnectionCloseFrame) { // least packet sequence number awaiting an ack 0xA0, 0x9A, 0x78, 0x56, 0x34, 0x12, - // largest received packet sequence number + // largest observed packet sequence number 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, // num missing packets @@ -978,7 +976,7 @@ TEST_F(QuicFramerTest, ConnectionCloseFrame) { ASSERT_EQ(1u, visitor_.ack_frames_.size()); const QuicAckFrame& frame = *visitor_.ack_frames_[0]; - EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame.received_info.largest_received); + EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame.received_info.largest_observed); ASSERT_EQ(1u, frame.received_info.missing_packets.size()); SequenceSet::const_iterator missing_iter = frame.received_info.missing_packets.begin(); @@ -1100,7 +1098,7 @@ TEST_F(QuicFramerTest, ConstructAckFramePacket) { header.fec_group = 0; QuicAckFrame ack_frame; - ack_frame.received_info.largest_received = GG_UINT64_C(0x0123456789ABF); + ack_frame.received_info.largest_observed = GG_UINT64_C(0x0123456789ABF); ack_frame.received_info.missing_packets.insert(GG_UINT64_C(0x0123456789ABE)); ack_frame.sent_info.least_unacked = GG_UINT64_C(0x0123456789AA0); @@ -1126,7 +1124,7 @@ TEST_F(QuicFramerTest, ConstructAckFramePacket) { // least packet sequence number awaiting an ack 0xA0, 0x9A, 0x78, 0x56, 0x34, 0x12, - // largest received packet sequence number + // largest observed packet sequence number 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, // num missing packets @@ -1389,7 +1387,7 @@ TEST_F(QuicFramerTest, ConstructCloseFramePacket) { close_frame.error_details = "because I can"; QuicAckFrame* ack_frame = &close_frame.ack_frame; - ack_frame->received_info.largest_received = GG_UINT64_C(0x0123456789ABF); + ack_frame->received_info.largest_observed = GG_UINT64_C(0x0123456789ABF); ack_frame->received_info.missing_packets.insert(GG_UINT64_C(0x0123456789ABE)); ack_frame->sent_info.least_unacked = GG_UINT64_C(0x0123456789AA0); @@ -1426,7 +1424,7 @@ TEST_F(QuicFramerTest, ConstructCloseFramePacket) { // least packet sequence number awaiting an ack 0xA0, 0x9A, 0x78, 0x56, 0x34, 0x12, - // largest received packet sequence number + // largest observed packet sequence number 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, // num missing packets @@ -1523,45 +1521,17 @@ TEST_F(QuicFramerTest, DISABLED_CalculateLargestReceived) { missing.insert(1); missing.insert(5); missing.insert(7); - missing.insert(8); - missing.insert(9); // These two we just walk to the next gap, and return the largest seen. - EXPECT_EQ(4u, QuicFramer::CalculateLargestReceived(missing, missing.find(1))); - EXPECT_EQ(6u, QuicFramer::CalculateLargestReceived(missing, missing.find(5))); + EXPECT_EQ(4u, QuicFramer::CalculateLargestObserved(missing, missing.find(1))); + EXPECT_EQ(6u, QuicFramer::CalculateLargestObserved(missing, missing.find(5))); missing.insert(2); - // For 1, we can't go forward as 2 would be implicitly acked. We must go - // backwards. - EXPECT_EQ(0u, QuicFramer::CalculateLargestReceived(missing, missing.find(1))); - // For 2, we've seen 3 and 4, so can admit to a largest received. - EXPECT_EQ(4u, QuicFramer::CalculateLargestReceived(missing, missing.find(2))); - - // 7+ are fun because there is no subsequent gap: we have to walk before - // them to find 6. - EXPECT_EQ(6u, QuicFramer::CalculateLargestReceived(missing, missing.find(7))); - EXPECT_EQ(6u, QuicFramer::CalculateLargestReceived(missing, missing.find(8))); - EXPECT_EQ(6u, QuicFramer::CalculateLargestReceived(missing, missing.find(9))); - - // Fill in the gap of 6 to make sure we handle a gap of more than 1 by - // returning 4 rather than 3. - missing.insert(6); - EXPECT_EQ(4u, QuicFramer::CalculateLargestReceived(missing, missing.find(9))); - - // Fill in the rest of the gaps: we should walk to 1 and return 0. - missing.insert(4); - missing.insert(3); - missing.insert(2); - EXPECT_EQ(0u, QuicFramer::CalculateLargestReceived(missing, missing.find(7))); - - // If we add a gap after 7-9, we will return that only for 9. - missing.insert(11); - EXPECT_EQ(0u, QuicFramer::CalculateLargestReceived(missing, - missing.find(7))); - EXPECT_EQ(0u, QuicFramer::CalculateLargestReceived(missing, - missing.find(8))); - EXPECT_EQ(10u, QuicFramer::CalculateLargestReceived(missing, - missing.find(9))); + // For 1, we can't go forward as 2 would be implicitly acked so we return the + // largest missing packet. + EXPECT_EQ(1u, QuicFramer::CalculateLargestObserved(missing, missing.find(1))); + // For 2, we've seen 3 and 4, so can admit to a largest observed. + EXPECT_EQ(4u, QuicFramer::CalculateLargestObserved(missing, missing.find(2))); } TEST_F(QuicFramerTest, Truncation) { @@ -1575,8 +1545,8 @@ TEST_F(QuicFramerTest, Truncation) { QuicAckFrame* ack_frame = &close_frame.ack_frame; close_frame.error_code = static_cast<QuicErrorCode>(0x05060708); close_frame.error_details = "because I can"; - ack_frame->received_info.largest_received = 201; - for (uint64 i = 1; i < ack_frame->received_info.largest_received; ++i) { + ack_frame->received_info.largest_observed = 201; + for (uint64 i = 1; i < ack_frame->received_info.largest_observed; ++i) { ack_frame->received_info.missing_packets.insert(i); } @@ -1622,8 +1592,8 @@ TEST_F(QuicFramerTest, Truncation) { EXPECT_EQ(0x05060708, visitor_.connection_close_frame_.error_code); EXPECT_EQ("because I can", visitor_.connection_close_frame_.error_details); - ValidateTruncatedAck(visitor_.ack_frames_[0], 190); - ValidateTruncatedAck(&visitor_.connection_close_frame_.ack_frame, 180); + ValidateTruncatedAck(visitor_.ack_frames_[0], 194); + ValidateTruncatedAck(&visitor_.connection_close_frame_.ack_frame, 191); } } // namespace test diff --git a/net/quic/quic_protocol.cc b/net/quic/quic_protocol.cc index 24b8416..6ba5468 100644 --- a/net/quic/quic_protocol.cc +++ b/net/quic/quic_protocol.cc @@ -24,25 +24,25 @@ QuicStreamFrame::QuicStreamFrame(QuicStreamId stream_id, data(data) { } -// TODO(ianswett): Initializing largest_received to 0 should not be necessary. -ReceivedPacketInfo::ReceivedPacketInfo() : largest_received(0) {} +// TODO(ianswett): Initializing largest_observed to 0 should not be necessary. +ReceivedPacketInfo::ReceivedPacketInfo() : largest_observed(0) {} ReceivedPacketInfo::~ReceivedPacketInfo() {} void ReceivedPacketInfo::RecordReceived( QuicPacketSequenceNumber sequence_number) { DCHECK(IsAwaitingPacket(sequence_number)); - if (largest_received < sequence_number) { - DCHECK_LT(sequence_number - largest_received, + if (largest_observed < sequence_number) { + DCHECK_LT(sequence_number - largest_observed, numeric_limits<uint16>::max()); // We've got a new high sequence number. Note any new intermediate missing // packets, and update the last_ack data. - for (QuicPacketSequenceNumber i = largest_received + 1; + for (QuicPacketSequenceNumber i = largest_observed + 1; i < sequence_number; ++i) { DVLOG(1) << "missing " << i; missing_packets.insert(i); } - largest_received = sequence_number; + largest_observed = sequence_number; } else { // We've gotten one of the out of order packets - remove it from our // "missing packets" list. @@ -53,7 +53,7 @@ void ReceivedPacketInfo::RecordReceived( bool ReceivedPacketInfo::IsAwaitingPacket( QuicPacketSequenceNumber sequence_number) const { - return sequence_number > largest_received || + return sequence_number > largest_observed || ContainsKey(missing_packets, sequence_number); } @@ -68,13 +68,13 @@ SentPacketInfo::SentPacketInfo() {} SentPacketInfo::~SentPacketInfo() {} // Testing convenience method. -QuicAckFrame::QuicAckFrame(QuicPacketSequenceNumber largest_received, +QuicAckFrame::QuicAckFrame(QuicPacketSequenceNumber largest_observed, QuicPacketSequenceNumber least_unacked) { for (QuicPacketSequenceNumber seq_num = 1; - seq_num <= largest_received; ++seq_num) { + seq_num <= largest_observed; ++seq_num) { received_info.RecordReceived(seq_num); } - received_info.largest_received = largest_received; + received_info.largest_observed = largest_observed; sent_info.least_unacked = least_unacked; } @@ -84,8 +84,8 @@ ostream& operator<<(ostream& os, const SentPacketInfo& sent_info) { } ostream& operator<<(ostream& os, const ReceivedPacketInfo& received_info) { - os << "largest_received: " - << received_info.largest_received + os << "largest_observed: " + << received_info.largest_observed << " missing_packets: [ "; for (SequenceSet::const_iterator it = received_info.missing_packets.begin(); it != received_info.missing_packets.end(); ++it) { diff --git a/net/quic/quic_protocol.h b/net/quic/quic_protocol.h index 04fbd91..45d63a2 100644 --- a/net/quic/quic_protocol.h +++ b/net/quic/quic_protocol.h @@ -198,7 +198,7 @@ struct NET_EXPORT_PRIVATE ReceivedPacketInfo { // Records a packet receipt. void RecordReceived(QuicPacketSequenceNumber sequence_number); - // True if the sequence number is greater than largest_received or is listed + // True if the sequence number is greater than largest_observed or is listed // as missing. // Always returns false for sequence numbers less than least_unacked. bool IsAwaitingPacket(QuicPacketSequenceNumber sequence_number) const; @@ -206,8 +206,15 @@ struct NET_EXPORT_PRIVATE ReceivedPacketInfo { // Clears all missing packets less than |least_unacked|. void ClearMissingBefore(QuicPacketSequenceNumber least_unacked); - // The highest packet sequence number we've received from the peer. - QuicPacketSequenceNumber largest_received; + // The highest packet sequence number we've observed from the peer. + // + // In general, this should be the largest packet number we've received. In + // the case of truncated acks, we may have to advertise a lower "upper bound" + // than largest received, to avoid implicitly acking missing packets that + // don't fit in the missing packet list due to size limitations. In this + // case, largest_observed may be a packet which is also in the missing packets + // list. + QuicPacketSequenceNumber largest_observed; // The set of packets which we're expecting and have not received. SequenceSet missing_packets; @@ -226,8 +233,8 @@ struct NET_EXPORT_PRIVATE SentPacketInfo { struct NET_EXPORT_PRIVATE QuicAckFrame { QuicAckFrame() {} // Testing convenience method to construct a QuicAckFrame with all packets - // from least_unacked to largest_received acked. - QuicAckFrame(QuicPacketSequenceNumber largest_received, + // from least_unacked to largest_observed acked. + QuicAckFrame(QuicPacketSequenceNumber largest_observed, QuicPacketSequenceNumber least_unacked); NET_EXPORT_PRIVATE friend std::ostream& operator<<( |