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..378fa5c230a9e64696e045dc5eed1e7ab468655a |
--- /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; |
terelius
2017/07/12 10:34:50
Is there any reason for not setting it to the mini
gnish1
2017/07/12 12:23:18
It depends on the situation, this variable shouldn
|
+// 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, |
+ int64_t min_rtt, |
+ float gain, |
+ size_t bytes_acked, |
+ int multiplier) { |
+ if (mode == BbrBweSender::PROBE_RTT) |
+ return kMinimumCongestionWindow; |
+ return GetTargetCongestionWindow(bandwidth_estimate, min_rtt, gain) + |
+ multiplier * bytes_acked; |
terelius
2017/07/12 10:34:51
Why do we add bytes_acked?
gnish1
2017/07/12 12:23:18
Done.
|
+} |
+ |
+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, |
+ int64_t min_rtt, |
+ float gain) { |
+ int bdp = min_rtt * bandwidth_estimate; |
+ 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; |
terelius
2017/07/12 10:34:50
Shouldn't the gain factor already be part of kStar
gnish1
2017/07/12 12:23:18
No, gain factor may change, so it is not possible
|
+ return std::max(congestion_window, kMinimumCongestionWindow); |
+} |
+} // namespace bwe |
+} // namespace testing |
+} // namespace webrtc |