Since the code measuring the RTT has been converted to using TimeDelta which internally stores the duration in microseconds, from DurationMs which uses milliseconds, the RTO calculation can use the higher precision to calculate lower non-zero durations on really fast networks such within a data center. Before this CL, which is from the initial drop of dcSCTP, the RTO calculation was done using the algorithm from the paper "V. Jacobson: Congestion avoidance and control", but now we're using the original algorith from https://tools.ietf.org/html/rfc4960#section-6.3.1, which comes from https://datatracker.ietf.org/doc/html/rfc6298#section-2. Two issues were found and corrected: 1. The min RTT variance that is specified in the config file was previously incorrectly divided by 8. That was not its intention, but we're keeping that behaviour as other clients have actually measured a good value to put there. This represents "G" in the "basic algorithm" above, and since that is multiplied with K, which is four, the default value of 220 wouldn't make sense if it wasn't scaled down, as that would make the RTO easily saturate to the RTO_max (800ms). 2. The previous algorithm had large round-off errors (probably because the code used milliseconds), which makes fairly big changes to the calculated RTO in some situations. Bug: webrtc:15593 Change-Id: I95a3e137c2bbbe7bf8b99c016381e9e63fd01d87 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/349000 Reviewed-by: Florent Castelli <orphis@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Victor Boivie <boivie@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42170}
58 lines
2.0 KiB
C++
58 lines
2.0 KiB
C++
/*
|
|
* Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
#ifndef NET_DCSCTP_TX_RETRANSMISSION_TIMEOUT_H_
|
|
#define NET_DCSCTP_TX_RETRANSMISSION_TIMEOUT_H_
|
|
|
|
#include <cstdint>
|
|
#include <functional>
|
|
|
|
#include "net/dcsctp/public/dcsctp_options.h"
|
|
|
|
namespace dcsctp {
|
|
|
|
// Manages updating of the Retransmission Timeout (RTO) SCTP variable, which is
|
|
// used directly as the base timeout for T3-RTX and for other timers, such as
|
|
// delayed ack.
|
|
//
|
|
// When a round-trip-time (RTT) is calculated (outside this class), `Observe`
|
|
// is called, which calculates the retransmission timeout (RTO) value. The RTO
|
|
// value will become larger if the RTT is high and/or the RTT values are varying
|
|
// a lot, which is an indicator of a bad connection.
|
|
class RetransmissionTimeout {
|
|
public:
|
|
explicit RetransmissionTimeout(const DcSctpOptions& options);
|
|
|
|
// To be called when a RTT has been measured, to update the RTO value.
|
|
void ObserveRTT(webrtc::TimeDelta rtt);
|
|
|
|
// Returns the Retransmission Timeout (RTO) value.
|
|
webrtc::TimeDelta rto() const { return rto_; }
|
|
|
|
// Returns the smoothed RTT value.
|
|
webrtc::TimeDelta srtt() const { return srtt_; }
|
|
|
|
private:
|
|
const webrtc::TimeDelta min_rto_;
|
|
const webrtc::TimeDelta max_rto_;
|
|
const webrtc::TimeDelta max_rtt_;
|
|
const webrtc::TimeDelta min_rtt_variance_;
|
|
// If this is the first measurement
|
|
bool first_measurement_ = true;
|
|
// Smoothed Round-Trip Time.
|
|
webrtc::TimeDelta srtt_;
|
|
// Round-Trip Time Variation.
|
|
webrtc::TimeDelta rtt_var_ = webrtc::TimeDelta::Zero();
|
|
// Retransmission Timeout
|
|
webrtc::TimeDelta rto_;
|
|
};
|
|
} // namespace dcsctp
|
|
|
|
#endif // NET_DCSCTP_TX_RETRANSMISSION_TIMEOUT_H_
|