Land Recent QUIC Changes.
[chromium-blink-merge.git] / net / quic / congestion_control / rtt_stats.h
blob6e04498c84b99f7242378a99d7a83433645a7c98
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.
4 //
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_
10 #include <algorithm>
12 #include "base/basictypes.h"
13 #include "net/quic/quic_protocol.h"
14 #include "net/quic/quic_time.h"
16 namespace net {
18 class NET_EXPORT_PRIVATE RttStats {
19 public:
20 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 {
37 return latest_rtt_;
40 QuicTime::Delta min_rtt() const {
41 return min_rtt_;
44 QuicTime::Delta mean_deviation() const {
45 return mean_deviation_;
48 private:
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_;
59 } // namespace net
61 #endif // NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_