| 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" |
| 11 #include "net/quic/congestion_control/pacing_sender.h" | 11 #include "net/quic/congestion_control/pacing_sender.h" |
| 12 #include "net/quic/crypto/crypto_protocol.h" | 12 #include "net/quic/crypto/crypto_protocol.h" |
| 13 #include "net/quic/quic_ack_notifier_manager.h" | 13 #include "net/quic/quic_ack_notifier_manager.h" |
| 14 #include "net/quic/quic_connection_stats.h" | 14 #include "net/quic/quic_connection_stats.h" |
| 15 #include "net/quic/quic_flags.h" | 15 #include "net/quic/quic_flags.h" |
| 16 #include "net/quic/quic_utils_chromium.h" | 16 #include "net/quic/quic_utils_chromium.h" |
| 17 | 17 |
| 18 using std::make_pair; | 18 using std::make_pair; |
| 19 using std::max; | 19 using std::max; |
| 20 using std::min; | 20 using std::min; |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| 23 |
| 24 // The length of the recent min rtt window in seconds. Windowing is disabled for |
| 25 // values less than or equal to 0. |
| 26 int32 FLAGS_quic_recent_min_rtt_window_s = 60; |
| 27 |
| 23 namespace { | 28 namespace { |
| 24 static const int kDefaultRetransmissionTimeMs = 500; | 29 static const int kDefaultRetransmissionTimeMs = 500; |
| 25 // TCP RFC calls for 1 second RTO however Linux differs from this default and | 30 // TCP RFC calls for 1 second RTO however Linux differs from this default and |
| 26 // define the minimum RTO to 200ms, we will use the same until we have data to | 31 // define the minimum RTO to 200ms, we will use the same until we have data to |
| 27 // support a higher or lower value. | 32 // support a higher or lower value. |
| 28 static const int kMinRetransmissionTimeMs = 200; | 33 static const int kMinRetransmissionTimeMs = 200; |
| 29 static const int kMaxRetransmissionTimeMs = 60000; | 34 static const int kMaxRetransmissionTimeMs = 60000; |
| 30 static const size_t kMaxRetransmissions = 10; | 35 static const size_t kMaxRetransmissions = 10; |
| 31 | 36 |
| 32 // Only exponentially back off the handshake timer 5 times due to a timeout. | 37 // Only exponentially back off the handshake timer 5 times due to a timeout. |
| 33 static const size_t kMaxHandshakeRetransmissionBackoffs = 5; | 38 static const size_t kMaxHandshakeRetransmissionBackoffs = 5; |
| 34 static const size_t kMinHandshakeTimeoutMs = 10; | 39 static const size_t kMinHandshakeTimeoutMs = 10; |
| 35 | 40 |
| 36 // Sends up to two tail loss probes before firing an RTO, | 41 // Sends up to two tail loss probes before firing an RTO, |
| 37 // per draft RFC draft-dukkipati-tcpm-tcp-loss-probe. | 42 // per draft RFC draft-dukkipati-tcpm-tcp-loss-probe. |
| 38 static const size_t kDefaultMaxTailLossProbes = 2; | 43 static const size_t kDefaultMaxTailLossProbes = 2; |
| 39 static const int64 kMinTailLossProbeTimeoutMs = 10; | 44 static const int64 kMinTailLossProbeTimeoutMs = 10; |
| 40 | 45 |
| 41 // 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. |
| 42 static const size_t kNumMinRttSamplesAfterQuiescence = 2; | 47 static const size_t kNumMinRttSamplesAfterQuiescence = 2; |
| 43 | 48 |
| 44 // Number of unpaced packets to send after quiescence. | 49 // Number of unpaced packets to send after quiescence. |
| 45 static const size_t kInitialUnpacedBurst = 10; | 50 static const size_t kInitialUnpacedBurst = 10; |
| 46 | 51 |
| 52 // Use a 1 minute window for Recent Min RTT with BBR. |
| 53 |
| 47 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) { | 54 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) { |
| 48 if (transmission_info.retransmittable_frames == NULL) { | 55 if (transmission_info.retransmittable_frames == NULL) { |
| 49 return false; | 56 return false; |
| 50 } | 57 } |
| 51 return transmission_info.retransmittable_frames->HasCryptoHandshake() == | 58 return transmission_info.retransmittable_frames->HasCryptoHandshake() == |
| 52 IS_HANDSHAKE; | 59 IS_HANDSHAKE; |
| 53 } | 60 } |
| 54 | 61 |
| 55 } // namespace | 62 } // namespace |
| 56 | 63 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 84 | 91 |
| 85 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { | 92 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { |
| 86 if (config.HasReceivedInitialRoundTripTimeUs() && | 93 if (config.HasReceivedInitialRoundTripTimeUs() && |
| 87 config.ReceivedInitialRoundTripTimeUs() > 0) { | 94 config.ReceivedInitialRoundTripTimeUs() > 0) { |
| 88 rtt_stats_.set_initial_rtt_us(min(kMaxInitialRoundTripTimeUs, | 95 rtt_stats_.set_initial_rtt_us(min(kMaxInitialRoundTripTimeUs, |
| 89 config.ReceivedInitialRoundTripTimeUs())); | 96 config.ReceivedInitialRoundTripTimeUs())); |
| 90 } | 97 } |
| 91 // TODO(ianswett): BBR is currently a server only feature. | 98 // TODO(ianswett): BBR is currently a server only feature. |
| 92 if (config.HasReceivedConnectionOptions() && | 99 if (config.HasReceivedConnectionOptions() && |
| 93 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { | 100 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { |
| 101 if (FLAGS_quic_recent_min_rtt_window_s > 0) { |
| 102 rtt_stats_.set_recent_min_rtt_window( |
| 103 QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s)); |
| 104 } |
| 94 send_algorithm_.reset( | 105 send_algorithm_.reset( |
| 95 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kTCPBBR, stats_)); | 106 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kTCPBBR, stats_)); |
| 96 } | 107 } |
| 97 if (config.congestion_feedback() == kPACE || | 108 if (config.congestion_feedback() == kPACE || |
| 98 (config.HasReceivedConnectionOptions() && | 109 (config.HasReceivedConnectionOptions() && |
| 99 ContainsQuicTag(config.ReceivedConnectionOptions(), kPACE))) { | 110 ContainsQuicTag(config.ReceivedConnectionOptions(), kPACE))) { |
| 100 MaybeEnablePacing(); | 111 MaybeEnablePacing(); |
| 101 } | 112 } |
| 102 // TODO(ianswett): Remove the "HasReceivedLossDetection" branch once | 113 // TODO(ianswett): Remove the "HasReceivedLossDetection" branch once |
| 103 // the ConnectionOptions code is live everywhere. | 114 // the ConnectionOptions code is live everywhere. |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 | 824 |
| 814 // Set up a pacing sender with a 5 millisecond alarm granularity. | 825 // Set up a pacing sender with a 5 millisecond alarm granularity. |
| 815 using_pacing_ = true; | 826 using_pacing_ = true; |
| 816 send_algorithm_.reset( | 827 send_algorithm_.reset( |
| 817 new PacingSender(send_algorithm_.release(), | 828 new PacingSender(send_algorithm_.release(), |
| 818 QuicTime::Delta::FromMilliseconds(5), | 829 QuicTime::Delta::FromMilliseconds(5), |
| 819 kInitialUnpacedBurst)); | 830 kInitialUnpacedBurst)); |
| 820 } | 831 } |
| 821 | 832 |
| 822 } // namespace net | 833 } // namespace net |
| OLD | NEW |