TimeTravel: relative time synchronization between nodes - etemu/satar GitHub Wiki
In RC2 TimeTravel packets will be sent out by the nodes. Each packet is forged with the following scheme:
N=int(3)
T_ID=int(3)
T=int(20)
U_ID=int(3)
U=int(20)
E=int(3)
I=int(20)
Whereas
variable | size | description |
---|---|---|
N | int(3) | author of the packet, the nodeID of the node, which sent this |
T_ID | int(3) | nodeID of the following timestamp T, 1-254 |
T | int(20) | timestamp of the event from node T_ID in ms since T_ID's last reset |
U_ID | int(3) | nodeID of the following timestamp U, 1-254 |
U | int(20) | timestamp of the event from node U_ID in ms since U_ID's last reset |
E | int(3) | event type, 0-254, whereas 0=bootup, 1=heartbeat, 101=trigger at input 1, 102=trigger at input 2 |
I | int(20) | (reserved for the participant's ID, not used for RC2) |
Example output for a trigger event at input 1, sent from node 7 at time 131861060, whereas the supplied information reveals that node 9 had a time of 139465287 when the event happened:
N=7
T_ID=7
T=131861060
U_ID=9
U=139465287
E=101
I=0
The time delta Delta_U,T = U - T
of the nodes 7 and 9 would be 139465287 - 131861060 = 7604227 (ms)
.
If the server now receives a second event, preferably from another node at the finish line, it can derive the run time. Let's assume the following packet from node 9 arrives after the former packet from node 7:
N=9
T_ID=7
T=131881062 (let's call it T2)
U_ID=9
U=139485287 (let's call it U2)
E=101
I=0
The overall run time would then simply be calculated at the Server with runtime_T = T2 - T
, in this case 20002 ms.
Note that we have a differing Delta_U,T=7604225 (ms)
due to clock drift - an interpolation with the assumption of a linear clock drift will yield a better precision. runtime_U = U2 - U
equals 20000 ms - which is off by 2 ms compared to runtime_T. Thus the run time should be calculated with the arithmetic mean of both U and T: runtime_result = ( runtime_U + runtime_T ) / 2
In a later revision (RC3) the run time will be less faulty with more intensive interpolation. Every heartbeat and event is used to calculate a momentary delta, feeding a drift and error compensation curve which can be applied to run time results.
Note that everything happens in a relative time base: Even with sophisticated interpolation, without any drift changes and consistent results, we can not say anything about the accuracy of the resulting run time outside of the Satar system, because it is never compared to a higher stratum level. A manually operated stopwatch may be orders of magnitude more accurate, especially at long run times, but not as precise, especially at short run times.