| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // A send algorithm which adds pacing on top of an another send algorithm. | 5 // A send algorithm which adds pacing on top of an another send algorithm. |
| 6 // It uses the underlying sender's bandwidth estimate to determine the | 6 // It uses the underlying sender's bandwidth estimate to determine the |
| 7 // pacing rate to be used. It also takes into consideration the expected | 7 // pacing rate to be used. It also takes into consideration the expected |
| 8 // resolution of the underlying alarm mechanism to ensure that alarms are | 8 // resolution of the underlying alarm mechanism to ensure that alarms are |
| 9 // not set too aggressively, and to smooth out variations. | 9 // not set too aggressively, and to smooth out variations. |
| 10 | 10 |
| 11 #ifndef NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ | 11 #ifndef NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ |
| 12 #define NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ | 12 #define NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "net/quic/congestion_control/send_algorithm_interface.h" | 18 #include "net/quic/congestion_control/send_algorithm_interface.h" |
| 19 #include "net/quic/quic_bandwidth.h" | 19 #include "net/quic/quic_bandwidth.h" |
| 20 #include "net/quic/quic_config.h" | 20 #include "net/quic/quic_config.h" |
| 21 #include "net/quic/quic_protocol.h" | 21 #include "net/quic/quic_protocol.h" |
| 22 #include "net/quic/quic_time.h" | 22 #include "net/quic/quic_time.h" |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 | 25 |
| 26 class NET_EXPORT_PRIVATE PacingSender : public SendAlgorithmInterface { | 26 class NET_EXPORT_PRIVATE PacingSender : public SendAlgorithmInterface { |
| 27 public: | 27 public: |
| 28 // Create a PacingSender to wrap the specified sender. |alarm_granularity| |
| 29 // indicates to the pacer to send that far into the future, since it should |
| 30 // not expect a callback before that time delta. |initial_packet_burst| is |
| 31 // the number of packets sent without pacing after quiescence. |
| 28 PacingSender(SendAlgorithmInterface* sender, | 32 PacingSender(SendAlgorithmInterface* sender, |
| 29 QuicTime::Delta alarm_granularity); | 33 QuicTime::Delta alarm_granularity, |
| 34 uint32 initial_packet_burst); |
| 30 virtual ~PacingSender(); | 35 virtual ~PacingSender(); |
| 31 | 36 |
| 32 // SendAlgorithmInterface methods. | 37 // SendAlgorithmInterface methods. |
| 33 virtual void SetFromConfig(const QuicConfig& config, bool is_server) OVERRIDE; | 38 virtual void SetFromConfig(const QuicConfig& config, bool is_server) OVERRIDE; |
| 34 virtual void OnIncomingQuicCongestionFeedbackFrame( | 39 virtual void OnIncomingQuicCongestionFeedbackFrame( |
| 35 const QuicCongestionFeedbackFrame& feedback, | 40 const QuicCongestionFeedbackFrame& feedback, |
| 36 QuicTime feedback_receive_time) OVERRIDE; | 41 QuicTime feedback_receive_time) OVERRIDE; |
| 37 virtual void OnCongestionEvent(bool rtt_updated, | 42 virtual void OnCongestionEvent(bool rtt_updated, |
| 38 QuicByteCount bytes_in_flight, | 43 QuicByteCount bytes_in_flight, |
| 39 const CongestionMap& acked_packets, | 44 const CongestionMap& acked_packets, |
| 40 const CongestionMap& lost_packets) OVERRIDE; | 45 const CongestionMap& lost_packets) OVERRIDE; |
| 41 virtual bool OnPacketSent(QuicTime sent_time, | 46 virtual bool OnPacketSent(QuicTime sent_time, |
| 42 QuicByteCount bytes_in_flight, | 47 QuicByteCount bytes_in_flight, |
| 43 QuicPacketSequenceNumber sequence_number, | 48 QuicPacketSequenceNumber sequence_number, |
| 44 QuicByteCount bytes, | 49 QuicByteCount bytes, |
| 45 HasRetransmittableData is_retransmittable) OVERRIDE; | 50 HasRetransmittableData is_retransmittable) OVERRIDE; |
| 46 virtual void OnRetransmissionTimeout(bool packets_retransmitted) OVERRIDE; | 51 virtual void OnRetransmissionTimeout(bool packets_retransmitted) OVERRIDE; |
| 47 virtual void RevertRetransmissionTimeout() OVERRIDE; | 52 virtual void RevertRetransmissionTimeout() OVERRIDE; |
| 48 virtual QuicTime::Delta TimeUntilSend( | 53 virtual QuicTime::Delta TimeUntilSend( |
| 49 QuicTime now, | 54 QuicTime now, |
| 50 QuicByteCount bytes_in_flight, | 55 QuicByteCount bytes_in_flight, |
| 51 HasRetransmittableData has_retransmittable_data) const OVERRIDE; | 56 HasRetransmittableData has_retransmittable_data) const OVERRIDE; |
| 52 virtual QuicBandwidth BandwidthEstimate() const OVERRIDE; | 57 virtual QuicBandwidth BandwidthEstimate() const OVERRIDE; |
| 58 virtual bool HasReliableBandwidthEstimate() const OVERRIDE; |
| 53 virtual QuicTime::Delta RetransmissionDelay() const OVERRIDE; | 59 virtual QuicTime::Delta RetransmissionDelay() const OVERRIDE; |
| 54 virtual QuicByteCount GetCongestionWindow() const OVERRIDE; | 60 virtual QuicByteCount GetCongestionWindow() const OVERRIDE; |
| 55 | 61 |
| 56 private: | 62 private: |
| 57 scoped_ptr<SendAlgorithmInterface> sender_; // Underlying sender. | 63 scoped_ptr<SendAlgorithmInterface> sender_; // Underlying sender. |
| 58 QuicTime::Delta alarm_granularity_; | 64 QuicTime::Delta alarm_granularity_; |
| 65 uint32 initial_packet_burst_; |
| 66 uint32 burst_tokens_; |
| 59 // Send time of the last packet considered delayed. | 67 // Send time of the last packet considered delayed. |
| 60 QuicTime last_delayed_packet_sent_time_; | 68 QuicTime last_delayed_packet_sent_time_; |
| 61 QuicTime next_packet_send_time_; // When can the next packet be sent. | 69 QuicTime next_packet_send_time_; // When can the next packet be sent. |
| 62 mutable bool was_last_send_delayed_; // True when the last send was delayed. | 70 mutable bool was_last_send_delayed_; // True when the last send was delayed. |
| 63 bool has_valid_rtt_; // True if we have at least one RTT update. | 71 bool has_valid_rtt_; // True if we have at least one RTT update. |
| 64 | 72 |
| 65 DISALLOW_COPY_AND_ASSIGN(PacingSender); | 73 DISALLOW_COPY_AND_ASSIGN(PacingSender); |
| 66 }; | 74 }; |
| 67 | 75 |
| 68 } // namespace net | 76 } // namespace net |
| 69 | 77 |
| 70 #endif // NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ | 78 #endif // NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ |
| OLD | NEW |