Fixes congestion window bug in network control tester.
The network control tester did not handle congestion windows correctly. Time passed when no packets were sent were not counted. This hindered the buffer delays from decreasing in congested mode. Bug: webrtc:8415 Change-Id: Id46116c6125eb5a50caa5766a3cc7291404ff920 Reviewed-on: https://webrtc-review.googlesource.com/77761 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Stefan Holmer <stefan@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23361}
This commit is contained in:
parent
547e3169d9
commit
ce532a1c3c
@ -21,27 +21,27 @@ namespace {
|
||||
void Update(NetworkControlUpdate* target, const NetworkControlUpdate& update) {
|
||||
if (update.congestion_window) {
|
||||
RTC_LOG(LS_INFO) << "Received window="
|
||||
<< ToString(*update.congestion_window) << "\n";
|
||||
<< ToString(*update.congestion_window);
|
||||
target->congestion_window = update.congestion_window;
|
||||
}
|
||||
if (update.pacer_config) {
|
||||
RTC_LOG(LS_INFO) << "Received pacing at:"
|
||||
<< ToString(update.pacer_config->at_time)
|
||||
<< ": rate=" << ToString(update.pacer_config->data_rate())
|
||||
<< "\n";
|
||||
<< ", pad=" << ToString(update.pacer_config->pad_rate());
|
||||
target->pacer_config = update.pacer_config;
|
||||
}
|
||||
if (update.target_rate) {
|
||||
RTC_LOG(LS_INFO) << "Received target at:"
|
||||
<< ToString(update.target_rate->at_time)
|
||||
<< ": rate=" << ToString(update.target_rate->target_rate)
|
||||
<< "\n";
|
||||
RTC_LOG(LS_INFO)
|
||||
<< "Received target at:" << ToString(update.target_rate->at_time)
|
||||
<< ": rate=" << ToString(update.target_rate->target_rate) << ", rtt="
|
||||
<< ToString(update.target_rate->network_estimate.round_trip_time);
|
||||
target->target_rate = update.target_rate;
|
||||
}
|
||||
for (const auto& probe : update.probe_cluster_configs) {
|
||||
target->probe_cluster_configs.push_back(probe);
|
||||
RTC_LOG(LS_INFO) << "Received probe at:" << ToString(probe.at_time)
|
||||
<< ": target=" << ToString(probe.target_data_rate) << "\n";
|
||||
<< ": target=" << ToString(probe.target_data_rate);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
@ -63,33 +63,17 @@ NetworkControllerTester::NetworkControllerTester(
|
||||
NetworkControllerConfig initial_config)
|
||||
: current_time_(Timestamp::seconds(100000)),
|
||||
packet_sequence_number_(1),
|
||||
accumulated_delay_(TimeDelta::ms(0)) {
|
||||
accumulated_buffer_(DataSize::Zero()) {
|
||||
initial_config.constraints.at_time = current_time_;
|
||||
controller_ = factory->Create(initial_config);
|
||||
process_interval_ = factory->GetProcessInterval();
|
||||
ProcessInterval interval_msg;
|
||||
interval_msg.at_time = current_time_;
|
||||
state_ = controller_->OnProcessInterval(interval_msg);
|
||||
Update(&state_, controller_->OnProcessInterval(interval_msg));
|
||||
}
|
||||
|
||||
NetworkControllerTester::~NetworkControllerTester() = default;
|
||||
|
||||
PacketResult NetworkControllerTester::SimulateSend(SentPacket packet,
|
||||
TimeDelta time_delta,
|
||||
TimeDelta propagation_delay,
|
||||
DataRate actual_bandwidth) {
|
||||
TimeDelta bandwidth_delay = packet.size / actual_bandwidth;
|
||||
accumulated_delay_ =
|
||||
std::max(accumulated_delay_ - time_delta, TimeDelta::Zero());
|
||||
accumulated_delay_ += bandwidth_delay;
|
||||
TimeDelta total_delay = propagation_delay + accumulated_delay_;
|
||||
|
||||
PacketResult result;
|
||||
result.sent_packet = packet;
|
||||
result.receive_time = packet.send_time + total_delay;
|
||||
return result;
|
||||
}
|
||||
|
||||
void NetworkControllerTester::RunSimulation(TimeDelta duration,
|
||||
TimeDelta packet_interval,
|
||||
DataRate actual_bandwidth,
|
||||
@ -112,10 +96,21 @@ void NetworkControllerTester::RunSimulation(TimeDelta duration,
|
||||
sent_packet = next_packet(state_, current_time_, packet_interval);
|
||||
sent_packet.sequence_number = packet_sequence_number_++;
|
||||
Update(&state_, controller_->OnSentPacket(sent_packet));
|
||||
outstanding_packets_.push_back(SimulateSend(
|
||||
sent_packet, packet_interval, propagation_delay, actual_bandwidth));
|
||||
|
||||
accumulated_buffer_ += sent_packet.size;
|
||||
TimeDelta buffer_delay = accumulated_buffer_ / actual_bandwidth;
|
||||
TimeDelta total_delay = propagation_delay + buffer_delay;
|
||||
PacketResult result;
|
||||
result.sent_packet = sent_packet;
|
||||
result.receive_time = sent_packet.send_time + total_delay;
|
||||
|
||||
outstanding_packets_.push_back(result);
|
||||
}
|
||||
|
||||
DataSize buffer_consumed =
|
||||
std::min(accumulated_buffer_, packet_interval * actual_bandwidth);
|
||||
accumulated_buffer_ -= buffer_consumed;
|
||||
|
||||
if (outstanding_packets_.size() >= 2 &&
|
||||
current_time_ >=
|
||||
outstanding_packets_[1].receive_time + propagation_delay) {
|
||||
|
||||
@ -59,15 +59,11 @@ class NetworkControllerTester {
|
||||
NetworkControlUpdate GetState() { return state_; }
|
||||
|
||||
private:
|
||||
PacketResult SimulateSend(SentPacket packet,
|
||||
TimeDelta time_delta,
|
||||
TimeDelta propagation_delay,
|
||||
DataRate actual_bandwidth);
|
||||
std::unique_ptr<NetworkControllerInterface> controller_;
|
||||
TimeDelta process_interval_ = TimeDelta::PlusInfinity();
|
||||
Timestamp current_time_;
|
||||
int64_t packet_sequence_number_;
|
||||
TimeDelta accumulated_delay_;
|
||||
DataSize accumulated_buffer_;
|
||||
std::deque<PacketResult> outstanding_packets_;
|
||||
NetworkControlUpdate state_;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user