Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.cc

Issue 2966403002: Added implementation of three classes in BBR,with unit-tests. (Closed)
Patch Set: Variables' names changed, added units in which they are measured. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.cc
diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.cc b/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7d9270200a6dbccb2f25091162f6f7e058f04345
--- /dev/null
+++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.cc
@@ -0,0 +1,69 @@
+/*
+ * 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/congestion_window.h"
+
+#include <algorithm>
+
+#include "webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h"
+
+namespace webrtc {
+namespace testing {
+namespace bwe {
+namespace {
+// kStartingCongestionWindow is used to set congestion window when bandwidth
+// delay product is equal to zero, so that we don't set window to zero as well.
+// Chosen randomly by me, because this value shouldn't make any significant
+// difference, as bandwidth delay product is more than zero almost every time.
+const int kStartingCongestionWindow = 6000;
+// Size of congestion window while in PROBE_RTT mode, suggested by BBR's source
+// code of QUIC's implementation.
+const int kMinimumCongestionWindow = 5840;
+} // namespace
+
+CongestionWindow::CongestionWindow() : data_inflight_(0) {}
+
+CongestionWindow::~CongestionWindow() {}
+
+int CongestionWindow::GetCongestionWindow(
+ BbrBweSender::Mode mode,
+ int64_t bandwidth_estimate_bytes_per_ms,
+ int64_t min_rtt_ms,
+ float gain) {
+ if (mode == BbrBweSender::PROBE_RTT)
+ return kMinimumCongestionWindow;
+ return GetTargetCongestionWindow(bandwidth_estimate_bytes_per_ms, min_rtt_ms,
terelius 2017/07/12 14:52:21 Measured in bytes/ms, the lowest rate you could es
+ gain);
+}
+
+void CongestionWindow::PacketSent(size_t sent_packet_size) {
+ data_inflight_ += sent_packet_size;
+}
+
+void CongestionWindow::AckReceived(size_t received_packet_size) {
+ data_inflight_ -= received_packet_size;
+}
+
+int CongestionWindow::GetTargetCongestionWindow(
+ int64_t bandwidth_estimate_bytes_per_ms,
+ int64_t min_rtt_ms,
+ float gain) {
+ int bdp = min_rtt_ms * bandwidth_estimate_bytes_per_ms;
+ int congestion_window = bdp * gain;
+ // Congestion window could be zero in rare cases, when either no bandwidth
+ // estimate is available, or path's min_rtt value is zero.
+ if (!congestion_window)
+ congestion_window = gain * kStartingCongestionWindow;
+ return std::max(congestion_window, kMinimumCongestionWindow);
+}
+} // namespace bwe
+} // namespace testing
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698