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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.cc

Issue 2999073002: Tweaked version of BBR for WebRTC. (Closed)
Patch Set: Updated according to comments. Created 3 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 * 9 *
10 */ 10 */
11 11
12 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_win dow.h" 12 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_win dow.h"
13 13
14 #include <algorithm> 14 #include <algorithm>
15 15
16 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h" 16 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h"
17 17
18 namespace webrtc { 18 namespace webrtc {
19 namespace testing { 19 namespace testing {
20 namespace bwe { 20 namespace bwe {
21 namespace { 21 namespace {
22 // kStartingCongestionWindowBytes is used to set congestion window when 22 // kStartingCongestionWindowBytes is used to set congestion window when
23 // bandwidth delay product is equal to zero, so that we don't set window to zero 23 // bandwidth delay product is equal to zero, so that we don't set window to zero
24 // as well. Chosen randomly by me, because this value shouldn't make any 24 // as well. Chosen randomly by me, because this value shouldn't make any
25 // significant difference, as bandwidth delay product is more than zero almost 25 // significant difference, as bandwidth delay product is more than zero almost
26 // every time. 26 // every time.
27 const int kStartingCongestionWindowBytes = 6000; 27 const int kStartingCongestionWindowBytes = 6000;
28 } // namespace 28 } // namespace
29 29
30 const int CongestionWindow::kMinimumCongestionWindowBytes;
31
32 CongestionWindow::CongestionWindow() : data_inflight_bytes_(0) {} 30 CongestionWindow::CongestionWindow() : data_inflight_bytes_(0) {}
33 31
34 CongestionWindow::~CongestionWindow() {} 32 CongestionWindow::~CongestionWindow() {}
35 33
36 int CongestionWindow::GetCongestionWindow(BbrBweSender::Mode mode, 34 int CongestionWindow::GetCongestionWindow(BbrBweSender::Mode mode,
37 int64_t bandwidth_estimate_bps, 35 int64_t bandwidth_estimate_bps,
38 rtc::Optional<int64_t> min_rtt_ms, 36 rtc::Optional<int64_t> min_rtt_ms,
39 float gain) { 37 float gain) {
40 if (mode == BbrBweSender::PROBE_RTT)
41 return CongestionWindow::kMinimumCongestionWindowBytes;
42 return GetTargetCongestionWindow(bandwidth_estimate_bps, min_rtt_ms, gain); 38 return GetTargetCongestionWindow(bandwidth_estimate_bps, min_rtt_ms, gain);
43 } 39 }
44 40
45 void CongestionWindow::PacketSent(size_t sent_packet_size_bytes) { 41 void CongestionWindow::PacketSent(size_t sent_packet_size_bytes) {
46 data_inflight_bytes_ += sent_packet_size_bytes; 42 data_inflight_bytes_ += sent_packet_size_bytes;
47 } 43 }
48 44
49 void CongestionWindow::AckReceived(size_t received_packet_size_bytes) { 45 void CongestionWindow::AckReceived(size_t received_packet_size_bytes) {
46 RTC_DCHECK_GE(data_inflight_bytes_ >= received_packet_size_bytes, true);
50 data_inflight_bytes_ -= received_packet_size_bytes; 47 data_inflight_bytes_ -= received_packet_size_bytes;
51 } 48 }
52 49
53 int CongestionWindow::GetTargetCongestionWindow( 50 int CongestionWindow::GetTargetCongestionWindow(
54 int64_t bandwidth_estimate_bps, 51 int64_t bandwidth_estimate_bps,
55 rtc::Optional<int64_t> min_rtt_ms, 52 rtc::Optional<int64_t> min_rtt_ms,
56 float gain) { 53 float gain) {
57 // If we have no rtt sample yet, return the starting congestion window size. 54 // If we have no rtt sample yet, return the starting congestion window size.
58 if (!min_rtt_ms) 55 if (!min_rtt_ms)
59 return gain * kStartingCongestionWindowBytes; 56 return gain * kStartingCongestionWindowBytes;
60 int bdp = *min_rtt_ms * bandwidth_estimate_bps; 57 int bdp = *min_rtt_ms * bandwidth_estimate_bps / 8000;
61 int congestion_window = bdp * gain; 58 int congestion_window = bdp * gain;
62 // Congestion window could be zero in rare cases, when either no bandwidth 59 // Congestion window could be zero in rare cases, when either no bandwidth
63 // estimate is available, or path's min_rtt value is zero. 60 // estimate is available, or path's min_rtt value is zero.
64 if (!congestion_window) 61 if (!congestion_window)
65 congestion_window = gain * kStartingCongestionWindowBytes; 62 congestion_window = gain * kStartingCongestionWindowBytes;
66 return std::max(congestion_window, 63 return congestion_window;
67 CongestionWindow::kMinimumCongestionWindowBytes);
68 } 64 }
69 } // namespace bwe 65 } // namespace bwe
70 } // namespace testing 66 } // namespace testing
71 } // namespace webrtc 67 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698