java.lang.Object
net.i2p.router.peermanager.SpeedCalculator
Quantify how fast the peer is based on advertised bandwidth tier, measured latency, congestion capability, and actual tunnel throughput.
Scoring: - Base score from bandwidth tier (X=10000, P=5000, O=2500, N=1250, M=625, L=312, K=125) - RTT penalty reduces score for high-latency peers (linear: factor = max(0.1, 1 - RTT/16s)) - Congestion caps (D=0.75x, E=0.50x) multiply down the effective speed - Actual peak 1-min tunnel throughput adds to bandwidth tier estimate when available - When no throughput data exists, the bandwidth-tier estimate stands alone (freshness is handled by selection gates, not by eroding the score).
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final doubleBase speed score of a tier K peer.private static final doubleBase speed score of a tier L peer.private static final doubleBase speed score of a tier M peer.private static final doubleBase speed score of a tier N peer.private static final doubleBase speed score of a tier O peer.private static final doubleBase speed score of a tier P peer.private static final doubleBase speed score of an untracked peer.private static final doubleBase scores for profiled bandwidth tiers.private static final doubleCongestion capability multipliers.private static final doubleFactor penalizing a congested peer.private static final doubleRTT threshold where speed is fully penalized (16s).Constructor Summary
ConstructorsModifierConstructorDescriptionprivateNot called, the calculator class is never instantiated.Method Summary
Modifier and TypeMethodDescriptionstatic doublecalc(PeerProfile profile) Calculate the estimated speed score for the given peer.private static doublegetBaseScore(RouterContext context, PeerProfile profile) The base speed score of the peer.private static doublegetCongestionFactor(RouterContext context, PeerProfile profile) Factor scaling the score by the network congestion.private static doublegetRTTFactor(PeerProfile profile) Factor scaling the score by the round trip time.
Field Details
BASE_X
private static final double BASE_XBase scores for profiled bandwidth tiers.- See Also:
BASE_P
BASE_O
BASE_N
BASE_M
BASE_L
BASE_K
BASE_UNKNOWN
private static final double BASE_UNKNOWNBase speed score of an untracked peer.- See Also:
MAX_RTT
private static final double MAX_RTTRTT threshold where speed is fully penalized (16s).- See Also:
CONGESTION_D
private static final double CONGESTION_DCongestion capability multipliers.- See Also:
CONGESTION_E
private static final double CONGESTION_EFactor penalizing a congested peer.- See Also:
Constructor Details
SpeedCalculator
private SpeedCalculator()Not called, the calculator class is never instantiated.
Method Details
calc
Calculate the estimated speed score for the given peer.- Parameters:
profile- the peer to score, read for its bandwidth tier, average RTT and peak 1-minute tunnel throughput- Returns:
- the score in bytes per second, never negative
getBaseScore
The base speed score of the peer.- Parameters:
context- the router contextprofile- the peer's profile- Returns:
- the base score
getRTTFactor
Factor scaling the score by the round trip time.- Parameters:
profile- the peer's profile- Returns:
- the factor, one if unknown
getCongestionFactor
Factor scaling the score by the network congestion.- Parameters:
context- the router contextprofile- the peer's profile- Returns:
- the factor, one if uncongested