2015-02-16 12:02:20 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_H_
|
|
|
|
|
#define MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_H_
|
2015-02-16 12:02:20 +00:00
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
2015-02-16 12:02:20 +00:00
|
|
|
#include <list>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "api/rtp_headers.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2018-09-14 08:26:32 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
2015-02-16 12:02:20 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace testing {
|
|
|
|
|
namespace bwe {
|
|
|
|
|
|
|
|
|
|
class Packet {
|
|
|
|
|
public:
|
|
|
|
|
enum Type { kMedia, kFeedback };
|
|
|
|
|
|
|
|
|
|
Packet();
|
|
|
|
|
Packet(int flow_id, int64_t send_time_us, size_t payload_size);
|
|
|
|
|
virtual ~Packet();
|
|
|
|
|
|
|
|
|
|
virtual bool operator<(const Packet& rhs) const;
|
|
|
|
|
|
2018-07-18 15:37:01 +02:00
|
|
|
virtual int flow_id() const;
|
2015-02-16 12:02:20 +00:00
|
|
|
virtual void set_send_time_us(int64_t send_time_us);
|
2018-07-18 15:37:01 +02:00
|
|
|
virtual int64_t send_time_us() const;
|
|
|
|
|
virtual int64_t sender_timestamp_us() const;
|
|
|
|
|
virtual size_t payload_size() const;
|
2015-02-16 12:02:20 +00:00
|
|
|
virtual Packet::Type GetPacketType() const = 0;
|
2018-07-18 15:37:01 +02:00
|
|
|
virtual void set_sender_timestamp_us(int64_t sender_timestamp_us);
|
|
|
|
|
virtual int64_t creation_time_ms() const;
|
|
|
|
|
virtual int64_t sender_timestamp_ms() const;
|
|
|
|
|
virtual int64_t send_time_ms() const;
|
2015-02-16 12:02:20 +00:00
|
|
|
|
2015-05-06 22:29:01 +02:00
|
|
|
protected:
|
2015-02-16 12:02:20 +00:00
|
|
|
int flow_id_;
|
|
|
|
|
int64_t creation_time_us_; // Time when the packet was created.
|
|
|
|
|
int64_t send_time_us_; // Time the packet left last processor touching it.
|
2015-05-06 22:29:01 +02:00
|
|
|
int64_t sender_timestamp_us_; // Time the packet left the Sender.
|
|
|
|
|
size_t payload_size_; // Size of the (non-existent, simulated) payload.
|
2015-02-16 12:02:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MediaPacket : public Packet {
|
|
|
|
|
public:
|
|
|
|
|
MediaPacket();
|
2015-04-16 19:55:45 +02:00
|
|
|
MediaPacket(int flow_id,
|
|
|
|
|
int64_t send_time_us,
|
|
|
|
|
size_t payload_size,
|
|
|
|
|
uint16_t sequence_number);
|
2015-02-16 12:02:20 +00:00
|
|
|
MediaPacket(int flow_id,
|
|
|
|
|
int64_t send_time_us,
|
|
|
|
|
size_t payload_size,
|
|
|
|
|
const RTPHeader& header);
|
2015-07-15 19:52:08 +02:00
|
|
|
MediaPacket(int64_t send_time_us, uint16_t sequence_number);
|
2015-07-15 16:31:18 +02:00
|
|
|
|
2018-07-18 15:37:01 +02:00
|
|
|
~MediaPacket() override {}
|
2015-02-16 12:02:20 +00:00
|
|
|
|
2015-03-18 13:40:54 +00:00
|
|
|
int64_t GetAbsSendTimeInMs() const {
|
|
|
|
|
int64_t timestamp = header_.extension.absoluteSendTime
|
|
|
|
|
<< kAbsSendTimeInterArrivalUpshift;
|
|
|
|
|
return 1000.0 * timestamp / static_cast<double>(1 << kInterArrivalShift);
|
|
|
|
|
}
|
2015-02-16 12:02:20 +00:00
|
|
|
void SetAbsSendTimeMs(int64_t abs_send_time_ms);
|
|
|
|
|
const RTPHeader& header() const { return header_; }
|
2018-07-18 15:37:01 +02:00
|
|
|
Packet::Type GetPacketType() const override;
|
2015-05-06 22:29:01 +02:00
|
|
|
uint16_t sequence_number() const { return header_.sequenceNumber; }
|
2018-09-14 08:26:32 +02:00
|
|
|
RtpPacketReceived GetRtpPacket() const;
|
2015-02-16 12:02:20 +00:00
|
|
|
|
|
|
|
|
private:
|
2015-03-18 13:40:54 +00:00
|
|
|
static const int kAbsSendTimeFraction = 18;
|
|
|
|
|
static const int kAbsSendTimeInterArrivalUpshift = 8;
|
|
|
|
|
static const int kInterArrivalShift =
|
|
|
|
|
kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift;
|
|
|
|
|
|
2015-02-16 12:02:20 +00:00
|
|
|
RTPHeader header_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class FeedbackPacket : public Packet {
|
|
|
|
|
public:
|
2015-05-06 22:29:01 +02:00
|
|
|
FeedbackPacket(int flow_id,
|
|
|
|
|
int64_t this_send_time_us,
|
|
|
|
|
int64_t latest_send_time_ms)
|
|
|
|
|
: Packet(flow_id, this_send_time_us, 0),
|
|
|
|
|
latest_send_time_ms_(latest_send_time_ms) {}
|
2018-07-18 15:37:01 +02:00
|
|
|
~FeedbackPacket() override {}
|
2015-02-16 12:02:20 +00:00
|
|
|
|
2018-07-18 15:37:01 +02:00
|
|
|
Packet::Type GetPacketType() const override;
|
2015-05-06 22:29:01 +02:00
|
|
|
int64_t latest_send_time_ms() const { return latest_send_time_ms_; }
|
|
|
|
|
|
|
|
|
|
private:
|
2015-07-15 16:31:18 +02:00
|
|
|
int64_t latest_send_time_ms_; // Time stamp for the latest sent FbPacket.
|
2015-02-16 12:02:20 +00:00
|
|
|
};
|
|
|
|
|
|
This is an initial cl, which contains small amount of implemented functions, and large amount of unimplemented ones.
Code should implement BBR which is the congestion controlling algorithm. BBR tries to estimate two values bottle-neck bandwidth(bw) and round trip time(rtt),then use these two values to set two control parameters pacing rate(pacing_rate),the rate at which data should be sent and congestion window size (cwnd), cwnd is the upper bound for data in flight,data_in_flight <= cwnd at all time.
BBR has four modes:
1)Startup-ramping up throughput discovering estimated bw.
2)Drain-after Startup decrease throughput to drain queues.
3)Probe Bandwidth-most of the time BBR should be in this mode,
sending data at the rate of estimated bw, while sometimes trying to discover new bandwidth.
4)Probe Rtt-in this mode BBR tries to discover new rtt for the connection.
The key moment in BBR is when we receive feedback from the receiver,as this is the only moment which should effect our two estimators. At this moment all the switches between modes should happen, except switch to ProbeRtt mode (switching to ProbeRtt mode should happen when current min_rtt value expires).
This cl serves to emphasize the structure of Bbr, when switches happen and what key classes/functions should be implemented for proper functionality.
BUG=webrtc:7713
NOTRY=True
Review-Url: https://codereview.webrtc.org/2904183002
Cr-Commit-Position: refs/heads/master@{#18444}
2017-06-05 06:01:26 -07:00
|
|
|
class BbrBweFeedback : public FeedbackPacket {
|
|
|
|
|
public:
|
2017-07-05 05:00:46 -07:00
|
|
|
BbrBweFeedback(int flow_id,
|
|
|
|
|
int64_t send_time_us,
|
|
|
|
|
int64_t latest_send_time_ms,
|
2017-08-20 09:19:58 -07:00
|
|
|
const std::vector<uint16_t>& packet_feedback_vector);
|
2018-07-18 15:37:01 +02:00
|
|
|
~BbrBweFeedback() override;
|
This is an initial cl, which contains small amount of implemented functions, and large amount of unimplemented ones.
Code should implement BBR which is the congestion controlling algorithm. BBR tries to estimate two values bottle-neck bandwidth(bw) and round trip time(rtt),then use these two values to set two control parameters pacing rate(pacing_rate),the rate at which data should be sent and congestion window size (cwnd), cwnd is the upper bound for data in flight,data_in_flight <= cwnd at all time.
BBR has four modes:
1)Startup-ramping up throughput discovering estimated bw.
2)Drain-after Startup decrease throughput to drain queues.
3)Probe Bandwidth-most of the time BBR should be in this mode,
sending data at the rate of estimated bw, while sometimes trying to discover new bandwidth.
4)Probe Rtt-in this mode BBR tries to discover new rtt for the connection.
The key moment in BBR is when we receive feedback from the receiver,as this is the only moment which should effect our two estimators. At this moment all the switches between modes should happen, except switch to ProbeRtt mode (switching to ProbeRtt mode should happen when current min_rtt value expires).
This cl serves to emphasize the structure of Bbr, when switches happen and what key classes/functions should be implemented for proper functionality.
BUG=webrtc:7713
NOTRY=True
Review-Url: https://codereview.webrtc.org/2904183002
Cr-Commit-Position: refs/heads/master@{#18444}
2017-06-05 06:01:26 -07:00
|
|
|
|
2017-08-20 09:19:58 -07:00
|
|
|
const std::vector<uint16_t>& packet_feedback_vector() const {
|
This is an initial cl, which contains small amount of implemented functions, and large amount of unimplemented ones.
Code should implement BBR which is the congestion controlling algorithm. BBR tries to estimate two values bottle-neck bandwidth(bw) and round trip time(rtt),then use these two values to set two control parameters pacing rate(pacing_rate),the rate at which data should be sent and congestion window size (cwnd), cwnd is the upper bound for data in flight,data_in_flight <= cwnd at all time.
BBR has four modes:
1)Startup-ramping up throughput discovering estimated bw.
2)Drain-after Startup decrease throughput to drain queues.
3)Probe Bandwidth-most of the time BBR should be in this mode,
sending data at the rate of estimated bw, while sometimes trying to discover new bandwidth.
4)Probe Rtt-in this mode BBR tries to discover new rtt for the connection.
The key moment in BBR is when we receive feedback from the receiver,as this is the only moment which should effect our two estimators. At this moment all the switches between modes should happen, except switch to ProbeRtt mode (switching to ProbeRtt mode should happen when current min_rtt value expires).
This cl serves to emphasize the structure of Bbr, when switches happen and what key classes/functions should be implemented for proper functionality.
BUG=webrtc:7713
NOTRY=True
Review-Url: https://codereview.webrtc.org/2904183002
Cr-Commit-Position: refs/heads/master@{#18444}
2017-06-05 06:01:26 -07:00
|
|
|
return packet_feedback_vector_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2017-08-20 09:19:58 -07:00
|
|
|
const std::vector<uint16_t> packet_feedback_vector_;
|
This is an initial cl, which contains small amount of implemented functions, and large amount of unimplemented ones.
Code should implement BBR which is the congestion controlling algorithm. BBR tries to estimate two values bottle-neck bandwidth(bw) and round trip time(rtt),then use these two values to set two control parameters pacing rate(pacing_rate),the rate at which data should be sent and congestion window size (cwnd), cwnd is the upper bound for data in flight,data_in_flight <= cwnd at all time.
BBR has four modes:
1)Startup-ramping up throughput discovering estimated bw.
2)Drain-after Startup decrease throughput to drain queues.
3)Probe Bandwidth-most of the time BBR should be in this mode,
sending data at the rate of estimated bw, while sometimes trying to discover new bandwidth.
4)Probe Rtt-in this mode BBR tries to discover new rtt for the connection.
The key moment in BBR is when we receive feedback from the receiver,as this is the only moment which should effect our two estimators. At this moment all the switches between modes should happen, except switch to ProbeRtt mode (switching to ProbeRtt mode should happen when current min_rtt value expires).
This cl serves to emphasize the structure of Bbr, when switches happen and what key classes/functions should be implemented for proper functionality.
BUG=webrtc:7713
NOTRY=True
Review-Url: https://codereview.webrtc.org/2904183002
Cr-Commit-Position: refs/heads/master@{#18444}
2017-06-05 06:01:26 -07:00
|
|
|
};
|
|
|
|
|
|
2015-02-16 12:02:20 +00:00
|
|
|
class RembFeedback : public FeedbackPacket {
|
|
|
|
|
public:
|
|
|
|
|
RembFeedback(int flow_id,
|
|
|
|
|
int64_t send_time_us,
|
2015-05-06 22:29:01 +02:00
|
|
|
int64_t latest_send_time_ms,
|
2015-02-16 12:02:20 +00:00
|
|
|
uint32_t estimated_bps,
|
|
|
|
|
RTCPReportBlock report_block);
|
2018-07-18 15:37:01 +02:00
|
|
|
~RembFeedback() override {}
|
2015-02-16 12:02:20 +00:00
|
|
|
|
|
|
|
|
uint32_t estimated_bps() const { return estimated_bps_; }
|
|
|
|
|
RTCPReportBlock report_block() const { return report_block_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const uint32_t estimated_bps_;
|
|
|
|
|
const RTCPReportBlock report_block_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class SendSideBweFeedback : public FeedbackPacket {
|
|
|
|
|
public:
|
|
|
|
|
typedef std::map<uint16_t, int64_t> ArrivalTimesMap;
|
2017-03-06 05:32:21 -08:00
|
|
|
SendSideBweFeedback(
|
|
|
|
|
int flow_id,
|
|
|
|
|
int64_t send_time_us,
|
|
|
|
|
int64_t latest_send_time_ms,
|
|
|
|
|
const std::vector<PacketFeedback>& packet_feedback_vector);
|
2018-07-18 15:37:01 +02:00
|
|
|
~SendSideBweFeedback() override;
|
2015-02-16 12:02:20 +00:00
|
|
|
|
2017-03-06 05:32:21 -08:00
|
|
|
const std::vector<PacketFeedback>& packet_feedback_vector() const {
|
2015-02-16 12:02:20 +00:00
|
|
|
return packet_feedback_vector_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2017-03-06 05:32:21 -08:00
|
|
|
const std::vector<PacketFeedback> packet_feedback_vector_;
|
2015-02-16 12:02:20 +00:00
|
|
|
};
|
|
|
|
|
|
2015-02-17 16:03:45 +00:00
|
|
|
class NadaFeedback : public FeedbackPacket {
|
|
|
|
|
public:
|
|
|
|
|
NadaFeedback(int flow_id,
|
2015-05-06 22:29:01 +02:00
|
|
|
int64_t this_send_time_us,
|
|
|
|
|
int64_t exp_smoothed_delay_ms,
|
|
|
|
|
int64_t est_queuing_delay_signal_ms,
|
2015-02-17 16:03:45 +00:00
|
|
|
int64_t congestion_signal,
|
2015-05-06 22:29:01 +02:00
|
|
|
float derivative,
|
|
|
|
|
float receiving_rate,
|
|
|
|
|
int64_t latest_send_time_ms)
|
|
|
|
|
: FeedbackPacket(flow_id, this_send_time_us, latest_send_time_ms),
|
|
|
|
|
exp_smoothed_delay_ms_(exp_smoothed_delay_ms),
|
|
|
|
|
est_queuing_delay_signal_ms_(est_queuing_delay_signal_ms),
|
2015-02-17 16:03:45 +00:00
|
|
|
congestion_signal_(congestion_signal),
|
2015-05-06 22:29:01 +02:00
|
|
|
derivative_(derivative),
|
|
|
|
|
receiving_rate_(receiving_rate) {}
|
2018-07-18 15:37:01 +02:00
|
|
|
~NadaFeedback() override {}
|
2015-02-17 16:03:45 +00:00
|
|
|
|
2015-05-06 22:29:01 +02:00
|
|
|
int64_t exp_smoothed_delay_ms() const { return exp_smoothed_delay_ms_; }
|
|
|
|
|
int64_t est_queuing_delay_signal_ms() const {
|
|
|
|
|
return est_queuing_delay_signal_ms_;
|
|
|
|
|
}
|
2015-02-17 16:03:45 +00:00
|
|
|
int64_t congestion_signal() const { return congestion_signal_; }
|
|
|
|
|
float derivative() const { return derivative_; }
|
2015-05-06 22:29:01 +02:00
|
|
|
float receiving_rate() const { return receiving_rate_; }
|
2015-02-17 16:03:45 +00:00
|
|
|
|
|
|
|
|
private:
|
2015-05-06 22:29:01 +02:00
|
|
|
int64_t exp_smoothed_delay_ms_; // Referred as d_hat_n.
|
|
|
|
|
int64_t est_queuing_delay_signal_ms_; // Referred as d_tilde_n.
|
|
|
|
|
int64_t congestion_signal_; // Referred as x_n.
|
|
|
|
|
float derivative_; // Referred as x'_n.
|
|
|
|
|
float receiving_rate_; // Referred as R_r.
|
2015-02-17 16:03:45 +00:00
|
|
|
};
|
|
|
|
|
|
2015-04-16 19:55:45 +02:00
|
|
|
class TcpFeedback : public FeedbackPacket {
|
|
|
|
|
public:
|
|
|
|
|
TcpFeedback(int flow_id,
|
|
|
|
|
int64_t send_time_us,
|
2015-05-06 22:29:01 +02:00
|
|
|
int64_t latest_send_time_ms,
|
2018-07-18 15:37:01 +02:00
|
|
|
const std::vector<uint16_t>& acked_packets);
|
|
|
|
|
~TcpFeedback() override;
|
2015-04-16 19:55:45 +02:00
|
|
|
|
|
|
|
|
const std::vector<uint16_t>& acked_packets() const { return acked_packets_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const std::vector<uint16_t> acked_packets_;
|
|
|
|
|
};
|
|
|
|
|
|
2015-02-16 12:02:20 +00:00
|
|
|
typedef std::list<Packet*> Packets;
|
|
|
|
|
typedef std::list<Packet*>::iterator PacketsIt;
|
|
|
|
|
typedef std::list<Packet*>::const_iterator PacketsConstIt;
|
2015-05-06 22:29:01 +02:00
|
|
|
|
2015-02-16 12:02:20 +00:00
|
|
|
} // namespace bwe
|
|
|
|
|
} // namespace testing
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_H_
|