Access NIC or kernel timestamping data from Java

677 Views Asked by At

I'm using Solarflare cards with sfptpd and I'm consuming the hardware timestamps in my C code. It is not much different from the Solarflare example that gives the following output:

$ export EF_RX_TIMESTAMPING=3
$ onload ./rx_timestamping --proto udp --port 6666
oo:rx_timestamping[32356]: Using OpenOnload 201509-u1 Copyright 2006-2016 Solarflare Communications, 2002-2005 Level 5 Networks [1]
Socket created, listening on port 6666
Socket accepted
Selecting hardware timestamping mode.
Packet 1 - 3 bytes  timestamps 1468588400.706881929 1468588400.706878923 1468588400.706878923 
Packet 2 - 3 bytes  timestamps 1468588403.815893129 1468588403.815890313 1468588403.815890313

The idea is to inspect the ancillary data associated with the msghdr structure and extract the timespec from the SO_TIMESTAMPNS (well, it would be almost the same if I wanted to rely on software kernel timestamps - without Solarflare, onload, etc).

So far so good. I would like to know if there is any way to access these timestamps using the standard Java APIs? If not, then what would be the easiest way to proceed? I don't mind hacking some JNI code. In the worst case I could handle networking in the native code providing Java with the received data along the metadata (but if possible I would like to avoid doing that as I'm looking at accessing the timestamps from an existing app).

0

There are 0 best solutions below