#ifndef NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_
#define NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "net/base/net_export.h"
#include "net/quic/congestion_control/cubic.h"
#include "net/quic/congestion_control/hybrid_slow_start.h"
#include "net/quic/congestion_control/send_algorithm_interface.h"
#include "net/quic/quic_bandwidth.h"
#include "net/quic/quic_connection_stats.h"
#include "net/quic/quic_protocol.h"
#include "net/quic/quic_time.h"
namespace net {
const QuicByteCount kDefaultTCPMSS = 1460;
class RttStats;
namespace test {
class TcpCubicSenderPeer;
}
class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface {
public:
TcpCubicSender(const QuicClock* clock,
const RttStats* rtt_stats,
bool reno,
QuicTcpCongestionWindow max_tcp_congestion_window,
QuicConnectionStats* stats);
virtual ~TcpCubicSender();
bool InSlowStart() const;
virtual void SetFromConfig(const QuicConfig& config, bool is_server) OVERRIDE;
virtual void OnIncomingQuicCongestionFeedbackFrame(
const QuicCongestionFeedbackFrame& feedback,
QuicTime feedback_receive_time) OVERRIDE;
virtual void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number,
QuicByteCount acked_bytes) OVERRIDE;
virtual void OnPacketLost(QuicPacketSequenceNumber largest_loss,
QuicTime ack_receive_time) OVERRIDE;
virtual bool OnPacketSent(QuicTime sent_time,
QuicPacketSequenceNumber sequence_number,
QuicByteCount bytes,
HasRetransmittableData is_retransmittable) OVERRIDE;
virtual void OnRetransmissionTimeout(bool packets_retransmitted) OVERRIDE;
virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number,
QuicByteCount abandoned_bytes) OVERRIDE;
virtual QuicTime::Delta TimeUntilSend(
QuicTime now,
HasRetransmittableData has_retransmittable_data) OVERRIDE;
virtual QuicBandwidth BandwidthEstimate() const OVERRIDE;
virtual void UpdateRtt(QuicTime::Delta rtt_sample) OVERRIDE;
virtual QuicTime::Delta RetransmissionDelay() const OVERRIDE;
virtual QuicByteCount GetCongestionWindow() const OVERRIDE;
private:
friend class test::TcpCubicSenderPeer;
QuicByteCount AvailableSendWindow();
QuicByteCount SendWindow();
void MaybeIncreaseCwnd(QuicPacketSequenceNumber acked_sequence_number);
bool IsCwndLimited() const;
bool InRecovery() const;
HybridSlowStart hybrid_slow_start_;
Cubic cubic_;
const RttStats* rtt_stats_;
const bool reno_;
int64 congestion_window_count_;
QuicByteCount receive_window_;
QuicByteCount bytes_in_flight_;
QuicByteCount prr_out_;
QuicByteCount prr_delivered_;
size_t ack_count_since_loss_;
QuicByteCount bytes_in_flight_before_loss_;
QuicPacketSequenceNumber largest_sent_sequence_number_;
QuicPacketSequenceNumber largest_acked_sequence_number_;
QuicPacketSequenceNumber largest_sent_at_last_cutback_;
QuicTcpCongestionWindow congestion_window_;
QuicTcpCongestionWindow slowstart_threshold_;
QuicTcpCongestionWindow max_tcp_congestion_window_;
DISALLOW_COPY_AND_ASSIGN(TcpCubicSender);
};
}
#endif