Fastest clock synchronization algorithm
Embodiments of the present disclosure are directed to synchronizing clocks across a plurality of computing devices. Generally speaking, the clocks of the plurality of devices can be synchronized to whichever of the clocks is the furthest ahead in time. More specifically, embodiments provide for determining a common time reference establishment without need for an external reference. Rather, a computing device or node with the furthest ahead in time clock among devices or nodes in a group or time domain can be become the leader node and propagate time to the other nodes. Embodiments of the present disclosure can replace the traditional one-way time transfer from the IEEE 1588 timeTransmitter to the timeReceiver with two-way communication and time transfer.
1 . A first device of a plurality of devices in a time domain, the device comprising:
a communications interface coupled with a communications network;
a control circuit coupled with the communications interface and controlling operations of the first device, wherein the control circuit of the first device causes the first device to:
maintain a clock indicating a current time for the first device;
send, via the communications interface, to two or more other devices of the plurality of devices, an electronic message comprising a timestamp indicating the current time for the first device;
receive, via the communications interface, from each of the two or more other devices, an electronic message comprising a timestamp indicating a current time for the two or more other devices based on a clock of each of the two or more other devices;
determine, based on the timestamp of the received electronic messages from the two or more other devices, which of the clock of the first device and the clocks of the two or more other devices is furthest ahead in time; and
set the current time for the first device based on the determined furthest ahead in time of the clock of the first device and the clocks of the two or more other devices.
2 . The device of claim 1 , wherein setting the current time for the first device based on the determined furthest ahead in time of the clock of the first device and the clocks of the second device comprises setting the current time for the first device to the current time for one of the two or more other devices in response to the determining the clock of the one of the two or more other devices is faster than the clock of the first device.
3 . The device of claim 1 , wherein setting the current time for the first device based on the determined furthest ahead in time of the clock of the first device and the clocks of the two or more other devices comprises maintaining the current time of the first device based on the clock of the first device in response to determining the clock of the first device is faster than the clocks of the two or more other devices.
4 . The device of claim 1 , wherein determining which of the clock of the first device and the clock of the is furthest ahead in time comprises:
calculating an offset between the current time for the first device and the current time for each of the two or more other devices; and
determining, based on the calculated offsets, which of the clock of the first device and the clocks of the two or more other devices is furthest ahead in time.
5 . The device of claim 4 , wherein setting the current time for the first device based on the determined furthest ahead in time of the clock of the first device and clocks of the two or more other devices comprises adding values to the current time for the first device based on the calculated offsets between the current time for the first device and the current time for each of the two or more other devices.
6 . The device of claim 1 , wherein the control circuit of the first device further causes the first device to:
send, via the communications interface, to each of the two or more other devices, a delay request message; and
receive, via the communications interface, from each of the two or more other devices, a delay response message indicating a transit time for the delay request message.
7 . The device of claim 6 , wherein in determining which of the clock of the first device and the clocks of the two or more other devices is furthest ahead in time is furthest ahead in time is based on the delay response message.
8 . A data center comprising:
a communications network;
a first device of a plurality of peer devices coupled with the communications network and comprising a control circuit controlling operation of the first device; and
a second device of the plurality of peer devices coupled with the communication network and comprising a control circuit controlling operation of the second device; wherein:
the control circuit of the first device causes the first device to send a first electronic message to the second device via the communications network, the first electronic message comprising a timestamp indicating a current time for the first device;
the control circuit of the second device causes the second device to receive the first electronic message from the first device and send a second electronic message to the first device via the communications network, the second electronic message comprising a timestamp indicating a current time for the second device; and
the control circuit of the first device causes the first device to receive the second electronic message from the second device, determine, based on the timestamp of the received second electronic message, which of the clock of the first device and the clock of the second device is furthest ahead in time, and set the current time for the first device based on the determined furthest ahead in time of the clock of the first device and clock of the second device.
9 . The data center of claim 8 , wherein the control circuit of the second device causes the second device to determine, based on the timestamp of the received first electronic message, which of the clock of the first device and the clock of the second device is furthest ahead in time, and set the current time for the second device based on the determined furthest ahead in time of the clock of the first device and clock of the second device.
10 . The data center of claim 8 , wherein setting the current time for the first device based on the determined furthest ahead in time of the clock of the first device and clock of the second device comprises, in response to the determining the clock of the second device is faster than the clock of the first device, setting the current time for the first device to the current time for the second device.
11 . The data center of claim 8 , wherein setting the current time for the first device based on the determined furthest ahead in time of the clock of the first device and clock of the second device comprises, in response to determining the clock of the first device is faster than the clock of the second device, maintaining the current time of the first device based on the clock of the first device.
12 . The data center of claim 8 , wherein determining which of the clock of the first device and the clock of the second device is furthest ahead in time comprises:
calculating an offset between the current time for the first device and the current time for the second device; and
determining, based on the calculated offset, which of the clock of the first device and the clock of the second device is furthest ahead in time.
13 . The data center of claim 12 , wherein setting the current time for the first device based on the determined furthest ahead in time of the clock of the first device and clock of the second device comprises adding a value to the current time for the first device based on the calculated offset between the current time for the first device and the current time for the second device.
14 . The data center of claim 8 , wherein:
the control circuit of the first device further causes the first device to send, via the communications network, to the second device, a delay request message;
the control circuit of the second device causes the second device to receive the delay request message from the first device, determine a transit time for the delay request message, and send, via the communications network, to the first device, a delay response message comprising the determined transit time; and
the control circuit of the first device further causes the first device to receive the delay response message, wherein in determining which of the clock of the first device and the clock of the second device is furthest ahead in time is further based on the delay response message.
15 . A method for synchronizing clocks between a plurality of peer computing devices, the method comprising:
sending, by a first peer computing device of the plurality of peer computing devices, a first electronic message to a second peer computing device of the plurality of peer computing devices via a communications network, the first electronic message comprising a timestamp indicating a current time for the first peer computing device;
receiving, by the second peer computing device, the first electronic message from the first peer computing device;
sending, by the second peer computer device, a second electronic message to the first peer computing device via the communications network, the second electronic message comprising a timestamp indicating a current time for the second peer computing device;
receiving, by the first peer computing device, the second electronic message from the second peer computing device;
determining, by the first peer computing device, based on the timestamp of the received second electronic message, which of the clock of the first peer computing device and the clock of the second peer computing device is furthest ahead in time; and
setting, by the first peer computing device, the current time for the first peer computing device based on the determined furthest ahead in time of the clock of the first peer computing device and clock of the second peer computing device.
16 . The method of claim 15 , further comprising:
determining, by the second peer computing device, based on the timestamp of the received first electronic message, which of the clock of the first peer computing device and the clock of the second peer computing device is furthest ahead in time; and
setting, by the second peer computing device, the current time for the second peer computing device based on the determined furthest ahead in time of the clock of the first peer computing device and clock of the second peer computing device.
17 . The method of claim 15 , wherein setting the current time for the first peer computing device based on the determined furthest ahead in time of the clock of the first peer computing device and clock of the second peer computing device comprises, in response to the determining the clock of the second peer computing device is faster than the clock of the first peer computing device, setting the current time for the first peer computing device to the current time for the second peer computing device.
18 . The method of claim 15 , wherein setting the current time for the first peer computing device based on the determined furthest ahead in time of the clock of the first peer computing device and clock of the second peer computing device comprises, in response to determining the clock of the first peer computing device is faster than the clock of the second peer computing device, maintaining the current time of the first peer computing device based on the clock of the first peer computing device.
19 . The method of claim 15 , wherein determining which of the clock of the first peer computing device and the clock of the second peer computing device is furthest ahead in time comprises:
calculating an offset between the current time for the first peer computing device and the current time for the second peer computing device; and
determining, based on the calculated offset, which of the clock of the first peer computing device and the clock of the second peer computing device is furthest ahead in time and wherein setting the current time for the first peer computing device based on the determined furthest ahead in time of the clock of the first peer computing device and clock of the second peer computing device comprises adding a value to the current time for the first peer computing device based on the calculated offset between the current time for the first peer computing device and the current time for the second peer computing device.
20 . The method of claim 15 , further comprising:
sending, by the first peer computing device, via the communications network, to the second peer computing device, a delay request message;
receiving, by the second peer computing device, the delay request message from the first peer computing device;
determining, by the second peer computing device, a transit time for the delay request message;
sending, by the second peer computing device, via the communications network, to the first peer computing device, a delay response message comprising the determined transit time; and
receiving, by the first peer computing device, the delay response message, wherein in determining which of the clock of the first peer computing device and the clock of the second peer computing device is furthest ahead in time is further based on the delay response message.