I am receiving a stream of messages from a TCP server (a robot sending its status) every 0.1 s. I can not guarantee that I call recvmsg every 0.1 s, so I would like to have a timestamp on those received messages so that when I recvmsg them I know if I've just received them, or if they had been in the buffer for long enough to be outdated and I should call recvmsg again until I read a recent msg.
First of all, which clock does the struct timespec of the SO_TIMESTAMP timestamp use? I've found sources on google that point to CLOCK_REALTIME, but they are around 10 years old, so they might be outdated.
Which of all the time functions should I call to get a time that's comparable to that of the timestamp?
Is it possible to use CLOCK_BOOTTIME to avoid continuity problems?
I made a mistake. I mixed SO_TIMESTAMP (uses struct timeval) with SO_TIMESTAMPNS (uses struct timespec) (SO_TIMESTAMPNS doesn't seem available).
While SO_TIMESTAMPNS doesn't seem available per the documentation, when I #include <sys/socket.h> I have it defined as 35.
It uses CLOCK_REALTIME.
Puff. So: SO_TIMESTAMP is mentioned in sock_setsockopt. From there I jumped to sock_enable_timestamp. But right above that function is sock_get_timestamp and sock_get_timestampns. They use ktime_get_real. Just to check sock_get_timestamp is used in inet_ioctl in af_inet.c. Just to be sore I researched documentation on ktime accessors that ktime_get_real is the same as CLOCK_REALTIME. And ktime_get_real is also used by __net_timestamp in socket buffer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With