| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Cubic algorithm, helper class to TCP cubic. | 5 // Cubic algorithm, helper class to TCP cubic. |
| 6 // For details see http://netsrv.csc.ncsu.edu/export/cubic_a_new_tcp_2008.pdf. | 6 // For details see http://netsrv.csc.ncsu.edu/export/cubic_a_new_tcp_2008.pdf. |
| 7 | 7 |
| 8 #ifndef NET_QUIC_CONGESTION_CONTROL_CUBIC_H_ | 8 #ifndef NET_QUIC_CONGESTION_CONTROL_CUBIC_H_ |
| 9 #define NET_QUIC_CONGESTION_CONTROL_CUBIC_H_ | 9 #define NET_QUIC_CONGESTION_CONTROL_CUBIC_H_ |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 #include "net/quic/quic_clock.h" | 13 #include "net/quic/quic_clock.h" |
| 14 #include "net/quic/quic_connection_stats.h" | 14 #include "net/quic/quic_connection_stats.h" |
| 15 #include "net/quic/quic_time.h" | 15 #include "net/quic/quic_time.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 // TCP congestion window in QUIC is in packets, not bytes. | 19 // TCP congestion window in QUIC is in packets, not bytes. |
| 20 typedef uint32 QuicTcpCongestionWindow; | 20 typedef uint32 QuicTcpCongestionWindow; |
| 21 | 21 |
| 22 class NET_EXPORT_PRIVATE Cubic { | 22 class NET_EXPORT_PRIVATE Cubic { |
| 23 public: | 23 public: |
| 24 Cubic(const QuicClock* clock, QuicConnectionStats* stats); | 24 Cubic(const QuicClock* clock, QuicConnectionStats* stats); |
| 25 | 25 |
| 26 void SetNumConnections(int num_connections); |
| 27 |
| 26 // Call after a timeout to reset the cubic state. | 28 // Call after a timeout to reset the cubic state. |
| 27 void Reset(); | 29 void Reset(); |
| 28 | 30 |
| 29 // Compute a new congestion window to use after a loss event. | 31 // Compute a new congestion window to use after a loss event. |
| 30 // Returns the new congestion window in packets. The new congestion window is | 32 // Returns the new congestion window in packets. The new congestion window is |
| 31 // a multiplicative decrease of our current window. | 33 // a multiplicative decrease of our current window. |
| 32 QuicTcpCongestionWindow CongestionWindowAfterPacketLoss( | 34 QuicTcpCongestionWindow CongestionWindowAfterPacketLoss( |
| 33 QuicTcpCongestionWindow current); | 35 QuicTcpCongestionWindow current); |
| 34 | 36 |
| 35 // Compute a new congestion window to use after a received ACK. | 37 // Compute a new congestion window to use after a received ACK. |
| 36 // Returns the new congestion window in packets. The new congestion window | 38 // Returns the new congestion window in packets. The new congestion window |
| 37 // follows a cubic function that depends on the time passed since last | 39 // follows a cubic function that depends on the time passed since last |
| 38 // packet loss. | 40 // packet loss. |
| 39 QuicTcpCongestionWindow CongestionWindowAfterAck( | 41 QuicTcpCongestionWindow CongestionWindowAfterAck( |
| 40 QuicTcpCongestionWindow current, | 42 QuicTcpCongestionWindow current, |
| 41 QuicTime::Delta delay_min); | 43 QuicTime::Delta delay_min); |
| 42 | 44 |
| 43 private: | 45 private: |
| 44 static const QuicTime::Delta MaxCubicTimeInterval() { | 46 static const QuicTime::Delta MaxCubicTimeInterval() { |
| 45 return QuicTime::Delta::FromMilliseconds(30); | 47 return QuicTime::Delta::FromMilliseconds(30); |
| 46 } | 48 } |
| 47 | 49 |
| 50 // Compute the TCP Cubic alpha and beta based on the current number of |
| 51 // connections. |
| 52 float Alpha() const; |
| 53 float Beta() const; |
| 54 |
| 48 // Update congestion control variables in QuicConnectionStats. | 55 // Update congestion control variables in QuicConnectionStats. |
| 49 void UpdateCongestionControlStats(QuicTcpCongestionWindow new_cubic_mode_cwnd, | 56 void UpdateCongestionControlStats(QuicTcpCongestionWindow new_cubic_mode_cwnd, |
| 50 QuicTcpCongestionWindow new_reno_mode_cwnd); | 57 QuicTcpCongestionWindow new_reno_mode_cwnd); |
| 51 const QuicClock* clock_; | 58 const QuicClock* clock_; |
| 52 | 59 |
| 60 // Number of connections to simulate. |
| 61 int num_connections_; |
| 62 |
| 53 // Time when this cycle started, after last loss event. | 63 // Time when this cycle started, after last loss event. |
| 54 QuicTime epoch_; | 64 QuicTime epoch_; |
| 55 | 65 |
| 56 // Time when we updated last_congestion_window. | 66 // Time when we updated last_congestion_window. |
| 57 QuicTime last_update_time_; | 67 QuicTime last_update_time_; |
| 58 | 68 |
| 59 // Last congestion window (in packets) used. | 69 // Last congestion window (in packets) used. |
| 60 QuicTcpCongestionWindow last_congestion_window_; | 70 QuicTcpCongestionWindow last_congestion_window_; |
| 61 | 71 |
| 62 // Max congestion window (in packets) used just before last loss event. | 72 // Max congestion window (in packets) used just before last loss event. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 | 91 |
| 82 // QuicConnectionStats includes congestion control related stats. | 92 // QuicConnectionStats includes congestion control related stats. |
| 83 QuicConnectionStats* stats_; | 93 QuicConnectionStats* stats_; |
| 84 | 94 |
| 85 DISALLOW_COPY_AND_ASSIGN(Cubic); | 95 DISALLOW_COPY_AND_ASSIGN(Cubic); |
| 86 }; | 96 }; |
| 87 | 97 |
| 88 } // namespace net | 98 } // namespace net |
| 89 | 99 |
| 90 #endif // NET_QUIC_CONGESTION_CONTROL_CUBIC_H_ | 100 #endif // NET_QUIC_CONGESTION_CONTROL_CUBIC_H_ |
| OLD | NEW |