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

Side by Side Diff: net/quic/quic_sent_packet_manager.cc

Issue 306573002: Add an IncreaseLargestObserved to QuicUnackedPacketMap to remove the rtt (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_connection_test.cc ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_sent_packet_manager.h" 5 #include "net/quic/quic_sent_packet_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 new_sequence_number); 119 new_sequence_number);
120 } 120 }
121 121
122 void QuicSentPacketManager::OnIncomingAck( 122 void QuicSentPacketManager::OnIncomingAck(
123 const ReceivedPacketInfo& received_info, 123 const ReceivedPacketInfo& received_info,
124 QuicTime ack_receive_time) { 124 QuicTime ack_receive_time) {
125 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); 125 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight();
126 126
127 // We rely on delta_time_largest_observed to compute an RTT estimate, so 127 // We rely on delta_time_largest_observed to compute an RTT estimate, so
128 // we only update rtt when the largest observed gets acked. 128 // we only update rtt when the largest observed gets acked.
129 largest_observed_ = received_info.largest_observed;
130 bool largest_observed_acked = MaybeUpdateRTT(received_info, ack_receive_time); 129 bool largest_observed_acked = MaybeUpdateRTT(received_info, ack_receive_time);
130 if (largest_observed_ < received_info.largest_observed) {
131 largest_observed_ = received_info.largest_observed;
132 unacked_packets_.IncreaseLargestObserved(largest_observed_);
133 }
131 HandleAckForSentPackets(received_info); 134 HandleAckForSentPackets(received_info);
132 InvokeLossDetection(ack_receive_time); 135 InvokeLossDetection(ack_receive_time);
133 MaybeInvokeCongestionEvent(largest_observed_acked, bytes_in_flight); 136 MaybeInvokeCongestionEvent(largest_observed_acked, bytes_in_flight);
134 137
135 // If we have received a truncated ack, then we need to clear out some 138 // If we have received a truncated ack, then we need to clear out some
136 // previous transmissions to allow the peer to actually ACK new packets. 139 // previous transmissions to allow the peer to actually ACK new packets.
137 if (received_info.is_truncated) { 140 if (received_info.is_truncated) {
138 unacked_packets_.ClearPreviousRetransmissions( 141 unacked_packets_.ClearPreviousRetransmissions(
139 received_info.missing_packets.size() / 2); 142 received_info.missing_packets.size() / 2);
140 } 143 }
(...skipping 27 matching lines...) Expand all
168 received_info.delta_time_largest_observed; 171 received_info.delta_time_largest_observed;
169 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 172 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
170 while (it != unacked_packets_.end()) { 173 while (it != unacked_packets_.end()) {
171 QuicPacketSequenceNumber sequence_number = it->first; 174 QuicPacketSequenceNumber sequence_number = it->first;
172 if (sequence_number > received_info.largest_observed) { 175 if (sequence_number > received_info.largest_observed) {
173 // These packets are still in flight. 176 // These packets are still in flight.
174 break; 177 break;
175 } 178 }
176 179
177 if (IsAwaitingPacket(received_info, sequence_number)) { 180 if (IsAwaitingPacket(received_info, sequence_number)) {
178 // Remove any rtt only packets less than or equal to the largest observed, 181 // Consider it multiple nacks when there is a gap between the missing
179 // since they will not produce an RTT measurement. 182 // packet and the largest observed, since the purpose of a nack
180 if (QuicUnackedPacketMap::IsForRttOnly(it->second)) { 183 // threshold is to tolerate re-ordering. This handles both StretchAcks
181 ++it; 184 // and Forward Acks.
182 unacked_packets_.RemoveRttOnlyPacket(sequence_number); 185 // The nack count only increases when the largest observed increases.
183 } else { 186 size_t min_nacks = received_info.largest_observed - sequence_number;
184 // Consider it multiple nacks when there is a gap between the missing 187 // Truncated acks can nack the largest observed, so use a min of 1.
185 // packet and the largest observed, since the purpose of a nack 188 if (min_nacks == 0) {
186 // threshold is to tolerate re-ordering. This handles both StretchAcks 189 min_nacks = 1;
187 // and Forward Acks.
188 // The nack count only increases when the largest observed increases.
189 size_t min_nacks = received_info.largest_observed - sequence_number;
190 // Truncated acks can nack the largest observed, so use a min of 1.
191 if (min_nacks == 0) {
192 min_nacks = 1;
193 }
194 unacked_packets_.NackPacket(sequence_number, min_nacks);
195 ++it;
196 } 190 }
191 unacked_packets_.NackPacket(sequence_number, min_nacks);
192 ++it;
197 continue; 193 continue;
198 } 194 }
199
200 // Packet was acked, so remove it from our unacked packet list. 195 // Packet was acked, so remove it from our unacked packet list.
201 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number; 196 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number;
202 // If data is associated with the most recent transmission of this 197 // If data is associated with the most recent transmission of this
203 // packet, then inform the caller. 198 // packet, then inform the caller.
204 if (it->second.pending) { 199 if (it->second.pending) {
205 packets_acked_[sequence_number] = it->second; 200 packets_acked_[sequence_number] = it->second;
206 } 201 }
207 it = MarkPacketHandled(it, delta_largest_observed); 202 it = MarkPacketHandled(it, delta_largest_observed);
208 } 203 }
209 204
(...skipping 21 matching lines...) Expand all
231 // numbers with no connection to the previous ones. 226 // numbers with no connection to the previous ones.
232 if (frames != NULL && (retransmission_type == ALL_PACKETS || 227 if (frames != NULL && (retransmission_type == ALL_PACKETS ||
233 frames->encryption_level() == ENCRYPTION_INITIAL)) { 228 frames->encryption_level() == ENCRYPTION_INITIAL)) {
234 MarkForRetransmission(unacked_it->first, ALL_UNACKED_RETRANSMISSION); 229 MarkForRetransmission(unacked_it->first, ALL_UNACKED_RETRANSMISSION);
235 } 230 }
236 ++unacked_it; 231 ++unacked_it;
237 } 232 }
238 } 233 }
239 234
240 void QuicSentPacketManager::NeuterUnencryptedPackets() { 235 void QuicSentPacketManager::NeuterUnencryptedPackets() {
241 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 236 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
242 it != unacked_packets_.end(); ++it) { 237 while (it != unacked_packets_.end()) {
243 const RetransmittableFrames* frames = 238 const RetransmittableFrames* frames =
244 it->second.retransmittable_frames; 239 it->second.retransmittable_frames;
240 QuicPacketSequenceNumber sequence_number = it->first;
241 ++it;
245 if (frames != NULL && frames->encryption_level() == ENCRYPTION_NONE) { 242 if (frames != NULL && frames->encryption_level() == ENCRYPTION_NONE) {
246 // Once you're forward secure, no unencrypted packets will be sent, crypto 243 // Once you're forward secure, no unencrypted packets will be sent, crypto
247 // or otherwise. Unencrypted packets are neutered and abandoned, to ensure 244 // or otherwise. Unencrypted packets are neutered and abandoned, to ensure
248 // they are not retransmitted or considered lost from a congestion control 245 // they are not retransmitted or considered lost from a congestion control
249 // perspective. 246 // perspective.
250 pending_retransmissions_.erase(it->first); 247 pending_retransmissions_.erase(sequence_number);
251 unacked_packets_.RemoveRetransmittability(it->first, largest_observed_); 248 unacked_packets_.SetNotPending(sequence_number);
252 unacked_packets_.SetNotPending(it->first); 249 // RemoveRetransmittibility is safe because only the newest sequence
250 // number can have frames.
251 unacked_packets_.RemoveRetransmittability(sequence_number);
253 } 252 }
254 } 253 }
255 } 254 }
256 255
257 void QuicSentPacketManager::MarkForRetransmission( 256 void QuicSentPacketManager::MarkForRetransmission(
258 QuicPacketSequenceNumber sequence_number, 257 QuicPacketSequenceNumber sequence_number,
259 TransmissionType transmission_type) { 258 TransmissionType transmission_type) {
260 const TransmissionInfo& transmission_info = 259 const TransmissionInfo& transmission_info =
261 unacked_packets_.GetTransmissionInfo(sequence_number); 260 unacked_packets_.GetTransmissionInfo(sequence_number);
262 LOG_IF(DFATAL, transmission_info.retransmittable_frames == NULL); 261 LOG_IF(DFATAL, transmission_info.retransmittable_frames == NULL);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // retransmit it, do not retransmit it anymore. 320 // retransmit it, do not retransmit it anymore.
322 pending_retransmissions_.erase(newest_transmission); 321 pending_retransmissions_.erase(newest_transmission);
323 322
324 // The AckNotifierManager needs to be notified for revived packets, 323 // The AckNotifierManager needs to be notified for revived packets,
325 // since it indicates the packet arrived from the appliction's perspective. 324 // since it indicates the packet arrived from the appliction's perspective.
326 if (transmission_info.retransmittable_frames) { 325 if (transmission_info.retransmittable_frames) {
327 ack_notifier_manager_.OnPacketAcked( 326 ack_notifier_manager_.OnPacketAcked(
328 newest_transmission, delta_largest_observed); 327 newest_transmission, delta_largest_observed);
329 } 328 }
330 329
331 unacked_packets_.RemoveRetransmittability(sequence_number, largest_observed_); 330 unacked_packets_.RemoveRetransmittability(sequence_number);
332 } 331 }
333 332
334 QuicUnackedPacketMap::const_iterator QuicSentPacketManager::MarkPacketHandled( 333 QuicUnackedPacketMap::const_iterator QuicSentPacketManager::MarkPacketHandled(
335 QuicUnackedPacketMap::const_iterator it, 334 QuicUnackedPacketMap::const_iterator it,
336 QuicTime::Delta delta_largest_observed) { 335 QuicTime::Delta delta_largest_observed) {
337 LOG_IF(DFATAL, it == unacked_packets_.end()) 336 LOG_IF(DFATAL, it == unacked_packets_.end())
338 << "MarkPacketHandled must be passed a valid iterator entry."; 337 << "MarkPacketHandled must be passed a valid iterator entry.";
339 const QuicPacketSequenceNumber sequence_number = it->first; 338 const QuicPacketSequenceNumber sequence_number = it->first;
340 const TransmissionInfo& transmission_info = it->second; 339 const TransmissionInfo& transmission_info = it->second;
341 340
(...skipping 18 matching lines...) Expand all
360 359
361 // If it's a crypto handshake packet, discard it and all retransmissions, 360 // If it's a crypto handshake packet, discard it and all retransmissions,
362 // since they won't be acked now that one has been processed. 361 // since they won't be acked now that one has been processed.
363 // TODO(ianswett): Instead of handling all crypto packets in a special way, 362 // TODO(ianswett): Instead of handling all crypto packets in a special way,
364 // only handle NULL encrypted packets in a special way. 363 // only handle NULL encrypted packets in a special way.
365 if (HasCryptoHandshake( 364 if (HasCryptoHandshake(
366 unacked_packets_.GetTransmissionInfo(newest_transmission))) { 365 unacked_packets_.GetTransmissionInfo(newest_transmission))) {
367 unacked_packets_.SetNotPending(newest_transmission); 366 unacked_packets_.SetNotPending(newest_transmission);
368 } 367 }
369 unacked_packets_.SetNotPending(sequence_number); 368 unacked_packets_.SetNotPending(sequence_number);
370 unacked_packets_.RemoveRetransmittability(sequence_number, largest_observed_); 369 unacked_packets_.RemoveRetransmittability(sequence_number);
371 370
372 QuicUnackedPacketMap::const_iterator next_unacked = unacked_packets_.begin(); 371 QuicUnackedPacketMap::const_iterator next_unacked = unacked_packets_.begin();
373 while (next_unacked != unacked_packets_.end() && 372 while (next_unacked != unacked_packets_.end() &&
374 next_unacked->first <= sequence_number) { 373 next_unacked->first <= sequence_number) {
375 ++next_unacked; 374 ++next_unacked;
376 } 375 }
377 return next_unacked; 376 return next_unacked;
378 } 377 }
379 378
380 bool QuicSentPacketManager::IsUnacked( 379 bool QuicSentPacketManager::IsUnacked(
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // retransmission delay. 503 // retransmission delay.
505 504
506 DVLOG(1) << "OnRetransmissionTimeout() fired with " 505 DVLOG(1) << "OnRetransmissionTimeout() fired with "
507 << unacked_packets_.GetNumUnackedPackets() << " unacked packets."; 506 << unacked_packets_.GetNumUnackedPackets() << " unacked packets.";
508 507
509 // Request retransmission of all retransmittable packets when the RTO 508 // Request retransmission of all retransmittable packets when the RTO
510 // fires, and let the congestion manager decide how many to send 509 // fires, and let the congestion manager decide how many to send
511 // immediately and the remaining packets will be queued. 510 // immediately and the remaining packets will be queued.
512 // Abandon any non-retransmittable packets that are sufficiently old. 511 // Abandon any non-retransmittable packets that are sufficiently old.
513 bool packets_retransmitted = false; 512 bool packets_retransmitted = false;
514 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 513 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
515 it != unacked_packets_.end(); ++it) { 514 while (it != unacked_packets_.end()) {
516 if (it->second.retransmittable_frames != NULL) { 515 const RetransmittableFrames* frames =
516 it->second.retransmittable_frames;
517 QuicPacketSequenceNumber sequence_number = it->first;
518 ++it;
519 if (frames != NULL) {
517 packets_retransmitted = true; 520 packets_retransmitted = true;
518 MarkForRetransmission(it->first, RTO_RETRANSMISSION); 521 MarkForRetransmission(sequence_number, RTO_RETRANSMISSION);
519 } else { 522 } else {
520 unacked_packets_.SetNotPending(it->first); 523 unacked_packets_.SetNotPending(sequence_number);
521 } 524 }
522 } 525 }
523 526
524 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted); 527 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted);
525 if (packets_retransmitted) { 528 if (packets_retransmitted) {
526 ++consecutive_rto_count_; 529 ++consecutive_rto_count_;
527 } 530 }
528 } 531 }
529 532
530 QuicSentPacketManager::RetransmissionTimeoutMode 533 QuicSentPacketManager::RetransmissionTimeoutMode
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number; 573 DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number;
571 574
572 if (transmission_info.retransmittable_frames != NULL) { 575 if (transmission_info.retransmittable_frames != NULL) {
573 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION); 576 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION);
574 } else { 577 } else {
575 // Since we will not retransmit this, we need to remove it from 578 // Since we will not retransmit this, we need to remove it from
576 // unacked_packets_. This is either the current transmission of 579 // unacked_packets_. This is either the current transmission of
577 // a packet whose previous transmission has been acked, a packet that has 580 // a packet whose previous transmission has been acked, a packet that has
578 // been TLP retransmitted, or an FEC packet. 581 // been TLP retransmitted, or an FEC packet.
579 unacked_packets_.SetNotPending(sequence_number); 582 unacked_packets_.SetNotPending(sequence_number);
580 if (QuicUnackedPacketMap::IsForRttOnly(transmission_info)) {
581 unacked_packets_.RemoveRttOnlyPacket(sequence_number);
582 }
583 } 583 }
584 } 584 }
585 } 585 }
586 586
587 bool QuicSentPacketManager::MaybeUpdateRTT( 587 bool QuicSentPacketManager::MaybeUpdateRTT(
588 const ReceivedPacketInfo& received_info, 588 const ReceivedPacketInfo& received_info,
589 const QuicTime& ack_receive_time) { 589 const QuicTime& ack_receive_time) {
590 if (!unacked_packets_.IsUnacked(received_info.largest_observed)) { 590 if (!unacked_packets_.IsUnacked(received_info.largest_observed)) {
591 return false; 591 return false;
592 } 592 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 return; 734 return;
735 } 735 }
736 736
737 using_pacing_ = true; 737 using_pacing_ = true;
738 send_algorithm_.reset( 738 send_algorithm_.reset(
739 new PacingSender(send_algorithm_.release(), 739 new PacingSender(send_algorithm_.release(),
740 QuicTime::Delta::FromMicroseconds(1))); 740 QuicTime::Delta::FromMicroseconds(1)));
741 } 741 }
742 742
743 } // namespace net 743 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection_test.cc ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698