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

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

Issue 2904183002: Structure of BBR's implementation,some main classes and functions which are going to be used (Closed)
Patch Set: Moved include on top Created 3 years, 6 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/bbr.h"
13
14 #include <time.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
22 namespace webrtc {
23 namespace testing {
24 namespace bwe {
25 namespace {
26 const float kHighGain = 2.885f;
stefan-webrtc 2017/05/30 09:45:13 Could you point to a reference which recommends th
gnish2 2017/05/30 15:13:20 Done.
27 const float kDrainGain = 1.f / kHighGain;
28 const int kFeedbackIntervals = 100;
stefan-webrtc 2017/05/30 09:45:13 Unit?
gnish2 2017/05/30 15:13:20 Done.
29 }
30
31 BbrBweSender::BbrBweSender(int kbps, BitrateObserver* observer, Clock* clock)
32 : BweSender(kbps),
33 clock_(clock),
34 observer_(observer),
35 send_time_(),
36 mode_(STARTUP),
37 stats_(),
38 round_trip_end_(0),
39 rt_count_(0),
40 last_packet_sent_(0) {
41 // Initially enter Startup mode.
42 EnterStartup();
43 }
44
45 BbrBweSender::~BbrBweSender() {}
46
47 int BbrBweSender::GetFeedbackIntervalMs() const {
48 return kFeedbackIntervals;
49 }
50
51 int BbrBweSender::GetPacketSize(uint64_t sequence_number) {
philipel 2017/05/30 09:43:38 Is this function necessary, wont it be trivial whe
gnish2 2017/05/30 15:13:20 Done.
52 return 0;
53 }
54
55 void BbrBweSender::GiveFeedback(const FeedbackPacket& feedback) {
56 bool min_rtt_expired = false;
stefan-webrtc 2017/05/30 09:45:13 Move declaration down to where it's used the first
gnish2 2017/05/30 15:13:20 Done.
57 int now = clock_->TimeInMilliseconds();
58 int64_t bytes_acked = 0;
stefan-webrtc 2017/05/30 09:45:13 Same with these two
gnish2 2017/05/30 15:13:20 Done.
59 const BbrBweFeedback& fb = static_cast<const BbrBweFeedback&>(feedback);
60 const std::vector<std::pair<uint64_t, int64_t>>& feedback_vector =
stefan-webrtc 2017/05/30 09:45:12 Here I'd probably use const auto&
gnish2 2017/05/30 15:13:20 Done.
61 fb.packet_feedback_vector();
62 // Calculate number of bytes acknowledged after the feedback.
philipel 2017/05/30 09:43:38 For trivial pieces of code comments are not useful
gnish2 2017/05/30 15:13:21 Done.
63 for (const auto& feedback : feedback_vector) {
philipel 2017/05/30 09:43:38 remove {}
gnish2 2017/05/30 15:13:20 Done.
64 bytes_acked += GetPacketSize(feedback.first);
65 }
66 // Update bandwidth and min_rtt estimates,also
stefan-webrtc 2017/05/30 09:45:12 space after ,
gnish2 2017/05/30 15:13:21 Done.
67 // check if current min_rtt estimate expired or not.
philipel 2017/05/30 09:43:38 Since you choose descriptive names (good! :)) this
gnish2 2017/05/30 15:13:21 Done.
68 min_rtt_expired = UpdateBandwidthAndMinRtt(now, feedback_vector, bytes_acked);
69 // If it did enter ProbeRtt mode.
philipel 2017/05/30 09:43:38 Remove comment
stefan-webrtc 2017/05/30 09:45:13 I don't understand this comment
gnish2 2017/05/30 15:13:20 Done.
gnish2 2017/05/30 15:13:21 Done.
70 if (min_rtt_expired) {
philipel 2017/05/30 09:43:38 remove {}
gnish2 2017/05/30 15:13:20 Done.
71 EnterProbeRtt(now);
72 }
73 // This switch checks whether it is time or not to exit
74 // the current mode we are in.
75 switch (mode_) {
76 case STARTUP:
77 TryExitingStartup();
78 break;
79 case DRAIN:
80 TryExitingDrain(now);
81 break;
82 case PROBE_BW:
83 TryUpdatingCyclePhase(now);
84 break;
85 case PROBE_RTT:
86 TryExitingProbeRtt(now);
87 break;
88 }
89
90 // Update pacing rate and congestion window values.
91 // TODO(gnish): Implement CalculatePacingRate() and
92 // CalculateCongestionWindow() functions.
93 stats_->CalculatePacingRate();
94 stats_->CalculateCongestionWindow();
95 }
96
97 bool BbrBweSender::UpdateBandwidthAndMinRtt(
98 int64_t now,
99 const std::vector<std::pair<uint64_t, int64_t>>& feedback_vector,
100 int64_t bytes_acked) {
101 return false;
102 }
103
104 void BbrBweSender::EnterStartup() {
105 mode_ = STARTUP;
106 stats_->set_pacing_gain(kHighGain);
stefan-webrtc 2017/05/30 09:45:12 What is the purpose of stats_? Seems odd that it's
gnish2 2017/05/30 15:13:21 stats_ is responsible to basically store all the d
107 }
108
109 void BbrBweSender::TryExitingStartup() {
110 // If delivery rate hasn't grown
111 // switch to Drain mode.
stefan-webrtc 2017/05/30 09:45:13 Merge these lines.
gnish2 2017/05/30 15:13:20 Done.
112 // TODO(gnish): Implement DeliveryRateGrows()
113 if (!stats_->DeliveryRateGrows()) {
114 mode_ = DRAIN;
115 stats_->set_pacing_gain(kDrainGain);
116 }
117 }
118
119 void BbrBweSender::TryExitingDrain(int64_t now) {}
120
121 void BbrBweSender::EnterProbeBw(int64_t now) {}
122
123 void BbrBweSender::TryUpdatingCyclePhase(int64_t now) {}
124
125 void BbrBweSender::EnterProbeRtt(int64_t now) {}
126
127 void BbrBweSender::TryExitingProbeRtt(int64_t now) {}
128
129 int64_t BbrBweSender::TimeUntilNextProcess() {
130 return 100;
131 }
132
133 void BbrBweSender::OnPacketsSent(const Packets& packets) {}
134
135 void BbrBweSender::Process() {}
136
137 BbrBweReceiver::BbrBweReceiver(int flow_id)
138 : BweReceiver(flow_id, kReceivingRateTimeWindowMs),
139 last_feedback_ms_(0),
140 clock_(0),
141 packet_feedbacks_() {}
142
143 BbrBweReceiver::~BbrBweReceiver() {}
144
145 void BbrBweReceiver::ReceivePacket(int64_t arrival_time_ms,
146 const MediaPacket& media_packet) {
147 packet_feedbacks_.push_back(
philipel 2017/05/30 09:43:38 Instead of packet_feedbacks_.push_back( {m
gnish2 2017/05/30 15:13:21 Done.
148 {media_packet.sequence_number(), arrival_time_ms});
149 BweReceiver::ReceivePacket(arrival_time_ms, media_packet);
150 }
151
152 FeedbackPacket* BbrBweReceiver::GetFeedback(int64_t now_ms) {
philipel 2017/05/30 09:43:38 I think this function should be as bare bone as po
gnish2 2017/05/30 15:13:21 Done.
153 if (now_ms - last_feedback_ms_ < kFeedbackIntervals)
154 return NULL;
philipel 2017/05/30 09:43:38 NULL --> nullptr
gnish2 2017/05/30 15:13:20 Done.
155 last_feedback_ms_ = now_ms;
156 int64_t corrected_send_time_ms = 0L;
157 if (!received_packets_.empty()) {
158 PacketIdentifierNode* latest = *(received_packets_.begin());
stefan-webrtc 2017/05/30 09:45:13 Remove parentheses.
gnish2 2017/05/30 15:13:20 Done.
159 corrected_send_time_ms =
160 latest->send_time_ms + now_ms - latest->arrival_time_ms;
161 }
162 FeedbackPacket* fb = new BbrBweFeedback(
163 flow_id_, now_ms * 1000, corrected_send_time_ms, packet_feedbacks_);
164 packet_feedbacks_.clear();
165 return fb;
166 }
167 } // namespace bwe
168 } // namespace testing
169 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698