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

Side by Side 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: Changed names of some variables. 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 *
10 */
11
12 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_win dow.h"
13
14 #include <algorithm>
15
16 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h"
17
18 namespace webrtc {
19 namespace testing {
20 namespace bwe {
21 namespace {
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.
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.
26 const int kStartingCongestionWindow = 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
31
32 CongestionWindow::CongestionWindow() : data_inflight_(0) {}
33
34 CongestionWindow::~CongestionWindow() {}
35
36 int CongestionWindow::GetCongestionWindow(BbrBweSender::Mode mode,
37 int64_t bandwidth_estimate,
38 int64_t min_rtt,
39 float gain) {
40 if (mode == BbrBweSender::PROBE_RTT)
41 return kMinimumCongestionWindow;
42 return GetTargetCongestionWindow(bandwidth_estimate, min_rtt, gain);
43 }
44
45 void CongestionWindow::PacketSent(size_t sent_packet_size) {
46 data_inflight_ += sent_packet_size;
47 }
48
49 void CongestionWindow::AckReceived(size_t received_packet_size) {
50 data_inflight_ -= received_packet_size;
51 }
52
53 int CongestionWindow::GetTargetCongestionWindow(int64_t bandwidth_estimate,
54 int64_t min_rtt,
55 float gain) {
56 int bdp = min_rtt * bandwidth_estimate;
57 int congestion_window = bdp * gain;
58 // Congestion window could be zero in rare cases, when either no bandwidth
59 // estimate is available, or path's min_rtt value is zero.
60 if (!congestion_window)
61 congestion_window = gain * kStartingCongestionWindow;
62 return std::max(congestion_window, kMinimumCongestionWindow);
63 }
64 } // namespace bwe
65 } // namespace testing
66 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698