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

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

Issue 2924603002: Added implementation of four functions in the BBR congestion controller. (Closed)
Patch Set: f removed. 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
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/bbr.h" 12 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h"
13 13
14 #include <time.h> 14 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/max_bandwidth_ filter.h"
15 #include <algorithm>
16 #include <utility>
17
18 #include "webrtc/base/logging.h"
19 #include "webrtc/modules/congestion_controller/delay_based_bwe.h"
20 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h"
21 15
22 namespace webrtc { 16 namespace webrtc {
23 namespace testing { 17 namespace testing {
24 namespace bwe { 18 namespace bwe {
25 BbrBweSender::BbrBweSender() : BweSender() { 19 namespace {
20 const int kFeedbackIntervalsMs = 100;
21 // BBR uses this value to double sending rate each round trip. Design document
22 // suggests using this value.
23 const float kHighGain = 2.885f;
24 // BBR uses this value to drain queues created during STARTUP in one round trip
25 // time.
26 const float kDrainGain = 1 / kHighGain;
27 // kStartupGrowthTarget and kMaxRoundsWithoutGrowth are chosen from
28 // experiments,according to design document.
29 const float kStartupGrowthTarget = 1.25f;
30 const int kMaxRoundsWithoutGrowth = 3;
31 } // namespace
32
33 BbrBweSender::BbrBweSender(Clock* clock)
34 : BweSender(0),
35 clock_(clock),
36 mode_(STARTUP),
37 max_bandwidth_filter_(new MaxBandwidthFilter()),
38 round_count_(0),
39 last_packet_sent_(0),
40 round_trip_end_(0),
41 full_bandwidth_reached_(false) {
26 // Initially enter Startup mode. 42 // Initially enter Startup mode.
27 EnterStartup(); 43 EnterStartup();
28 } 44 }
29 45
30 BbrBweSender::~BbrBweSender() {} 46 BbrBweSender::~BbrBweSender() {}
31 47
32 int BbrBweSender::GetFeedbackIntervalMs() const { 48 int BbrBweSender::GetFeedbackIntervalMs() const {
33 return 0; 49 return kFeedbackIntervalsMs;
34 } 50 }
35 51
36 void BbrBweSender::GiveFeedback(const FeedbackPacket& feedback) {} 52 void BbrBweSender::GiveFeedback(const FeedbackPacket& feedback) {
53 const BbrBweFeedback& fb = static_cast<const BbrBweFeedback&>(feedback);
54 // feedback_vector holds values of acknowledged packets' sequence numbers.
55 const std::vector<uint64_t>& feedback_vector = fb.packet_feedback_vector();
56 // Check if new round started for the connection. Round is the period of time
57 // from sending packet to its acknowledgement.
58 bool new_round_started = false;
59 if (!feedback_vector.empty()) {
60 uint64_t last_acked_packet = *feedback_vector.rbegin();
61 if (last_acked_packet > round_trip_end_) {
62 new_round_started = true;
63 round_count_++;
64 round_trip_end_ = last_packet_sent_;
65 }
66 }
67 if (new_round_started && !full_bandwidth_reached_) {
68 full_bandwidth_reached_ = max_bandwidth_filter_->FullBandwidthReached(
69 kStartupGrowthTarget, kMaxRoundsWithoutGrowth);
70 }
71 int now = clock_->TimeInMilliseconds();
72 switch (mode_) {
73 break;
74 case STARTUP:
75 TryExitingStartup();
76 break;
77 case DRAIN:
78 TryExitingDrain(now);
79 break;
80 case PROBE_BW:
81 TryUpdatingCyclePhase(now);
82 break;
83 case PROBE_RTT:
84 TryExitingProbeRtt(now);
85 break;
86 }
87 TryEnteringProbeRtt(now);
88 // TODO(gnish): implement functions updating congestion window and pacing rate
89 // controllers.
90 }
37 91
38 bool BbrBweSender::UpdateBandwidthAndMinRtt() { 92 bool BbrBweSender::UpdateBandwidthAndMinRtt() {
39 return false; 93 return false;
40 } 94 }
41 95
42 void BbrBweSender::EnterStartup() {} 96 void BbrBweSender::EnterStartup() {
97 mode_ = STARTUP;
98 pacing_gain_ = kHighGain;
99 congestion_window_gain_ = kHighGain;
100 }
43 101
44 void BbrBweSender::TryExitingStartup() {} 102 void BbrBweSender::TryExitingStartup() {
103 if (full_bandwidth_reached_) {
104 mode_ = DRAIN;
105 pacing_gain_ = kDrainGain;
106 congestion_window_gain_ = kHighGain;
107 }
108 }
45 109
46 void BbrBweSender::TryExitingDrain(int64_t now) {} 110 void BbrBweSender::TryExitingDrain(int64_t now) {}
47 111
48 void BbrBweSender::EnterProbeBw(int64_t now) {} 112 void BbrBweSender::EnterProbeBw(int64_t now) {}
49 113
50 void BbrBweSender::TryUpdatingCyclePhase(int64_t now) {} 114 void BbrBweSender::TryUpdatingCyclePhase(int64_t now) {}
51 115
52 void BbrBweSender::EnterProbeRtt(int64_t now) {} 116 void BbrBweSender::TryEnteringProbeRtt(int64_t now) {}
53
54 void BbrBweSender::TryExitingProbeRtt(int64_t now) {} 117 void BbrBweSender::TryExitingProbeRtt(int64_t now) {}
55 118
56 int64_t BbrBweSender::TimeUntilNextProcess() { 119 int64_t BbrBweSender::TimeUntilNextProcess() {
57 return 100; 120 return 100;
58 } 121 }
59 122
60 void BbrBweSender::OnPacketsSent(const Packets& packets) {} 123 void BbrBweSender::OnPacketsSent(const Packets& packets) {
124 last_packet_sent_ =
125 static_cast<const MediaPacket*>(packets.back())->sequence_number();
126 }
61 127
62 void BbrBweSender::Process() {} 128 void BbrBweSender::Process() {}
63 129
64 BbrBweReceiver::BbrBweReceiver(int flow_id) 130 BbrBweReceiver::BbrBweReceiver(int flow_id)
65 : BweReceiver(flow_id, kReceivingRateTimeWindowMs), 131 : BweReceiver(flow_id, kReceivingRateTimeWindowMs), clock_(0) {}
66 clock_(0),
67 packet_feedbacks_() {}
68 132
69 BbrBweReceiver::~BbrBweReceiver() {} 133 BbrBweReceiver::~BbrBweReceiver() {}
70 134
71 void BbrBweReceiver::ReceivePacket(int64_t arrival_time_ms, 135 void BbrBweReceiver::ReceivePacket(int64_t arrival_time_ms,
72 const MediaPacket& media_packet) {} 136 const MediaPacket& media_packet) {}
73 137
74 FeedbackPacket* BbrBweReceiver::GetFeedback(int64_t now_ms) { 138 FeedbackPacket* BbrBweReceiver::GetFeedback(int64_t now_ms) {
75 return nullptr; 139 return nullptr;
76 } 140 }
77 } // namespace bwe 141 } // namespace bwe
78 } // namespace testing 142 } // namespace testing
79 } // namespace webrtc 143 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698