Este conteúdo não está disponível no idioma selecionado.
Chapter 3. Chrony with hardware timestamping
			Hardware (HW) timestamping in some Network Interface Controller (NICs) provides accurate timestamping of incoming and outgoing packets. NTP timestamps are usually created by the kernel and chronyd with the use of the system clock. However, when HW timestamping is enabled, the NIC uses its own clock to generate the timestamps when packets are entering or leaving the link layer or the physical layer. When used with NTP, hardware timestamping can significantly improve the accuracy of synchronization. For best accuracy, both NTP servers and NTP clients need to use hardware timestamping. Under ideal conditions, a sub-microsecond accuracy might be possible.
		
			Another protocol for time synchronization that uses hardware timestamping is PTP.
		
			Unlike NTP, PTP relies on assistance in network switches and routers. If you want to achieve the best accuracy of synchronization, use PTP on networks that have switches and routers with PTP support, and prefer NTP on networks that do not have such switches and routers.
		
3.1. Verifying support for hardware timestamping
				To verify that hardware timestamping with NTP is supported by an interface, use the ethtool -T command. An interface can be used for hardware timestamping with NTP if ethtool lists the SOF_TIMESTAMPING_TX_HARDWARE and SOF_TIMESTAMPING_TX_SOFTWARE capabilities and also the HWTSTAMP_FILTER_ALL filter mode.
			
Procedure
- Display a device’s time stamping capabilities and associated PTP hardware clock:
ethtool -T enp1s0
# ethtool -T enp1s03.2. Enabling hardware timestamping
				You can enable the hardware timestamping on one or multiple interfaces by using the hwtimestamp directive in the /etc/chrony.conf file. The directive can either specify a single interface, or a wildcard character can be used to enable hardware timestamping on all interfaces that support it.
			
Procedure
- Edit the - /etc/chrony.conffile and make the following changes:- Add the - hwtimestampsetting for interfaces which support hardware timestamping. For example:- hwtimestamp enp1s0 hwtimestamp eno* - hwtimestamp enp1s0 hwtimestamp eno*- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - You can use the * wildcard if no other application, such as - ptp4luses hardware timestamping.
- Configure a short client polling interval by appending the - minpolland- maxpolloptions to the server setting, for example:- server ntp.example.comlocal minpoll 0 maxpoll 0 - server ntp.example.comlocal minpoll 0 maxpoll 0- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - For hardware timestamping, you must configure a shorter polling interval than the default range (64-1024 seconds) to minimize the offset of the system clock. 
- Enable the NTP interleaved mode by appending the - xleaveoption to the server setting:- server ntp.example.comlocal minpoll 0 maxpoll 0 xleave - server ntp.example.comlocal minpoll 0 maxpoll 0 xleave- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - With this setting, chrony gets the hardware transmit timestamp only after sending a packet. This behavior prevents the serever from saving the timestamp in packets to which it responds. With the - xleaveoption, chrony can receive transmit timestamps that were generated after the transmission.
- Optional: Increase the maximum size of memory allocated for logging of client’s access on the server, for example: - clientloglimit 100000000 - clientloglimit 100000000- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - The default server configuration allows a few thousands of clients to use the interleaved mode concurrently. By increasing the value of the - clientloglimitsetting, you can configure the server for a large number of clients.
 
- Restart the chronyd service: - systemctl restart chronyd - # systemctl restart chronyd- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
Verification
- Optional: Verify in the - /var/log/messageslog file that hardware timesamping is enabled:- chronyd[4081]: Enabled HW timestamping on enp1s0 chronyd[4081]: Enabled HW timestamping on eno1 - chronyd[4081]: Enabled HW timestamping on enp1s0 chronyd[4081]: Enabled HW timestamping on eno1- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- If chronyd is configured as an NTP client or peer, display the transmit and receive timestamping modes and the interleaved mode: - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Report the stability of NTP measurements: - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
				This stability is reported in the Std Dev column. With hardware timestamping enabled, stability of NTP measurements should be in tens or hundreds of nanoseconds, under normal load.
			
3.3. Configuring PTP-NTP bridge
				If a highly accurate Precision Time Protocol (PTP) primary timeserver is available in a network that does not have switches or routers with PTP support, a computer may be dedicated to operate as a PTP client and a stratum-1 NTP server. Such a computer needs to have two or more network interfaces, and be close to the primary timeserver or have a direct connection to it. This will ensure highly accurate synchronization in the network.
			
Procedure
- 
						Configure the ptp4l and phc2sys programs from the linuxptppackages to use one interface to synchronize the system clock by usingPTP.
- Configure - chronydto provide the system time by using the other interface:- bindaddress 203.0.113.74 hwtimestamp enp1s0 local stratum 1 - bindaddress 203.0.113.74 hwtimestamp enp1s0 local stratum 1- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Restart the chronyd service: - systemctl restart chronyd - # systemctl restart chronyd- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow