[Interest] Packet arrival-time resolution? QUdpSocket

Jason H jhihn at gmx.com
Tue Nov 28 17:34:22 CET 2017


> On Monday, 27 November 2017 06:05:16 PST Jason H wrote:
> > I was wondering what the maximum packet arrival time granularity is for Qt
> > (On linux) using a normal timestamp, I can easily do 1ms. However if I was
> > dealing with a raw socket descriptor, timing below this there is a ioctl()
> > call I can do to get a lower resolution for the packet arrival time. I'm
> > not sure how well this would play with Qt's internals though. For now my
> > packet is UDP,  but if needed, I'd like to be able to extend it to TCP. I'm
> > trying to time sync 2-3 systems on the same LAN. Ultimately, actual time of
> > day isn't needed, just the amount of time of travel between the hosts. On a
> > RaspberyPi zero
> > 
> > Has anyone done anything like this? Any tips? Many thanks in advance.
> 
> If you can find out what the ioctls() or, even better, the getsockopt() calls, 
> I can add this as a feature to QNetworkDatagram.
> 
> Obviously, this will not apply to TCP. If you need the time and you're using 
> TCP, you're doing something wrong.
> 
> If you're going to sync time, use NTP.

Replying to everyone who contributed to this thread- 
So it sounds relatively bad if we're looking at 100ms. I'm trying to do some audio triangulation and 1ms = ~1ft of resolution which would be generally acceptable in ideal conditions at STP. If the jitter is 100ms though, the range then increases to 100ft which is not really acceptable. 

It sounds like the best approach is to sync all the clocks independently and just report events relative to the local clock rather than trying to add a layer on top, even though the nodes are in direct contact. 
https://github.com/bsdphk/Ntimed - says that in 60 seconds, we're accurate to a few ms, and by 5-10 minutes it can start compensating for jitter in the crystal. 

As for the API:
https://stackoverflow.com/questions/13304672/socket-reading-and-timestamps - uses recvmsg()
https://github.com/torvalds/linux/blob/master/Documentation/networking/timestamping.txt - really good guide
It looks like Linux will support usec and even nsec resolution timestamps.


Thank you all for your input!



More information about the Interest mailing list