[Mac] Enable MacViews bookmark editor behind --enable-mac-views-dialogs.
[chromium-blink-merge.git] / net / quic / congestion_control / tcp_cubic_bytes_sender.h
blob663bc1109ab44b1800d1e052af17ac35234256ca
1 // Copyright (c) 2015 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.
5 // TCP cubic send side congestion algorithm, emulates the behavior of TCP cubic.
7 #ifndef NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_BYTES_SENDER_H_
8 #define NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_BYTES_SENDER_H_
10 #include "base/basictypes.h"
11 #include "net/base/net_export.h"
12 #include "net/quic/congestion_control/cubic_bytes.h"
13 #include "net/quic/congestion_control/hybrid_slow_start.h"
14 #include "net/quic/congestion_control/prr_sender.h"
15 #include "net/quic/congestion_control/send_algorithm_interface.h"
16 #include "net/quic/quic_bandwidth.h"
17 #include "net/quic/quic_connection_stats.h"
18 #include "net/quic/quic_protocol.h"
19 #include "net/quic/quic_time.h"
21 namespace net {
23 class RttStats;
25 namespace test {
26 class TcpCubicBytesSenderPeer;
27 } // namespace test
29 class NET_EXPORT_PRIVATE TcpCubicBytesSender : public SendAlgorithmInterface {
30 public:
31 TcpCubicBytesSender(const QuicClock* clock,
32 const RttStats* rtt_stats,
33 bool reno,
34 QuicPacketCount initial_tcp_congestion_window,
35 QuicPacketCount max_congestion_window,
36 QuicConnectionStats* stats);
37 ~TcpCubicBytesSender() override;
39 // Start implementation of SendAlgorithmInterface.
40 void SetFromConfig(const QuicConfig& config,
41 Perspective perspective) override;
42 void ResumeConnectionState(
43 const CachedNetworkParameters& cached_network_params,
44 bool max_bandwidth_resumption) override;
45 void SetNumEmulatedConnections(int num_connections) override;
46 void SetMaxCongestionWindow(QuicByteCount max_congestion_window) override;
47 void OnCongestionEvent(bool rtt_updated,
48 QuicByteCount bytes_in_flight,
49 const CongestionVector& acked_packets,
50 const CongestionVector& lost_packets) override;
51 bool OnPacketSent(QuicTime sent_time,
52 QuicByteCount bytes_in_flight,
53 QuicPacketSequenceNumber sequence_number,
54 QuicByteCount bytes,
55 HasRetransmittableData is_retransmittable) override;
56 void OnRetransmissionTimeout(bool packets_retransmitted) override;
57 QuicTime::Delta TimeUntilSend(
58 QuicTime now,
59 QuicByteCount bytes_in_flight,
60 HasRetransmittableData has_retransmittable_data) const override;
61 QuicBandwidth PacingRate() const override;
62 QuicBandwidth BandwidthEstimate() const override;
63 QuicTime::Delta RetransmissionDelay() const override;
64 QuicByteCount GetCongestionWindow() const override;
65 bool InSlowStart() const override;
66 bool InRecovery() const override;
67 QuicByteCount GetSlowStartThreshold() const override;
68 CongestionControlType GetCongestionControlType() const override;
69 // End implementation of SendAlgorithmInterface.
71 private:
72 friend class test::TcpCubicBytesSenderPeer;
74 // Compute the TCP Reno beta based on the current number of connections.
75 float RenoBeta() const;
77 // TODO(ianswett): Remove these and migrate to OnCongestionEvent.
78 void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number,
79 QuicByteCount acked_bytes,
80 QuicByteCount bytes_in_flight);
81 void OnPacketLost(QuicPacketSequenceNumber largest_loss,
82 QuicByteCount bytes_in_flight);
84 void MaybeIncreaseCwnd(QuicPacketSequenceNumber acked_sequence_number,
85 QuicByteCount acked_bytes,
86 QuicByteCount bytes_in_flight);
87 bool IsCwndLimited(QuicByteCount bytes_in_flight) const;
89 HybridSlowStart hybrid_slow_start_;
90 CubicBytes cubic_;
91 PrrSender prr_;
92 const RttStats* rtt_stats_;
93 QuicConnectionStats* stats_;
95 // If true, Reno congestion control is used instead of Cubic.
96 const bool reno_;
98 // Number of connections to simulate.
99 uint32 num_connections_;
101 // ACK counter for the Reno implementation.
102 uint64 num_acked_packets_;
104 // Track the largest packet that has been sent.
105 QuicPacketSequenceNumber largest_sent_sequence_number_;
107 // Track the largest packet that has been acked.
108 QuicPacketSequenceNumber largest_acked_sequence_number_;
110 // Track the largest sequence number outstanding when a CWND cutback occurs.
111 QuicPacketSequenceNumber largest_sent_at_last_cutback_;
113 // Congestion window in bytes.
114 QuicByteCount congestion_window_;
116 // Minimum congestion window in bytes.
117 QuicByteCount min_congestion_window_;
119 // Whether to use 4 packets as the actual min, but pace lower.
120 bool min4_mode_;
122 // Maximum congestion window in bytes.
123 QuicByteCount max_congestion_window_;
125 // Slow start congestion window in bytes, aka ssthresh.
126 QuicByteCount slowstart_threshold_;
128 // Whether the last loss event caused us to exit slowstart. Used for stats
129 // collection of slowstart_packets_lost.
130 bool last_cutback_exited_slowstart_;
132 const QuicClock* clock_;
134 DISALLOW_COPY_AND_ASSIGN(TcpCubicBytesSender);
137 } // namespace net
139 #endif // NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_BYTES_SENDER_H_