| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // A send algorithm that adds pacing on top of an another send algorithm. | |
| 6 // It uses the underlying sender's pacing rate to schedule packets. | |
| 7 // It also takes into consideration the expected granularity of the underlying | |
| 8 // alarm to ensure that alarms are not set too aggressively, and err towards | |
| 9 // sending packets too early instead of too late. | |
| 10 | |
| 11 #ifndef NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ | |
| 12 #define NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ | |
| 13 | |
| 14 #include <stdint.h> | |
| 15 | |
| 16 #include <map> | |
| 17 #include <memory> | |
| 18 | |
| 19 #include "base/macros.h" | |
| 20 #include "net/quic/congestion_control/send_algorithm_interface.h" | |
| 21 #include "net/quic/quic_bandwidth.h" | |
| 22 #include "net/quic/quic_config.h" | |
| 23 #include "net/quic/quic_protocol.h" | |
| 24 #include "net/quic/quic_time.h" | |
| 25 | |
| 26 namespace net { | |
| 27 | |
| 28 class NET_EXPORT_PRIVATE PacingSender : public SendAlgorithmInterface { | |
| 29 public: | |
| 30 // Create a PacingSender to wrap the specified sender. |alarm_granularity| | |
| 31 // indicates to the pacer to send that far into the future, since it should | |
| 32 // not expect a callback before that time delta. |initial_packet_burst| is | |
| 33 // the number of packets sent without pacing after quiescence. | |
| 34 PacingSender(SendAlgorithmInterface* sender, | |
| 35 QuicTime::Delta alarm_granularity, | |
| 36 uint32_t initial_packet_burst); | |
| 37 ~PacingSender() override; | |
| 38 | |
| 39 void SetMaxPacingRate(QuicBandwidth max_pacing_rate); | |
| 40 | |
| 41 // SendAlgorithmInterface methods. | |
| 42 void SetFromConfig(const QuicConfig& config, | |
| 43 Perspective perspective) override; | |
| 44 void ResumeConnectionState( | |
| 45 const CachedNetworkParameters& cached_network_params, | |
| 46 bool max_bandwidth_resumption) override; | |
| 47 void SetNumEmulatedConnections(int num_connections) override; | |
| 48 void OnCongestionEvent(bool rtt_updated, | |
| 49 QuicByteCount bytes_in_flight, | |
| 50 const CongestionVector& acked_packets, | |
| 51 const CongestionVector& lost_packets) override; | |
| 52 bool OnPacketSent(QuicTime sent_time, | |
| 53 QuicByteCount bytes_in_flight, | |
| 54 QuicPacketNumber packet_number, | |
| 55 QuicByteCount bytes, | |
| 56 HasRetransmittableData is_retransmittable) override; | |
| 57 void OnRetransmissionTimeout(bool packets_retransmitted) override; | |
| 58 void OnConnectionMigration() override; | |
| 59 QuicTime::Delta TimeUntilSend(QuicTime now, | |
| 60 QuicByteCount bytes_in_flight) const override; | |
| 61 QuicBandwidth PacingRate(QuicByteCount bytes_in_flight) const override; | |
| 62 QuicBandwidth BandwidthEstimate() const override; | |
| 63 QuicTime::Delta RetransmissionDelay() const override; | |
| 64 QuicByteCount GetCongestionWindow() const override; | |
| 65 bool InSlowStart() const override; | |
| 66 bool InRecovery() const override; | |
| 67 QuicByteCount GetSlowStartThreshold() const override; | |
| 68 CongestionControlType GetCongestionControlType() const override; | |
| 69 // End implementation of SendAlgorithmInterface. | |
| 70 | |
| 71 private: | |
| 72 std::unique_ptr<SendAlgorithmInterface> sender_; // Underlying sender. | |
| 73 // The estimated system alarm granularity. | |
| 74 const QuicTime::Delta alarm_granularity_; | |
| 75 // Configured maximum size of the burst coming out of quiescence. The burst | |
| 76 // is never larger than the current CWND in packets. | |
| 77 const uint32_t initial_packet_burst_; | |
| 78 // If not QuicBandidth::Zero, the maximum rate the PacingSender will use. | |
| 79 QuicBandwidth max_pacing_rate_; | |
| 80 | |
| 81 // Number of unpaced packets to be sent before packets are delayed. | |
| 82 uint32_t burst_tokens_; | |
| 83 // Send time of the last packet considered delayed. | |
| 84 QuicTime last_delayed_packet_sent_time_; | |
| 85 QuicTime ideal_next_packet_send_time_; // When can the next packet be sent. | |
| 86 mutable bool was_last_send_delayed_; // True when the last send was delayed. | |
| 87 | |
| 88 DISALLOW_COPY_AND_ASSIGN(PacingSender); | |
| 89 }; | |
| 90 | |
| 91 } // namespace net | |
| 92 | |
| 93 #endif // NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ | |
| OLD | NEW |