14 : smoothed_rtt_(kInitialRtt)
15 , rttvar_(kInitialRtt / 2)
16 , min_rtt_(std::chrono::microseconds::max())
17 , latest_rtt_(std::chrono::microseconds{0})
18 , max_ack_delay_(kDefaultMaxAckDelay)
19 , initial_rtt_(kInitialRtt)
25 std::chrono::microseconds max_ack_delay)
26 : smoothed_rtt_(initial_rtt)
27 , rttvar_(initial_rtt / 2)
28 , min_rtt_(std::chrono::microseconds::max())
29 , latest_rtt_(std::chrono::microseconds{0})
30 , max_ack_delay_(max_ack_delay)
31 , initial_rtt_(initial_rtt)
37 std::chrono::microseconds ack_delay,
38 bool is_handshake_confirmed) ->
void
40 latest_rtt_ = latest_rtt;
43 if (latest_rtt < min_rtt_)
45 min_rtt_ = latest_rtt;
49 auto adjusted_rtt = latest_rtt;
50 if (is_handshake_confirmed)
54 auto effective_ack_delay = std::min(ack_delay, max_ack_delay_);
57 if (adjusted_rtt > min_rtt_ + effective_ack_delay)
59 adjusted_rtt -= effective_ack_delay;
61 else if (adjusted_rtt > min_rtt_)
63 adjusted_rtt = min_rtt_;
70 smoothed_rtt_ = adjusted_rtt;
71 rttvar_ = adjusted_rtt / 2;
72 first_sample_ =
false;
78 auto rtt_diff = smoothed_rtt_ > adjusted_rtt
79 ? smoothed_rtt_ - adjusted_rtt
80 : adjusted_rtt - smoothed_rtt_;
82 rttvar_ = std::chrono::microseconds{
83 (3 * rttvar_.count() + rtt_diff.count()) / 4};
86 smoothed_rtt_ = std::chrono::microseconds{
87 (7 * smoothed_rtt_.count() + adjusted_rtt.count()) / 8};