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 // This is the interface from the QuicConnection into the QUIC | 5 // This is the interface from the QuicConnection into the QUIC |
6 // congestion control code. It wraps the SendAlgorithmInterface and | 6 // congestion control code. It wraps the SendAlgorithmInterface and |
7 // ReceiveAlgorithmInterface and provides a single interface | 7 // ReceiveAlgorithmInterface and provides a single interface |
8 // for consumers. | 8 // for consumers. |
9 | 9 |
10 #ifndef NET_QUIC_CONGESTION_CONTROL_QUIC_CONGESTION_MANAGER_H_ | 10 #ifndef NET_QUIC_CONGESTION_CONTROL_QUIC_CONGESTION_MANAGER_H_ |
(...skipping 28 matching lines...) Expand all Loading... |
39 // Called when a congestion feedback frame is received from peer. | 39 // Called when a congestion feedback frame is received from peer. |
40 virtual void OnIncomingQuicCongestionFeedbackFrame( | 40 virtual void OnIncomingQuicCongestionFeedbackFrame( |
41 const QuicCongestionFeedbackFrame& frame, | 41 const QuicCongestionFeedbackFrame& frame, |
42 QuicTime feedback_receive_time); | 42 QuicTime feedback_receive_time); |
43 | 43 |
44 // Called when we have sent bytes to the peer. This informs the manager both | 44 // Called when we have sent bytes to the peer. This informs the manager both |
45 // the number of bytes sent and if they were retransmitted. | 45 // the number of bytes sent and if they were retransmitted. |
46 virtual void SentPacket(QuicPacketSequenceNumber sequence_number, | 46 virtual void SentPacket(QuicPacketSequenceNumber sequence_number, |
47 QuicTime sent_time, | 47 QuicTime sent_time, |
48 QuicByteCount bytes, | 48 QuicByteCount bytes, |
49 bool is_retransmission, | 49 bool is_retransmission); |
50 bool has_retransmittable_data); | 50 |
| 51 // Called when a packet is timed out. |
| 52 virtual void AbandoningPacket(QuicPacketSequenceNumber sequence_number); |
51 | 53 |
52 // Calculate the time until we can send the next packet to the wire. | 54 // Calculate the time until we can send the next packet to the wire. |
53 // Note 1: When kUnknownWaitTime is returned, there is no need to poll | 55 // Note 1: When kUnknownWaitTime is returned, there is no need to poll |
54 // TimeUntilSend again until we receive an OnIncomingAckFrame event. | 56 // TimeUntilSend again until we receive an OnIncomingAckFrame event. |
55 // Note 2: Send algorithms may or may not use |retransmit| in their | 57 // Note 2: Send algorithms may or may not use |retransmit| in their |
56 // calculations. | 58 // calculations. |
57 virtual QuicTime::Delta TimeUntilSend(QuicTime now, | 59 virtual QuicTime::Delta TimeUntilSend(QuicTime now, |
58 bool is_retransmission); | 60 bool is_retransmission, |
| 61 bool has_retransmittable_data); |
59 | 62 |
60 // Should be called before sending an ACK packet, to decide if we need | 63 // Should be called before sending an ACK packet, to decide if we need |
61 // to attach a QuicCongestionFeedbackFrame block. | 64 // to attach a QuicCongestionFeedbackFrame block. |
62 // Returns false if no QuicCongestionFeedbackFrame block is needed. | 65 // Returns false if no QuicCongestionFeedbackFrame block is needed. |
63 // Otherwise fills in feedback and returns true. | 66 // Otherwise fills in feedback and returns true. |
64 virtual bool GenerateCongestionFeedback( | 67 virtual bool GenerateCongestionFeedback( |
65 QuicCongestionFeedbackFrame* feedback); | 68 QuicCongestionFeedbackFrame* feedback); |
66 | 69 |
67 // Should be called for each incoming packet. | 70 // Should be called for each incoming packet. |
68 // bytes: the packet size in bytes including IP headers. | 71 // bytes: the packet size in bytes including Quic Headers. |
69 // sequence_number: the unique sequence number from the QUIC packet header. | 72 // sequence_number: the unique sequence number from the QUIC packet header. |
70 // timestamp: the arrival time of the packet. | 73 // timestamp: the arrival time of the packet. |
71 // revived: true if the packet was lost and then recovered with help of a | 74 // revived: true if the packet was lost and then recovered with help of a |
72 // FEC packet. | 75 // FEC packet. |
73 virtual void RecordIncomingPacket(QuicByteCount bytes, | 76 virtual void RecordIncomingPacket(QuicByteCount bytes, |
74 QuicPacketSequenceNumber sequence_number, | 77 QuicPacketSequenceNumber sequence_number, |
75 QuicTime timestamp, | 78 QuicTime timestamp, |
76 bool revived); | 79 bool revived); |
77 | 80 |
78 const QuicTime::Delta DefaultRetransmissionTime(); | 81 const QuicTime::Delta DefaultRetransmissionTime(); |
79 | 82 |
80 const QuicTime::Delta GetRetransmissionDelay( | 83 const QuicTime::Delta GetRetransmissionDelay( |
81 size_t unacked_packets_count, | 84 size_t unacked_packets_count, |
82 size_t number_retransmissions); | 85 size_t number_retransmissions); |
83 | 86 |
| 87 // Returns the estimated smoothed RTT calculated by the congestion algorithm. |
| 88 const QuicTime::Delta SmoothedRtt(); |
| 89 |
| 90 // Returns the estimated bandwidth calculated by the congestion algorithm. |
| 91 QuicBandwidth BandwidthEstimate(); |
| 92 |
84 private: | 93 private: |
85 friend class test::QuicConnectionPeer; | 94 friend class test::QuicConnectionPeer; |
86 friend class test::QuicCongestionManagerPeer; | 95 friend class test::QuicCongestionManagerPeer; |
87 typedef std::map<QuicPacketSequenceNumber, size_t> PendingPacketsMap; | 96 typedef std::map<QuicPacketSequenceNumber, size_t> PendingPacketsMap; |
88 | 97 |
| 98 // Get the current(last) rtt. Infinite is returned if invalid. |
| 99 const QuicTime::Delta rtt(); |
| 100 |
89 QuicBandwidth SentBandwidth(QuicTime feedback_receive_time) const; | 101 QuicBandwidth SentBandwidth(QuicTime feedback_receive_time) const; |
90 // TODO(pwestin): Currently only used for testing. How do we surface this? | |
91 QuicBandwidth BandwidthEstimate(); | |
92 void CleanupPacketHistory(); | 102 void CleanupPacketHistory(); |
93 | 103 |
94 const QuicClock* clock_; | 104 const QuicClock* clock_; |
95 scoped_ptr<ReceiveAlgorithmInterface> receive_algorithm_; | 105 scoped_ptr<ReceiveAlgorithmInterface> receive_algorithm_; |
96 scoped_ptr<SendAlgorithmInterface> send_algorithm_; | 106 scoped_ptr<SendAlgorithmInterface> send_algorithm_; |
97 SendAlgorithmInterface::SentPacketsMap packet_history_map_; | 107 SendAlgorithmInterface::SentPacketsMap packet_history_map_; |
98 PendingPacketsMap pending_packets_; | 108 PendingPacketsMap pending_packets_; |
99 QuicPacketSequenceNumber largest_missing_; | 109 QuicPacketSequenceNumber largest_missing_; |
| 110 QuicTime::Delta current_rtt_; |
100 | 111 |
101 DISALLOW_COPY_AND_ASSIGN(QuicCongestionManager); | 112 DISALLOW_COPY_AND_ASSIGN(QuicCongestionManager); |
102 }; | 113 }; |
103 | 114 |
104 } // namespace net | 115 } // namespace net |
105 | 116 |
106 #endif // NET_QUIC_CONGESTION_CONTROL_QUIC_CONGESTION_MANAGER_H_ | 117 #endif // NET_QUIC_CONGESTION_CONTROL_QUIC_CONGESTION_MANAGER_H_ |
OLD | NEW |