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

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: 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 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.
22 const int64_t kMinimumCongestionWindow = 5840;
23
24 CongestionWindow::CongestionWindow() : data_inflight_(0) {}
25
26 CongestionWindow::~CongestionWindow() {}
27
28 int64_t CongestionWindow::GetCongestionWindow(BbrBweSender::Mode mode,
29 int64_t bandwidth_estimate,
30 int64_t min_rtt,
31 float gain,
32 size_t bytes_acked,
33 int multiplier) {
34 if (mode == 3)
philipel 2017/07/06 12:15:15 Use enum, not '3'.
gnish1 2017/07/07 13:43:34 Done.
35 return kMinimumCongestionWindow;
36 return GetTargetCongestionWindow(bandwidth_estimate, min_rtt, gain) +
37 multiplier * bytes_acked;
38 }
39
40 void CongestionWindow::PacketSent(size_t sent_packet_size) {
41 data_inflight_ += sent_packet_size;
42 }
43
44 void CongestionWindow::AckReceived(size_t received_packet_size) {
45 data_inflight_ -= received_packet_size;
46 }
47
48 int64_t CongestionWindow::GetTargetCongestionWindow(int64_t bandwidth_estimate,
49 int64_t min_rtt,
50 float gain) {
51 int64_t bdp = min_rtt * bandwidth_estimate;
52 int64_t congestion_window = bdp * gain;
53 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.
54 congestion_window = gain * kStartingCongestionWindow;
55 }
56 return std::max(congestion_window, kMinimumCongestionWindow);
57 }
58 } // namespace bwe
59 } // namespace testing
60 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698