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