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/crypto/cached_network_parameters.h" |
19 #include "net/quic/quic_bandwidth.h" | 20 #include "net/quic/quic_bandwidth.h" |
20 #include "net/quic/quic_config.h" | 21 #include "net/quic/quic_config.h" |
21 #include "net/quic/quic_protocol.h" | 22 #include "net/quic/quic_protocol.h" |
22 #include "net/quic/quic_time.h" | 23 #include "net/quic/quic_time.h" |
23 | 24 |
24 namespace net { | 25 namespace net { |
25 | 26 |
26 class NET_EXPORT_PRIVATE PacingSender : public SendAlgorithmInterface { | 27 class NET_EXPORT_PRIVATE PacingSender : public SendAlgorithmInterface { |
27 public: | 28 public: |
28 // Create a PacingSender to wrap the specified sender. |alarm_granularity| | 29 // 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 // 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 // not expect a callback before that time delta. |initial_packet_burst| is |
31 // the number of packets sent without pacing after quiescence. | 32 // the number of packets sent without pacing after quiescence. |
32 PacingSender(SendAlgorithmInterface* sender, | 33 PacingSender(SendAlgorithmInterface* sender, |
33 QuicTime::Delta alarm_granularity, | 34 QuicTime::Delta alarm_granularity, |
34 uint32 initial_packet_burst); | 35 uint32 initial_packet_burst); |
35 ~PacingSender() override; | 36 ~PacingSender() override; |
36 | 37 |
37 // SendAlgorithmInterface methods. | 38 // SendAlgorithmInterface methods. |
38 void SetFromConfig(const QuicConfig& config, | 39 void SetFromConfig(const QuicConfig& config, |
39 bool is_server, | 40 bool is_server, |
40 bool using_pacing) override; | 41 bool using_pacing) override; |
| 42 void ResumeConnectionState( |
| 43 const CachedNetworkParameters& cached_network_params) override; |
41 void SetNumEmulatedConnections(int num_connections) override; | 44 void SetNumEmulatedConnections(int num_connections) override; |
42 void OnCongestionEvent(bool rtt_updated, | 45 void OnCongestionEvent(bool rtt_updated, |
43 QuicByteCount bytes_in_flight, | 46 QuicByteCount bytes_in_flight, |
44 const CongestionVector& acked_packets, | 47 const CongestionVector& acked_packets, |
45 const CongestionVector& lost_packets) override; | 48 const CongestionVector& lost_packets) override; |
46 bool OnPacketSent(QuicTime sent_time, | 49 bool OnPacketSent(QuicTime sent_time, |
47 QuicByteCount bytes_in_flight, | 50 QuicByteCount bytes_in_flight, |
48 QuicPacketSequenceNumber sequence_number, | 51 QuicPacketSequenceNumber sequence_number, |
49 QuicByteCount bytes, | 52 QuicByteCount bytes, |
50 HasRetransmittableData is_retransmittable) override; | 53 HasRetransmittableData is_retransmittable) override; |
51 void OnRetransmissionTimeout(bool packets_retransmitted) override; | 54 void OnRetransmissionTimeout(bool packets_retransmitted) override; |
52 void RevertRetransmissionTimeout() override; | 55 void RevertRetransmissionTimeout() override; |
53 QuicTime::Delta TimeUntilSend( | 56 QuicTime::Delta TimeUntilSend( |
54 QuicTime now, | 57 QuicTime now, |
55 QuicByteCount bytes_in_flight, | 58 QuicByteCount bytes_in_flight, |
56 HasRetransmittableData has_retransmittable_data) const override; | 59 HasRetransmittableData has_retransmittable_data) const override; |
57 QuicBandwidth PacingRate() const override; | 60 QuicBandwidth PacingRate() const override; |
58 QuicBandwidth BandwidthEstimate() const override; | 61 QuicBandwidth BandwidthEstimate() const override; |
59 bool HasReliableBandwidthEstimate() const override; | 62 bool HasReliableBandwidthEstimate() const override; |
60 QuicTime::Delta RetransmissionDelay() const override; | 63 QuicTime::Delta RetransmissionDelay() const override; |
61 QuicByteCount GetCongestionWindow() const override; | 64 QuicByteCount GetCongestionWindow() const override; |
62 bool InSlowStart() const override; | 65 bool InSlowStart() const override; |
63 bool InRecovery() const override; | 66 bool InRecovery() const override; |
64 QuicByteCount GetSlowStartThreshold() const override; | 67 QuicByteCount GetSlowStartThreshold() const override; |
65 CongestionControlType GetCongestionControlType() const override; | 68 CongestionControlType GetCongestionControlType() const override; |
| 69 // End implementation of SendAlgorithmInterface. |
66 | 70 |
67 private: | 71 private: |
68 scoped_ptr<SendAlgorithmInterface> sender_; // Underlying sender. | 72 scoped_ptr<SendAlgorithmInterface> sender_; // Underlying sender. |
69 QuicTime::Delta alarm_granularity_; | 73 QuicTime::Delta alarm_granularity_; |
70 uint32 initial_packet_burst_; | 74 uint32 initial_packet_burst_; |
71 mutable uint32 burst_tokens_; | 75 mutable uint32 burst_tokens_; |
72 // Send time of the last packet considered delayed. | 76 // Send time of the last packet considered delayed. |
73 QuicTime last_delayed_packet_sent_time_; | 77 QuicTime last_delayed_packet_sent_time_; |
74 QuicTime next_packet_send_time_; // When can the next packet be sent. | 78 QuicTime next_packet_send_time_; // When can the next packet be sent. |
75 mutable bool was_last_send_delayed_; // True when the last send was delayed. | 79 mutable bool was_last_send_delayed_; // True when the last send was delayed. |
76 | 80 |
77 DISALLOW_COPY_AND_ASSIGN(PacingSender); | 81 DISALLOW_COPY_AND_ASSIGN(PacingSender); |
78 }; | 82 }; |
79 | 83 |
80 } // namespace net | 84 } // namespace net |
81 | 85 |
82 #endif // NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ | 86 #endif // NET_QUIC_CONGESTION_CONTROL_PACING_SENDER_H_ |
OLD | NEW |