| 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 15 matching lines...) Expand all Loading... |
| 26 class QuicClock; | 26 class QuicClock; |
| 27 class ReceiveAlgorithmInterface; | 27 class ReceiveAlgorithmInterface; |
| 28 | 28 |
| 29 class QuicCongestionManager { | 29 class QuicCongestionManager { |
| 30 public: | 30 public: |
| 31 QuicCongestionManager(const QuicClock* clock, | 31 QuicCongestionManager(const QuicClock* clock, |
| 32 CongestionFeedbackType congestion_type); | 32 CongestionFeedbackType congestion_type); |
| 33 virtual ~QuicCongestionManager(); | 33 virtual ~QuicCongestionManager(); |
| 34 | 34 |
| 35 // Called when we have received an ack frame from peer. | 35 // Called when we have received an ack frame from peer. |
| 36 virtual void OnIncomingAckFrame(const QuicAckFrame& frame); | 36 virtual void OnIncomingAckFrame(const QuicAckFrame& frame, |
| 37 QuicTime ack_receive_time); |
| 37 | 38 |
| 38 // Called when a congestion feedback frame is received from peer. | 39 // Called when a congestion feedback frame is received from peer. |
| 39 virtual void OnIncomingQuicCongestionFeedbackFrame( | 40 virtual void OnIncomingQuicCongestionFeedbackFrame( |
| 40 const QuicCongestionFeedbackFrame& frame); | 41 const QuicCongestionFeedbackFrame& frame, |
| 42 QuicTime feedback_receive_time); |
| 41 | 43 |
| 42 // 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 |
| 43 // the number of bytes sent and if they were retransmitted. | 45 // the number of bytes sent and if they were retransmitted. |
| 44 virtual void SentPacket(QuicPacketSequenceNumber sequence_number, | 46 virtual void SentPacket(QuicPacketSequenceNumber sequence_number, |
| 47 QuicTime sent_time, |
| 45 QuicByteCount bytes, | 48 QuicByteCount bytes, |
| 46 bool is_retransmission); | 49 bool is_retransmission); |
| 47 | 50 |
| 48 // Calculate the time until we can send the next packet to the wire. | 51 // Calculate the time until we can send the next packet to the wire. |
| 49 // Note 1: When kUnknownWaitTime is returned, there is no need to poll | 52 // Note 1: When kUnknownWaitTime is returned, there is no need to poll |
| 50 // TimeUntilSend again until we receive an OnIncomingAckFrame event. | 53 // TimeUntilSend again until we receive an OnIncomingAckFrame event. |
| 51 // Note 2: Send algorithms may or may not use |retransmit| in their | 54 // Note 2: Send algorithms may or may not use |retransmit| in their |
| 52 // calculations. | 55 // calculations. |
| 53 virtual QuicTime::Delta TimeUntilSend(bool is_retransmission); | 56 virtual QuicTime::Delta TimeUntilSend(QuicTime now, |
| 57 bool is_retransmission); |
| 54 | 58 |
| 55 // Should be called before sending an ACK packet, to decide if we need | 59 // Should be called before sending an ACK packet, to decide if we need |
| 56 // to attach a QuicCongestionFeedbackFrame block. | 60 // to attach a QuicCongestionFeedbackFrame block. |
| 57 // Returns false if no QuicCongestionFeedbackFrame block is needed. | 61 // Returns false if no QuicCongestionFeedbackFrame block is needed. |
| 58 // Otherwise fills in feedback and returns true. | 62 // Otherwise fills in feedback and returns true. |
| 59 virtual bool GenerateCongestionFeedback( | 63 virtual bool GenerateCongestionFeedback( |
| 60 QuicCongestionFeedbackFrame* feedback); | 64 QuicCongestionFeedbackFrame* feedback); |
| 61 | 65 |
| 62 // Should be called for each incoming packet. | 66 // Should be called for each incoming packet. |
| 63 // bytes: the packet size in bytes including IP headers. | 67 // bytes: the packet size in bytes including IP headers. |
| 64 // sequence_number: the unique sequence number from the QUIC packet header. | 68 // sequence_number: the unique sequence number from the QUIC packet header. |
| 65 // timestamp: the arrival time of the packet. | 69 // timestamp: the arrival time of the packet. |
| 66 // revived: true if the packet was lost and then recovered with help of a | 70 // revived: true if the packet was lost and then recovered with help of a |
| 67 // FEC packet. | 71 // FEC packet. |
| 68 virtual void RecordIncomingPacket(QuicByteCount bytes, | 72 virtual void RecordIncomingPacket(QuicByteCount bytes, |
| 69 QuicPacketSequenceNumber sequence_number, | 73 QuicPacketSequenceNumber sequence_number, |
| 70 QuicTime timestamp, | 74 QuicTime timestamp, |
| 71 bool revived); | 75 bool revived); |
| 72 | 76 |
| 73 const QuicTime::Delta DefaultRetransmissionTime(); | 77 const QuicTime::Delta DefaultRetransmissionTime(); |
| 74 | 78 |
| 75 const QuicTime::Delta GetRetransmissionDelay( | 79 const QuicTime::Delta GetRetransmissionDelay( |
| 80 size_t unacked_packets_count, |
| 76 size_t number_retransmissions); | 81 size_t number_retransmissions); |
| 77 | 82 |
| 78 private: | 83 private: |
| 79 friend class test::QuicConnectionPeer; | 84 friend class test::QuicConnectionPeer; |
| 80 friend class test::QuicCongestionManagerPeer; | 85 friend class test::QuicCongestionManagerPeer; |
| 81 typedef std::map<QuicPacketSequenceNumber, size_t> PendingPacketsMap; | 86 typedef std::map<QuicPacketSequenceNumber, size_t> PendingPacketsMap; |
| 82 | 87 |
| 83 // TODO(pwestin): Currently only used for testing. How do we surface this? | 88 QuicBandwidth SentBandwidth(QuicTime feedback_receive_time) const; |
| 84 QuicBandwidth SentBandwidth() const; | |
| 85 // TODO(pwestin): Currently only used for testing. How do we surface this? | 89 // TODO(pwestin): Currently only used for testing. How do we surface this? |
| 86 QuicBandwidth BandwidthEstimate(); | 90 QuicBandwidth BandwidthEstimate(); |
| 87 void CleanupPacketHistory(); | 91 void CleanupPacketHistory(); |
| 88 | 92 |
| 89 const QuicClock* clock_; | 93 const QuicClock* clock_; |
| 90 scoped_ptr<ReceiveAlgorithmInterface> receive_algorithm_; | 94 scoped_ptr<ReceiveAlgorithmInterface> receive_algorithm_; |
| 91 scoped_ptr<SendAlgorithmInterface> send_algorithm_; | 95 scoped_ptr<SendAlgorithmInterface> send_algorithm_; |
| 92 SendAlgorithmInterface::SentPacketsMap packet_history_map_; | 96 SendAlgorithmInterface::SentPacketsMap packet_history_map_; |
| 93 PendingPacketsMap pending_packets_; | 97 PendingPacketsMap pending_packets_; |
| 98 QuicPacketSequenceNumber largest_missing_; |
| 94 | 99 |
| 95 DISALLOW_COPY_AND_ASSIGN(QuicCongestionManager); | 100 DISALLOW_COPY_AND_ASSIGN(QuicCongestionManager); |
| 96 }; | 101 }; |
| 97 | 102 |
| 98 } // namespace net | 103 } // namespace net |
| 99 | 104 |
| 100 #endif // NET_QUIC_CONGESTION_CONTROL_QUIC_CONGESTION_MANAGER_H_ | 105 #endif // NET_QUIC_CONGESTION_CONTROL_QUIC_CONGESTION_MANAGER_H_ |
| OLD | NEW |