Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(943)

Side by Side Diff: net/quic/congestion_control/rtt_stats.h

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
6
7 #ifndef NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_
8 #define NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_
9
10 #include <stdint.h>
11
12 #include <algorithm>
13
14 #include "base/macros.h"
15 #include "net/quic/congestion_control/windowed_filter.h"
16 #include "net/quic/quic_bug_tracker.h"
17 #include "net/quic/quic_protocol.h"
18 #include "net/quic/quic_time.h"
19
20 namespace net {
21
22 namespace test {
23 class RttStatsPeer;
24 } // namespace test
25
26 class NET_EXPORT_PRIVATE RttStats {
27 public:
28 RttStats();
29
30 // Updates the RTT from an incoming ack which is received |send_delta| after
31 // the packet is sent and the peer reports the ack being delayed |ack_delay|.
32 void UpdateRtt(QuicTime::Delta send_delta,
33 QuicTime::Delta ack_delay,
34 QuicTime now);
35
36 // Causes the smoothed_rtt to be increased to the latest_rtt if the latest_rtt
37 // is larger. The mean deviation is increased to the most recent deviation if
38 // it's larger.
39 void ExpireSmoothedMetrics();
40
41 // Forces RttStats to sample a new windowed min rtt within the next
42 // |num_samples| UpdateRtt calls.
43 void SampleNewWindowedMinRtt(uint32_t num_samples);
44
45 // Called when connection migrates and rtt measurement needs to be reset.
46 void OnConnectionMigration();
47
48 // Returns the EWMA smoothed RTT for the connection.
49 // May return Zero if no valid updates have occurred.
50 QuicTime::Delta smoothed_rtt() const { return smoothed_rtt_; }
51
52 // Returns the EWMA smoothed RTT prior to the most recent RTT sample.
53 QuicTime::Delta previous_srtt() const { return previous_srtt_; }
54
55 int64_t initial_rtt_us() const { return initial_rtt_us_; }
56
57 // Sets an initial RTT to be used for SmoothedRtt before any RTT updates.
58 void set_initial_rtt_us(int64_t initial_rtt_us) {
59 if (initial_rtt_us <= 0) {
60 QUIC_BUG << "Attempt to set initial rtt to <= 0.";
61 return;
62 }
63 initial_rtt_us_ = initial_rtt_us;
64 }
65
66 // The most recent rtt measurement.
67 // May return Zero if no valid updates have occurred.
68 QuicTime::Delta latest_rtt() const { return latest_rtt_; }
69
70 // Returns the min_rtt for the entire connection.
71 // May return Zero if no valid updates have occurred.
72 QuicTime::Delta min_rtt() const { return min_rtt_; }
73
74 QuicTime::Delta mean_deviation() const { return mean_deviation_; }
75
76 QuicTime::Delta WindowedMinRtt() { return windowed_min_rtt_.GetBest(); }
77
78 private:
79 friend class test::RttStatsPeer;
80
81 // Updates the windowed min rtt. Also forces a new windowed_min_rtt sample,
82 // if set by a call to SampleNewWindowedMinRtt() above.
83 void UpdateWindowedMinRtt(QuicTime::Delta rtt_sample, QuicTime now);
84
85 QuicTime::Delta latest_rtt_;
86 QuicTime::Delta min_rtt_;
87 QuicTime::Delta smoothed_rtt_;
88 QuicTime::Delta previous_srtt_;
89 // Mean RTT deviation during this session.
90 // Approximation of standard deviation, the error is roughly 1.25 times
91 // larger than the standard deviation, for a normally distributed signal.
92 QuicTime::Delta mean_deviation_;
93 int64_t initial_rtt_us_;
94
95 // Variables used to force a new windowed_min_rtt measurement within
96 // num_samples_for_forced_min_.
97 QuicTime::Delta forced_windowed_min_rtt_;
98 QuicTime forced_windowed_min_rtt_time_;
99 uint32_t num_samples_for_forced_min_;
100
101 // Windowed min_rtt.
102 WindowedFilter<QuicTime::Delta,
103 MinFilter<QuicTime::Delta>,
104 QuicTime,
105 QuicTime::Delta>
106 windowed_min_rtt_;
107
108 DISALLOW_COPY_AND_ASSIGN(RttStats);
109 };
110
111 } // namespace net
112
113 #endif // NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_
OLDNEW
« no previous file with comments | « net/quic/congestion_control/prr_sender_test.cc ('k') | net/quic/congestion_control/rtt_stats.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698