Interface Controller
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
FieldsModifier and TypeFieldDescriptionstatic final longThe datagram size the initial windows are computed from (RFC 9002 section 7.2). -
Method Summary
Modifier and TypeMethodDescriptioncopy()A copy of the controller's state, for a new path that starts from this one.longThe initial window.default ControllerMetricsmetrics()Metrics for statistics and tracing.default voidonAck(long now, long sent, long bytes, boolean appLimited, RttEstimator rtt) A packet's delivery was confirmed.voidonCongestionEvent(long now, long sent, boolean persistentCongestion, boolean ecn, long lostBytes) Packets were deemed lost, or marked with ECN congestion experienced.default voidonEndAcks(long now, long inFlight, boolean appLimited, long largestPacketNumberAcked) A batch of acknowledgements, all with the samenow, is complete.voidonMtuUpdate(int newMtu) The path's MTU changed.default voidonRateSample(long now, RateSample sample) The delivery rate sample of a batch of acknowledgements, given after theironAck(long, long, long, boolean, io.github.mahmoudimus.quic.congestion.RttEstimator)calls and beforeonEndAcks(long, long, boolean, long), when the batch acknowledged packets in flight. quinn has no such call.default voidonSent(long now, long bytes, long lastPacketNumber) One or more packets were just sent.default voidPackets deemed lost were all acknowledged after all: the last congestion event was spurious.default longThe rate the controller wants packets paced at.longwindow()The congestion window.
-
Field Details
-
BASE_DATAGRAM_SIZE
static final long BASE_DATAGRAM_SIZEThe 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 timebytes- the bytes sentlastPacketNumber- the number of the last packet sent
-
onAck
A packet's delivery was confirmed.- Parameters:
now- the current timesent- when the packet was sentbytes- the packet's sizeappLimited- whether the connection was limited by the application, not the window, before these acknowledgementsrtt- the path's RTT estimate
-
onRateSample
The delivery rate sample of a batch of acknowledgements, given after theironAck(long, long, long, boolean, io.github.mahmoudimus.quic.congestion.RttEstimator)calls and beforeonEndAcks(long, long, boolean, long), when the batch acknowledged packets in flight. quinn has no such call.- Parameters:
now- the current timesample- the sample
-
onEndAcks
default void onEndAcks(long now, long inFlight, boolean appLimited, long largestPacketNumberAcked) A batch of acknowledgements, all with the samenow, is complete.- Parameters:
now- the current timeinFlight- the bytes still in flightappLimited- whether the connection was application limitedlargestPacketNumberAcked- 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 timesent- when the most recent lost packet was sentpersistentCongestion- 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 losslostBytes- 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
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
-