Package io.aeron.driver
Interface CongestionControl
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
CubicCongestionControl
,StaticWindowCongestionControl
Strategy for applying congestion control to determine the receiver window length of the Status Messages.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Bit flag for if a status message should be forced out. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
int
Called byDriverConductor
to initialise window length for a newPublicationImage
.int
Called byDriverConductor
limit the window length for a newPublicationImage
.void
onRttMeasurement
(long nowNs, long rttNs, InetSocketAddress srcAddress) Called byReceiver
on reception of an RTT Measurement.void
onRttMeasurementSent
(long nowNs) Called byReceiver
to record that a measurement request has been sent.long
onTrackRebuild
(long nowNs, long newConsumptionPosition, long lastSmPosition, long hwmPosition, long startingRebuildPosition, long endingRebuildPosition, boolean lossOccurred) Called byDriverConductor
upon execution ofPublicationImage.trackRebuild(long)
to pass on current status.static long
packOutcome
(int receiverWindowLength, boolean forceStatusMessage) Pack values into a long, so they can be returned on the stack without allocation.static int
receiverWindowLength
(long outcome) Extract the receiver window length from the packed value.static boolean
shouldForceStatusMessage
(long outcome) Extract the boolean value for if a status message should be forced from the packed value.boolean
shouldMeasureRtt
(long nowNs) Polled byReceiver
to determine when to initiate an RTT measurement to a Sender.static int
threshold
(int windowLength) Threshold increment in a window after which a status message should be scheduled.
-
Field Details
-
FORCE_STATUS_MESSAGE_BIT
static final int FORCE_STATUS_MESSAGE_BITBit flag for if a status message should be forced out.- See Also:
-
-
Method Details
-
packOutcome
static long packOutcome(int receiverWindowLength, boolean forceStatusMessage) Pack values into a long, so they can be returned on the stack without allocation.- Parameters:
receiverWindowLength
- to go in the lower bits.forceStatusMessage
- to go in the higher bits.- Returns:
- the packed value.
-
receiverWindowLength
static int receiverWindowLength(long outcome) Extract the receiver window length from the packed value.- Parameters:
outcome
- as the packed value.- Returns:
- the receiver window length.
-
shouldForceStatusMessage
static boolean shouldForceStatusMessage(long outcome) Extract the boolean value for if a status message should be forced from the packed value.- Parameters:
outcome
- which is packed containing the force status message flag.- Returns:
- true if the force status message bit has been set.
-
threshold
static int threshold(int windowLength) Threshold increment in a window after which a status message should be scheduled.- Parameters:
windowLength
- to calculate the threshold from.- Returns:
- the threshold in the window after which a status message should be scheduled.
-
shouldMeasureRtt
boolean shouldMeasureRtt(long nowNs) Polled byReceiver
to determine when to initiate an RTT measurement to a Sender.- Parameters:
nowNs
- in nanoseconds- Returns:
- true for should measure RTT now or false for no measurement
-
onRttMeasurementSent
void onRttMeasurementSent(long nowNs) Called byReceiver
to record that a measurement request has been sent.- Parameters:
nowNs
- in nanoseconds.
-
onRttMeasurement
Called byReceiver
on reception of an RTT Measurement.- Parameters:
nowNs
- in nanosecondsrttNs
- to the Sender in nanosecondssrcAddress
- of the Sender
-
onTrackRebuild
long onTrackRebuild(long nowNs, long newConsumptionPosition, long lastSmPosition, long hwmPosition, long startingRebuildPosition, long endingRebuildPosition, boolean lossOccurred) Called byDriverConductor
upon execution ofPublicationImage.trackRebuild(long)
to pass on current status.The return value must be packed using
packOutcome(int, boolean)
.- Parameters:
nowNs
- current timenewConsumptionPosition
- of the subscriberslastSmPosition
- of the imagehwmPosition
- of the imagestartingRebuildPosition
- of the rebuildendingRebuildPosition
- of the rebuildlossOccurred
- during rebuild- Returns:
- outcome of congestion control calculation containing window length and whether to force sending an SM.
-
initialWindowLength
int initialWindowLength()Called byDriverConductor
to initialise window length for a newPublicationImage
.- Returns:
- initial window length for flow and congestion control.
-
maxWindowLength
int maxWindowLength()Called byDriverConductor
limit the window length for a newPublicationImage
.- Returns:
- maximum window length for flow and congestion control.
-
close
void close()- Specified by:
close
in interfaceAutoCloseable
-