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..1f2785390ecf952ffa9c6b38f69b0d212008045c |
--- /dev/null |
+++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.cc |
@@ -0,0 +1,60 @@ |
+/* |
+ * 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 { |
+const int64_t kStartingCongestionWindow = 6000; |
philipel
2017/07/06 12:15:14
Put const values inside an anonymous namespace.
philipel
2017/07/06 12:15:14
Add comments about what these values mean and wher
gnish1
2017/07/07 13:43:33
Done.
gnish1
2017/07/07 13:43:34
Done.
gnish1
2017/07/07 13:43:34
Done.
gnish1
2017/07/07 13:43:34
Done.
|
+const int64_t kMinimumCongestionWindow = 5840; |
+ |
+CongestionWindow::CongestionWindow() : data_inflight_(0) {} |
+ |
+CongestionWindow::~CongestionWindow() {} |
+ |
+int64_t CongestionWindow::GetCongestionWindow(BbrBweSender::Mode mode, |
+ int64_t bandwidth_estimate, |
+ int64_t min_rtt, |
+ float gain, |
+ size_t bytes_acked, |
+ int multiplier) { |
+ if (mode == 3) |
philipel
2017/07/06 12:15:15
Use enum, not '3'.
gnish1
2017/07/07 13:43:34
Done.
|
+ return kMinimumCongestionWindow; |
+ return GetTargetCongestionWindow(bandwidth_estimate, min_rtt, gain) + |
+ multiplier * bytes_acked; |
+} |
+ |
+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; |
+} |
+ |
+int64_t CongestionWindow::GetTargetCongestionWindow(int64_t bandwidth_estimate, |
+ int64_t min_rtt, |
+ float gain) { |
+ int64_t bdp = min_rtt * bandwidth_estimate; |
+ int64_t congestion_window = bdp * gain; |
+ if (!congestion_window) { |
philipel
2017/07/06 12:15:14
How/why can the congestion window be 0? Add commen
philipel
2017/07/06 12:15:14
remove {}
gnish1
2017/07/07 13:43:34
Done.
gnish1
2017/07/07 13:43:34
Done.
|
+ congestion_window = gain * kStartingCongestionWindow; |
+ } |
+ return std::max(congestion_window, kMinimumCongestionWindow); |
+} |
+} // namespace bwe |
+} // namespace testing |
+} // namespace webrtc |