Skip to main content

physics.networking

physics.networking

Network latency and distance physics.

Functions

Name Description
calc_great_circle_distance Calculate spherical great-circle distance between geographic coordinates.
calc_network_latency_ms Calculate the round-trip propagation floor for an optical-fiber path.

calc_great_circle_distance

physics.networking.calc_great_circle_distance(
    lat1_deg,
    lon1_deg,
    lat2_deg,
    lon2_deg,
)

Calculate spherical great-circle distance between geographic coordinates.

Parameters

Name Type Description Default
lat1_deg float First latitude in degrees, conventionally in [-90, 90]. required
lon1_deg float First longitude in degrees, conventionally in [-180, 180]. required
lat2_deg float Second latitude in degrees, conventionally in [-90, 90]. required
lon2_deg float Second longitude in degrees, conventionally in [-180, 180]. required

Returns

Name Type Description
Quantity Shortest spherical surface distance in kilometers.

Notes

Equation: d = 2 R asin(sqrt(sin(dphi/2)**2 + cos(phi1) cos(phi2) sin(dlambda/2)**2)), with angles in radians and the registry mean Earth radius R.

Assumptions: Earth is a sphere; input coordinates refer to points on its surface.

Excludes: Ellipsoidal geodesy, terrain, cable-route detours, and network delay.

References

Derivation: the haversine identity converts the central angle between spherical coordinates to an arc length R times angle. EARTH_MEAN_RADIUS is sourced in mlsysim.physics.constants.

Examples

>>> calc_great_circle_distance(0, 0, 0, 0).magnitude == 0
True
>>> calc_great_circle_distance(0, 0, 0, 90) == calc_great_circle_distance(0, 90, 0, 0)
True

calc_network_latency_ms

physics.networking.calc_network_latency_ms(distance_km)

Calculate the round-trip propagation floor for an optical-fiber path.

Parameters

Name Type Description Default
distance_km Quantity or float Nonnegative one-way fiber-route length; bare numbers mean kilometers. required

Returns

Name Type Description
float Round-trip propagation duration in milliseconds.

Notes

Equation: RTT = 2 d/vfiber, using SPEED_OF_LIGHT_FIBER_KM_S.

Assumptions: Both directions have the supplied route length and the registry’s constant propagation speed.

Excludes: Switching, queueing, serialization, transceiver processing, and route stretch if supplied distance is geographic.

References

Derivation: distance divided by speed gives one-way travel time; the return path doubles it. The propagation-speed convention is sourced with SPEED_OF_LIGHT_FIBER_KM_S in mlsysim.physics.constants.

Examples

>>> calc_network_latency_ms(200) == 2 * calc_network_latency_ms(100)
True
Back to top