-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Suppose that _T_ is the correct time (remote time) and our local time | ||
is offset by _θ_. | ||
|
||
To determine _θ_, we perform these steps: | ||
|
||
1. \(A) sends a request to (B) at _t₀_ (local clock) | ||
2. \(B) receives and answers (A)'s request at _t₁_ (remote clock) | ||
3. \(A) receives (B)'s answer at _t₂_ (local clock) | ||
|
||
These steps are represented in the following diagram: | ||
|
||
``` | ||
t₁ | ||
(B) --------^--------> T | ||
/ \ | ||
/ \ | ||
(A) -----^-----v-----> T + θ | ||
t₀ t₂ | ||
``` | ||
|
||
Bringing _t₁_ to the local time (between _t₀_ and _t₂_): | ||
|
||
t₀ < t₁ + θ < t₂ | ||
|
||
So, | ||
|
||
* θ > t₀ - t₁ | ||
* θ < t₂ - t₁ | ||
|
||
But since _t₁ ∈ [⌊t₁⌋, ⌊t₁⌋ + 1)_, then: | ||
|
||
* θ > t₀ - ⌊t₁⌋ - 1 | ||
* θ < t₂ - ⌊t₁⌋ | ||
|
||
**Note**: Observe that the closer _t₁_ is to _⌊t₁⌋_ or _⌊t₁⌋ + 1_, | ||
smaller is the error in one of the two equations above. | ||
|
||
We can repeat the above procedure to decrease the range of possible | ||
values for _θ_. The ideal delay _d_ before sending the next request is | ||
calculated so that the next value of _t₁_ is close to a "full" second: | ||
|
||
t₂ + d + (t₂ - t₀)/2 - θ = ⌊t₁⌋ + k, k ∈ ℤ | ||
|
||
⇒ d = ⌊t₁⌋ + k + θ - t₂ - (t₂ - t₀)/2 mod 1 | ||
|
||
⇒ d = θ - t₂ - (t₂ - t₀)/2 mod 1 |