java.lang.Object
io.github.mahmoudimus.quic.congestion.Cubic
All Implemented Interfaces:
Controller

public final class Cubic extends Object implements Controller
The CUBIC congestion controller (RFC 9438), counting the window in bytes: slow start, then the cubic window function W_cubic(t) = C * (t - K)^3 + W_max with the Reno-friendly estimate W_est, fast convergence, and a multiplicative decrease of beta_cubic = 0.7. A congestion event later found spurious restores the state from before it.

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

  • Constructor Details

    • Cubic

      public Cubic(CubicConfig config, long now, int currentMtu)
      A controller in slow start.
      Parameters:
      config - the configuration
      now - the current time, in nanoseconds
      currentMtu - the path's maximum UDP payload size
  • Method Details

    • onAck

      public void onAck(long now, long sent, long bytes, boolean appLimited, RttEstimator rtt)
      Description copied from interface: Controller
      A packet's delivery was confirmed.
      Specified by:
      onAck in interface Controller
      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
    • onCongestionEvent

      public void onCongestionEvent(long now, long sent, boolean persistentCongestion, boolean ecn, long lostBytes)
      Description copied from interface: Controller
      Packets were deemed lost, or marked with ECN congestion experienced.
      Specified by:
      onCongestionEvent in interface Controller
      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

      public void onSpuriousCongestionEvent()
      Description copied from interface: Controller
      Packets deemed lost were all acknowledged after all: the last congestion event was spurious.
      Specified by:
      onSpuriousCongestionEvent in interface Controller
    • onMtuUpdate

      public void onMtuUpdate(int newMtu)
      Description copied from interface: Controller
      The path's MTU changed.
      Specified by:
      onMtuUpdate in interface Controller
      Parameters:
      newMtu - the new maximum UDP payload size
    • window

      public long window()
      Description copied from interface: Controller
      The congestion window.
      Specified by:
      window in interface Controller
      Returns:
      the ack-eliciting bytes that may be in flight
    • slowStartThreshold

      public long slowStartThreshold()
      The slow start threshold.
      Returns:
      bytes, Long.MAX_VALUE before the first congestion event
    • metrics

      public ControllerMetrics metrics()
      Description copied from interface: Controller
      Metrics for statistics and tracing.
      Specified by:
      metrics in interface Controller
      Returns:
      the window and, where known, the slow start threshold
    • copy

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

      public long initialWindow()
      Description copied from interface: Controller
      The initial window.
      Specified by:
      initialWindow in interface Controller
      Returns:
      bytes