May 24, 2021

Introducing ptp_vmw: A new Linux driver to Achieve High Time Synchronization Accuracy

Linux VMs can now achieve PTP level time synchronization accuracy because of ptp_vmw driver. This driver communicates with VMware Precision Clock device to fetch host system time.

Introduction

Timekeeping is critical in industries like financial services, audio/video streaming, telecommunication.

Transactions must be timestamped with sufficient accuracy from a reference clock in the financial sector. Failure to do so may result in executing transaction requests in incorrect order leading to a catastrophe.

Likewise, applications must time-stamp incoming packets from various sources to reassemble them in a meaningful order in the telecommunications industry.

The core idea behind timekeeping is to ensure that we have sufficient timing information to re-create the outcome of the events in a correct and meaningful order that might have otherwise happened randomly.

Precision Time Protocol (PTP)

The Precision Time Protocol, as defined in the IEEE-1588 standard, provides a method to precisely synchronize computers over a Local Area Network (LAN)

PTP capable networks aim to achieve nanosecond or even picosecond-level time synchronization accuracy compared to millisecond-level time synchronization accuracy achievable through Network Time Protocol(NTP). While NTP is accurate enough for most commercial and enterprise applications, industries like financial services, video streaming, telecommunication, etc., require higher time synchronization accuracy that PTP can deliver.

VMware Precision Clock Device

Introduced in ESXi7, VMware Precision Clock is a new virtual device capable of providing ESXi system time to the VMs. VMware Precision Clock leverages a proprietary low jitter paravirtual interface to fetch ESXi system time and pass it to the VMs.

Achievable accuracy using network synchronization in a VM is always limited by delay and variability in the virtual networking paths (including the guest's networking stack), especially under high loads. By bypassing the virtual networking stack, VMware Precision Clock can achieve a significantly higher level of time synchronization.

VMware Precision Clock can be added to the VM(in a powered-off state) from the VM Edit Settings wizard.

Adding a Precision Clock

ptp_vmw

With vSphere 7, a new driver – "ptp_vmw" is made available for Linux VMs running RHEL/CentOS 7.6 and RHEL/CentOS 8,8.1 operating systems.

The ptp_vmw driver enables Linux VMs to communicate with VMware Precision Clock. This facilitates time-sensitive applications running on Linux VMs to achieve a significant level of time synchronization accuracy. If the host is configured to use PTP, applications running on Linux VMs can also derive PTP synchronized time through the ptp_vmw driver.

ptp

More about "ptp_vmw" Driver

A PHC or PTP Hardware Clock is a Linux kernel built-in framework for managing and exposing hardware clocks on IEEE 1588 capable NICs( NICs capable of PTP timestamping.) For more information on IEEE 1588, please refer to this link.

The framework is also flexible enough to incorporate standalone time sources such as VMware Precision Clock virtual device.

In a VM with a precision clock device attached, once the ptp_vmw driver is installed, a PTP device is automatically created. The newly created PTP device is available in the sys directory

# ls /sys/class/ptp/
ptp0 ptp1

Specific device node corresponding to ptp_vmw can be found by validating its clock name.

# cat /sys/class/ptp/ptp1/clock_name
ptp_vmw

Using ptp_vmw driver for time synchronization with the host( configured with PTP source)overcomes the challenges associated with syncing VM’s time with the host using a non-PTP source.

My colleague Deji Akomlafe has written a fantastic blog describing all the challenges associated with syncing VMs time with the host configured with a non-PTP source.

ptp_vmw driver Installation

ptp_vmw driver can be downloaded from the VMware flings website. A readme file shipped with the driver contains detailed step-by-step procedure about the driver installation and testing.

Usage

ptp_vmw  can be used as a time source in Chrony. Chrony is a time synchronization application and is part of all major Linux distros such as RHEL, CentOS, etc. It is designed to perform well in a wide range of conditions, including intermittent network connections, heavily congested networks, and systems that do not run continuously or run on a virtual machine.

Time Scale and Leap Second

VMware Precision Clock virtual device provides time on the UTC scale. To be more precise, it provides Unix (or POSIX) time as maintained by the host system clock, which is the total number of seconds since the epoch, i.e., Jan 1, 1970, 00:00:00 UTC. This time scale ignores leap seconds, and on ESXi, the system clock steps time backward at the time of a leap second insertion.

A leap second is the insertion (or removal) of a second to (or from) a UTC day to keep its time – based on an atomic time scale – close (within 0.9 seconds) to time based on the earth's rotation (UT1), which is slowing down by a few milliseconds each year.

Unlike NTP and PTP protocols, ptp_vmw does not indicate the leap second. Chrony must be configured to use the correct configuration of tzdata (Timezone Database) to infer an upcoming leap second insertion or removal. To do this, add the “leapsectz” directive to your Chrony configuration file, which can found in the, etc. directory:

leapsectz right/UTC

Conclusion

Ensuring Precise timekeeping is critical for many types of time-sensitive applications. It allows time for these applications to accurately construct the precise sequence of events that have occurred or are occurring in real-time at a high level.

vmw_ptp driver ensures that Linux VMs can get the highest level of time synchronization accuracy. This driver will help customers that are very particular about timestamping transactions and events.

Filter Tags

Compliance vCenter Server vSphere vSphere 7 Blog Feature Walkthrough Fundamental Quick-Start Tool What's New Intermediate Deploy Optimize