Interface Controller

All Known Implementing Classes:
Bbr, Cubic, NewReno

public interface Controller
A congestion controller (RFC 9002 section 7): decides how many ack-eliciting bytes may be in flight. Times are nanoseconds from the connection's monotonic clock.

Threads. Implementations are not thread-safe; a controller belongs to one path of one connection, which serializes access.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    The datagram size the initial windows are computed from (RFC 9002 section 7.2).
  • Method Summary

    Modifier and Type
    Method
    Description
    A copy of the controller's state, for a new path that starts from this one.
    long
    The initial window.
    Metrics for statistics and tracing.
    default void
    onAck(long now, long sent, long bytes, boolean appLimited, RttEstimator rtt)
    A packet's delivery was confirmed.
    void
    onCongestionEvent(long now, long sent, boolean persistentCongestion, boolean ecn, long lostBytes)
    Packets were deemed lost, or marked with ECN congestion experienced.
    default void
    onEndAcks(long now, long inFlight, boolean appLimited, long largestPacketNumberAcked)
    A batch of acknowledgements, all with the same now, is complete.
    void
    onMtuUpdate(int newMtu)
    The path's MTU changed.
    default void
    onRateSample(long now, RateSample sample)
    The delivery rate sample of a batch of acknowledgements, given after their onAck(long, long, long, boolean, io.github.mahmoudimus.quic.congestion.RttEstimator) calls and before onEndAcks(long, long, boolean, long), when the batch acknowledged packets in flight. quinn has no such call.
    default void
    onSent(long now, long bytes, long lastPacketNumber)
    One or more packets were just sent.
    default void
    Packets deemed lost were all acknowledged after all: the last congestion event was spurious.
    default long
    The rate the controller wants packets paced at.
    long
    The congestion window.
  • Field Details

    • BASE_DATAGRAM_SIZE

      static final long BASE_DATAGRAM_SIZE
      The datagram size the initial windows are computed from (RFC 9002 section 7.2).
      See Also:
  • Method Details

    • onSent

      default void onSent(long now, long bytes, long lastPacketNumber)
      One or more packets were just sent.
      Parameters:
      now - the current time
      bytes - the bytes sent
      lastPacketNumber - the number of the last packet sent
    • onAck

      default void onAck(long now, long sent, long bytes, boolean appLimited, RttEstimator rtt)
      A packet's delivery was confirmed.
      Parameters:
      now - the current time
      sent - when the packet was sent
      bytes - the packet's size
      appLimited - whether the connection was limited by the application, not the window, before these acknowledgements
      rtt - the path's RTT estimate
    • onRateSample

      default void onRateSample(long now, RateSample sample)
      The delivery rate sample of a batch of acknowledgements, given after their onAck(long, long, long, boolean, io.github.mahmoudimus.quic.congestion.RttEstimator) calls and before onEndAcks(long, long, boolean, long), when the batch acknowledged packets in flight. quinn has no such call.
      Parameters:
      now - the current time
      sample - the sample
    • onEndAcks

      default void onEndAcks(long now, long inFlight, boolean appLimited, long largestPacketNumberAcked)
      A batch of acknowledgements, all with the same now, is complete.
      Parameters:
      now - the current time
      inFlight - the bytes still in flight
      appLimited - whether the connection was application limited
      largestPacketNumberAcked - the largest packet number ever acknowledged in the space, or -1
    • onCongestionEvent

      void onCongestionEvent(long now, long sent, boolean persistentCongestion, boolean ecn, long lostBytes)
      Packets were deemed lost, or marked with ECN congestion experienced.
      Parameters:
      now - the current time
      sent - when the most recent lost packet was sent
      persistentCongestion - whether every packet in the persistent congestion period ending with that packet was lost (RFC 9002 section 7.6)
      ecn - whether this is an ECN signal rather than loss
      lostBytes - the bytes lost, zero for ECN
    • onSpuriousCongestionEvent

      default void onSpuriousCongestionEvent()
      Packets deemed lost were all acknowledged after all: the last congestion event was spurious.
    • onMtuUpdate

      void onMtuUpdate(int newMtu)
      The path's MTU changed.
      Parameters:
      newMtu - the new maximum UDP payload size
    • window

      long window()
      The congestion window.
      Returns:
      the ack-eliciting bytes that may be in flight
    • pacingRate

      default long pacingRate()
      The rate the controller wants packets paced at. The connection's pacer sends at no more than this, nor than 1.25 congestion windows per smoothed RTT; a controller without a rate of its own leaves pacing to the window. quinn has no such method: its pacer always paces the window, and BBR's rate only reaches its metrics.
      Returns:
      bytes per second, or -1 to pace by the window alone
    • metrics

      default ControllerMetrics metrics()
      Metrics for statistics and tracing.
      Returns:
      the window and, where known, the slow start threshold
    • copy

      Controller copy()
      A copy of the controller's state, for a new path that starts from this one.
      Returns:
      an independent copy
    • initialWindow

      long initialWindow()
      The initial window.
      Returns:
      bytes