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

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

Issue 2982233002: Added implementations for entering/exiting STARTUP, DRAIN, PROBE_BW, PROBE_RTT modes, also updated M (Closed)
Patch Set: Added comments to variables. 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 // kStartingCongestionWindow is used to set congestion window when bandwidth 22 // kStartingCongestionWindow is used to set congestion window when bandwidth
23 // delay product is equal to zero, so that we don't set window to zero as well. 23 // delay product is equal to zero, so that we don't set window to zero as well.
24 // Chosen randomly by me, because this value shouldn't make any significant 24 // Chosen randomly by me, because this value shouldn't make any significant
25 // difference, as bandwidth delay product is more than zero almost every time. 25 // difference, as bandwidth delay product is more than zero almost every time.
26 const int kStartingCongestionWindow = 6000; 26 const int kStartingCongestionWindowBytes = 6000;
27 // Size of congestion window while in PROBE_RTT mode, suggested by BBR's source
28 // code of QUIC's implementation.
29 const int kMinimumCongestionWindow = 5840;
30 } // namespace 27 } // namespace
31 28
29 const int CongestionWindow::kMinimumCongestionWindowBytes;
30
32 CongestionWindow::CongestionWindow() : data_inflight_bytes_(0) {} 31 CongestionWindow::CongestionWindow() : data_inflight_bytes_(0) {}
33 32
34 CongestionWindow::~CongestionWindow() {} 33 CongestionWindow::~CongestionWindow() {}
35 34
36 int CongestionWindow::GetCongestionWindow( 35 int CongestionWindow::GetCongestionWindow(BbrBweSender::Mode mode,
37 BbrBweSender::Mode mode, 36 int64_t bandwidth_estimate_bps,
38 int64_t bandwidth_estimate_bytes_per_ms, 37 rtc::Optional<int64_t> min_rtt_ms,
39 int64_t min_rtt_ms, 38 float gain) {
40 float gain) {
41 if (mode == BbrBweSender::PROBE_RTT) 39 if (mode == BbrBweSender::PROBE_RTT)
42 return kMinimumCongestionWindow; 40 return CongestionWindow::kMinimumCongestionWindowBytes;
43 return GetTargetCongestionWindow(bandwidth_estimate_bytes_per_ms, min_rtt_ms, 41 return GetTargetCongestionWindow(bandwidth_estimate_bps, min_rtt_ms, gain);
44 gain);
45 } 42 }
46 43
47 void CongestionWindow::PacketSent(size_t sent_packet_size_bytes) { 44 void CongestionWindow::PacketSent(size_t sent_packet_size_bytes) {
48 data_inflight_bytes_ += sent_packet_size_bytes; 45 data_inflight_bytes_ += sent_packet_size_bytes;
49 } 46 }
50 47
51 void CongestionWindow::AckReceived(size_t received_packet_size_bytes) { 48 void CongestionWindow::AckReceived(size_t received_packet_size_bytes) {
52 data_inflight_bytes_ -= received_packet_size_bytes; 49 data_inflight_bytes_ -= received_packet_size_bytes;
53 } 50 }
54 51
55 int CongestionWindow::GetTargetCongestionWindow( 52 int CongestionWindow::GetTargetCongestionWindow(
56 int64_t bandwidth_estimate_bytes_per_ms, 53 int64_t bandwidth_estimate_bps,
57 int64_t min_rtt_ms, 54 rtc::Optional<int64_t> min_rtt_ms,
58 float gain) { 55 float gain) {
59 int bdp = min_rtt_ms * bandwidth_estimate_bytes_per_ms; 56 int bdp = *min_rtt_ms * bandwidth_estimate_bps;
philipel 2017/07/27 09:15:28 |min_rtt_ms| is an Optional but you assume it is a
gnish1 2017/07/27 11:24:25 Done.
60 int congestion_window = bdp * gain; 57 int congestion_window = bdp * gain;
61 // Congestion window could be zero in rare cases, when either no bandwidth 58 // Congestion window could be zero in rare cases, when either no bandwidth
62 // estimate is available, or path's min_rtt value is zero. 59 // estimate is available, or path's min_rtt value is zero.
63 if (!congestion_window) 60 if (!congestion_window)
64 congestion_window = gain * kStartingCongestionWindow; 61 congestion_window = gain * kStartingCongestionWindowBytes;
65 return std::max(congestion_window, kMinimumCongestionWindow); 62 return std::max(congestion_window,
63 CongestionWindow::kMinimumCongestionWindowBytes);
66 } 64 }
67 } // namespace bwe 65 } // namespace bwe
68 } // namespace testing 66 } // namespace testing
69 } // namespace webrtc 67 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698