Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(745)

Side by Side Diff: net/quic/congestion_control/tcp_cubic_sender_base.h

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 TCP cubic.
6
7 #ifndef NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_BASE_H_
8 #define NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_BASE_H_
9
10 #include <stdint.h>
11
12 #include "base/compiler_specific.h"
13 #include "base/macros.h"
14 #include "net/base/net_export.h"
15 #include "net/quic/congestion_control/cubic.h"
16 #include "net/quic/congestion_control/hybrid_slow_start.h"
17 #include "net/quic/congestion_control/prr_sender.h"
18 #include "net/quic/congestion_control/send_algorithm_interface.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"
23
24 namespace net {
25
26 class RttStats;
27
28 // Maximum window to allow when doing bandwidth resumption.
29 const QuicPacketCount kMaxResumptionCongestionWindow = 200;
30
31 namespace test {
32 class TcpCubicSenderBasePeer;
33 } // namespace test
34
35 class NET_EXPORT_PRIVATE TcpCubicSenderBase : public SendAlgorithmInterface {
36 public:
37 // Reno option and max_tcp_congestion_window are provided for testing.
38 TcpCubicSenderBase(const QuicClock* clock,
39 const RttStats* rtt_stats,
40 bool reno,
41 QuicConnectionStats* stats);
42 ~TcpCubicSenderBase() override;
43
44 // Start implementation of SendAlgorithmInterface.
45 void SetFromConfig(const QuicConfig& config,
46 Perspective perspective) override;
47 void ResumeConnectionState(
48 const CachedNetworkParameters& cached_network_params,
49 bool max_bandwidth_resumption) override;
50 void SetNumEmulatedConnections(int num_connections) override;
51 void OnCongestionEvent(bool rtt_updated,
52 QuicByteCount bytes_in_flight,
53 const CongestionVector& acked_packets,
54 const CongestionVector& lost_packets) override;
55 bool OnPacketSent(QuicTime sent_time,
56 QuicByteCount bytes_in_flight,
57 QuicPacketNumber packet_number,
58 QuicByteCount bytes,
59 HasRetransmittableData is_retransmittable) override;
60 void OnRetransmissionTimeout(bool packets_retransmitted) override;
61 void OnConnectionMigration() override;
62 QuicTime::Delta TimeUntilSend(QuicTime now,
63 QuicByteCount bytes_in_flight) const override;
64 QuicBandwidth PacingRate(QuicByteCount bytes_in_flight) const override;
65 QuicBandwidth BandwidthEstimate() const override;
66 QuicTime::Delta RetransmissionDelay() const override;
67 bool InSlowStart() const override;
68 bool InRecovery() const override;
69
70 protected:
71 // Called when resuming a previous bandwidth.
72 virtual void SetCongestionWindowFromBandwidthAndRtt(QuicBandwidth bandwidth,
73 QuicTime::Delta rtt) = 0;
74
75 // Called when initializing the congestion window.
76 virtual void SetCongestionWindowInPackets(
77 QuicPacketCount congestion_window) = 0;
78
79 // Called when initializing the minimum congestion window.
80 virtual void SetMinCongestionWindowInPackets(
81 QuicPacketCount congestion_window) = 0;
82
83 // Called when slow start is exited to set SSTHRESH.
84 virtual void ExitSlowstart() = 0;
85
86 // Called when a packet is lost.
87 virtual void OnPacketLost(QuicPacketNumber largest_loss,
88 QuicByteCount lost_bytes,
89 QuicByteCount bytes_in_flight) = 0;
90
91 // Called when a packet has been acked to possibly increase the congestion
92 // window.
93 virtual void MaybeIncreaseCwnd(QuicPacketNumber acked_packet_number,
94 QuicByteCount acked_bytes,
95 QuicByteCount bytes_in_flight) = 0;
96
97 // Called when a retransmission has occured which resulted in packets
98 // being retransmitted.
99 virtual void HandleRetransmissionTimeout() = 0;
100
101 // Compute the TCP Reno beta based on the current number of connections.
102 float RenoBeta() const;
103
104 bool IsCwndLimited(QuicByteCount bytes_in_flight) const;
105
106 private:
107 friend class test::TcpCubicSenderBasePeer;
108
109 // TODO(ianswett): Remove these and migrate to OnCongestionEvent.
110 void OnPacketAcked(QuicPacketNumber acked_packet_number,
111 QuicByteCount acked_bytes,
112 QuicByteCount bytes_in_flight);
113
114 protected:
115 // TODO(rch): Make these private and clean up subclass access to them.
116 HybridSlowStart hybrid_slow_start_;
117 PrrSender prr_;
118 const RttStats* rtt_stats_;
119 QuicConnectionStats* stats_;
120
121 // If true, Reno congestion control is used instead of Cubic.
122 const bool reno_;
123
124 // Number of connections to simulate.
125 uint32_t num_connections_;
126
127 // Track the largest packet that has been sent.
128 QuicPacketNumber largest_sent_packet_number_;
129
130 // Track the largest packet that has been acked.
131 QuicPacketNumber largest_acked_packet_number_;
132
133 // Track the largest packet number outstanding when a CWND cutback occurs.
134 QuicPacketNumber largest_sent_at_last_cutback_;
135
136 // Whether to use 4 packets as the actual min, but pace lower.
137 bool min4_mode_;
138
139 // Whether the last loss event caused us to exit slowstart.
140 // Used for stats collection of slowstart_packets_lost
141 bool last_cutback_exited_slowstart_;
142
143 // When true, exit slow start with large cutback of congestion window.
144 bool slow_start_large_reduction_;
145
146 // When true, use rate based sending instead of only sending if there's CWND.
147 bool rate_based_sending_;
148
149 // When true, use unity pacing instead of PRR.
150 bool no_prr_;
151
152 private:
153 DISALLOW_COPY_AND_ASSIGN(TcpCubicSenderBase);
154 };
155
156 } // namespace net
157
158 #endif // NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_BASE_H_
OLDNEW
« no previous file with comments | « net/quic/congestion_control/send_algorithm_simulator.cc ('k') | net/quic/congestion_control/tcp_cubic_sender_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698