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. | |
29 // 2/ln(2)=2.885,because derivative of 2^t = 2/ln(2) + constant. | |
terelius
2017/06/07 08:11:22
Please clarify your explanation. The derivative of
terelius
2017/06/07 08:11:22
space after comma
gnish1
2017/06/07 09:25:56
Done.
gnish1
2017/06/07 09:25:56
Done.
| |
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. | |
36 const float kStartupGrowthTarget = 1.25; | |
37 const int kMaxRoundsWithoutGrowth = 3; | |
38 } // namespace | |
39 BbrBweSender::BbrBweSender(Clock* clock) | |
40 : BweSender(0), | |
41 clock_(clock), | |
42 mode_(STARTUP), | |
43 max_bandwidth_filter_(), | |
44 rt_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 = | |
61 fb.packet_feedback_vector(); | |
62 // Check if new round started for the connection. | |
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 rt_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 break; | |
91 } | |
92 TryEnteringOrExitingProbeRtt(now); | |
93 // TODO(gnish): implement functions updating | |
94 // congestion window and pacing rate controllers. | |
95 } | |
37 | 96 |
38 bool BbrBweSender::UpdateBandwidthAndMinRtt() { | 97 bool BbrBweSender::UpdateBandwidthAndMinRtt() { |
39 return false; | 98 return false; |
40 } | 99 } |
41 | 100 |
42 void BbrBweSender::EnterStartup() {} | 101 void BbrBweSender::EnterStartup() { |
102 mode_ = STARTUP; | |
103 pacing_gain_ = kHighGain; | |
104 congestion_window_gain_ = kHighGain; | |
105 } | |
43 | 106 |
44 void BbrBweSender::TryExitingStartup() {} | 107 void BbrBweSender::TryExitingStartup() { |
108 if (full_bandwidth_reached_) { | |
109 mode_ = DRAIN; | |
110 pacing_gain_ = kDrainGain; | |
111 congestion_window_gain_ = kHighGain; | |
112 } | |
113 } | |
45 | 114 |
46 void BbrBweSender::TryExitingDrain(int64_t now) {} | 115 void BbrBweSender::TryExitingDrain(int64_t now) {} |
47 | 116 |
48 void BbrBweSender::EnterProbeBw(int64_t now) {} | 117 void BbrBweSender::EnterProbeBw(int64_t now) {} |
49 | 118 |
50 void BbrBweSender::TryUpdatingCyclePhase(int64_t now) {} | 119 void BbrBweSender::TryUpdatingCyclePhase(int64_t now) {} |
51 | 120 |
52 void BbrBweSender::EnterProbeRtt(int64_t now) {} | 121 void BbrBweSender::TryEnteringOrExitingProbeRtt(int64_t now) {} |
terelius
2017/06/07 08:11:22
Do we really want one function that both tries to
gnish1
2017/06/07 09:25:56
Done.
| |
53 | |
54 void BbrBweSender::TryExitingProbeRtt(int64_t now) {} | |
55 | 122 |
56 int64_t BbrBweSender::TimeUntilNextProcess() { | 123 int64_t BbrBweSender::TimeUntilNextProcess() { |
57 return 100; | 124 return 100; |
58 } | 125 } |
59 | 126 |
60 void BbrBweSender::OnPacketsSent(const Packets& packets) {} | 127 void BbrBweSender::OnPacketsSent(const Packets& packets) { |
128 last_packet_sent_ = | |
129 static_cast<const MediaPacket*>(packets.back())->sequence_number(); | |
130 } | |
61 | 131 |
62 void BbrBweSender::Process() {} | 132 void BbrBweSender::Process() {} |
63 | 133 |
64 BbrBweReceiver::BbrBweReceiver(int flow_id) | 134 BbrBweReceiver::BbrBweReceiver(int flow_id) |
65 : BweReceiver(flow_id, kReceivingRateTimeWindowMs), | 135 : BweReceiver(flow_id, kReceivingRateTimeWindowMs), |
66 clock_(0), | 136 clock_(0), |
67 packet_feedbacks_() {} | 137 packet_feedbacks_() {} |
68 | 138 |
69 BbrBweReceiver::~BbrBweReceiver() {} | 139 BbrBweReceiver::~BbrBweReceiver() {} |
70 | 140 |
71 void BbrBweReceiver::ReceivePacket(int64_t arrival_time_ms, | 141 void BbrBweReceiver::ReceivePacket(int64_t arrival_time_ms, |
72 const MediaPacket& media_packet) {} | 142 const MediaPacket& media_packet) {} |
73 | 143 |
74 FeedbackPacket* BbrBweReceiver::GetFeedback(int64_t now_ms) { | 144 FeedbackPacket* BbrBweReceiver::GetFeedback(int64_t now_ms) { |
75 return nullptr; | 145 return nullptr; |
76 } | 146 } |
77 } // namespace bwe | 147 } // namespace bwe |
78 } // namespace testing | 148 } // namespace testing |
79 } // namespace webrtc | 149 } // namespace webrtc |
OLD | NEW |