I am using a PC and a raspberry pi(both run Linux) to gather sensor data, raspberry pi gathers laser scan data, PC gathers image captured by camera. I must synchronize time for these two machines. I hope the time difference between them can be less than 1ms.
I connect them directly with a network capble, so I can't use some well known NTP servers. I pinged PC on raspberry pi, the ping time is less than 0.6ms. I come up with two ideas:
- Regard the PC as a NTP server, raspberry pi synchronize time from it.
- Create a socket connection between them, raspberry pi just send its timestamp to PC when the connection is established, thus we can know the time difference of two machines.
Which one is a better idea? Or do you have any better ideas? How to calculate the actual time difference between two machines? Can I limit the time difference to 1ms?