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 // The pure virtual class for send side congestion control algorithm. | 5 // The pure virtual class for send side congestion control algorithm. |
6 | 6 |
7 #ifndef NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_INTERFACE_H_ | 7 #ifndef NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_INTERFACE_H_ |
8 #define NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_INTERFACE_H_ | 8 #define NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_INTERFACE_H_ |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <map> | 11 #include <map> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
15 #include "net/quic/quic_bandwidth.h" | 15 #include "net/quic/quic_bandwidth.h" |
16 #include "net/quic/quic_clock.h" | 16 #include "net/quic/quic_clock.h" |
17 #include "net/quic/quic_config.h" | 17 #include "net/quic/quic_config.h" |
18 #include "net/quic/quic_connection_stats.h" | 18 #include "net/quic/quic_connection_stats.h" |
19 #include "net/quic/quic_protocol.h" | 19 #include "net/quic/quic_protocol.h" |
20 #include "net/quic/quic_time.h" | 20 #include "net/quic/quic_time.h" |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 | 23 |
24 class RttStats; | 24 class RttStats; |
25 | 25 |
26 class NET_EXPORT_PRIVATE SendAlgorithmInterface { | 26 class NET_EXPORT_PRIVATE SendAlgorithmInterface { |
27 public: | 27 public: |
28 typedef std::map<QuicPacketSequenceNumber, TransmissionInfo> CongestionMap; | 28 // A sorted vector of packets. |
| 29 typedef std::vector<std::pair<QuicPacketSequenceNumber, TransmissionInfo>> |
| 30 CongestionVector; |
29 | 31 |
30 static SendAlgorithmInterface* Create(const QuicClock* clock, | 32 static SendAlgorithmInterface* Create(const QuicClock* clock, |
31 const RttStats* rtt_stats, | 33 const RttStats* rtt_stats, |
32 CongestionControlType type, | 34 CongestionControlType type, |
33 QuicConnectionStats* stats); | 35 QuicConnectionStats* stats); |
34 | 36 |
35 virtual ~SendAlgorithmInterface() {} | 37 virtual ~SendAlgorithmInterface() {} |
36 | 38 |
37 virtual void SetFromConfig(const QuicConfig& config, bool is_server) = 0; | 39 virtual void SetFromConfig(const QuicConfig& config, bool is_server) = 0; |
38 | 40 |
39 // Called when we receive congestion feedback from remote peer. | 41 // Called when we receive congestion feedback from remote peer. |
40 virtual void OnIncomingQuicCongestionFeedbackFrame( | 42 virtual void OnIncomingQuicCongestionFeedbackFrame( |
41 const QuicCongestionFeedbackFrame& feedback, | 43 const QuicCongestionFeedbackFrame& feedback, |
42 QuicTime feedback_receive_time) = 0; | 44 QuicTime feedback_receive_time) = 0; |
43 | 45 |
44 // Indicates an update to the congestion state, caused either by an incoming | 46 // Indicates an update to the congestion state, caused either by an incoming |
45 // ack or loss event timeout. |rtt_updated| indicates whether a new | 47 // ack or loss event timeout. |rtt_updated| indicates whether a new |
46 // latest_rtt sample has been taken, |byte_in_flight| the bytes in flight | 48 // latest_rtt sample has been taken, |byte_in_flight| the bytes in flight |
47 // prior to the congestion event. |acked_packets| and |lost_packets| are | 49 // prior to the congestion event. |acked_packets| and |lost_packets| are |
48 // any packets considered acked or lost as a result of the congestion event. | 50 // any packets considered acked or lost as a result of the congestion event. |
49 virtual void OnCongestionEvent(bool rtt_updated, | 51 virtual void OnCongestionEvent(bool rtt_updated, |
50 QuicByteCount bytes_in_flight, | 52 QuicByteCount bytes_in_flight, |
51 const CongestionMap& acked_packets, | 53 const CongestionVector& acked_packets, |
52 const CongestionMap& lost_packets) = 0; | 54 const CongestionVector& lost_packets) = 0; |
53 | 55 |
54 // Inform that we sent |bytes| to the wire, and if the packet is | 56 // Inform that we sent |bytes| to the wire, and if the packet is |
55 // retransmittable. Returns true if the packet should be tracked by the | 57 // retransmittable. Returns true if the packet should be tracked by the |
56 // congestion manager and included in bytes_in_flight, false otherwise. | 58 // congestion manager and included in bytes_in_flight, false otherwise. |
57 // |bytes_in_flight| is the number of bytes in flight before the packet was | 59 // |bytes_in_flight| is the number of bytes in flight before the packet was |
58 // sent. | 60 // sent. |
59 // Note: this function must be called for every packet sent to the wire. | 61 // Note: this function must be called for every packet sent to the wire. |
60 virtual bool OnPacketSent(QuicTime sent_time, | 62 virtual bool OnPacketSent(QuicTime sent_time, |
61 QuicByteCount bytes_in_flight, | 63 QuicByteCount bytes_in_flight, |
62 QuicPacketSequenceNumber sequence_number, | 64 QuicPacketSequenceNumber sequence_number, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // aka ssthresh. Some send algorithms do not define a slow start | 106 // aka ssthresh. Some send algorithms do not define a slow start |
105 // threshold and will return 0. | 107 // threshold and will return 0. |
106 virtual QuicByteCount GetSlowStartThreshold() const = 0; | 108 virtual QuicByteCount GetSlowStartThreshold() const = 0; |
107 | 109 |
108 virtual CongestionControlType GetCongestionControlType() const = 0; | 110 virtual CongestionControlType GetCongestionControlType() const = 0; |
109 }; | 111 }; |
110 | 112 |
111 } // namespace net | 113 } // namespace net |
112 | 114 |
113 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_INTERFACE_H_ | 115 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_INTERFACE_H_ |
OLD | NEW |