Vixen
02b45cc4
csharp
public sealed class RoundTripEstimator

Smoothed round-trip time and jitter, from samples.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The estimator TCP uses (RFC 6298): an exponentially weighted average of the samples, and beside it an exponentially weighted average of how far each sample fell from that average. The second number is the one that matters here — the interpolation buffer and the tick lead are sized from the variance, because a steady 200 ms link is easy and a link that swings between 40 and 90 ms is not.

The weights are the standard 1/8 and 1/4, which is a deliberate refusal to invent: they have been load-bearing in every TCP stack for thirty years, and a netcode-specific constant chosen by eye would be worse and unjustifiable.

Fields and properties (5)

  • public TimeSpan RoundTrip

    The smoothed round trip.

  • public TimeSpan OneWay

    Half the smoothed round trip — how old the newest thing from the server is.

  • public TimeSpan Jitter

    How far samples typically fall from the average. The number that sizes buffers.

  • public long SampleCount

    How many samples have been taken.

  • public bool HasSamples

    Whether anything has been measured yet.

Methods (2)

  • public void Add(TimeSpan sample)

    Takes a sample.

  • public void Reset()

    Forgets everything measured, for a reconnect to a different server.

Used by (10)

  • LocalMatchMultiplayer
  • NetworkMatchMultiplayer
  • NetworkMetricsVixen.Net
  • NetworkPlayerVixen.Net
  • NetworkSessionVixen.Net
  • SessionTestsVixen.Net.Tests
  • TickManagerVixen.Net
  • TickManagerTestsVixen.Net.Tests
  • UdpConnectionVixen.Net.Transport.Udp
  • UdpTransportVixen.Net.Transport.Udp