Class SpeedOfLightLatency

java.lang.Object
com.eqixiac.equinix.design.geo.SpeedOfLightLatency

public final class SpeedOfLightLatency extends Object
Estimates network latency from geographic distance using the speed of light in optical fiber.

Light in glass fiber travels at c / n, where n ≈ 1.467 is the refractive index — roughly 204,000 km/s, or ~4.9 µs per km one-way. The estimate is:

one-way ms = distanceKm * routeFactor / (c / n / 1000)

and round-trip is twice that. routeFactor (default 1.0) inflates the great-circle distance for non-direct fibre paths; leave it at 1.0 for the theoretical speed-of-light floor, or set ~1.3–1.5 for a realistic terrestrial route. The result is a physical lower bound (or estimate) — it excludes switching, queuing, and serialization delay.

The round-trip (RTT) mode is the default, since RTT is what most latency budgets are quoted in.

Latency is computed IBX-to-IBX — between two specific Equinix data centers using each IBX's own coordinates — not between metro centroids, so two IBXes in the same metro have a real (small, non-zero) distance.

Endpoint types

Latency can be computed between any mix of the SDK's location-bearing types:

Coordinates are optional in both source APIs, so every typed overload throws IllegalArgumentException naming the offending IBX/metro when coordinates are missing — fail loud rather than return a bogus zero.

For metro-to-metro, compare the calculated floor against Equinix's measured inter-metro RTT: metro.getConnectedMetros() carries avgLatency (ms) observed on the Fabric backbone. The floor tells you what physics allows; avgLatency tells you what the network delivers.

Ibx la4 = internetAccess.ibxs().getByCode("LA4");
Ibx sv5 = internetAccess.ibxs().getByCode("SV5");
Metro dc = fabric.metros().getByMetroCode(MetroCode.DC);
Metro sv = fabric.metros().getByMetroCode(MetroCode.SV);

SpeedOfLightLatency rtt = SpeedOfLightLatency.roundTrip();   // default
double ibxToIbx     = rtt.millisBetween(la4, sv5);           // precise, IBX-to-IBX
double metroToMetro = rtt.millisBetween(dc, sv);             // metro centroids
double ibxToMetro   = rtt.millisBetween(la4, dc);            // mixed

SpeedOfLightLatency realistic = SpeedOfLightLatency.builder()
        .mode(Mode.ONE_WAY).routeFactor(1.4).build();
double oneWay = realistic.millisForKm(1000);                 // ~6.85 ms
Author:
ianjones
  • Field Details

    • SPEED_OF_LIGHT_KM_PER_S

      public static final double SPEED_OF_LIGHT_KM_PER_S
      Speed of light in vacuum, km/s.
      See Also:
    • DEFAULT_FIBER_REFRACTIVE_INDEX

      public static final double DEFAULT_FIBER_REFRACTIVE_INDEX
      Refractive index of single-mode optical fibre (~1.467); fibre speed is c / n.
      See Also:
    • DEFAULT_ROUTE_FACTOR

      public static final double DEFAULT_ROUTE_FACTOR
      Default path inflation over the great-circle distance (1.0 = theoretical straight-line floor).
      See Also:
  • Method Details

    • roundTrip

      public static SpeedOfLightLatency roundTrip()
      Returns:
      a round-trip (RTT) calculator with default fibre and route parameters
    • oneWay

      public static SpeedOfLightLatency oneWay()
      Returns:
      a one-way calculator with default fibre and route parameters
    • builder

      public static SpeedOfLightLatency.Builder builder()
      Starts a builder for a customized calculator (mode, refractive index, route factor). The no-argument chain builder().build() is equivalent to roundTrip().
      Returns:
      a new builder with the defaults pre-set
    • getMode

      public SpeedOfLightLatency.Mode getMode()
      Returns:
      the configured mode (round-trip by default)
    • millisForKm

      public double millisForKm(double distanceKm)
      Fibre latency for a great-circle distance.
      Parameters:
      distanceKm - the distance in kilometres (negative values are treated as 0)
      Returns:
      the estimated latency in milliseconds, round-trip or one-way per getMode()
    • millisBetween

      public double millisBetween(GeoCoordinate a, GeoCoordinate b)
      Fibre latency between two coordinates (great-circle distance).
      Parameters:
      a - one endpoint
      b - the other endpoint
      Returns:
      the estimated latency in milliseconds
      Throws:
      IllegalArgumentException - if either coordinate is null or missing latitude/longitude
    • millisBetween

      public double millisBetween(Ibx a, Ibx b)
      Fibre latency between two Equinix IBX data centers, using each IBX's own coordinates. This is the IBX-to-IBX figure: two IBXes in the same metro have a real (small) latency rather than zero.
      Parameters:
      a - one IBX
      b - the other IBX
      Returns:
      the estimated latency in milliseconds
      Throws:
      IllegalArgumentException - if either IBX is null or has no coordinates
    • millisBetween

      public double millisBetween(Metro a, Metro b)
      Fibre latency between two Equinix metros, using each metro's Fabric centroid coordinates. This is a metro-level figure: two IBXes in the same metro compute as 0 — use millisBetween(Ibx, Ibx) for per-data-center precision.
      Parameters:
      a - one metro
      b - the other metro
      Returns:
      the estimated latency in milliseconds
      Throws:
      IllegalArgumentException - if either metro is null or has no coordinates
    • millisBetween

      public double millisBetween(Ibx a, Metro b)
      Fibre latency between an IBX data center and a metro centroid (mixed precision) — e.g. "from my cage in LA4 to the Dallas metro".
      Parameters:
      a - the IBX
      b - the metro
      Returns:
      the estimated latency in milliseconds
      Throws:
      IllegalArgumentException - if either endpoint is null or has no coordinates
    • millisBetween

      public double millisBetween(Metro a, Ibx b)
      Fibre latency between a metro centroid and an IBX data center (mixed precision).
      Parameters:
      a - the metro
      b - the IBX
      Returns:
      the estimated latency in milliseconds
      Throws:
      IllegalArgumentException - if either endpoint is null or has no coordinates
    • distanceKm

      public static double distanceKm(GeoCoordinate a, GeoCoordinate b)
      Great-circle (haversine) distance between two coordinates.
      Parameters:
      a - one endpoint
      b - the other endpoint
      Returns:
      the distance in kilometres
      Throws:
      IllegalArgumentException - if either coordinate is null or missing latitude/longitude
    • distanceKm

      public static double distanceKm(Ibx a, Ibx b)
      Great-circle (haversine) distance between two Equinix IBX data centers.
      Parameters:
      a - one IBX
      b - the other IBX
      Returns:
      the distance in kilometres
      Throws:
      IllegalArgumentException - if either IBX is null or is missing its coordinates
    • distanceKm

      public static double distanceKm(Metro a, Metro b)
      Great-circle (haversine) distance between two Equinix metro centroids.
      Parameters:
      a - one metro
      b - the other metro
      Returns:
      the distance in kilometres
      Throws:
      IllegalArgumentException - if either metro is null or is missing its coordinates
    • distanceKm

      public static double distanceKm(Ibx a, Metro b)
      Great-circle (haversine) distance between an IBX data center and a metro centroid.
      Parameters:
      a - the IBX
      b - the metro
      Returns:
      the distance in kilometres
      Throws:
      IllegalArgumentException - if either endpoint is null or is missing its coordinates
    • distanceKm

      public static double distanceKm(Metro a, Ibx b)
      Great-circle (haversine) distance between a metro centroid and an IBX data center.
      Parameters:
      a - the metro
      b - the IBX
      Returns:
      the distance in kilometres
      Throws:
      IllegalArgumentException - if either endpoint is null or is missing its coordinates
    • distanceKm

      public static double distanceKm(double lat1, double lon1, double lat2, double lon2)
      Great-circle (haversine) distance between two latitude/longitude pairs.
      Returns:
      the distance in kilometres