1 /* 2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_CONGESTION_CONTROLLER_PCC_MONITOR_INTERVAL_H_ 12 #define MODULES_CONGESTION_CONTROLLER_PCC_MONITOR_INTERVAL_H_ 13 14 #include <vector> 15 16 #include "api/transport/network_types.h" 17 #include "api/units/data_rate.h" 18 #include "api/units/data_size.h" 19 #include "api/units/time_delta.h" 20 #include "api/units/timestamp.h" 21 22 namespace webrtc { 23 namespace pcc { 24 25 // PCC divides time into consecutive monitor intervals which are used to test 26 // consequences for performance of sending at a certain rate. 27 class PccMonitorInterval { 28 public: 29 PccMonitorInterval(DataRate target_sending_rate, 30 Timestamp start_time, 31 TimeDelta duration); 32 ~PccMonitorInterval(); 33 PccMonitorInterval(const PccMonitorInterval& other); 34 void OnPacketsFeedback(const std::vector<PacketResult>& packets_results); 35 // Returns true if got complete information about packets. 36 // Notice, this only happens when received feedback about the first packet 37 // which were sent after the end of the monitor interval. If such event 38 // doesn't occur, we don't mind anyway and stay in the same state. 39 bool IsFeedbackCollectionDone() const; 40 Timestamp GetEndTime() const; 41 42 double GetLossRate() const; 43 // Estimates the gradient using linear regression on the 2-dimensional 44 // dataset (sampled packets delay, time of sampling). 45 double ComputeDelayGradient(double delay_gradient_threshold) const; 46 DataRate GetTargetSendingRate() const; 47 // How fast receiving side gets packets. 48 DataRate GetTransmittedPacketsRate() const; 49 50 private: 51 struct ReceivedPacket { 52 TimeDelta delay; 53 Timestamp sent_time; 54 }; 55 // Target bitrate used to generate and pace the outgoing packets. 56 // Actually sent bitrate might not match the target exactly. 57 DataRate target_sending_rate_; 58 // Start time is not included into interval while end time is included. 59 Timestamp start_time_; 60 TimeDelta interval_duration_; 61 // Vectors below updates while receiving feedback. 62 std::vector<ReceivedPacket> received_packets_; 63 std::vector<Timestamp> lost_packets_sent_time_; 64 DataSize received_packets_size_; 65 bool feedback_collection_done_; 66 }; 67 68 } // namespace pcc 69 } // namespace webrtc 70 71 #endif // MODULES_CONGESTION_CONTROLLER_PCC_MONITOR_INTERVAL_H_ 72