This class is completely new and tracks data transfer in a slightly different way compared to the BBR implementation in QUIC. The fundamental change is that receive time is used rather than packet index to identify the packets over which data rates should be calculated. This is part of a series of CLs adding a network controller based on the BBR congestion control method. The code is based on the QUIC BBR implementation in Chromium. Bug: webrtc:8415 Change-Id: I9d1f12634073ac89c4d542f965e3677a89a1526c Reviewed-on: https://webrtc-review.googlesource.com/63680 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22589}
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
#ifndef MODULES_CONGESTION_CONTROLLER_BBR_DATA_TRANSFER_TRACKER_H_
|
|
#define MODULES_CONGESTION_CONTROLLER_BBR_DATA_TRANSFER_TRACKER_H_
|
|
|
|
#include <deque>
|
|
#include "modules/congestion_controller/network_control/include/network_units.h"
|
|
|
|
namespace webrtc {
|
|
namespace bbr {
|
|
class DataTransferTracker {
|
|
public:
|
|
struct Result {
|
|
TimeDelta ack_timespan;
|
|
TimeDelta send_timespan;
|
|
DataSize acked_data;
|
|
};
|
|
DataTransferTracker();
|
|
~DataTransferTracker();
|
|
void AddSample(DataSize size_delta, Timestamp send_time, Timestamp ack_time);
|
|
void ClearOldSamples(Timestamp excluding_end);
|
|
|
|
// Get the average data rate in the window that starts with the last ack which
|
|
// comes before covered_start and ends at the first ack that comes after or at
|
|
// including_end.
|
|
Result GetRatesByAckTime(Timestamp covered_start, Timestamp including_end);
|
|
|
|
private:
|
|
struct Sample {
|
|
Timestamp ack_time;
|
|
Timestamp send_time;
|
|
DataSize size_delta;
|
|
DataSize size_sum;
|
|
};
|
|
std::deque<Sample> samples_;
|
|
DataSize size_sum_ = DataSize::Zero();
|
|
};
|
|
} // namespace bbr
|
|
} // namespace webrtc
|
|
#endif // MODULES_CONGESTION_CONTROLLER_BBR_DATA_TRANSFER_TRACKER_H_
|