Up to some years ago, hardware timestamps were available only on costly FPGA-based NICs. Slowly, NIC manufactures started to consider hw timestamps as an important feature, and they started to introduce them in new cards. As of today Silicom PE2Gi80, Intel 1 Gbit Ethernet Server Adapter i340 (1 Gbit) and Neterion X3110/X3120 (10 Gbit) offer off-the-shelf hardware timestamps. These cards do not feature a GPS connector, but support IEEE 1588 for clock synchronization. The accuracy of the hw timestamps of these cards ranges from 3 to 7 ns.
PF_RING has been enhanced to support hw timestamps, whatever is their source. PF_RING 4.6.1 introduced hw timestamp support in both the PF_RING kernel module, applications (e.g. pfcount), and even libpcap. The user-space pfring library via ioctl()’s call with SIOCSHWTSTAMP, informs the NIC that received packets must be timestamped. The new PF_RING module does the magic by exploiting and passing to userland all the hw timestamps present in packets. Using them is pretty simple
- Intel 1Gbit
- cd PF_RING
- insmod ./drivers/intel/igb/igb-2.4.12/src/igb.ko
- Neterion X3110/X3210
- cd PF_RING
- insmod ./drivers/neterion/vxge.ko pf_ring_en=1 lro=0 func_mode=0
Supposing to access you card as ethX, you can access hw timestamps using pfcount.
pfcount -i ethX
00:07:14.230020938 [00:1B:ED:26:A9:4F -> 00:16:9C:6E:FD:80][eth_type=0x0800] [18.104.22.168:1637 -> 22.214.171.124:25] [tos=0][tcp_seq_num=2571580375][caplen=128][len=1514][parsed_header_len=0][eth_offset=0][l3_offset=14][l4_offset=34][payload_offset=54]
generated packet with ns timestamp accuracy.
The libpcap library present under PF_RING/userland and it companion product tcpdump, demonstrate hw timestamps