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

Side by Side Diff: net/quic/congestion_control/hybrid_slow_start.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/congestion_control/hybrid_slow_start.h" 5 #include "net/quic/congestion_control/hybrid_slow_start.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 using std::max; 9 using std::max;
10 using std::min; 10 using std::min;
11 11
12 namespace net { 12 namespace net {
13 13
14 // Note(pwestin): the magic clamping numbers come from the original code in 14 // Note(pwestin): the magic clamping numbers come from the original code in
15 // tcp_cubic.c. 15 // tcp_cubic.c.
16 const int64 kHybridStartLowWindow = 16; 16 const int64_t kHybridStartLowWindow = 16;
17 // Number of delay samples for detecting the increase of delay. 17 // Number of delay samples for detecting the increase of delay.
18 const uint32 kHybridStartMinSamples = 8; 18 const uint32_t kHybridStartMinSamples = 8;
19 // Exit slow start if the min rtt has increased by more than 1/8th. 19 // Exit slow start if the min rtt has increased by more than 1/8th.
20 const int kHybridStartDelayFactorExp = 3; // 2^3 = 8 20 const int kHybridStartDelayFactorExp = 3; // 2^3 = 8
21 // The original paper specifies 2 and 8ms, but those have changed over time. 21 // The original paper specifies 2 and 8ms, but those have changed over time.
22 const int64 kHybridStartDelayMinThresholdUs = 4000; 22 const int64_t kHybridStartDelayMinThresholdUs = 4000;
23 const int64 kHybridStartDelayMaxThresholdUs = 16000; 23 const int64_t kHybridStartDelayMaxThresholdUs = 16000;
24 24
25 HybridSlowStart::HybridSlowStart() 25 HybridSlowStart::HybridSlowStart()
26 : started_(false), 26 : started_(false),
27 hystart_found_(NOT_FOUND), 27 hystart_found_(NOT_FOUND),
28 last_sent_packet_number_(0), 28 last_sent_packet_number_(0),
29 end_packet_number_(0), 29 end_packet_number_(0),
30 rtt_sample_count_(0), 30 rtt_sample_count_(0),
31 current_min_rtt_(QuicTime::Delta::Zero()) {} 31 current_min_rtt_(QuicTime::Delta::Zero()) {}
32 32
33 void HybridSlowStart::OnPacketAcked(QuicPacketNumber acked_packet_number, 33 void HybridSlowStart::OnPacketAcked(QuicPacketNumber acked_packet_number,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // bursts. 79 // bursts.
80 rtt_sample_count_++; 80 rtt_sample_count_++;
81 if (rtt_sample_count_ <= kHybridStartMinSamples) { 81 if (rtt_sample_count_ <= kHybridStartMinSamples) {
82 if (current_min_rtt_.IsZero() || current_min_rtt_ > latest_rtt) { 82 if (current_min_rtt_.IsZero() || current_min_rtt_ > latest_rtt) {
83 current_min_rtt_ = latest_rtt; 83 current_min_rtt_ = latest_rtt;
84 } 84 }
85 } 85 }
86 // We only need to check this once per round. 86 // We only need to check this once per round.
87 if (rtt_sample_count_ == kHybridStartMinSamples) { 87 if (rtt_sample_count_ == kHybridStartMinSamples) {
88 // Divide min_rtt by 8 to get a rtt increase threshold for exiting. 88 // Divide min_rtt by 8 to get a rtt increase threshold for exiting.
89 int64 min_rtt_increase_threshold_us = 89 int64_t min_rtt_increase_threshold_us =
90 min_rtt.ToMicroseconds() >> kHybridStartDelayFactorExp; 90 min_rtt.ToMicroseconds() >> kHybridStartDelayFactorExp;
91 // Ensure the rtt threshold is never less than 2ms or more than 16ms. 91 // Ensure the rtt threshold is never less than 2ms or more than 16ms.
92 min_rtt_increase_threshold_us = 92 min_rtt_increase_threshold_us =
93 min(min_rtt_increase_threshold_us, kHybridStartDelayMaxThresholdUs); 93 min(min_rtt_increase_threshold_us, kHybridStartDelayMaxThresholdUs);
94 QuicTime::Delta min_rtt_increase_threshold = 94 QuicTime::Delta min_rtt_increase_threshold =
95 QuicTime::Delta::FromMicroseconds(max(min_rtt_increase_threshold_us, 95 QuicTime::Delta::FromMicroseconds(max(min_rtt_increase_threshold_us,
96 kHybridStartDelayMinThresholdUs)); 96 kHybridStartDelayMinThresholdUs));
97 97
98 if (current_min_rtt_ > min_rtt.Add(min_rtt_increase_threshold)) { 98 if (current_min_rtt_ > min_rtt.Add(min_rtt_increase_threshold)) {
99 hystart_found_ = DELAY; 99 hystart_found_ = DELAY;
100 } 100 }
101 } 101 }
102 // Exit from slow start if the cwnd is greater than 16 and 102 // Exit from slow start if the cwnd is greater than 16 and
103 // increasing delay is found. 103 // increasing delay is found.
104 return congestion_window >= kHybridStartLowWindow && 104 return congestion_window >= kHybridStartLowWindow &&
105 hystart_found_ != NOT_FOUND; 105 hystart_found_ != NOT_FOUND;
106 } 106 }
107 107
108 } // namespace net 108 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/hybrid_slow_start.h ('k') | net/quic/congestion_control/loss_detection_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698