java.lang.Object
net.i2p.router.peermanager.SpeedCalculator

class SpeedCalculatorextends Object
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

    Fields
    Modifier and Type
    Field
    Description
    private static final double
    Base speed score of a tier K peer.
    private static final double
    Base speed score of a tier L peer.
    private static final double
    Base speed score of a tier M peer.
    private static final double
    Base speed score of a tier N peer.
    private static final double
    Base speed score of a tier O peer.
    private static final double
    Base speed score of a tier P peer.
    private static final double
    Base speed score of an untracked peer.
    private static final double
    Base scores for profiled bandwidth tiers.
    private static final double
    Congestion capability multipliers.
    private static final double
    Factor penalizing a congested peer.
    private static final double
    RTT threshold where speed is fully penalized (16s).
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Not called, the calculator class is never instantiated.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    calc(PeerProfile profile)
    Calculate the estimated speed score for the given peer.
    private static double
    The base speed score of the peer.
    private static double
    Factor scaling the score by the network congestion.
    private static double
    Factor scaling the score by the round trip time.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BASE_X

      private static final double BASE_X
      Base scores for profiled bandwidth tiers.
      See Also:
    • BASE_P

      private static final double BASE_P
      Base speed score of a tier P peer.
      See Also:
    • BASE_O

      private static final double BASE_O
      Base speed score of a tier O peer.
      See Also:
    • BASE_N

      private static final double BASE_N
      Base speed score of a tier N peer.
      See Also:
    • BASE_M

      private static final double BASE_M
      Base speed score of a tier M peer.
      See Also:
    • BASE_L

      private static final double BASE_L
      Base speed score of a tier L peer.
      See Also:
    • BASE_K

      private static final double BASE_K
      Base speed score of a tier K peer.
      See Also:
    • BASE_UNKNOWN

      private static final double BASE_UNKNOWN
      Base speed score of an untracked peer.
      See Also:
    • MAX_RTT

      private static final double MAX_RTT
      RTT threshold where speed is fully penalized (16s).
      See Also:
    • CONGESTION_D

      private static final double CONGESTION_D
      Congestion capability multipliers.
      See Also:
    • CONGESTION_E

      private static final double CONGESTION_E
      Factor penalizing a congested peer.
      See Also:
  • Constructor Details

    • SpeedCalculator

      private SpeedCalculator()
      Not called, the calculator class is never instantiated.
  • Method Details

    • calc

      public static double calc(PeerProfile profile)
      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

      private static double getBaseScore(RouterContext context, PeerProfile profile)
      The base speed score of the peer.
      Parameters:
      context - the router context
      profile - the peer's profile
      Returns:
      the base score
    • getRTTFactor

      private static double getRTTFactor(PeerProfile profile)
      Factor scaling the score by the round trip time.
      Parameters:
      profile - the peer's profile
      Returns:
      the factor, one if unknown
    • getCongestionFactor

      private static double getCongestionFactor(RouterContext context, PeerProfile profile)
      Factor scaling the score by the network congestion.
      Parameters:
      context - the router context
      profile - the peer's profile
      Returns:
      the factor, one if uncongested