Package io.aeron.driver
Class OptimalMulticastDelayGenerator
java.lang.Object
io.aeron.driver.OptimalMulticastDelayGenerator
- All Implemented Interfaces:
FeedbackDelayGenerator
Feedback delay used for NAKs as well as for some retransmission use cases.
Generates delay based on Optimal Multicast Feedback
http://tools.ietf.org/html/rfc5401#page-13
maxBackoffT
is max interval for delay
C version of the code:
double RandomBackoff(double maxBackoffT, double groupSize)
{
double lambda = log(groupSize) + 1;
double x = UniformRand(lambda / maxBackoffT) + lambda / (maxBackoffT * (exp(lambda) - 1));
return ((maxBackoffT / lambda) * log(x * (exp(lambda) - 1) * (maxBackoffT / lambda)));
}
where UniformRand(x)
is uniform distribution from 0..max
In this implementation's calculation:
- the
groupSize
is a constant (could be configurable as system property) maxBackoffT
is a constant (could be configurable as system property)GRTT
is a constant (could be configurable as a system property)
N
(the expected number of feedback messages per RTT) is:
N = exp(1.2 * L / (2 * maxBackoffT / GRTT))
Assumptions:
maxBackoffT = K * GRTT (K >= 1)
Recommended K
:
- K = 4 for situations where responses come from multiple places (i.e. for NAKs, multiple retransmitters)
- K = 6 for situations where responses come from single places (i.e. for NAKs, source only retransmit)
-
Constructor Summary
ConstructorsConstructorDescriptionOptimalMulticastDelayGenerator
(double maxBackoffT, double groupSize) Create new feedback delay generator based on estimates. -
Method Summary
Modifier and TypeMethodDescriptionlong
Generate a new delay value on initial request.double
Generate a new randomized delay value in the units ofmaxBackoffT
}.boolean
toString()
static double
uniformRandom
(double max) Return uniform random value in the range 0 to max.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.aeron.driver.FeedbackDelayGenerator
retryDelayNs
-
Constructor Details
-
OptimalMulticastDelayGenerator
public OptimalMulticastDelayGenerator(double maxBackoffT, double groupSize) Create new feedback delay generator based on estimates. Pre-calculating some parameters upfront.- Parameters:
maxBackoffT
- of the delay intervalgroupSize
- estimate
-
-
Method Details
-
generateDelayNs
public long generateDelayNs()Generate a new delay value on initial request.- Specified by:
generateDelayNs
in interfaceFeedbackDelayGenerator
- Returns:
- delay value in nanoseconds
-
shouldFeedbackImmediately
public boolean shouldFeedbackImmediately() -
generateNewOptimalDelay
public double generateNewOptimalDelay()Generate a new randomized delay value in the units ofmaxBackoffT
}.- Returns:
- delay in units of
maxBackoffT
.
-
uniformRandom
public static double uniformRandom(double max) Return uniform random value in the range 0 to max.- Parameters:
max
- of the random range- Returns:
- random value
-
toString
-