From 503da9435084305869cda5bfe861bcb103c93d71 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Tue, 18 Dec 2018 15:54:41 +0100 Subject: [PATCH] Adds first unacknowledged packet send time. This will be used to calculate a lower bound for the round trip time in a later CL. Bug: webrtc:9718 Change-Id: I0a1d22045961fe6bd343d1d6ce9b36490b036bb1 Reviewed-on: https://webrtc-review.googlesource.com/c/114680 Commit-Queue: Sebastian Jansson Reviewed-by: Christoffer Rodbro Cr-Commit-Position: refs/heads/master@{#26050} --- api/transport/network_types.h | 1 + modules/congestion_controller/rtp/send_time_history.cc | 10 ++++++++++ modules/congestion_controller/rtp/send_time_history.h | 2 ++ .../rtp/transport_feedback_adapter.cc | 7 +++++++ 4 files changed, 20 insertions(+) diff --git a/api/transport/network_types.h b/api/transport/network_types.h index 0f1d7ab683..43778caaac 100644 --- a/api/transport/network_types.h +++ b/api/transport/network_types.h @@ -136,6 +136,7 @@ struct TransportPacketsFeedback { ~TransportPacketsFeedback(); Timestamp feedback_time = Timestamp::PlusInfinity(); + Timestamp first_unacked_send_time = Timestamp::PlusInfinity(); DataSize data_in_flight = DataSize::Zero(); DataSize prior_in_flight = DataSize::Zero(); std::vector packet_feedbacks; diff --git a/modules/congestion_controller/rtp/send_time_history.cc b/modules/congestion_controller/rtp/send_time_history.cc index 110dac3993..5011da1d1a 100644 --- a/modules/congestion_controller/rtp/send_time_history.cc +++ b/modules/congestion_controller/rtp/send_time_history.cc @@ -121,6 +121,16 @@ DataSize SendTimeHistory::GetOutstandingData(uint16_t local_net_id, } } +absl::optional SendTimeHistory::GetFirstUnackedSendTime() const { + if (!last_ack_seq_num_) + return absl::nullopt; + auto it = history_.find(*last_ack_seq_num_); + if (it == history_.end() || + it->second.send_time_ms == PacketFeedback::kNoSendTime) + return absl::nullopt; + return it->second.send_time_ms; +} + void SendTimeHistory::AddPacketBytes(const PacketFeedback& packet) { if (packet.send_time_ms < 0 || packet.payload_size == 0 || (last_ack_seq_num_ && *last_ack_seq_num_ >= packet.long_sequence_number)) diff --git a/modules/congestion_controller/rtp/send_time_history.h b/modules/congestion_controller/rtp/send_time_history.h index 656b7e16a3..c28ca61507 100644 --- a/modules/congestion_controller/rtp/send_time_history.h +++ b/modules/congestion_controller/rtp/send_time_history.h @@ -47,6 +47,8 @@ class SendTimeHistory { DataSize GetOutstandingData(uint16_t local_net_id, uint16_t remote_net_id) const; + absl::optional GetFirstUnackedSendTime() const; + private: using RemoteAndLocalNetworkId = std::pair; diff --git a/modules/congestion_controller/rtp/transport_feedback_adapter.cc b/modules/congestion_controller/rtp/transport_feedback_adapter.cc index c4bbc1921a..662cbef7ea 100644 --- a/modules/congestion_controller/rtp/transport_feedback_adapter.cc +++ b/modules/congestion_controller/rtp/transport_feedback_adapter.cc @@ -148,6 +148,13 @@ TransportFeedbackAdapter::ProcessTransportFeedback( Timestamp::ms(rtp_feedback.arrival_time_ms)); } } + { + rtc::CritScope cs(&lock_); + absl::optional first_unacked_send_time_ms = + send_time_history_.GetFirstUnackedSendTime(); + if (first_unacked_send_time_ms) + msg.first_unacked_send_time = Timestamp::ms(*first_unacked_send_time_ms); + } msg.feedback_time = Timestamp::ms(feedback_time_ms); msg.prior_in_flight = prior_in_flight; msg.data_in_flight = GetOutstandingData();