A method for clock synchronization of a plurality of electronic devices (1), said plurality comprising at least three devices, wherein each of the plurality of devices (1) comprises:
- a respective local clock having a respective clock rate and a respective clock offset;
- wireless communication means (11) for transmitting and receiving packets to and from the other devices of said plurality of devices;
- second communication means (12) for connecting to a server (2);
- said method comprising the steps of:
- for each respective one of the devices, controlling the device to transmit at least two respective measurement packets (3) via said wireless connection means (11) and generate respective local transmission timestamps based on the respective local clock of the device;
- for each respective of said transmitted measurement packets, controlling at least one device different from the transmitting device to, upon receipt of the transmitted measurement packet (3) via said wireless connection means (11), generate a respective local reception timestamp based on the respective local clock of the respective device;
- for each device and for each respective of said transmitted measurement packets (3), controlling the transmitting device to transmit the local transmission timestamp to the server (2) via the second connection means (12);
- for each respective of said transmitted measurement packets (3), controlling the at least one receiving device to transmit the local reception timestamp to the server (2) via the second connection means (12);
- calculating, by the server (2), the clock rates and the clock offsets of each of the plurality of respective devices based on the received local transmission timestamps and the received local reception timestamps;
- wherein said calculating of the clock rates and the clock offsets is performed after reception, by the server (2), of each of said generated local transmission timestamps and each of said generated local reception timestamps;
- wherein said step of calculating the clock rates and the clock offsets comprises the substeps of:
- (a) calculating the clock rates of each of the plurality of respective devices based on the received local transmission timestamps and the received local reception timestamps;
- (b) calculating the clock offsets of each of the plurality of respective devices based on at least the received local transmission timestamps and the received local reception timestamps;
- wherein said substep (b) is carried out after completion of substep (a), and wherein preferably the calculating of the clock offsets is further based on the calculated clock rates;
- and
- wherein the calculating of the clock offsets of substep (b) is based on the received local transmission timestamps, the received local reception timestamps and the calculated clock rates solely through coefficients oi,j, wherein
- oi,j is proportional to γi([τA1,i]τi,ref+[τT2,i]τi,ref)−γi([τT1,i]τi,ref+[τA2,i]τi,ref);
- wherein
- γi denotes the clock rate of device i, i=1, . . . , N;
- wherein N is the number of devices;
- τTk,i denotes the local transmission timestamp corresponding to the kth measurement packet that is transmitted by device i;
- τAk,i denotes the local reception timestamp corresponding to the kth measurement that is transmitted by device i and received by device j;
- and
- [τ] τi,ref denotes (τi−τi,ref) module τM, wherein τi,ref denotes a reference timestamp for overflow compensation of device i, and IM denotes a maximal timestamp relating to overflow.