Makes send time information in feedback non-optional.

This makes it safer to reason about the common case where send
time information is available. We don't have to either assume that
it's available, or check it everywhere the PacketResult struct is used.

To achieve this, a new field is added to TransportPacketsFeedback
and a new interface is introduced to clearly separate which field is
used. A possible followup would be to introduce a separate struct.
That would complicate the signature of ProcessTransportFeedback.

Bug: webrtc:9934
Change-Id: I2b319e4df2b557fbd4de66b812744bca7d91ca15
Reviewed-on: https://webrtc-review.googlesource.com/c/107080
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25465}
This commit is contained in:
Sebastian Jansson
2018-11-01 12:58:25 +01:00
committed by Commit Bot
parent be837ac3bc
commit af6d741fe1
13 changed files with 100 additions and 95 deletions

View File

@ -38,7 +38,7 @@ std::vector<PacketResult> TransportPacketsFeedback::ReceivedWithSendInfo()
const {
std::vector<PacketResult> res;
for (const PacketResult& fb : packet_feedbacks) {
if (fb.receive_time.IsFinite() && fb.sent_packet.has_value()) {
if (fb.receive_time.IsFinite()) {
res.push_back(fb);
}
}
@ -48,7 +48,7 @@ std::vector<PacketResult> TransportPacketsFeedback::ReceivedWithSendInfo()
std::vector<PacketResult> TransportPacketsFeedback::LostWithSendInfo() const {
std::vector<PacketResult> res;
for (const PacketResult& fb : packet_feedbacks) {
if (fb.receive_time.IsPlusInfinity() && fb.sent_packet.has_value()) {
if (fb.receive_time.IsPlusInfinity()) {
res.push_back(fb);
}
}

View File

@ -126,14 +126,10 @@ struct PacketResult {
PacketResult(const PacketResult&);
~PacketResult();
absl::optional<SentPacket> sent_packet;
SentPacket sent_packet;
Timestamp receive_time = Timestamp::PlusInfinity();
// TODO(bugs.webrtc.org/9934): Remove this when sent_packet is made
// non-optional.
const SentPacket& GetSentPacket() const {
RTC_DCHECK(sent_packet.has_value());
return *sent_packet;
}
// TODO(bugs.webrtc.org/9934): Remove this when downsrteam projects are ready.
const SentPacket& GetSentPacket() const { return sent_packet; }
};
struct TransportPacketsFeedback {
@ -146,6 +142,9 @@ struct TransportPacketsFeedback {
DataSize prior_in_flight = DataSize::Zero();
std::vector<PacketResult> packet_feedbacks;
// Arrival times for messages without send time information.
std::vector<Timestamp> sendless_arrival_times;
std::vector<PacketResult> ReceivedWithSendInfo() const;
std::vector<PacketResult> LostWithSendInfo() const;
std::vector<PacketResult> PacketsWithFeedback() const;

View File

@ -87,7 +87,7 @@ void NetworkControllerTester::RunSimulation(TimeDelta duration,
if (state_.congestion_window && state_.congestion_window->IsFinite()) {
DataSize data_in_flight = DataSize::Zero();
for (PacketResult& packet : outstanding_packets_)
data_in_flight += packet.sent_packet->size;
data_in_flight += packet.sent_packet.size;
if (data_in_flight > *state_.congestion_window)
send_packet = false;
}
@ -98,7 +98,7 @@ void NetworkControllerTester::RunSimulation(TimeDelta duration,
sent_packet.sequence_number = packet_sequence_number_++;
sent_packet.data_in_flight = sent_packet.size;
for (PacketResult& packet : outstanding_packets_)
sent_packet.data_in_flight += packet.sent_packet->size;
sent_packet.data_in_flight += packet.sent_packet.size;
Update(&state_, controller_->OnSentPacket(sent_packet));
TimeDelta time_in_flight = sent_packet.size / actual_bandwidth;
@ -120,7 +120,7 @@ void NetworkControllerTester::RunSimulation(TimeDelta duration,
TransportPacketsFeedback feedback;
feedback.prior_in_flight = DataSize::Zero();
for (PacketResult& packet : outstanding_packets_)
feedback.prior_in_flight += packet.sent_packet->size;
feedback.prior_in_flight += packet.sent_packet.size;
while (!outstanding_packets_.empty() &&
current_time_ >= outstanding_packets_.front().receive_time +
propagation_delay) {
@ -131,7 +131,7 @@ void NetworkControllerTester::RunSimulation(TimeDelta duration,
feedback.packet_feedbacks.back().receive_time + propagation_delay;
feedback.data_in_flight = DataSize::Zero();
for (PacketResult& packet : outstanding_packets_)
feedback.data_in_flight += packet.sent_packet->size;
feedback.data_in_flight += packet.sent_packet.size;
Update(&state_, controller_->OnTransportPacketsFeedback(feedback));
}
current_time_ += packet_interval;