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