[email protected] | ec86d546 | 2013-11-17 16:04:49 | [diff] [blame^] | 1 | // Copyright 2013 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 | // 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 |
| 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 |
| 9 | // not set too aggressively, and to smooth out variations. |
| 10 | |
| 11 | #ifndef NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ |
| 12 | #define NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ |
| 13 | |
| 14 | #include <map> |
| 15 | |
| 16 | #include "base/basictypes.h" |
| 17 | #include "base/memory/scoped_ptr.h" |
| 18 | #include "net/quic/congestion_control/send_algorithm_interface.h" |
| 19 | #include "net/quic/quic_bandwidth.h" |
| 20 | #include "net/quic/quic_clock.h" |
| 21 | #include "net/quic/quic_config.h" |
| 22 | #include "net/quic/quic_protocol.h" |
| 23 | #include "net/quic/quic_time.h" |
| 24 | |
| 25 | namespace net { |
| 26 | |
| 27 | class NET_EXPORT_PRIVATE PacingSender : public SendAlgorithmInterface { |
| 28 | public: |
| 29 | PacingSender(SendAlgorithmInterface* sender, |
| 30 | QuicTime::Delta alarm_granularity); |
| 31 | virtual ~PacingSender(); |
| 32 | |
| 33 | // SendAlgorithmInterface methods. |
| 34 | virtual void SetFromConfig(const QuicConfig& config, bool is_server) OVERRIDE; |
| 35 | virtual void OnIncomingQuicCongestionFeedbackFrame( |
| 36 | const QuicCongestionFeedbackFrame& feedback, |
| 37 | QuicTime feedback_receive_time, |
| 38 | const SendAlgorithmInterface::SentPacketsMap& sent_packets) OVERRIDE; |
| 39 | virtual void OnIncomingAck(QuicPacketSequenceNumber acked_sequence_number, |
| 40 | QuicByteCount acked_bytes, |
| 41 | QuicTime::Delta rtt) OVERRIDE; |
| 42 | virtual void OnIncomingLoss(QuicPacketSequenceNumber largest_loss, |
| 43 | QuicTime ack_receive_time) OVERRIDE; |
| 44 | virtual bool OnPacketSent(QuicTime sent_time, |
| 45 | QuicPacketSequenceNumber sequence_number, |
| 46 | QuicByteCount bytes, |
| 47 | TransmissionType transmission_type, |
| 48 | HasRetransmittableData is_retransmittable) OVERRIDE; |
| 49 | virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number, |
| 50 | QuicByteCount abandoned_bytes) OVERRIDE; |
| 51 | virtual QuicTime::Delta TimeUntilSend( |
| 52 | QuicTime now, |
| 53 | TransmissionType transmission_type, |
| 54 | HasRetransmittableData has_retransmittable_data, |
| 55 | IsHandshake handshake) OVERRIDE; |
| 56 | virtual QuicBandwidth BandwidthEstimate() OVERRIDE; |
| 57 | virtual QuicTime::Delta SmoothedRtt() OVERRIDE; |
| 58 | virtual QuicTime::Delta RetransmissionDelay() OVERRIDE; |
| 59 | virtual QuicByteCount GetCongestionWindow() const OVERRIDE; |
| 60 | virtual void SetCongestionWindow(QuicByteCount window) OVERRIDE; |
| 61 | |
| 62 | private: |
| 63 | QuicTime::Delta GetTransferTime(QuicByteCount bytes); |
| 64 | |
| 65 | scoped_ptr<SendAlgorithmInterface> sender_; // Underlying sender. |
| 66 | QuicTime::Delta alarm_granularity_; |
| 67 | QuicTime next_packet_send_time_; // When can the next packet be sent. |
| 68 | bool was_last_send_delayed_; // True when the last send was delayed. |
| 69 | QuicByteCount max_segment_size_; |
| 70 | |
| 71 | DISALLOW_COPY_AND_ASSIGN(PacingSender); |
| 72 | }; |
| 73 | |
| 74 | } // namespace net |
| 75 | |
| 76 | #endif // NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ |