Class SpeedOfLightLatency
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:
- IBX to IBX -
millisBetween(Ibx, Ibx): the most precise figure, using each data center's own coordinates (frominternetAccess.ibxs()); two IBXes in the same metro get a real, small, non-zero distance. - Metro to Metro -
millisBetween(Metro, Metro): metro-centroid figure using Fabric's metro coordinates (fromfabric.metros()/fabric.metroRegistry()). Fine for city-to-city planning; same-metro pairs compute as 0. - IBX to Metro -
millisBetween(Ibx, Metro)/millisBetween(Metro, Ibx): mixed precision, e.g. "from my cage in LA4 to the Dallas metro". - Raw -
millisBetween(GeoCoordinate, GeoCoordinate),distanceKm(double, double, double, double)andmillisForKm(double)for arbitrary coordinates or known distances, fully offline.
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent configuration forSpeedOfLightLatency.static enumWhether to report a one-way or a round-trip (RTT) figure. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleRefractive index of single-mode optical fibre (~1.467); fibre speed isc / n.static final doubleDefault path inflation over the great-circle distance (1.0 = theoretical straight-line floor).static final doubleSpeed of light in vacuum, km/s. -
Method Summary
Modifier and TypeMethodDescriptionstatic SpeedOfLightLatency.Builderbuilder()Starts a builder for a customized calculator (mode, refractive index, route factor).static doubledistanceKm(double lat1, double lon1, double lat2, double lon2) Great-circle (haversine) distance between two latitude/longitude pairs.static doubleGreat-circle (haversine) distance between two coordinates.static doubledistanceKm(Metro a, Metro b) Great-circle (haversine) distance between two Equinix metro centroids.static doubledistanceKm(Metro a, Ibx b) Great-circle (haversine) distance between a metro centroid and an IBX data center.static doubledistanceKm(Ibx a, Metro b) Great-circle (haversine) distance between an IBX data center and a metro centroid.static doubledistanceKm(Ibx a, Ibx b) Great-circle (haversine) distance between two Equinix IBX data centers.getMode()doubleFibre latency between two coordinates (great-circle distance).doublemillisBetween(Metro a, Metro b) Fibre latency between two Equinix metros, using each metro's Fabric centroid coordinates.doublemillisBetween(Metro a, Ibx b) Fibre latency between a metro centroid and an IBX data center (mixed precision).doublemillisBetween(Ibx a, Metro b) Fibre latency between an IBX data center and a metro centroid (mixed precision) - e.g.doublemillisBetween(Ibx a, Ibx b) Fibre latency between two Equinix IBX data centers, using each IBX's own coordinates.doublemillisForKm(double distanceKm) Fibre latency for a great-circle distance.static SpeedOfLightLatencyoneWay()static SpeedOfLightLatency
-
Field Details
-
SPEED_OF_LIGHT_KM_PER_S
public static final double SPEED_OF_LIGHT_KM_PER_SSpeed of light in vacuum, km/s.- See Also:
-
DEFAULT_FIBER_REFRACTIVE_INDEX
public static final double DEFAULT_FIBER_REFRACTIVE_INDEXRefractive index of single-mode optical fibre (~1.467); fibre speed isc / n.- See Also:
-
DEFAULT_ROUTE_FACTOR
public static final double DEFAULT_ROUTE_FACTORDefault path inflation over the great-circle distance (1.0 = theoretical straight-line floor).- See Also:
-
-
Method Details
-
roundTrip
- Returns:
- a round-trip (RTT) calculator with default fibre and route parameters
-
oneWay
- Returns:
- a one-way calculator with default fibre and route parameters
-
builder
Starts a builder for a customized calculator (mode, refractive index, route factor). The no-argument chainbuilder().build()is equivalent toroundTrip().- Returns:
- a new builder with the defaults pre-set
-
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() - Throws:
IllegalArgumentException- ifdistanceKmis NaN or infinite (a missing distance must not turn into a latency figure)
-
millisBetween
Fibre latency between two coordinates (great-circle distance).- Parameters:
a- one endpointb- the other endpoint- Returns:
- the estimated latency in milliseconds
- Throws:
IllegalArgumentException- if either coordinate is null or missing latitude/longitude
-
millisBetween
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 IBXb- the other IBX- Returns:
- the estimated latency in milliseconds
- Throws:
IllegalArgumentException- if either IBX is null or has no coordinates
-
millisBetween
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 - usemillisBetween(Ibx, Ibx)for per-data-center precision.- Parameters:
a- one metrob- the other metro- Returns:
- the estimated latency in milliseconds
- Throws:
IllegalArgumentException- if either metro is null or has no coordinates
-
millisBetween
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 IBXb- the metro- Returns:
- the estimated latency in milliseconds
- Throws:
IllegalArgumentException- if either endpoint is null or has no coordinates
-
millisBetween
Fibre latency between a metro centroid and an IBX data center (mixed precision).- Parameters:
a- the metrob- the IBX- Returns:
- the estimated latency in milliseconds
- Throws:
IllegalArgumentException- if either endpoint is null or has no coordinates
-
distanceKm
Great-circle (haversine) distance between two coordinates.- Parameters:
a- one endpointb- the other endpoint- Returns:
- the distance in kilometres
- Throws:
IllegalArgumentException- if either coordinate is null or missing latitude/longitude
-
distanceKm
Great-circle (haversine) distance between two Equinix IBX data centers.- Parameters:
a- one IBXb- the other IBX- Returns:
- the distance in kilometres
- Throws:
IllegalArgumentException- if either IBX is null or is missing its coordinates
-
distanceKm
Great-circle (haversine) distance between two Equinix metro centroids.- Parameters:
a- one metrob- the other metro- Returns:
- the distance in kilometres
- Throws:
IllegalArgumentException- if either metro is null or is missing its coordinates
-
distanceKm
Great-circle (haversine) distance between an IBX data center and a metro centroid.- Parameters:
a- the IBXb- the metro- Returns:
- the distance in kilometres
- Throws:
IllegalArgumentException- if either endpoint is null or is missing its coordinates
-
distanceKm
Great-circle (haversine) distance between a metro centroid and an IBX data center.- Parameters:
a- the metrob- 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.- Parameters:
lat1- latitude of the first point, decimal degreeslon1- longitude of the first point, decimal degreeslat2- latitude of the second point, decimal degreeslon2- longitude of the second point, decimal degrees- Returns:
- the distance in kilometres
- Throws:
IllegalArgumentException- if any coordinate is NaN or infinite
-