Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / net / quic / congestion_control / hybrid_slow_start.h
blob9f72f1f6b5a66c8508b22625c8af096f256cf5ed
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
3 // found in the LICENSE file.
4 //
5 // This class is a helper class to TcpCubicSender.
6 // Slow start is the initial startup phase of TCP, it lasts until first packet
7 // loss. This class implements hybrid slow start of the TCP cubic send side
8 // congestion algorithm. The key feaure of hybrid slow start is that it tries to
9 // avoid running into the wall too hard during the slow start phase, which
10 // the traditional TCP implementation does.
11 // This does not implement ack train detection because it interacts poorly with
12 // pacing.
13 // http://netsrv.csc.ncsu.edu/export/hybridstart_pfldnet08.pdf
14 // http://research.csc.ncsu.edu/netsrv/sites/default/files/hystart_techreport_2008.pdf
16 #ifndef NET_QUIC_CONGESTION_CONTROL_HYBRID_SLOW_START_H_
17 #define NET_QUIC_CONGESTION_CONTROL_HYBRID_SLOW_START_H_
19 #include "base/basictypes.h"
20 #include "net/base/net_export.h"
21 #include "net/quic/quic_clock.h"
22 #include "net/quic/quic_protocol.h"
23 #include "net/quic/quic_time.h"
25 namespace net {
27 class NET_EXPORT_PRIVATE HybridSlowStart {
28 public:
29 explicit HybridSlowStart(const QuicClock* clock);
31 void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number,
32 bool in_slow_start);
34 void OnPacketSent(QuicPacketSequenceNumber sequence_number);
36 // ShouldExitSlowStart should be called on every new ack frame, since a new
37 // RTT measurement can be made then.
38 // rtt: the RTT for this ack packet.
39 // min_rtt: is the lowest delay (RTT) we have seen during the session.
40 // congestion_window: the congestion window in packets.
41 bool ShouldExitSlowStart(QuicTime::Delta rtt,
42 QuicTime::Delta min_rtt,
43 int64 congestion_window);
45 // Start a new slow start phase.
46 void Restart();
48 // TODO(ianswett): The following methods should be private, but that requires
49 // a follow up CL to update the unit test.
50 // Returns true if this ack the last sequence number of our current slow start
51 // round.
52 // Call Reset if this returns true.
53 bool IsEndOfRound(QuicPacketSequenceNumber ack) const;
55 // Call for the start of each receive round (burst) in the slow start phase.
56 void StartReceiveRound(QuicPacketSequenceNumber last_sent);
58 // Whether slow start has started.
59 bool started() const {
60 return started_;
63 private:
64 // Whether a condition for exiting slow start has been found.
65 enum HystartState {
66 NOT_FOUND,
67 DELAY, // Too much increase in the round's min_rtt was observed.
70 const QuicClock* clock_;
71 // Whether the hybrid slow start has been started.
72 bool started_;
73 HystartState hystart_found_;
74 // Last sequence number sent which was CWND limited.
75 QuicPacketSequenceNumber last_sent_sequence_number_;
77 // Variables for tracking acks received during a slow start round.
78 QuicPacketSequenceNumber end_sequence_number_; // End of the receive round.
79 uint32 rtt_sample_count_; // Number of rtt samples in the current round.
80 QuicTime::Delta current_min_rtt_; // The minimum rtt of current round.
82 DISALLOW_COPY_AND_ASSIGN(HybridSlowStart);
85 } // namespace net
87 #endif // NET_QUIC_CONGESTION_CONTROL_HYBRID_SLOW_START_H_