OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // per draft RFC draft-dukkipati-tcpm-tcp-loss-probe. | 42 // per draft RFC draft-dukkipati-tcpm-tcp-loss-probe. |
43 static const size_t kDefaultMaxTailLossProbes = 2; | 43 static const size_t kDefaultMaxTailLossProbes = 2; |
44 static const int64 kMinTailLossProbeTimeoutMs = 10; | 44 static const int64 kMinTailLossProbeTimeoutMs = 10; |
45 | 45 |
46 // Number of samples before we force a new recent min rtt to be captured. | 46 // Number of samples before we force a new recent min rtt to be captured. |
47 static const size_t kNumMinRttSamplesAfterQuiescence = 2; | 47 static const size_t kNumMinRttSamplesAfterQuiescence = 2; |
48 | 48 |
49 // Number of unpaced packets to send after quiescence. | 49 // Number of unpaced packets to send after quiescence. |
50 static const size_t kInitialUnpacedBurst = 10; | 50 static const size_t kInitialUnpacedBurst = 10; |
51 | 51 |
52 // Use a 1 minute window for Recent Min RTT with BBR. | |
53 | |
54 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) { | 52 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) { |
55 if (transmission_info.retransmittable_frames == NULL) { | 53 if (transmission_info.retransmittable_frames == NULL) { |
56 return false; | 54 return false; |
57 } | 55 } |
58 return transmission_info.retransmittable_frames->HasCryptoHandshake() == | 56 return transmission_info.retransmittable_frames->HasCryptoHandshake() == |
59 IS_HANDSHAKE; | 57 IS_HANDSHAKE; |
60 } | 58 } |
61 | 59 |
62 } // namespace | 60 } // namespace |
63 | 61 |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 HasRetransmittableData retransmittable) { | 731 HasRetransmittableData retransmittable) { |
734 // The TLP logic is entirely contained within QuicSentPacketManager, so the | 732 // The TLP logic is entirely contained within QuicSentPacketManager, so the |
735 // send algorithm does not need to be consulted. | 733 // send algorithm does not need to be consulted. |
736 if (pending_tlp_transmission_) { | 734 if (pending_tlp_transmission_) { |
737 return QuicTime::Delta::Zero(); | 735 return QuicTime::Delta::Zero(); |
738 } | 736 } |
739 return send_algorithm_->TimeUntilSend( | 737 return send_algorithm_->TimeUntilSend( |
740 now, unacked_packets_.bytes_in_flight(), retransmittable); | 738 now, unacked_packets_.bytes_in_flight(), retransmittable); |
741 } | 739 } |
742 | 740 |
| 741 // Uses a 25ms delayed ack timer. Also helps with better signaling |
| 742 // in low-bandwidth (< ~384 kbps), where an ack is sent per packet. |
743 // Ensures that the Delayed Ack timer is always set to a value lesser | 743 // Ensures that the Delayed Ack timer is always set to a value lesser |
744 // than the retransmission timer's minimum value (MinRTO). We want the | 744 // than the retransmission timer's minimum value (MinRTO). We want the |
745 // delayed ack to get back to the QUIC peer before the sender's | 745 // delayed ack to get back to the QUIC peer before the sender's |
746 // retransmission timer triggers. Since we do not know the | 746 // retransmission timer triggers. Since we do not know the |
747 // reverse-path one-way delay, we assume equal delays for forward and | 747 // reverse-path one-way delay, we assume equal delays for forward and |
748 // reverse paths, and ensure that the timer is set to less than half | 748 // reverse paths, and ensure that the timer is set to less than half |
749 // of the MinRTO. | 749 // of the MinRTO. |
750 // There may be a value in making this delay adaptive with the help of | 750 // There may be a value in making this delay adaptive with the help of |
751 // the sender and a signaling mechanism -- if the sender uses a | 751 // the sender and a signaling mechanism -- if the sender uses a |
752 // different MinRTO, we may get spurious retransmissions. May not have | 752 // different MinRTO, we may get spurious retransmissions. May not have |
753 // any benefits, but if the delayed ack becomes a significant source | 753 // any benefits, but if the delayed ack becomes a significant source |
754 // of (likely, tail) latency, then consider such a mechanism. | 754 // of (likely, tail) latency, then consider such a mechanism. |
755 const QuicTime::Delta QuicSentPacketManager::DelayedAckTime() const { | 755 const QuicTime::Delta QuicSentPacketManager::DelayedAckTime() const { |
756 return QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs/2); | 756 return QuicTime::Delta::FromMilliseconds(min(kMaxDelayedAckTime, |
| 757 kMinRetransmissionTimeMs/2)); |
757 } | 758 } |
758 | 759 |
759 const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { | 760 const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { |
760 // Don't set the timer if there are no packets in flight or we've already | 761 // Don't set the timer if there are no packets in flight or we've already |
761 // queued a tlp transmission and it hasn't been sent yet. | 762 // queued a tlp transmission and it hasn't been sent yet. |
762 if (!unacked_packets_.HasInFlightPackets() || pending_tlp_transmission_) { | 763 if (!unacked_packets_.HasInFlightPackets() || pending_tlp_transmission_) { |
763 return QuicTime::Zero(); | 764 return QuicTime::Zero(); |
764 } | 765 } |
765 switch (GetRetransmissionMode()) { | 766 switch (GetRetransmissionMode()) { |
766 case HANDSHAKE_MODE: | 767 case HANDSHAKE_MODE: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 int64 delay_ms = max<int64>(kMinHandshakeTimeoutMs, | 799 int64 delay_ms = max<int64>(kMinHandshakeTimeoutMs, |
799 1.5 * rtt_stats_.SmoothedRtt().ToMilliseconds()); | 800 1.5 * rtt_stats_.SmoothedRtt().ToMilliseconds()); |
800 return QuicTime::Delta::FromMilliseconds( | 801 return QuicTime::Delta::FromMilliseconds( |
801 delay_ms << consecutive_crypto_retransmission_count_); | 802 delay_ms << consecutive_crypto_retransmission_count_); |
802 } | 803 } |
803 | 804 |
804 const QuicTime::Delta QuicSentPacketManager::GetTailLossProbeDelay() const { | 805 const QuicTime::Delta QuicSentPacketManager::GetTailLossProbeDelay() const { |
805 QuicTime::Delta srtt = rtt_stats_.SmoothedRtt(); | 806 QuicTime::Delta srtt = rtt_stats_.SmoothedRtt(); |
806 if (!unacked_packets_.HasMultipleInFlightPackets()) { | 807 if (!unacked_packets_.HasMultipleInFlightPackets()) { |
807 return QuicTime::Delta::Max( | 808 return QuicTime::Delta::Max( |
808 srtt.Multiply(1.5).Add(DelayedAckTime()), srtt.Multiply(2)); | 809 srtt.Multiply(2), srtt.Multiply(1.5) |
| 810 .Add(QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs/2))); |
809 } | 811 } |
810 return QuicTime::Delta::FromMilliseconds( | 812 return QuicTime::Delta::FromMilliseconds( |
811 max(kMinTailLossProbeTimeoutMs, | 813 max(kMinTailLossProbeTimeoutMs, |
812 static_cast<int64>(2 * srtt.ToMilliseconds()))); | 814 static_cast<int64>(2 * srtt.ToMilliseconds()))); |
813 } | 815 } |
814 | 816 |
815 const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const { | 817 const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const { |
816 QuicTime::Delta retransmission_delay = send_algorithm_->RetransmissionDelay(); | 818 QuicTime::Delta retransmission_delay = send_algorithm_->RetransmissionDelay(); |
817 // TODO(rch): This code should move to |send_algorithm_|. | 819 // TODO(rch): This code should move to |send_algorithm_|. |
818 if (retransmission_delay.IsZero()) { | 820 if (retransmission_delay.IsZero()) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 | 867 |
866 // Set up a pacing sender with a 5 millisecond alarm granularity. | 868 // Set up a pacing sender with a 5 millisecond alarm granularity. |
867 using_pacing_ = true; | 869 using_pacing_ = true; |
868 send_algorithm_.reset( | 870 send_algorithm_.reset( |
869 new PacingSender(send_algorithm_.release(), | 871 new PacingSender(send_algorithm_.release(), |
870 QuicTime::Delta::FromMilliseconds(5), | 872 QuicTime::Delta::FromMilliseconds(5), |
871 kInitialUnpacedBurst)); | 873 kInitialUnpacedBurst)); |
872 } | 874 } |
873 | 875 |
874 } // namespace net | 876 } // namespace net |
OLD | NEW |