summaryrefslogtreecommitdiffstats
path: root/chromium/net/quic/congestion_control/pacing_sender.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/quic/congestion_control/pacing_sender.cc')
-rw-r--r--chromium/net/quic/congestion_control/pacing_sender.cc108
1 files changed, 54 insertions, 54 deletions
diff --git a/chromium/net/quic/congestion_control/pacing_sender.cc b/chromium/net/quic/congestion_control/pacing_sender.cc
index a20e7522750..97138f767d0 100644
--- a/chromium/net/quic/congestion_control/pacing_sender.cc
+++ b/chromium/net/quic/congestion_control/pacing_sender.cc
@@ -10,50 +10,44 @@ PacingSender::PacingSender(SendAlgorithmInterface* sender,
QuicTime::Delta alarm_granularity)
: sender_(sender),
alarm_granularity_(alarm_granularity),
+ last_delayed_packet_sent_time_(QuicTime::Zero()),
next_packet_send_time_(QuicTime::Zero()),
was_last_send_delayed_(false),
- max_segment_size_(kDefaultMaxPacketSize) {
+ has_valid_rtt_(false) {
}
PacingSender::~PacingSender() {}
-void PacingSender::SetMaxPacketSize(QuicByteCount max_packet_size) {
- max_segment_size_ = max_packet_size;
- sender_->SetMaxPacketSize(max_packet_size);
-}
-
void PacingSender::SetFromConfig(const QuicConfig& config, bool is_server) {
sender_->SetFromConfig(config, is_server);
}
void PacingSender::OnIncomingQuicCongestionFeedbackFrame(
const QuicCongestionFeedbackFrame& feedback,
- QuicTime feedback_receive_time,
- const SendAlgorithmInterface::SentPacketsMap& sent_packets) {
+ QuicTime feedback_receive_time) {
sender_->OnIncomingQuicCongestionFeedbackFrame(
- feedback, feedback_receive_time, sent_packets);
-}
-
-void PacingSender::OnPacketAcked(
- QuicPacketSequenceNumber acked_sequence_number,
- QuicByteCount acked_bytes,
- QuicTime::Delta rtt) {
- sender_->OnPacketAcked(acked_sequence_number, acked_bytes, rtt);
+ feedback, feedback_receive_time);
}
-void PacingSender::OnPacketLost(QuicPacketSequenceNumber sequence_number,
- QuicTime ack_receive_time) {
- sender_->OnPacketLost(sequence_number, ack_receive_time);
+void PacingSender::OnCongestionEvent(bool rtt_updated,
+ QuicByteCount bytes_in_flight,
+ const CongestionMap& acked_packets,
+ const CongestionMap& lost_packets) {
+ if (rtt_updated) {
+ has_valid_rtt_ = true;
+ }
+ sender_->OnCongestionEvent(
+ rtt_updated, bytes_in_flight, acked_packets, lost_packets);
}
bool PacingSender::OnPacketSent(
QuicTime sent_time,
+ QuicByteCount bytes_in_flight,
QuicPacketSequenceNumber sequence_number,
QuicByteCount bytes,
- TransmissionType transmission_type,
HasRetransmittableData has_retransmittable_data) {
- // Only pace data packets.
- if (has_retransmittable_data == HAS_RETRANSMITTABLE_DATA) {
+ // Only pace data packets once we have an updated RTT.
+ if (has_retransmittable_data == HAS_RETRANSMITTABLE_DATA && has_valid_rtt_) {
// The next packet should be sent as soon as the current packets has
// been transferred. We pace at twice the rate of the underlying
// sender's bandwidth estimate to help ensure that pacing doesn't become
@@ -61,29 +55,50 @@ bool PacingSender::OnPacketSent(
const float kPacingAggression = 2;
QuicTime::Delta delay =
BandwidthEstimate().Scale(kPacingAggression).TransferTime(bytes);
- next_packet_send_time_ = next_packet_send_time_.Add(delay);
+ // If the last send was delayed, and the alarm took a long time to get
+ // invoked, allow the connection to make up for lost time.
+ if (was_last_send_delayed_) {
+ next_packet_send_time_ = next_packet_send_time_.Add(delay);
+ // The send was application limited if it takes longer than the
+ // pacing delay between sent packets.
+ const bool application_limited =
+ last_delayed_packet_sent_time_.IsInitialized() &&
+ sent_time > last_delayed_packet_sent_time_.Add(delay);
+ const bool making_up_for_lost_time = next_packet_send_time_ <= sent_time;
+ // As long as we're making up time and not application limited,
+ // continue to consider the packets delayed, allowing the packets to be
+ // sent immediately.
+ if (making_up_for_lost_time && !application_limited) {
+ last_delayed_packet_sent_time_ = sent_time;
+ } else {
+ was_last_send_delayed_ = false;
+ last_delayed_packet_sent_time_ = QuicTime::Zero();
+ }
+ } else {
+ next_packet_send_time_ =
+ QuicTime::Max(next_packet_send_time_.Add(delay),
+ sent_time.Add(delay).Subtract(alarm_granularity_));
+ }
}
- return sender_->OnPacketSent(sent_time, sequence_number, bytes,
- transmission_type, has_retransmittable_data);
-}
-
-void PacingSender::OnRetransmissionTimeout() {
- sender_->OnRetransmissionTimeout();
+ return sender_->OnPacketSent(sent_time, bytes_in_flight, sequence_number,
+ bytes, has_retransmittable_data);
}
-void PacingSender::OnPacketAbandoned(QuicPacketSequenceNumber sequence_number,
- QuicByteCount abandoned_bytes) {
- sender_->OnPacketAbandoned(sequence_number, abandoned_bytes);
+void PacingSender::OnRetransmissionTimeout(bool packets_retransmitted) {
+ sender_->OnRetransmissionTimeout(packets_retransmitted);
}
QuicTime::Delta PacingSender::TimeUntilSend(
QuicTime now,
- TransmissionType transmission_type,
- HasRetransmittableData has_retransmittable_data,
- IsHandshake handshake) {
+ QuicByteCount bytes_in_flight,
+ HasRetransmittableData has_retransmittable_data) const {
QuicTime::Delta time_until_send =
- sender_->TimeUntilSend(now, transmission_type,
- has_retransmittable_data, handshake);
+ sender_->TimeUntilSend(now, bytes_in_flight, has_retransmittable_data);
+ if (!has_valid_rtt_) {
+ // Don't pace if we don't have an updated RTT estimate.
+ return time_until_send;
+ }
+
if (!time_until_send.IsZero()) {
DCHECK(time_until_send.IsInfinite());
// The underlying sender prevents sending.
@@ -96,25 +111,14 @@ QuicTime::Delta PacingSender::TimeUntilSend(
return QuicTime::Delta::Zero();
}
- if (!was_last_send_delayed_ &&
- (!next_packet_send_time_.IsInitialized() ||
- now > next_packet_send_time_.Add(alarm_granularity_))) {
- // An alarm did not go off late, instead the application is "slow"
- // delivering data. In this case, we restrict the amount of lost time
- // that we can make up for.
- next_packet_send_time_ = now.Subtract(alarm_granularity_);
- }
-
- // If the end of the epoch is far enough in the future, delay the send.
+ // If the next send time is within the alarm granularity, send immediately.
if (next_packet_send_time_ > now.Add(alarm_granularity_)) {
- was_last_send_delayed_ = true;
DVLOG(1) << "Delaying packet: "
<< next_packet_send_time_.Subtract(now).ToMicroseconds();
+ was_last_send_delayed_ = true;
return next_packet_send_time_.Subtract(now);
}
- // Sent it immediately. The epoch end will be adjusted in OnPacketSent.
- was_last_send_delayed_ = false;
DVLOG(1) << "Sending packet now";
return QuicTime::Delta::Zero();
}
@@ -123,10 +127,6 @@ QuicBandwidth PacingSender::BandwidthEstimate() const {
return sender_->BandwidthEstimate();
}
-QuicTime::Delta PacingSender::SmoothedRtt() const {
- return sender_->SmoothedRtt();
-}
-
QuicTime::Delta PacingSender::RetransmissionDelay() const {
return sender_->RetransmissionDelay();
}