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

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

Issue 302783003: Rename QUIC's TransmissionInfo pending to in_flight and the associated (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_protocol.cc ('k') | net/quic/quic_unacked_packet_map.h » ('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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 min_nacks = 1; 189 min_nacks = 1;
190 } 190 }
191 unacked_packets_.NackPacket(sequence_number, min_nacks); 191 unacked_packets_.NackPacket(sequence_number, min_nacks);
192 ++it; 192 ++it;
193 continue; 193 continue;
194 } 194 }
195 // Packet was acked, so remove it from our unacked packet list. 195 // Packet was acked, so remove it from our unacked packet list.
196 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number; 196 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number;
197 // If data is associated with the most recent transmission of this 197 // If data is associated with the most recent transmission of this
198 // packet, then inform the caller. 198 // packet, then inform the caller.
199 if (it->second.pending) { 199 if (it->second.in_flight) {
200 packets_acked_[sequence_number] = it->second; 200 packets_acked_[sequence_number] = it->second;
201 } 201 }
202 it = MarkPacketHandled(it, delta_largest_observed); 202 it = MarkPacketHandled(it, delta_largest_observed);
203 } 203 }
204 204
205 // Discard any retransmittable frames associated with revived packets. 205 // Discard any retransmittable frames associated with revived packets.
206 for (SequenceNumberSet::const_iterator revived_it = 206 for (SequenceNumberSet::const_iterator revived_it =
207 received_info.revived_packets.begin(); 207 received_info.revived_packets.begin();
208 revived_it != received_info.revived_packets.end(); ++revived_it) { 208 revived_it != received_info.revived_packets.end(); ++revived_it) {
209 MarkPacketRevived(*revived_it, delta_largest_observed); 209 MarkPacketRevived(*revived_it, delta_largest_observed);
210 } 210 }
211 } 211 }
212 212
213 bool QuicSentPacketManager::HasRetransmittableFrames( 213 bool QuicSentPacketManager::HasRetransmittableFrames(
214 QuicPacketSequenceNumber sequence_number) const { 214 QuicPacketSequenceNumber sequence_number) const {
215 return unacked_packets_.HasRetransmittableFrames(sequence_number); 215 return unacked_packets_.HasRetransmittableFrames(sequence_number);
216 } 216 }
217 217
218 void QuicSentPacketManager::RetransmitUnackedPackets( 218 void QuicSentPacketManager::RetransmitUnackedPackets(
219 RetransmissionType retransmission_type) { 219 RetransmissionType retransmission_type) {
220 QuicUnackedPacketMap::const_iterator unacked_it = unacked_packets_.begin(); 220 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
221 while (unacked_it != unacked_packets_.end()) { 221 while (it != unacked_packets_.end()) {
222 const RetransmittableFrames* frames = 222 const RetransmittableFrames* frames = it->second.retransmittable_frames;
223 unacked_it->second.retransmittable_frames;
224 // TODO(ianswett): Consider adding a new retransmission type which removes 223 // TODO(ianswett): Consider adding a new retransmission type which removes
225 // all these old packets from unacked and retransmits them as new sequence 224 // all these old packets from unacked and retransmits them as new sequence
226 // numbers with no connection to the previous ones. 225 // numbers with no connection to the previous ones.
227 if (frames != NULL && (retransmission_type == ALL_PACKETS || 226 if (frames != NULL && (retransmission_type == ALL_PACKETS ||
228 frames->encryption_level() == ENCRYPTION_INITIAL)) { 227 frames->encryption_level() == ENCRYPTION_INITIAL)) {
229 MarkForRetransmission(unacked_it->first, ALL_UNACKED_RETRANSMISSION); 228 MarkForRetransmission(it->first, ALL_UNACKED_RETRANSMISSION);
230 } 229 }
231 ++unacked_it; 230 ++it;
232 } 231 }
233 } 232 }
234 233
235 void QuicSentPacketManager::NeuterUnencryptedPackets() { 234 void QuicSentPacketManager::NeuterUnencryptedPackets() {
236 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 235 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
237 while (it != unacked_packets_.end()) { 236 while (it != unacked_packets_.end()) {
238 const RetransmittableFrames* frames = 237 const RetransmittableFrames* frames = it->second.retransmittable_frames;
239 it->second.retransmittable_frames;
240 QuicPacketSequenceNumber sequence_number = it->first; 238 QuicPacketSequenceNumber sequence_number = it->first;
241 ++it; 239 ++it;
242 if (frames != NULL && frames->encryption_level() == ENCRYPTION_NONE) { 240 if (frames != NULL && frames->encryption_level() == ENCRYPTION_NONE) {
243 // Once you're forward secure, no unencrypted packets will be sent, crypto 241 // Once you're forward secure, no unencrypted packets will be sent, crypto
244 // or otherwise. Unencrypted packets are neutered and abandoned, to ensure 242 // or otherwise. Unencrypted packets are neutered and abandoned, to ensure
245 // they are not retransmitted or considered lost from a congestion control 243 // they are not retransmitted or considered lost from a congestion control
246 // perspective. 244 // perspective.
247 pending_retransmissions_.erase(sequence_number); 245 pending_retransmissions_.erase(sequence_number);
248 unacked_packets_.SetNotPending(sequence_number); 246 unacked_packets_.RemoveFromInFlight(sequence_number);
249 // RemoveRetransmittibility is safe because only the newest sequence 247 // RemoveRetransmittibility is safe because only the newest sequence
250 // number can have frames. 248 // number can have frames.
251 unacked_packets_.RemoveRetransmittability(sequence_number); 249 unacked_packets_.RemoveRetransmittability(sequence_number);
252 } 250 }
253 } 251 }
254 } 252 }
255 253
256 void QuicSentPacketManager::MarkForRetransmission( 254 void QuicSentPacketManager::MarkForRetransmission(
257 QuicPacketSequenceNumber sequence_number, 255 QuicPacketSequenceNumber sequence_number,
258 TransmissionType transmission_type) { 256 TransmissionType transmission_type) {
259 const TransmissionInfo& transmission_info = 257 const TransmissionInfo& transmission_info =
260 unacked_packets_.GetTransmissionInfo(sequence_number); 258 unacked_packets_.GetTransmissionInfo(sequence_number);
261 LOG_IF(DFATAL, transmission_info.retransmittable_frames == NULL); 259 LOG_IF(DFATAL, transmission_info.retransmittable_frames == NULL);
262 if (transmission_type != TLP_RETRANSMISSION) { 260 if (transmission_type != TLP_RETRANSMISSION) {
263 unacked_packets_.SetNotPending(sequence_number); 261 unacked_packets_.RemoveFromInFlight(sequence_number);
264 } 262 }
265 // TODO(ianswett): Currently the RTO can fire while there are pending NACK 263 // TODO(ianswett): Currently the RTO can fire while there are pending NACK
266 // retransmissions for the same data, which is not ideal. 264 // retransmissions for the same data, which is not ideal.
267 if (ContainsKey(pending_retransmissions_, sequence_number)) { 265 if (ContainsKey(pending_retransmissions_, sequence_number)) {
268 return; 266 return;
269 } 267 }
270 268
271 pending_retransmissions_[sequence_number] = transmission_type; 269 pending_retransmissions_[sequence_number] = transmission_type;
272 } 270 }
273 271
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 // transmission, since that's the one only one it tracks. 354 // transmission, since that's the one only one it tracks.
357 ack_notifier_manager_.OnPacketAcked(newest_transmission, 355 ack_notifier_manager_.OnPacketAcked(newest_transmission,
358 delta_largest_observed); 356 delta_largest_observed);
359 357
360 // If it's a crypto handshake packet, discard it and all retransmissions, 358 // If it's a crypto handshake packet, discard it and all retransmissions,
361 // since they won't be acked now that one has been processed. 359 // since they won't be acked now that one has been processed.
362 // TODO(ianswett): Instead of handling all crypto packets in a special way, 360 // TODO(ianswett): Instead of handling all crypto packets in a special way,
363 // only handle NULL encrypted packets in a special way. 361 // only handle NULL encrypted packets in a special way.
364 if (HasCryptoHandshake( 362 if (HasCryptoHandshake(
365 unacked_packets_.GetTransmissionInfo(newest_transmission))) { 363 unacked_packets_.GetTransmissionInfo(newest_transmission))) {
366 unacked_packets_.SetNotPending(newest_transmission); 364 unacked_packets_.RemoveFromInFlight(newest_transmission);
367 } 365 }
368 unacked_packets_.SetNotPending(sequence_number); 366 unacked_packets_.RemoveFromInFlight(sequence_number);
369 unacked_packets_.RemoveRetransmittability(sequence_number); 367 unacked_packets_.RemoveRetransmittability(sequence_number);
370 368
371 QuicUnackedPacketMap::const_iterator next_unacked = unacked_packets_.begin(); 369 QuicUnackedPacketMap::const_iterator next_unacked = unacked_packets_.begin();
372 while (next_unacked != unacked_packets_.end() && 370 while (next_unacked != unacked_packets_.end() &&
373 next_unacked->first <= sequence_number) { 371 next_unacked->first <= sequence_number) {
374 ++next_unacked; 372 ++next_unacked;
375 } 373 }
376 return next_unacked; 374 return next_unacked;
377 } 375 }
378 376
(...skipping 26 matching lines...) Expand all
405 } 403 }
406 404
407 if (unacked_packets_.bytes_in_flight() == 0) { 405 if (unacked_packets_.bytes_in_flight() == 0) {
408 // TODO(ianswett): Consider being less aggressive to force a new 406 // TODO(ianswett): Consider being less aggressive to force a new
409 // recent_min_rtt, likely by not discarding a relatively new sample. 407 // recent_min_rtt, likely by not discarding a relatively new sample.
410 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" 408 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:"
411 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms"; 409 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms";
412 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence); 410 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence);
413 } 411 }
414 412
415 // Only track packets as pending that the send algorithm wants us to track. 413 // Only track packets as in flight that the send algorithm wants us to track.
416 const bool pending = 414 const bool in_flight =
417 send_algorithm_->OnPacketSent(sent_time, 415 send_algorithm_->OnPacketSent(sent_time,
418 unacked_packets_.bytes_in_flight(), 416 unacked_packets_.bytes_in_flight(),
419 sequence_number, 417 sequence_number,
420 bytes, 418 bytes,
421 has_retransmittable_data); 419 has_retransmittable_data);
422 unacked_packets_.SetSent(sequence_number, sent_time, bytes, pending); 420 unacked_packets_.SetSent(sequence_number, sent_time, bytes, in_flight);
423 421
424 // Reset the retransmission timer anytime a pending packet is sent. 422 // Reset the retransmission timer anytime a pending packet is sent.
425 return pending; 423 return in_flight;
426 } 424 }
427 425
428 void QuicSentPacketManager::OnRetransmissionTimeout() { 426 void QuicSentPacketManager::OnRetransmissionTimeout() {
429 DCHECK(unacked_packets_.HasPendingPackets()); 427 DCHECK(unacked_packets_.HasInFlightPackets());
430 // Handshake retransmission, timer based loss detection, TLP, and RTO are 428 // Handshake retransmission, timer based loss detection, TLP, and RTO are
431 // implemented with a single alarm. The handshake alarm is set when the 429 // implemented with a single alarm. The handshake alarm is set when the
432 // handshake has not completed, the loss alarm is set when the loss detection 430 // handshake has not completed, the loss alarm is set when the loss detection
433 // algorithm says to, and the TLP and RTO alarms are set after that. 431 // algorithm says to, and the TLP and RTO alarms are set after that.
434 // The TLP alarm is always set to run for under an RTO. 432 // The TLP alarm is always set to run for under an RTO.
435 switch (GetRetransmissionMode()) { 433 switch (GetRetransmissionMode()) {
436 case HANDSHAKE_MODE: 434 case HANDSHAKE_MODE:
437 ++stats_->crypto_retransmit_count; 435 ++stats_->crypto_retransmit_count;
438 RetransmitCryptoPackets(); 436 RetransmitCryptoPackets();
439 return; 437 return;
(...skipping 21 matching lines...) Expand all
461 DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode()); 459 DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode());
462 // TODO(ianswett): Typical TCP implementations only retransmit 5 times. 460 // TODO(ianswett): Typical TCP implementations only retransmit 5 times.
463 consecutive_crypto_retransmission_count_ = 461 consecutive_crypto_retransmission_count_ =
464 min(kMaxHandshakeRetransmissionBackoffs, 462 min(kMaxHandshakeRetransmissionBackoffs,
465 consecutive_crypto_retransmission_count_ + 1); 463 consecutive_crypto_retransmission_count_ + 1);
466 bool packet_retransmitted = false; 464 bool packet_retransmitted = false;
467 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 465 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
468 it != unacked_packets_.end(); ++it) { 466 it != unacked_packets_.end(); ++it) {
469 QuicPacketSequenceNumber sequence_number = it->first; 467 QuicPacketSequenceNumber sequence_number = it->first;
470 const RetransmittableFrames* frames = it->second.retransmittable_frames; 468 const RetransmittableFrames* frames = it->second.retransmittable_frames;
471 // Only retransmit frames which are pending, and therefore have been sent. 469 // Only retransmit frames which are in flight, and therefore have been sent.
472 if (!it->second.pending || frames == NULL || 470 if (!it->second.in_flight || frames == NULL ||
473 frames->HasCryptoHandshake() != IS_HANDSHAKE) { 471 frames->HasCryptoHandshake() != IS_HANDSHAKE) {
474 continue; 472 continue;
475 } 473 }
476 packet_retransmitted = true; 474 packet_retransmitted = true;
477 MarkForRetransmission(sequence_number, HANDSHAKE_RETRANSMISSION); 475 MarkForRetransmission(sequence_number, HANDSHAKE_RETRANSMISSION);
478 } 476 }
479 DCHECK(packet_retransmitted) << "No crypto packets found to retransmit."; 477 DCHECK(packet_retransmitted) << "No crypto packets found to retransmit.";
480 } 478 }
481 479
482 void QuicSentPacketManager::RetransmitOldestPacket() { 480 void QuicSentPacketManager::RetransmitOldestPacket() {
483 DCHECK_EQ(TLP_MODE, GetRetransmissionMode()); 481 DCHECK_EQ(TLP_MODE, GetRetransmissionMode());
484 ++consecutive_tlp_count_; 482 ++consecutive_tlp_count_;
485 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 483 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
486 it != unacked_packets_.end(); ++it) { 484 it != unacked_packets_.end(); ++it) {
487 QuicPacketSequenceNumber sequence_number = it->first; 485 QuicPacketSequenceNumber sequence_number = it->first;
488 const RetransmittableFrames* frames = it->second.retransmittable_frames; 486 const RetransmittableFrames* frames = it->second.retransmittable_frames;
489 // Only retransmit frames which are pending, and therefore have been sent. 487 // Only retransmit frames which are in flight, and therefore have been sent.
490 if (!it->second.pending || frames == NULL) { 488 if (!it->second.in_flight || frames == NULL) {
491 continue; 489 continue;
492 } 490 }
493 DCHECK_NE(IS_HANDSHAKE, frames->HasCryptoHandshake()); 491 DCHECK_NE(IS_HANDSHAKE, frames->HasCryptoHandshake());
494 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); 492 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION);
495 return; 493 return;
496 } 494 }
497 DLOG(FATAL) 495 DLOG(FATAL)
498 << "No retransmittable packets, so RetransmitOldestPacket failed."; 496 << "No retransmittable packets, so RetransmitOldestPacket failed.";
499 } 497 }
500 498
501 void QuicSentPacketManager::RetransmitAllPackets() { 499 void QuicSentPacketManager::RetransmitAllPackets() {
502 // Abandon all retransmittable packets and packets older than the 500 // Abandon all retransmittable packets and packets older than the
503 // retransmission delay. 501 // retransmission delay.
504 502
505 DVLOG(1) << "OnRetransmissionTimeout() fired with " 503 DVLOG(1) << "OnRetransmissionTimeout() fired with "
506 << unacked_packets_.GetNumUnackedPackets() << " unacked packets."; 504 << unacked_packets_.GetNumUnackedPackets() << " unacked packets.";
507 505
508 // Request retransmission of all retransmittable packets when the RTO 506 // Request retransmission of all retransmittable packets when the RTO
509 // fires, and let the congestion manager decide how many to send 507 // fires, and let the congestion manager decide how many to send
510 // immediately and the remaining packets will be queued. 508 // immediately and the remaining packets will be queued.
511 // Abandon any non-retransmittable packets that are sufficiently old. 509 // Abandon any non-retransmittable packets that are sufficiently old.
512 bool packets_retransmitted = false; 510 bool packets_retransmitted = false;
513 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 511 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
514 while (it != unacked_packets_.end()) { 512 while (it != unacked_packets_.end()) {
515 const RetransmittableFrames* frames = 513 const RetransmittableFrames* frames = it->second.retransmittable_frames;
516 it->second.retransmittable_frames;
517 QuicPacketSequenceNumber sequence_number = it->first; 514 QuicPacketSequenceNumber sequence_number = it->first;
518 ++it; 515 ++it;
519 if (frames != NULL) { 516 if (frames != NULL) {
520 packets_retransmitted = true; 517 packets_retransmitted = true;
521 MarkForRetransmission(sequence_number, RTO_RETRANSMISSION); 518 MarkForRetransmission(sequence_number, RTO_RETRANSMISSION);
522 } else { 519 } else {
523 unacked_packets_.SetNotPending(sequence_number); 520 unacked_packets_.RemoveFromInFlight(sequence_number);
524 } 521 }
525 } 522 }
526 523
527 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted); 524 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted);
528 if (packets_retransmitted) { 525 if (packets_retransmitted) {
529 ++consecutive_rto_count_; 526 ++consecutive_rto_count_;
530 } 527 }
531 } 528 }
532 529
533 QuicSentPacketManager::RetransmissionTimeoutMode 530 QuicSentPacketManager::RetransmissionTimeoutMode
534 QuicSentPacketManager::GetRetransmissionMode() const { 531 QuicSentPacketManager::GetRetransmissionMode() const {
535 DCHECK(unacked_packets_.HasPendingPackets()); 532 DCHECK(unacked_packets_.HasInFlightPackets());
536 if (unacked_packets_.HasPendingCryptoPackets()) { 533 if (unacked_packets_.HasPendingCryptoPackets()) {
537 return HANDSHAKE_MODE; 534 return HANDSHAKE_MODE;
538 } 535 }
539 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) { 536 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) {
540 return LOSS_MODE; 537 return LOSS_MODE;
541 } 538 }
542 if (consecutive_tlp_count_ < max_tail_loss_probes_) { 539 if (consecutive_tlp_count_ < max_tail_loss_probes_) {
543 if (unacked_packets_.HasUnackedRetransmittableFrames()) { 540 if (unacked_packets_.HasUnackedRetransmittableFrames()) {
544 return TLP_MODE; 541 return TLP_MODE;
545 } 542 }
(...skipping 26 matching lines...) Expand all
572 packets_lost_[sequence_number] = transmission_info; 569 packets_lost_[sequence_number] = transmission_info;
573 DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number; 570 DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number;
574 571
575 if (transmission_info.retransmittable_frames != NULL) { 572 if (transmission_info.retransmittable_frames != NULL) {
576 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION); 573 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION);
577 } else { 574 } else {
578 // Since we will not retransmit this, we need to remove it from 575 // Since we will not retransmit this, we need to remove it from
579 // unacked_packets_. This is either the current transmission of 576 // unacked_packets_. This is either the current transmission of
580 // a packet whose previous transmission has been acked, a packet that has 577 // a packet whose previous transmission has been acked, a packet that has
581 // been TLP retransmitted, or an FEC packet. 578 // been TLP retransmitted, or an FEC packet.
582 unacked_packets_.SetNotPending(sequence_number); 579 unacked_packets_.RemoveFromInFlight(sequence_number);
583 } 580 }
584 } 581 }
585 } 582 }
586 583
587 bool QuicSentPacketManager::MaybeUpdateRTT( 584 bool QuicSentPacketManager::MaybeUpdateRTT(
588 const ReceivedPacketInfo& received_info, 585 const ReceivedPacketInfo& received_info,
589 const QuicTime& ack_receive_time) { 586 const QuicTime& ack_receive_time) {
590 if (!unacked_packets_.IsUnacked(received_info.largest_observed)) { 587 if (!unacked_packets_.IsUnacked(received_info.largest_observed)) {
591 return false; 588 return false;
592 } 589 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 // There may be a value in making this delay adaptive with the help of 626 // There may be a value in making this delay adaptive with the help of
630 // the sender and a signaling mechanism -- if the sender uses a 627 // the sender and a signaling mechanism -- if the sender uses a
631 // different MinRTO, we may get spurious retransmissions. May not have 628 // different MinRTO, we may get spurious retransmissions. May not have
632 // any benefits, but if the delayed ack becomes a significant source 629 // any benefits, but if the delayed ack becomes a significant source
633 // of (likely, tail) latency, then consider such a mechanism. 630 // of (likely, tail) latency, then consider such a mechanism.
634 const QuicTime::Delta QuicSentPacketManager::DelayedAckTime() const { 631 const QuicTime::Delta QuicSentPacketManager::DelayedAckTime() const {
635 return QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs/2); 632 return QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs/2);
636 } 633 }
637 634
638 const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { 635 const QuicTime QuicSentPacketManager::GetRetransmissionTime() const {
639 // Don't set the timer if there are no pending packets. 636 // Don't set the timer if there are no packets in flight.
640 if (!unacked_packets_.HasPendingPackets()) { 637 if (!unacked_packets_.HasInFlightPackets()) {
641 return QuicTime::Zero(); 638 return QuicTime::Zero();
642 } 639 }
643 switch (GetRetransmissionMode()) { 640 switch (GetRetransmissionMode()) {
644 case HANDSHAKE_MODE: 641 case HANDSHAKE_MODE:
645 return clock_->ApproximateNow().Add(GetCryptoRetransmissionDelay()); 642 return clock_->ApproximateNow().Add(GetCryptoRetransmissionDelay());
646 case LOSS_MODE: 643 case LOSS_MODE:
647 return loss_algorithm_->GetLossTimeout(); 644 return loss_algorithm_->GetLossTimeout();
648 case TLP_MODE: { 645 case TLP_MODE: {
649 // TODO(ianswett): When CWND is available, it would be preferable to 646 // TODO(ianswett): When CWND is available, it would be preferable to
650 // set the timer based on the earliest retransmittable packet. 647 // set the timer based on the earliest retransmittable packet.
651 // Base the updated timer on the send time of the last packet. 648 // Base the updated timer on the send time of the last packet.
652 const QuicTime sent_time = unacked_packets_.GetLastPacketSentTime(); 649 const QuicTime sent_time = unacked_packets_.GetLastPacketSentTime();
653 const QuicTime tlp_time = sent_time.Add(GetTailLossProbeDelay()); 650 const QuicTime tlp_time = sent_time.Add(GetTailLossProbeDelay());
654 // Ensure the TLP timer never gets set to a time in the past. 651 // Ensure the TLP timer never gets set to a time in the past.
655 return QuicTime::Max(clock_->ApproximateNow(), tlp_time); 652 return QuicTime::Max(clock_->ApproximateNow(), tlp_time);
656 } 653 }
657 case RTO_MODE: { 654 case RTO_MODE: {
658 // The RTO is based on the first pending packet. 655 // The RTO is based on the first outstanding packet.
659 const QuicTime sent_time = 656 const QuicTime sent_time =
660 unacked_packets_.GetFirstPendingPacketSentTime(); 657 unacked_packets_.GetFirstInFlightPacketSentTime();
661 QuicTime rto_timeout = sent_time.Add(GetRetransmissionDelay()); 658 QuicTime rto_timeout = sent_time.Add(GetRetransmissionDelay());
662 // Always wait at least 1.5 * RTT from now. 659 // Always wait at least 1.5 * RTT from now.
663 QuicTime min_timeout = clock_->ApproximateNow().Add( 660 QuicTime min_timeout = clock_->ApproximateNow().Add(
664 rtt_stats_.SmoothedRtt().Multiply(1.5)); 661 rtt_stats_.SmoothedRtt().Multiply(1.5));
665 662
666 return QuicTime::Max(min_timeout, rto_timeout); 663 return QuicTime::Max(min_timeout, rto_timeout);
667 } 664 }
668 } 665 }
669 DCHECK(false); 666 DCHECK(false);
670 return QuicTime::Zero(); 667 return QuicTime::Zero();
671 } 668 }
672 669
673 const QuicTime::Delta QuicSentPacketManager::GetCryptoRetransmissionDelay() 670 const QuicTime::Delta QuicSentPacketManager::GetCryptoRetransmissionDelay()
674 const { 671 const {
675 // This is equivalent to the TailLossProbeDelay, but slightly more aggressive 672 // This is equivalent to the TailLossProbeDelay, but slightly more aggressive
676 // because crypto handshake messages don't incur a delayed ack time. 673 // because crypto handshake messages don't incur a delayed ack time.
677 int64 delay_ms = max<int64>(kMinHandshakeTimeoutMs, 674 int64 delay_ms = max<int64>(kMinHandshakeTimeoutMs,
678 1.5 * rtt_stats_.SmoothedRtt().ToMilliseconds()); 675 1.5 * rtt_stats_.SmoothedRtt().ToMilliseconds());
679 return QuicTime::Delta::FromMilliseconds( 676 return QuicTime::Delta::FromMilliseconds(
680 delay_ms << consecutive_crypto_retransmission_count_); 677 delay_ms << consecutive_crypto_retransmission_count_);
681 } 678 }
682 679
683 const QuicTime::Delta QuicSentPacketManager::GetTailLossProbeDelay() const { 680 const QuicTime::Delta QuicSentPacketManager::GetTailLossProbeDelay() const {
684 QuicTime::Delta srtt = rtt_stats_.SmoothedRtt(); 681 QuicTime::Delta srtt = rtt_stats_.SmoothedRtt();
685 if (!unacked_packets_.HasMultiplePendingPackets()) { 682 if (!unacked_packets_.HasMultipleInFlightPackets()) {
686 return QuicTime::Delta::Max( 683 return QuicTime::Delta::Max(
687 srtt.Multiply(1.5).Add(DelayedAckTime()), srtt.Multiply(2)); 684 srtt.Multiply(1.5).Add(DelayedAckTime()), srtt.Multiply(2));
688 } 685 }
689 return QuicTime::Delta::FromMilliseconds( 686 return QuicTime::Delta::FromMilliseconds(
690 max(kMinTailLossProbeTimeoutMs, 687 max(kMinTailLossProbeTimeoutMs,
691 static_cast<int64>(2 * srtt.ToMilliseconds()))); 688 static_cast<int64>(2 * srtt.ToMilliseconds())));
692 } 689 }
693 690
694 const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const { 691 const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const {
695 QuicTime::Delta retransmission_delay = send_algorithm_->RetransmissionDelay(); 692 QuicTime::Delta retransmission_delay = send_algorithm_->RetransmissionDelay();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 return; 731 return;
735 } 732 }
736 733
737 using_pacing_ = true; 734 using_pacing_ = true;
738 send_algorithm_.reset( 735 send_algorithm_.reset(
739 new PacingSender(send_algorithm_.release(), 736 new PacingSender(send_algorithm_.release(),
740 QuicTime::Delta::FromMicroseconds(1))); 737 QuicTime::Delta::FromMicroseconds(1)));
741 } 738 }
742 739
743 } // namespace net 740 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_protocol.cc ('k') | net/quic/quic_unacked_packet_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698