| Index: net/quic/congestion_control/quic_congestion_manager.cc
|
| diff --git a/net/quic/congestion_control/quic_congestion_manager.cc b/net/quic/congestion_control/quic_congestion_manager.cc
|
| index e5c6973e8e5bd7dafecf8b6c0ca4af17e0b1ffb5..79b6c4de46b400d87037c3b2d42cb34faf65f5f4 100644
|
| --- a/net/quic/congestion_control/quic_congestion_manager.cc
|
| +++ b/net/quic/congestion_control/quic_congestion_manager.cc
|
| @@ -35,7 +35,8 @@ QuicCongestionManager::QuicCongestionManager(
|
| : clock_(clock),
|
| receive_algorithm_(ReceiveAlgorithmInterface::Create(clock, type)),
|
| send_algorithm_(SendAlgorithmInterface::Create(clock, type)),
|
| - largest_missing_(0) {
|
| + largest_missing_(0),
|
| + current_rtt_(QuicTime::Delta::Infinite()) {
|
| }
|
|
|
| QuicCongestionManager::~QuicCongestionManager() {
|
| @@ -45,11 +46,10 @@ QuicCongestionManager::~QuicCongestionManager() {
|
| void QuicCongestionManager::SentPacket(QuicPacketSequenceNumber sequence_number,
|
| QuicTime sent_time,
|
| QuicByteCount bytes,
|
| - bool is_retransmission,
|
| - bool has_retransmittable_data) {
|
| + bool is_retransmission) {
|
| DCHECK(!ContainsKey(pending_packets_, sequence_number));
|
| send_algorithm_->SentPacket(sent_time, sequence_number, bytes,
|
| - is_retransmission, has_retransmittable_data);
|
| + is_retransmission);
|
|
|
| packet_history_map_[sequence_number] =
|
| new class SendAlgorithmInterface::SentPacket(bytes, sent_time);
|
| @@ -57,6 +57,16 @@ void QuicCongestionManager::SentPacket(QuicPacketSequenceNumber sequence_number,
|
| CleanupPacketHistory();
|
| }
|
|
|
| +// Called when a packet is timed out.
|
| +void QuicCongestionManager::AbandoningPacket(
|
| + QuicPacketSequenceNumber sequence_number) {
|
| + PendingPacketsMap::iterator it = pending_packets_.find(sequence_number);
|
| + if (it != pending_packets_.end()) {
|
| + send_algorithm_->AbandoningPacket(sequence_number, it->second);
|
| + pending_packets_.erase(it);
|
| + }
|
| +}
|
| +
|
| void QuicCongestionManager::OnIncomingQuicCongestionFeedbackFrame(
|
| const QuicCongestionFeedbackFrame& frame, QuicTime feedback_receive_time) {
|
| QuicBandwidth sent_bandwidth = SentBandwidth(feedback_receive_time);
|
| @@ -68,12 +78,17 @@ void QuicCongestionManager::OnIncomingAckFrame(const QuicAckFrame& frame,
|
| QuicTime ack_receive_time) {
|
| // We calculate the RTT based on the highest ACKed sequence number, the lower
|
| // sequence numbers will include the ACK aggregation delay.
|
| - QuicTime::Delta rtt = QuicTime::Delta::Zero();
|
| SendAlgorithmInterface::SentPacketsMap::iterator history_it =
|
| packet_history_map_.find(frame.received_info.largest_observed);
|
| - if (history_it != packet_history_map_.end()) {
|
| - // TODO(pwestin): we need to add the delta to the feedback message.
|
| - rtt = ack_receive_time.Subtract(history_it->second->SendTimestamp());
|
| + // TODO(satyamshekhar): largest_observed might be missing.
|
| + if (history_it != packet_history_map_.end() &&
|
| + !frame.received_info.delta_time_largest_observed.IsInfinite()) {
|
| + QuicTime::Delta send_delta = ack_receive_time.Subtract(
|
| + history_it->second->SendTimestamp());
|
| + if (send_delta > frame.received_info.delta_time_largest_observed) {
|
| + current_rtt_ = send_delta.Subtract(
|
| + frame.received_info.delta_time_largest_observed);
|
| + }
|
| }
|
| // We want to.
|
| // * Get all packets lower(including) than largest_observed
|
| @@ -89,9 +104,7 @@ void QuicCongestionManager::OnIncomingAckFrame(const QuicAckFrame& frame,
|
| QuicPacketSequenceNumber sequence_number = it->first;
|
| if (!IsAwaitingPacket(frame.received_info, sequence_number)) {
|
| // Not missing, hence implicitly acked.
|
| - send_algorithm_->OnIncomingAck(sequence_number,
|
| - it->second,
|
| - rtt);
|
| + send_algorithm_->OnIncomingAck(sequence_number, it->second, current_rtt_);
|
| pending_packets_.erase(it++); // Must be incremented post to work.
|
| } else {
|
| if (sequence_number > largest_missing_) {
|
| @@ -107,9 +120,12 @@ void QuicCongestionManager::OnIncomingAckFrame(const QuicAckFrame& frame,
|
| }
|
| }
|
|
|
| -QuicTime::Delta QuicCongestionManager::TimeUntilSend(QuicTime now,
|
| - bool is_retransmission) {
|
| - return send_algorithm_->TimeUntilSend(now, is_retransmission);
|
| +QuicTime::Delta QuicCongestionManager::TimeUntilSend(
|
| + QuicTime now,
|
| + bool is_retransmission,
|
| + bool has_retransmittable_data) {
|
| + return send_algorithm_->TimeUntilSend(now, is_retransmission,
|
| + has_retransmittable_data);
|
| }
|
|
|
| bool QuicCongestionManager::GenerateCongestionFeedback(
|
| @@ -126,15 +142,19 @@ void QuicCongestionManager::RecordIncomingPacket(
|
| revived);
|
| }
|
|
|
| -// static
|
| +const QuicTime::Delta QuicCongestionManager::rtt() {
|
| + return current_rtt_;
|
| +}
|
| +
|
| const QuicTime::Delta QuicCongestionManager::DefaultRetransmissionTime() {
|
| return QuicTime::Delta::FromMilliseconds(kDefaultRetransmissionTimeMs);
|
| }
|
|
|
| -// static
|
| const QuicTime::Delta QuicCongestionManager::GetRetransmissionDelay(
|
| size_t unacked_packets_count,
|
| size_t number_retransmissions) {
|
| + // TODO(pwestin): This should take the RTT into account instead of a hard
|
| + // coded kDefaultRetransmissionTimeMs. Ideally the variance of the RTT too.
|
| if (unacked_packets_count <= kTailDropWindowSize) {
|
| return QuicTime::Delta::FromMilliseconds(kDefaultRetransmissionTimeMs);
|
| }
|
| @@ -144,6 +164,10 @@ const QuicTime::Delta QuicCongestionManager::GetRetransmissionDelay(
|
| (1 << min<size_t>(number_retransmissions, kMaxRetransmissions)));
|
| }
|
|
|
| +const QuicTime::Delta QuicCongestionManager::SmoothedRtt() {
|
| + return send_algorithm_->SmoothedRtt();
|
| +}
|
| +
|
| QuicBandwidth QuicCongestionManager::SentBandwidth(
|
| QuicTime feedback_receive_time) const {
|
| const QuicTime::Delta kBitrateSmoothingPeriod =
|
|
|