We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / net / quic / congestion_control / hybrid_slow_start.h
blobcee9a6075ab2e4823b26af487788cf6c6d97d3e7
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 // http://netsrv.csc.ncsu.edu/export/hybridstart_pfldnet08.pdf
12 // http://research.csc.ncsu.edu/netsrv/sites/default/files/hystart_techreport_2008.pdf
14 #ifndef NET_QUIC_CONGESTION_CONTROL_HYBRID_SLOW_START_H_
15 #define NET_QUIC_CONGESTION_CONTROL_HYBRID_SLOW_START_H_
17 #include "base/basictypes.h"
18 #include "net/base/net_export.h"
19 #include "net/quic/quic_clock.h"
20 #include "net/quic/quic_protocol.h"
21 #include "net/quic/quic_time.h"
23 namespace net {
25 class NET_EXPORT_PRIVATE HybridSlowStart {
26 public:
27 explicit HybridSlowStart(const QuicClock* clock);
29 void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number,
30 bool in_slow_start);
32 void OnPacketSent(QuicPacketSequenceNumber sequence_number);
34 // ShouldExitSlowStart should be called on every new ack frame, since a new
35 // RTT measurement can be made then.
36 // rtt: the RTT for this ack packet.
37 // min_rtt: is the lowest delay (RTT) we have seen during the session.
38 // congestion_window: the congestion window in packets.
39 bool ShouldExitSlowStart(QuicTime::Delta rtt,
40 QuicTime::Delta min_rtt,
41 int64 congestion_window);
43 // Start a new slow start phase.
44 void Restart();
46 // TODO(ianswett): The following methods should be private, but that requires
47 // a follow up CL to update the unit test.
48 // Returns true if this ack the last sequence number of our current slow start
49 // round.
50 // Call Reset if this returns true.
51 bool IsEndOfRound(QuicPacketSequenceNumber ack) const;
53 // Call for the start of each receive round (burst) in the slow start phase.
54 void StartReceiveRound(QuicPacketSequenceNumber last_sent);
56 void set_ack_train_detection(bool ack_train_detection) {
57 ack_train_detection_ = ack_train_detection;
60 bool ack_train_detection() const {
61 return ack_train_detection_;
64 // Whether slow start has started.
65 bool started() const {
66 return started_;
69 private:
70 // Whether a condition for exiting slow start has been found.
71 enum HystartState {
72 NOT_FOUND,
73 ACK_TRAIN, // A closely spaced ack train is too long.
74 DELAY, // Too much increase in the round's min_rtt was observed.
77 const QuicClock* clock_;
78 bool ack_train_detection_;
79 // Whether the hybrid slow start has been started.
80 bool started_;
81 HystartState hystart_found_;
82 // Last sequence number sent which was CWND limited.
83 QuicPacketSequenceNumber last_sent_sequence_number_;
85 // Variables for tracking acks received during a slow start round.
86 QuicTime round_start_; // Beginning of each slow start receive round.
87 QuicPacketSequenceNumber end_sequence_number_; // End of the receive round.
88 // Last time when the spacing between ack arrivals was less than 2 ms.
89 // Defaults to the beginning of the round.
90 QuicTime last_close_ack_pair_time_;
91 uint32 rtt_sample_count_; // Number of rtt samples in the current round.
92 QuicTime::Delta current_min_rtt_; // The minimum rtt of current round.
94 DISALLOW_COPY_AND_ASSIGN(HybridSlowStart);
97 } // namespace net
99 #endif // NET_QUIC_CONGESTION_CONTROL_HYBRID_SLOW_START_H_