| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 // Cubic algorithm, helper class to TCP cubic. | |
| 6 // For details see http://netsrv.csc.ncsu.edu/export/cubic_a_new_tcp_2008.pdf. | |
| 7 | |
| 8 #ifndef NET_QUIC_CONGESTION_CONTROL_CUBIC_BYTES_H_ | |
| 9 #define NET_QUIC_CONGESTION_CONTROL_CUBIC_BYTES_H_ | |
| 10 | |
| 11 #include <stdint.h> | |
| 12 | |
| 13 #include "base/macros.h" | |
| 14 #include "net/base/net_export.h" | |
| 15 #include "net/quic/quic_bandwidth.h" | |
| 16 #include "net/quic/quic_clock.h" | |
| 17 #include "net/quic/quic_connection_stats.h" | |
| 18 #include "net/quic/quic_time.h" | |
| 19 | |
| 20 namespace net { | |
| 21 | |
| 22 class NET_EXPORT_PRIVATE CubicBytes { | |
| 23 public: | |
| 24 explicit CubicBytes(const QuicClock* clock); | |
| 25 | |
| 26 void SetNumConnections(int num_connections); | |
| 27 | |
| 28 // Call after a timeout to reset the cubic state. | |
| 29 void Reset(); | |
| 30 | |
| 31 // Compute a new congestion window to use after a loss event. | |
| 32 // Returns the new congestion window in packets. The new congestion window is | |
| 33 // a multiplicative decrease of our current window. | |
| 34 QuicByteCount CongestionWindowAfterPacketLoss(QuicPacketCount current); | |
| 35 | |
| 36 // Compute a new congestion window to use after a received ACK. | |
| 37 // Returns the new congestion window in bytes. The new congestion window | |
| 38 // follows a cubic function that depends on the time passed since last packet | |
| 39 // loss. | |
| 40 QuicByteCount CongestionWindowAfterAck(QuicByteCount acked_bytes, | |
| 41 QuicByteCount current, | |
| 42 QuicTime::Delta delay_min); | |
| 43 | |
| 44 // Call on ack arrival when sender is unable to use the available congestion | |
| 45 // window. Resets Cubic state during quiescence. | |
| 46 void OnApplicationLimited(); | |
| 47 | |
| 48 private: | |
| 49 static const QuicTime::Delta MaxCubicTimeInterval() { | |
| 50 return QuicTime::Delta::FromMilliseconds(30); | |
| 51 } | |
| 52 | |
| 53 // Compute the TCP Cubic alpha and beta based on the current number of | |
| 54 // connections. | |
| 55 float Alpha() const; | |
| 56 float Beta() const; | |
| 57 | |
| 58 const QuicClock* clock_; | |
| 59 | |
| 60 // Number of connections to simulate. | |
| 61 int num_connections_; | |
| 62 | |
| 63 // Time when this cycle started, after last loss event. | |
| 64 QuicTime epoch_; | |
| 65 | |
| 66 // Time when we updated last_congestion_window. | |
| 67 QuicTime last_update_time_; | |
| 68 | |
| 69 // Last congestion window used. | |
| 70 QuicByteCount last_congestion_window_; | |
| 71 | |
| 72 // Max congestion window used just before last loss event. | |
| 73 // Note: to improve fairness to other streams an additional back off is | |
| 74 // applied to this value if the new value is below our latest value. | |
| 75 QuicByteCount last_max_congestion_window_; | |
| 76 | |
| 77 // Number of acked bytes since the cycle started (epoch). | |
| 78 QuicByteCount acked_bytes_count_; | |
| 79 | |
| 80 // TCP Reno equivalent congestion window in packets. | |
| 81 QuicByteCount estimated_tcp_congestion_window_; | |
| 82 | |
| 83 // Origin point of cubic function. | |
| 84 QuicByteCount origin_point_congestion_window_; | |
| 85 | |
| 86 // Time to origin point of cubic function in 2^10 fractions of a second. | |
| 87 uint32_t time_to_origin_point_; | |
| 88 | |
| 89 // Last congestion window in packets computed by cubic function. | |
| 90 QuicByteCount last_target_congestion_window_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(CubicBytes); | |
| 93 }; | |
| 94 | |
| 95 } // namespace net | |
| 96 | |
| 97 #endif // NET_QUIC_CONGESTION_CONTROL_CUBIC_BYTES_H_ | |
| OLD | NEW |