[ntp:hackers] timespec vs timeval

Mark Martinec Mark.Martinec at ijs.si
Mon Oct 29 12:52:42 UTC 2007


> > Jean-Francois Argentino wrote:
> >> Another word about timestamp resolution, I think you can set the socket
> >> option SO_TIMESTAMPNS instead of SO_TIMESTAMP to get a timespec instead
> >> of timeval , the corresponding cmsg_type is SCM_TIMESTAMPNS, this is
> >> true for Linux kernel 2.6.23, I don't know for older release.
>
Brian Utterback wrote:
> Of course, PHK has the patch for Freebsd to do the same thing, except
> it was called SO_BINTIME. I don't know if that patch was integrated
> into the Freebsd kernel or not.

The SO_TIMESTAMP and SO_BINTIME socket options are available in FreeBSD 7.0:

man getsockopt 

  If the SO_TIMESTAMP or SO_BINTIME option is enabled on a SOCK_DGRAM
  socket, the recvmsg(2) call will return a timestamp corresponding to when
  the datagram was received.  The msg_control field in the msghdr structure
  points to a buffer that contains a cmsghdr structure followed by a struct
  timeval for SO_TIMESTAMP and struct bintime for SO_BINTIME.  The cmsghdr
  fields have the following values for TIMESTAMP:

    cmsg_len = sizeof(struct timeval);
    cmsg_level = SOL_SOCKET;
    cmsg_type = SCM_TIMESTAMP;

  and for SO_BINTIME:

    cmsg_len = sizeof(struct bintime);
    cmsg_level = SOL_SOCKET;
    cmsg_type = SCM_BINTIME;


Mark


More information about the hackers mailing list