1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // A convenience class to store rtt samples and calculate smoothed rtt.
7 #ifndef NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_
8 #define NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_
12 #include "base/basictypes.h"
13 #include "net/quic/quic_protocol.h"
14 #include "net/quic/quic_time.h"
18 class NET_EXPORT_PRIVATE RttStats
{
22 // Returns true if any RTT measurements have been made.
23 bool HasUpdates() const;
25 // Updates the RTT from an incoming ack which is received |send_delta| after
26 // the packet is sent and the peer reports the ack being delayed |ack_delay|.
27 void UpdateRtt(QuicTime::Delta send_delta
, QuicTime::Delta ack_delay
);
29 QuicTime::Delta
SmoothedRtt() const;
31 // Sets an initial RTT to be used for SmoothedRtt before any RTT updates.
32 void set_initial_rtt_us(int64 initial_rtt_us
) {
33 initial_rtt_us_
= initial_rtt_us
;
36 QuicTime::Delta
latest_rtt() const {
40 QuicTime::Delta
min_rtt() const {
44 QuicTime::Delta
mean_deviation() const {
45 return mean_deviation_
;
49 QuicTime::Delta latest_rtt_
;
50 QuicTime::Delta min_rtt_
;
51 QuicTime::Delta smoothed_rtt_
;
52 // Mean RTT deviation during this session.
53 // Approximation of standard deviation, the error is roughly 1.25 times
54 // larger than the standard deviation, for a normally distributed signal.
55 QuicTime::Delta mean_deviation_
;
56 int64 initial_rtt_us_
;
61 #endif // NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_