This is an initial cl, which contains small amount of implemented functions, and large amount of unimplemented ones.

Code should implement BBR which is the congestion controlling algorithm. BBR tries to estimate two values bottle-neck bandwidth(bw) and round trip time(rtt),then use these two values to set two control parameters pacing rate(pacing_rate),the rate at which data should be sent and congestion window size (cwnd), cwnd is the upper bound for data in flight,data_in_flight <= cwnd at all time.
BBR has four modes:
1)Startup-ramping up throughput discovering estimated bw.
2)Drain-after Startup decrease throughput to drain queues.
3)Probe Bandwidth-most of the time BBR should be in this mode,
sending data at the rate of estimated bw, while sometimes trying to discover new bandwidth.
4)Probe Rtt-in this mode BBR tries to discover new rtt for the connection.

The key moment in BBR is when we receive feedback from the receiver,as this is the only moment which should effect our two estimators. At this moment all the switches between modes should happen, except switch to ProbeRtt mode (switching to ProbeRtt mode should happen when current min_rtt value expires).

This cl serves to emphasize the structure of Bbr, when switches happen and what key classes/functions should be implemented for proper functionality.

BUG=webrtc:7713
NOTRY=True

Review-Url: https://codereview.webrtc.org/2904183002
Cr-Commit-Position: refs/heads/master@{#18444}
This commit is contained in:
gnish 2017-06-05 06:01:26 -07:00 committed by Commit Bot
parent 59ee91b68a
commit 6dcdf10c76
12 changed files with 352 additions and 4 deletions

View File

@ -198,7 +198,6 @@ if (rtc_include_tests) {
"//resources/verizon4g-uplink.rx",
"//resources/voice_engine/audio_tiny48.wav",
]
if (is_ios) {
bundle_data("modules_unittests_bundle_data") {
testonly = true

View File

@ -72,6 +72,11 @@ if (rtc_include_tests) {
"test/bwe_test_framework.cc",
"test/bwe_test_framework.h",
"test/bwe_test_logging.h",
"test/estimators/bbr.cc",
"test/estimators/bbr.h",
"test/estimators/congestion_window.h",
"test/estimators/max_bandwidth_filter.h",
"test/estimators/min_rtt_filter.h",
"test/estimators/nada.cc",
"test/estimators/nada.h",
"test/estimators/remb.cc",

View File

@ -48,7 +48,8 @@ INSTANTIATE_TEST_CASE_P(VideoSendersTest,
BweSimulation,
::testing::Values(kRembEstimator,
kSendSideEstimator,
kNadaEstimator));
kNadaEstimator,
kBbrEstimator));
TEST_P(BweSimulation, SprintUplinkTest) {
AdaptiveVideoSource source(0, 30, 300, 0, 0);

View File

@ -13,6 +13,7 @@
#include <limits>
#include "webrtc/base/constructormagic.h"
#include "webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h"
#include "webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h"
#include "webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h"
#include "webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.h"
@ -93,6 +94,8 @@ BweSender* CreateBweSender(BandwidthEstimatorType estimator,
return new SendSideBweSender(kbps, observer, clock);
case kNadaEstimator:
return new NadaBweSender(kbps, observer, clock);
case kBbrEstimator:
return new BbrBweSender();
case kTcpEstimator:
FALLTHROUGH();
case kNullEstimator:
@ -112,6 +115,8 @@ BweReceiver* CreateBweReceiver(BandwidthEstimatorType type,
return new SendSideBweReceiver(flow_id);
case kNadaEstimator:
return new NadaBweReceiver(flow_id);
case kBbrEstimator:
return new BbrBweReceiver(flow_id);
case kTcpEstimator:
return new TcpBweReceiver(flow_id);
case kNullEstimator:

View File

@ -177,10 +177,11 @@ enum BandwidthEstimatorType {
kNadaEstimator,
kRembEstimator,
kSendSideEstimator,
kTcpEstimator
kTcpEstimator,
kBbrEstimator
};
const char* const bwe_names[] = {"Null", "NADA", "REMB", "GCC", "TCP"};
const char* const bwe_names[] = {"Null", "NADA", "REMB", "GCC", "TCP", "BBR"};
int64_t GetAbsSendTimeInMs(uint32_t abs_send_time);

View File

@ -152,6 +152,14 @@ void MediaPacket::SetAbsSendTimeMs(int64_t abs_send_time_ms) {
(1 << 18)) + 500) / 1000) & 0x00fffffful;
}
BbrBweFeedback::BbrBweFeedback(
int flow_id,
int64_t send_time_us,
int64_t latest_send_time_ms,
const std::vector<std::pair<uint64_t, int64_t>>& packet_feedback_vector)
: FeedbackPacket(flow_id, send_time_us, latest_send_time_ms),
packet_feedback_vector_(packet_feedback_vector) {}
RembFeedback::RembFeedback(int flow_id,
int64_t send_time_us,
int64_t last_send_time_ms,

View File

@ -0,0 +1,79 @@
/*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*
*/
#include "webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h"
#include <time.h>
#include <algorithm>
#include <utility>
#include "webrtc/base/logging.h"
#include "webrtc/modules/congestion_controller/delay_based_bwe.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h"
namespace webrtc {
namespace testing {
namespace bwe {
BbrBweSender::BbrBweSender() : BweSender() {
// Initially enter Startup mode.
EnterStartup();
}
BbrBweSender::~BbrBweSender() {}
int BbrBweSender::GetFeedbackIntervalMs() const {
return 0;
}
void BbrBweSender::GiveFeedback(const FeedbackPacket& feedback) {}
bool BbrBweSender::UpdateBandwidthAndMinRtt() {
return false;
}
void BbrBweSender::EnterStartup() {}
void BbrBweSender::TryExitingStartup() {}
void BbrBweSender::TryExitingDrain(int64_t now) {}
void BbrBweSender::EnterProbeBw(int64_t now) {}
void BbrBweSender::TryUpdatingCyclePhase(int64_t now) {}
void BbrBweSender::EnterProbeRtt(int64_t now) {}
void BbrBweSender::TryExitingProbeRtt(int64_t now) {}
int64_t BbrBweSender::TimeUntilNextProcess() {
return 100;
}
void BbrBweSender::OnPacketsSent(const Packets& packets) {}
void BbrBweSender::Process() {}
BbrBweReceiver::BbrBweReceiver(int flow_id)
: BweReceiver(flow_id, kReceivingRateTimeWindowMs),
clock_(0),
packet_feedbacks_() {}
BbrBweReceiver::~BbrBweReceiver() {}
void BbrBweReceiver::ReceivePacket(int64_t arrival_time_ms,
const MediaPacket& media_packet) {}
FeedbackPacket* BbrBweReceiver::GetFeedback(int64_t now_ms) {
return nullptr;
}
} // namespace bwe
} // namespace testing
} // namespace webrtc

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*
*/
#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_BBR_H_
#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_BBR_H_
#include <climits>
#include <map>
#include <memory>
#include <utility>
#include <vector>
#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h"
#include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h"
namespace webrtc {
namespace testing {
namespace bwe {
class MaxBandwidthFilter;
class MinRttFilter;
class CongestionWindow;
class BbrBweSender : public BweSender {
public:
BbrBweSender();
virtual ~BbrBweSender();
enum Mode {
// Startup phase.
STARTUP,
// Queue draining phase, which where created during startup.
DRAIN,
// Cruising, probing new bandwidth.
PROBE_BW,
// Temporarily limiting congestion window size in order to measure
// minimum RTT.
PROBE_RTT
};
struct PacketStats {
PacketStats() {}
PacketStats(int64_t send_time_, size_t payload_size_)
: send_time(send_time_), payload_size(payload_size_) {}
int64_t send_time;
size_t payload_size;
};
void OnPacketsSent(const Packets& packets) override;
int GetFeedbackIntervalMs() const override;
void GiveFeedback(const FeedbackPacket& feedback) override;
int64_t TimeUntilNextProcess() override;
void Process() override;
private:
void EnterStartup();
bool UpdateBandwidthAndMinRtt();
void TryExitingStartup();
void TryExitingDrain(int64_t now);
void EnterProbeBw(int64_t now);
void EnterProbeRtt(int64_t now);
void TryExitingProbeRtt(int64_t now);
void TryUpdatingCyclePhase(int64_t now);
};
class BbrBweReceiver : public BweReceiver {
public:
explicit BbrBweReceiver(int flow_id);
virtual ~BbrBweReceiver();
void ReceivePacket(int64_t arrival_time_ms,
const MediaPacket& media_packet) override;
FeedbackPacket* GetFeedback(int64_t now_ms) override;
private:
SimulatedClock clock_;
std::vector<std::pair<uint64_t, int64_t>> packet_feedbacks_;
};
} // namespace bwe
} // namespace testing
} // namespace webrtc
#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_BBR_H_

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*
*/
#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_CONGESTION_WINDOW_H_
#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_CONGESTION_WINDOW_H_
#include <climits>
#include <list>
#include <map>
#include <memory>
#include <utility>
#include <vector>
#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h"
#include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h"
namespace webrtc {
namespace testing {
namespace bwe {
class CongestionWindow {
public:
void set_gain(float gain);
size_t data_inflight();
int64_t GetCongestionWindow();
// Packet sent from sender, meaning it is inflight
// until we receive it and we should add packet's size to data_inflight.
void PacketSent();
// Ack was received by sender, meaning
// packet is no longer inflight.
void AckReceived();
// Returnes whether or not data inflight has been under
// fixed value for past x rounds and y ms.
bool DataInflightDecreased();
};
} // namespace bwe
} // namespace testing
} // namespace webrtc
#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_CONGESTION_WINDOW_H_

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*
*/
#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MAX_BANDWIDTH_FILTER_H_
#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MAX_BANDWIDTH_FILTER_H_
#include <climits>
#include <list>
#include <map>
#include <memory>
#include <utility>
#include <vector>
#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h"
#include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h"
namespace webrtc {
namespace testing {
namespace bwe {
class MaxBandwidthFilter {
public:
MaxBandwidthFilter();
~MaxBandwidthFilter();
int64_t max_bandwidth_estimate();
// Save bandwidth sample for the current round.
// We save bandwidth samples for past 10 rounds to
// provide better bandwidth estimate.
void AddBandwidthSample(int64_t round);
// Check if bandwidth has grown by certain multiplier for past x rounds,
// to decide whether or not delivery rate plateaued.
bool DeliveryRateGrows();
};
} // namespace bwe
} // namespace testing
} // namespace webrtc
#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MAX_BANDWIDTH_FILTER_H_

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*
*/
#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTER_H_
#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTER_H_
#include <climits>
#include <map>
#include <memory>
#include <utility>
#include <vector>
#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h"
#include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h"
namespace webrtc {
namespace testing {
namespace bwe {
class MinRttFilter {
public:
MinRttFilter();
~MinRttFilter();
int64_t min_rtt();
void UpdateMinRtt(int64_t min_rtt);
// Checks whether or last discovered min_rtt value
// is older than x seconds.
bool MinRttExpired(int64_t now);
void set_min_rtt_discovery_time(int64_t discovery_time);
};
} // namespace bwe
} // namespace testing
} // namespace webrtc
#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTER_H_

View File

@ -13,6 +13,7 @@
#include <list>
#include <map>
#include <utility>
#include <vector>
#include "webrtc/common_types.h"
@ -108,6 +109,24 @@ class FeedbackPacket : public Packet {
int64_t latest_send_time_ms_; // Time stamp for the latest sent FbPacket.
};
class BbrBweFeedback : public FeedbackPacket {
public:
BbrBweFeedback(
int flow_id,
int64_t send_time_us,
int64_t latest_send_time_ms,
const std::vector<std::pair<uint64_t, int64_t>>& packet_feedback_vector);
virtual ~BbrBweFeedback() {}
const std::vector<std::pair<uint64_t, int64_t>>& packet_feedback_vector()
const {
return packet_feedback_vector_;
}
private:
const std::vector<std::pair<uint64_t, int64_t>> packet_feedback_vector_;
};
class RembFeedback : public FeedbackPacket {
public:
RembFeedback(int flow_id,