Index: webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h |
diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h |
index 2782f353d0bb7c4320b71e372c378d9c6d624104..4510bfb927751c5677bb9aaba9c7468f8e7db893 100644 |
--- a/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h |
+++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h |
@@ -12,6 +12,7 @@ |
#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_BBR_H_ |
#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_BBR_H_ |
+#include <list> |
#include <map> |
#include <memory> |
#include <vector> |
@@ -39,15 +40,58 @@ class BbrBweSender : public BweSender { |
PROBE_BW, |
// Temporarily limiting congestion window size in order to measure |
// minimum RTT. |
- PROBE_RTT |
+ PROBE_RTT, |
+ // Temporarily reducing pacing rate and congestion window, in order to |
+ // ensure no queues are built. |
+ RECOVERY |
}; |
struct PacketStats { |
PacketStats() {} |
- PacketStats(int64_t send_time_, size_t payload_size_) |
- : send_time(send_time_), payload_size(payload_size_) {} |
- |
+ PacketStats(int64_t sequence_number_, |
+ int64_t send_time_, |
+ int64_t send_time_before_, |
+ int64_t ack_time_, |
+ int64_t ack_time_before_, |
+ size_t payload_size_, |
+ size_t data_sent_, |
+ size_t data_sent_before_, |
+ size_t data_acked_, |
+ size_t data_acked_before_) |
+ : sequence_number(sequence_number_), |
+ send_time(send_time_), |
+ send_time_before(send_time_before_), |
+ ack_time(ack_time_), |
+ ack_time_before(ack_time_before_), |
+ payload_size(payload_size_), |
+ data_sent(data_sent_), |
+ data_sent_before(data_sent_before_), |
+ data_acked(data_acked_), |
+ data_acked_before(data_acked_before_) {} |
+ uint64_t sequence_number; |
+ // Send time of the packet which was sent, when current packet got acked. |
philipel
2017/08/04 12:08:07
I don't quite understand this comment.
gnish1
2017/08/07 10:34:28
Done.
|
int64_t send_time; |
+ // The actual send time of the packet. |
philipel
2017/08/04 12:08:07
Also not that clear, maybe explaining the differen
gnish1
2017/08/07 10:34:28
Done.
|
+ int64_t send_time_before; |
+ // Ack time of the packet. |
+ int64_t ack_time; |
+ // Ack time of the packet, which was acked when current packet got sent. |
+ int64_t ack_time_before; |
size_t payload_size; |
+ size_t data_sent; |
+ size_t data_sent_before; |
+ size_t data_acked; |
+ size_t data_acked_before; |
philipel
2017/08/04 12:08:07
Please add comments for all the member variables.
gnish1
2017/08/07 10:34:29
Done.
philipel
2017/08/08 11:54:54
If it's hard to find good names for the members th
|
+ }; |
+ struct AverageRtt { |
+ AverageRtt() {} |
+ AverageRtt(int64_t sum_of_rtts_, int64_t quantity_, uint64_t round_) |
+ : sum_of_rtts(sum_of_rtts_), quantity(quantity_), round(round_) {} |
+ // Sum of rtts over the round. |
+ int64_t sum_of_rtts; |
philipel
2017/08/04 12:08:08
miliseconds? microseconds? please add _ms
gnish1
2017/08/07 10:34:28
Done.
|
+ // Number of rtt samples over the round. |
+ int64_t quantity; |
philipel
2017/08/04 12:08:07
num_samples
gnish1
2017/08/07 10:34:29
Done.
|
+ // The number of the round average rtt is recorded for. |
+ uint64_t round; |
}; |
void OnPacketsSent(const Packets& packets) override; |
int GetFeedbackIntervalMs() const override; |
@@ -57,14 +101,37 @@ class BbrBweSender : public BweSender { |
private: |
void EnterStartup(); |
- bool UpdateBandwidthAndMinRtt(); |
+ bool UpdateBandwidthAndMinRtt(int64_t now, |
+ const std::vector<uint64_t>& feedback_vector, |
+ int64_t bytes_acked); |
void TryExitingStartup(); |
void TryExitingDrain(int64_t now_ms); |
void EnterProbeBw(int64_t now_ms); |
void TryUpdatingCyclePhase(int64_t now_ms); |
- void TryEnteringProbeRtt(int64_t now_ms); |
- void TryExitingProbeRtt(int64_t now_ms, int64_t round); |
+ void TryEnteringProbeRtt(int64_t now_ms, bool min_rtt_expired); |
+ void TryExitingProbeRtt(int64_t now_ms, int64_t round, bool min_rtt_expired); |
+ void TryEnteringRecovery(); |
+ void TryExitingRecovery(); |
size_t TargetCongestionWindow(float gain); |
+ void CalculatePacingRate(); |
+ |
+ // Calculates and returns bandwidth sample as minimum between send rate and |
+ // ack rate, returns nothing if sample cannot be calculated. |
+ rtc::Optional<int64_t> CalculateBandwidthSample(size_t data_sent, |
+ int64_t time_elapsed_1, |
philipel
2017/08/04 12:08:07
Is this the delta send time?
gnish1
2017/08/07 10:34:28
Done.
|
+ size_t data_acked, |
+ int64_t time_elapsed_2); |
philipel
2017/08/04 12:08:07
and this the delta receive time?
gnish1
2017/08/07 10:34:29
Done.
|
+ |
+ // Calculate and add bandwidth sample only for packets' sent during high gain |
+ // phase. Motivation of having a seperate bucket for high gain phase is to |
+ // achieve quicker ramp up. Slight overestimations may happen due to window |
+ // not being as large as usual. |
+ void AddSampleForHighGain(); |
+ |
+ // Declares lost packets as acked. Implements simple logic by looking at the |
+ // gap between sequence numbers. |
+ void HandleLoss(uint64_t last_acked_packet, uint64_t recently_acked_packet); |
+ void AddToPastRtts(int64_t rtt_sample_ms); |
Clock* const clock_; |
Mode mode_; |
std::unique_ptr<MaxBandwidthFilter> max_bandwidth_filter_; |
@@ -72,7 +139,6 @@ class BbrBweSender : public BweSender { |
std::unique_ptr<CongestionWindow> congestion_window_; |
std::unique_ptr<Random> rand_; |
uint64_t round_count_; |
- uint64_t last_packet_sent_; |
uint64_t round_trip_end_; |
float pacing_gain_; |
float congestion_window_gain_; |
@@ -87,8 +153,7 @@ class BbrBweSender : public BweSender { |
// Index number of the currently used gain value in PROBE_BW mode, from 0 to |
// kGainCycleLength - 1. |
int64_t cycle_index_; |
- |
- // Data inflight prior to the moment when last feedback was received. |
+ size_t bytes_acked_; |
size_t prior_in_flight_; |
// Time we entered PROBE_RTT mode. |
@@ -101,6 +166,46 @@ class BbrBweSender : public BweSender { |
// First round when data inflight decreased below kMinimumCongestionWindow in |
// PROBE_RTT mode. |
int64_t minimum_congestion_window_start_round_; |
+ size_t bytes_sent_; |
+ uint64_t last_packet_sent_sequence_number_; |
+ uint64_t last_packet_acked_sequence_number_; |
+ int64_t last_packet_ack_time_; |
+ int64_t last_packet_send_time_; |
+ int64_t pacing_rate_; |
philipel
2017/08/04 12:08:07
bps?
gnish1
2017/08/07 10:34:28
Done.
|
+ |
+ // Send time of a packet sent first during high gain phase. Also serves as a |
+ // flag, holding value means that we are already in high gain. |
+ rtc::Optional<int64_t> first_high_gain_send_time_; |
philipel
2017/08/04 12:08:07
Maybe |high_gain_start_ms_|? WDYT?
Please also ta
gnish1
2017/08/07 10:34:28
Done.
|
+ |
+ // Send time of a packet sent last during high gain phase. |
+ int64_t last_high_gain_send_time_; |
+ |
+ // Amount of data sent, before first packet was sent during high gain phase. |
+ int64_t first_high_gain_sent_before_; |
+ |
+ // Amount of data sent, before last packet was sent during high gain phase. |
+ int64_t last_high_gain_sent_before_; |
+ |
+ // Ack time of a packet acked first during high gain phase. |
+ int64_t first_high_gain_ack_time_; |
+ |
+ // Ack time of a packet acked last during high gain phase. |
+ int64_t last_high_gain_ack_time_; |
+ |
+ // Amount of data acked, before first packet was acked during high gain phase. |
+ int64_t first_high_gain_acked_before_; |
+ |
+ // Amount of data acked, before last packet was acked during high gain phase. |
+ int64_t last_high_gain_acked_before_; |
+ |
+ // Sequence number of the first packet sent during high gain phase. |
+ uint64_t first_high_gain_seq_num_; |
+ |
+ // Sequence number of the last packet sent during high gain phase. |
+ uint64_t last_high_gain_seq_num_; |
+ bool high_gain_over_; |
+ std::map<int64_t, PacketStats> packet_stats_; |
+ std::list<AverageRtt> past_rtts_; |
}; |
class BbrBweReceiver : public BweReceiver { |
@@ -113,6 +218,8 @@ class BbrBweReceiver : public BweReceiver { |
private: |
SimulatedClock clock_; |
+ std::vector<uint64_t> packet_feedbacks_; |
+ // int64_t last_feedback_ms_; |
philipel
2017/08/04 12:08:07
Remove unused member.
gnish1
2017/08/07 10:34:29
Done.
|
}; |
} // namespace bwe |
} // namespace testing |