- add sources.
[platform/framework/web/crosswalk.git] / src / net / quic / congestion_control / hybrid_slow_start.h
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
13
14 #ifndef NET_QUIC_CONGESTION_CONTROL_HYBRID_SLOW_START_H_
15 #define NET_QUIC_CONGESTION_CONTROL_HYBRID_SLOW_START_H_
16
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"
22
23 namespace net {
24
25 class NET_EXPORT_PRIVATE HybridSlowStart {
26  public:
27   explicit HybridSlowStart(const QuicClock* clock);
28
29   // Start a new slow start phase.
30   void Restart();
31
32   // Returns true if this ack the last sequence number of our current slow start
33   // round.
34   // Call Reset if this returns true.
35   bool EndOfRound(QuicPacketSequenceNumber ack);
36
37   // Call for each round (burst) in the slow start phase.
38   void Reset(QuicPacketSequenceNumber end_sequence_number);
39
40   // rtt: it the RTT for this ack packet.
41   // delay_min: is the lowest delay (RTT) we have seen during the session.
42   void Update(QuicTime::Delta rtt, QuicTime::Delta delay_min);
43
44   // Returns true when we should exit slow start.
45   bool Exit();
46
47   bool started() { return started_; }
48
49  private:
50   const QuicClock* clock_;
51   bool started_;
52   bool found_ack_train_;
53   bool found_delay_;
54   QuicTime round_start_;  // Beginning of each slow start round.
55   QuicPacketSequenceNumber end_sequence_number_;  // End of slow start round.
56   QuicTime last_time_;  // Last time when the ACK spacing was close.
57   uint8 sample_count_;  // Number of samples to decide current RTT.
58   QuicTime::Delta current_rtt_;  // The minimum rtt of current round.
59
60   DISALLOW_COPY_AND_ASSIGN(HybridSlowStart);
61 };
62
63 }  // namespace net
64
65 #endif  // NET_QUIC_CONGESTION_CONTROL_HYBRID_SLOW_START_H_