java.lang.Object
io.github.mahmoudimus.quic.connection.Pacer

public final class Pacer extends Object
A token-bucket pacer (RFC 9002 section 7.7). Its capacity is the part of the congestion window sent in one burst; the bucket refills at 1.25 congestion windows per RTT, and an empty bucket delays the next packet. Times and durations are nanoseconds.

Threads. Not thread-safe; owned by one connection.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Pacer(long smoothedRtt, long window, int mtu, long maxBytesPerSecond, long now)
    A pacer with a full bucket.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    delay(long smoothedRtt, long bytesToSend, int mtu, long window, long now)
    When the next packet may be sent.
    long
    The rate limit this pacer was built with.
    void
    onTransmit(int packetLength)
    Records that a packet was sent.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Pacer

      public Pacer(long smoothedRtt, long window, int mtu, long maxBytesPerSecond, long now)
      A pacer with a full bucket.
      Parameters:
      smoothedRtt - the smoothed RTT, in nanoseconds
      window - the congestion window, in bytes
      mtu - the path's maximum UDP payload size
      maxBytesPerSecond - a sending rate limit in bytes per second, or -1 for none
      now - the current time
  • Method Details

    • maxBytesPerSecond

      public long maxBytesPerSecond()
      The rate limit this pacer was built with.
      Returns:
      bytes per second, or -1 for none
    • onTransmit

      public void onTransmit(int packetLength)
      Records that a packet was sent.
      Parameters:
      packetLength - the packet's size in bytes
    • delay

      public long delay(long smoothedRtt, long bytesToSend, int mtu, long window, long now)
      When the next packet may be sent.
      Parameters:
      smoothedRtt - the smoothed RTT, in nanoseconds
      bytesToSend - the size of the next packet
      mtu - the path's maximum UDP payload size
      window - the congestion window, nonzero
      now - the current time
      Returns:
      the time to try again, or NanoClock.NONE if the packet may be sent now