WALT uses a three-step algorithm to synchronize a local clock with a remote clock, accounting for asymmetric USB latency. The goal is to bound the unknown clock difference E within a range minE < E < maxE.
Step 1: Rough Sync
- Record local time
T0. - Instruct the remote device to zero its clock.
- Wait for confirmation from the remote.
- Set
maxE = current_time() - T0. - All subsequent local time is measured relative to
T0.
At this stage, the remote clock lags behind the local clock by E, where 0 = minE < E < maxE.
Step 2: Find better lower bound (minE)
To increase minE, send messages from local to remote. The remote replies with its timestamp (t_remote) of when it received the message. The local machine records the time right before sending (t_local).
- Logic:
E > t_local - t_remote (since travel time > 0). - Action:
set minE to max(minE, t_local - t_remote). - Note: Send a batch of messages with random small delays before retrieving timestamps to mitigate kernel/hardware buffering delays.
Step 3: Find better upper bound (maxE)
To decrease maxE, the remote device sends messages to the local machine. The remote includes its timestamp (t_remote) of when the message was sent, and the local machine records the time of receipt (t_local).
- Logic:
E < t_local - t_remote. - Action:
set maxE = min(maxE, t_local - t_remote).
Comparison with NTP
Unlike NTP, which assumes symmetric travel time (latency), WALT is designed for asymmetric USB communication. While the resulting synchronization interval deltaE = maxE - minE may be larger than NTP's on symmetric networks, WALT provides guaranteed bounds even when asymmetry is present.