Is NTP time required for Syncthing?

I’ve been reading on how actual sync process works:

And there are mentions that modification time of the files is a factor for synchronization and conflict resolution. But i didn’t found a mention that i should strictly sync my time with reliable NTP server.

Do i need to do that? Or does syncthing use some kind of relative timing (or even vector clock) to achieve reliable sychronization?

Lets say i bidirectionaly sync server with laptop. Server is always online and has reasonable NTP setup. But the laptop i sometimes take to my cabin in the woods to work during weekends, but there is no internet (and no NTP). And for some reason my time goes month back in time without me noticing. And i do lot of work during that weekend, but modification times of files are suddenly month older than the copy that i have on server. I go back to the city and resync with the server only to find that my recent work was overwritten by the old files from server.

Is this something that i should be afraid of? Or does the syncthing knows IT HAS SEEN THE FILES ON SERVER BEFORE i did the modifications localy, which means my copy has to be more recent despite its modification date seems to be in the past.

Bonus use case: I sync my phone to my laptop. But i go to some developing country with crazy mobile network. Laptop uses my favourite NTP server, but my phone is setup to sync time with local mobile network (so i don’t have to care about timezone, whatever…). But since it’s developing country, they don’t care much about maintenance and their time is completely off for some negligence maybe even combined with religious reasons. This actualy happened to me this summer. Will this affect synchronization?

1 Like

No, not really. Modtime is indeed a factor in conflict resolution, because we need to use something to decide between concurrent changes, but it’s not a factor in normal synchronization.

So can i trust syncthing not to loose my data when clocks on my devices are completely random jumping back and forth doing all sorts of crazy stuff?

If or when Syncthing eats your data it won’t be due to clock discrepancies, no.

1 Like

That is really nice. Thank you for the answer.

I spent a bit of time reading up on Syncthing’s synchronization process and block exchange protocol trying to figure out how tightly clocks needed to be synchronized. Would it be reasonable to ask if this information could be added to the FAQ? Maybe something like: Q - How closely to computer clocks need to be kept synchronized when using Syncthing? A - Syncthing can perform normal file synchronization even if computer clocks are not kept in close agreement. However note that (1) the conflict resolution process will be biased in favour of modifications from the computer whose clock is ahead, (2) Syncthing depends on TLS, which uses system time to determine when certificate expie, allowing reuse of expired certificates if a computer clock is set way in the past, (3) file modification times will reflect the time on the computer where the modifications occurred, and (4) any other provisos the developers might wisely add to the FAQ entry.

Certificates generated by syncthing (for device authentication) are valid for 20 years and are backdated by an entire day. Furthermore, syncthing does not validate certificate expiry on device to device connections.