OLD | NEW |
---|---|
(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( | |
37 BbrBweSender::Mode mode, | |
38 int64_t bandwidth_estimate_bytes_per_ms, | |
39 int64_t min_rtt_ms, | |
40 float gain) { | |
41 if (mode == BbrBweSender::PROBE_RTT) | |
42 return kMinimumCongestionWindow; | |
43 return GetTargetCongestionWindow(bandwidth_estimate_bytes_per_ms, min_rtt_ms, | |
terelius
2017/07/12 14:52:21
Measured in bytes/ms, the lowest rate you could es
| |
44 gain); | |
45 } | |
46 | |
47 void CongestionWindow::PacketSent(size_t sent_packet_size) { | |
48 data_inflight_ += sent_packet_size; | |
49 } | |
50 | |
51 void CongestionWindow::AckReceived(size_t received_packet_size) { | |
52 data_inflight_ -= received_packet_size; | |
53 } | |
54 | |
55 int CongestionWindow::GetTargetCongestionWindow( | |
56 int64_t bandwidth_estimate_bytes_per_ms, | |
57 int64_t min_rtt_ms, | |
58 float gain) { | |
59 int bdp = min_rtt_ms * bandwidth_estimate_bytes_per_ms; | |
60 int congestion_window = bdp * gain; | |
61 // Congestion window could be zero in rare cases, when either no bandwidth | |
62 // estimate is available, or path's min_rtt value is zero. | |
63 if (!congestion_window) | |
64 congestion_window = gain * kStartingCongestionWindow; | |
65 return std::max(congestion_window, kMinimumCongestionWindow); | |
66 } | |
67 } // namespace bwe | |
68 } // namespace testing | |
69 } // namespace webrtc | |
OLD | NEW |