ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / net / quic / congestion_control / tcp_cubic_sender.h
blob4659a4b477b7de184728e6318e813e20d193aee6
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 // TCP cubic send side congestion algorithm, emulates the behavior of
6 // TCP cubic.
8 #ifndef NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_
9 #define NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "net/base/net_export.h"
14 #include "net/quic/congestion_control/cubic.h"
15 #include "net/quic/congestion_control/hybrid_slow_start.h"
16 #include "net/quic/congestion_control/prr_sender.h"
17 #include "net/quic/congestion_control/send_algorithm_interface.h"
18 #include "net/quic/crypto/cached_network_parameters.h"
19 #include "net/quic/quic_bandwidth.h"
20 #include "net/quic/quic_connection_stats.h"
21 #include "net/quic/quic_protocol.h"
22 #include "net/quic/quic_time.h"
24 namespace net {
26 class RttStats;
28 namespace test {
29 class TcpCubicSenderPeer;
30 } // namespace test
32 class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface {
33 public:
34 TcpCubicSender(const QuicClock* clock,
35 const RttStats* rtt_stats,
36 bool reno,
37 QuicPacketCount initial_tcp_congestion_window,
38 QuicConnectionStats* stats);
39 ~TcpCubicSender() override;
41 // Start implementation of SendAlgorithmInterface.
42 void SetFromConfig(const QuicConfig& config,
43 bool is_server,
44 bool using_pacing) override;
45 bool ResumeConnectionState(
46 const CachedNetworkParameters& cached_network_params) override;
47 void SetNumEmulatedConnections(int num_connections) override;
48 void OnCongestionEvent(bool rtt_updated,
49 QuicByteCount bytes_in_flight,
50 const CongestionVector& acked_packets,
51 const CongestionVector& lost_packets) override;
52 bool OnPacketSent(QuicTime sent_time,
53 QuicByteCount bytes_in_flight,
54 QuicPacketSequenceNumber sequence_number,
55 QuicByteCount bytes,
56 HasRetransmittableData is_retransmittable) override;
57 void OnRetransmissionTimeout(bool packets_retransmitted) override;
58 QuicTime::Delta TimeUntilSend(
59 QuicTime now,
60 QuicByteCount bytes_in_flight,
61 HasRetransmittableData has_retransmittable_data) const override;
62 QuicBandwidth PacingRate() const override;
63 QuicBandwidth BandwidthEstimate() const override;
64 bool HasReliableBandwidthEstimate() const override;
65 QuicTime::Delta RetransmissionDelay() const override;
66 QuicByteCount GetCongestionWindow() const override;
67 bool InSlowStart() const override;
68 bool InRecovery() const override;
69 QuicByteCount GetSlowStartThreshold() const override;
70 CongestionControlType GetCongestionControlType() const override;
71 // End implementation of SendAlgorithmInterface.
73 private:
74 friend class test::TcpCubicSenderPeer;
76 // Compute the TCP Reno beta based on the current number of connections.
77 float RenoBeta() const;
79 // TODO(ianswett): Remove these and migrate to OnCongestionEvent.
80 void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number,
81 QuicByteCount acked_bytes,
82 QuicByteCount bytes_in_flight);
83 void OnPacketLost(QuicPacketSequenceNumber largest_loss,
84 QuicByteCount bytes_in_flight);
86 void MaybeIncreaseCwnd(QuicPacketSequenceNumber acked_sequence_number,
87 QuicByteCount bytes_in_flight);
88 bool IsCwndLimited(QuicByteCount bytes_in_flight) const;
90 HybridSlowStart hybrid_slow_start_;
91 Cubic cubic_;
92 PrrSender prr_;
93 const RttStats* rtt_stats_;
94 QuicConnectionStats* stats_;
96 // If true, Reno congestion control is used instead of Cubic.
97 const bool reno_;
99 // Number of connections to simulate.
100 uint32 num_connections_;
102 // ACK counter for the Reno implementation.
103 uint64 num_acked_packets_;
105 // Track the largest packet that has been sent.
106 QuicPacketSequenceNumber largest_sent_sequence_number_;
108 // Track the largest packet that has been acked.
109 QuicPacketSequenceNumber largest_acked_sequence_number_;
111 // Track the largest sequence number outstanding when a CWND cutback occurs.
112 QuicPacketSequenceNumber largest_sent_at_last_cutback_;
114 // Congestion window in packets.
115 QuicPacketCount congestion_window_;
117 // Slow start congestion window in packets, aka ssthresh.
118 QuicPacketCount slowstart_threshold_;
120 // Whether the last loss event caused us to exit slowstart.
121 // Used for stats collection of slowstart_packets_lost
122 bool last_cutback_exited_slowstart_;
124 const QuicClock* clock_;
126 DISALLOW_COPY_AND_ASSIGN(TcpCubicSender);
129 } // namespace net
131 #endif // NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_