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