This source file includes following definitions.
- updated_rtt_
- SetFromConfig
- OnIncomingQuicCongestionFeedbackFrame
- OnPacketAcked
- OnPacketLost
- OnPacketSent
- OnRetransmissionTimeout
- OnPacketAbandoned
- TimeUntilSend
- BandwidthEstimate
- UpdateRtt
- RetransmissionDelay
- GetCongestionWindow
#include "net/quic/congestion_control/pacing_sender.h"
namespace net {
PacingSender::PacingSender(SendAlgorithmInterface* sender,
QuicTime::Delta alarm_granularity)
: sender_(sender),
alarm_granularity_(alarm_granularity),
next_packet_send_time_(QuicTime::Zero()),
was_last_send_delayed_(false),
updated_rtt_(false) {
}
PacingSender::~PacingSender() {}
void PacingSender::SetFromConfig(const QuicConfig& config, bool is_server) {
sender_->SetFromConfig(config, is_server);
}
void PacingSender::OnIncomingQuicCongestionFeedbackFrame(
const QuicCongestionFeedbackFrame& feedback,
QuicTime feedback_receive_time) {
sender_->OnIncomingQuicCongestionFeedbackFrame(
feedback, feedback_receive_time);
}
void PacingSender::OnPacketAcked(
QuicPacketSequenceNumber acked_sequence_number,
QuicByteCount acked_bytes) {
sender_->OnPacketAcked(acked_sequence_number, acked_bytes);
}
void PacingSender::OnPacketLost(QuicPacketSequenceNumber sequence_number,
QuicTime ack_receive_time) {
sender_->OnPacketLost(sequence_number, ack_receive_time);
}
bool PacingSender::OnPacketSent(
QuicTime sent_time,
QuicPacketSequenceNumber sequence_number,
QuicByteCount bytes,
HasRetransmittableData has_retransmittable_data) {
if (has_retransmittable_data == HAS_RETRANSMITTABLE_DATA && updated_rtt_) {
const float kPacingAggression = 2;
QuicTime::Delta delay =
BandwidthEstimate().Scale(kPacingAggression).TransferTime(bytes);
next_packet_send_time_ = next_packet_send_time_.Add(delay);
}
return sender_->OnPacketSent(sent_time, sequence_number, bytes,
has_retransmittable_data);
}
void PacingSender::OnRetransmissionTimeout(bool packets_retransmitted) {
sender_->OnRetransmissionTimeout(packets_retransmitted);
}
void PacingSender::OnPacketAbandoned(QuicPacketSequenceNumber sequence_number,
QuicByteCount abandoned_bytes) {
sender_->OnPacketAbandoned(sequence_number, abandoned_bytes);
}
QuicTime::Delta PacingSender::TimeUntilSend(
QuicTime now,
HasRetransmittableData has_retransmittable_data) {
QuicTime::Delta time_until_send =
sender_->TimeUntilSend(now, has_retransmittable_data);
if (!updated_rtt_) {
return time_until_send;
}
if (!time_until_send.IsZero()) {
DCHECK(time_until_send.IsInfinite());
return time_until_send;
}
if (has_retransmittable_data == NO_RETRANSMITTABLE_DATA) {
return QuicTime::Delta::Zero();
}
if (!was_last_send_delayed_ &&
(!next_packet_send_time_.IsInitialized() ||
now > next_packet_send_time_.Add(alarm_granularity_))) {
next_packet_send_time_ = now.Subtract(alarm_granularity_);
}
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();
return next_packet_send_time_.Subtract(now);
}
was_last_send_delayed_ = false;
DVLOG(1) << "Sending packet now";
return QuicTime::Delta::Zero();
}
QuicBandwidth PacingSender::BandwidthEstimate() const {
return sender_->BandwidthEstimate();
}
void PacingSender::UpdateRtt(QuicTime::Delta rtt_sample) {
updated_rtt_= true;
sender_->UpdateRtt(rtt_sample);
}
QuicTime::Delta PacingSender::RetransmissionDelay() const {
return sender_->RetransmissionDelay();
}
QuicByteCount PacingSender::GetCongestionWindow() const {
return sender_->GetCongestionWindow();
}
}