Precision Time Protocol on Linux ~ Introduction to linuxptp



Similar documents
Precision Time Protocol (PTP/IEEE-1588)

The Role of Precise Timing in High-Speed, Low-Latency Trading

IEEE-1588 Standard for a Precision Clock Synchronization Protocol for Networked Measurement and Control Systems

Welcome. People Power Partnership PROFIdag 2013 Peter Van Passen Sales & Business Development Manager HARTING Electric 1/44

Securing GNSS with PTP & SyncE Adam Wertheimer Microsemi Adam.Wertheimer@microsemi.com. Power Matters

Configuring NTP. Information about NTP. NTP Overview. Send document comments to CHAPTER

Introduction to MPIO, MCS, Trunking, and LACP

This document describes the new features of this release and important changes since the previous one.

Precision Clock Synchronization

How To Monitor And Test An Ethernet Network On A Computer Or Network Card

VXLAN: Scaling Data Center Capacity. White Paper

Evaluating 1588v2 Performance Rev 2

Wave Relay System and General Project Details

Enable customers to optimally tune their network performance with real time information and proactive recommendations.

Active-Active Servers and Connection Synchronisation for LVS

Performance Evaluation of VMXNET3 Virtual Network Device VMware vsphere 4 build

Network Time Management Configuration. Content CHAPTER 1 SNTP CONFIGURATION CHAPTER 2 NTP FUNCTION CONFIGURATION

Monitoring the NTP Server. eg Enterprise v6.0

Choosing the correct Time Synchronization Protocol and incorporating the 1756-TIME module into your Application

Kiwi SyslogGen. A Freeware Syslog message generator for Windows. by SolarWinds, Inc.

Application Note. EtherCAT Master Architecture. Applicable Products: Yaskawa Servodrives with CANopen over EtherCAT

Performance Evaluation of Linux Bridge

Computer Time Synchronization

Bridgewalling - Using Netfilter in Bridge Mode

Red Condor Syslog Server Configurations

Ethernet. Customer Provided Equipment Configuring the Ethernet port.

PT Activity: Configure Cisco Routers for Syslog, NTP, and SSH Operations

IPv6.marceln.org.

VMWARE WHITE PAPER 1

T200, PTP/IEEE 1588 Grandmaster Clock and

TimeKeeper Documentation for Version 7.1.2

Cisco Networking Academy CCNP Multilayer Switching

Configuring Your Computer and Network Adapters for Best Performance

An Introduction to Syslog. Rainer Gerhards Adiscon

Local Address Management in IoT environments

RESILIENT NETWORK DESIGN

Transport and Network Layer

A way towards Lower Latency and Jitter

SIP Registration Stress Test

Troubleshooting Tools

GregSowell.com. Mikrotik Basics

Multicast (Group) Addresses for Layer 2 (Ethernet) Transport of IEEE 1588 PTP Messages, with Application to AVB

Homework 3 TCP/IP Network Monitoring and Management

ebus Player Quick Start Guide

The new frontier of the DATA acquisition using 1 and 10 Gb/s Ethernet links. Filippo Costa on behalf of the ALICE DAQ group

TECHNICAL NOTE. Technical Note P/N REV 03. EMC NetWorker Simplifying firewall port requirements with NSR tunnel Release 8.

Infrastructure for active and passive measurements at 10Gbps and beyond

Document ID: FLXN111 PRODUCTS AND LICENSING

Contents. Connection Guide. What is Dante? Connections Network Set Up System Examples Copyright 2015 ROLAND CORPORATION

Agenda. clock tower in old city of Neuchatel ADVA Optical Networking. All rights reserved.

50. DFN Betriebstagung

High-Performance Automated Trading Network Architectures

Sage ERP Accpac Online

Sage 300 ERP Online. Mac Resource Guide. (Formerly Sage ERP Accpac Online) Updated June 1, Page 1

ZEN LOAD BALANCER EE v3.04 DATASHEET The Load Balancing made easy

ZEN LOAD BALANCER EE v3.02 DATASHEET The Load Balancing made easy

Linux Virtual Server Tutorial

Deploying Windows Streaming Media Servers NLB Cluster and metasan

Hands On Activities: TCP/IP Network Monitoring and Management

VLAN for DekTec Network Adapters

Yamaha Audio Network Monitor User Guide

Veritas Cluster Server

Real-time KVM from the ground up

Guideline for setting up a functional VPN

QualNet 4.5 Network Emulation Interface Model Library

GEVPlayer. Quick Start Guide

What communication protocols are used to discover Tesira servers on a network?

SYNCHRONIZATION IN PACKET NETWORKS: TIMING METRICS AND MONITORING

There are numerous ways to access monitors:

WANPIPE TM. Multi-protocol WANPIPE Driver CONFIGURATION M A N U A L. Author: Nenad Corbic/Alex Feldman

pco.interface GigE & USB Installation Guide

Performance Analysis of Time-Triggered Ether-Networks Using Off-The-Shelf-Components

How To Run A Power5 On A Powerbook On A Mini Computer (Power5) On A Microsoft Powerbook (Power4) On An Ipa (Power3) On Your Computer Or Ipa On A Minium (Power2

Deploying IP Anycast. Core DNS Services for University of Minnesota Introduction and General discussion

Clocks/timers, Time, and GPS

Real-time Virtual NIC on KVM for Real-Time Network with OpenFlow

Device Log Export ENGLISH

Setting up pfsense as a Stateful Bridging Firewall.

NetIQ Sentinel Quick Start Guide

Comparison of RIP, EIGRP, OSPF, IGRP Routing Protocols in Wireless Local Area Network (WLAN) By Using OPNET Simulator Tool - A Practical Approach

Parallels Virtuozzo Containers 4.7 for Linux Readme

Architecting for the next generation of Big Data Hortonworks HDP 2.0 on Red Hat Enterprise Linux 6 with OpenJDK 7

Tue Apr 19 11:03:19 PDT 2005 by Andrew Gristina thanks to Luca Deri and the ntop team

Joint ITU-T/IEEE Workshop on Next Generation Optical Access Systems. DBA & QoS on the PON - Commonalities with Switching & Routing

Gigabit Ethernet Packet Capture. User s Guide

PRESTA 10G Platform for High-accuracy 10-Gb/s Network Monitoring

Availability Digest. Redundant Load Balancing for High Availability July 2013

Benchmarking Virtual Switches in OPNFV draft-vsperf-bmwg-vswitch-opnfv-00. Maryam Tahhan Al Morton

dnsperf DNS Performance Tool Manual

BIT COMMANDER. Serial RS232 / RS485 to Ethernet Converter

Astaro Deployment Guide High Availability Options Clustering and Hot Standby

Configuration Maximums VMware vsphere 4.0

PARALLELS SERVER BARE METAL 5.0 README

Computer Time Synchronization

Systemverwaltung 2009 AIX / LPAR

Linux NIC and iscsi Performance over 40GbE

ENTERPRISE LINUX SECURITY ADMINISTRATION

Transcription:

Precision Time Protocol on Linux ~ Introduction to linuxptp Ken ICHIKAWA FUJITSU LIMITED. LinuxCon Japan 2014 Copyright 2014 FUJITSU LIMITED

Agenda Background Overview of Precision Time Protocol (PTP) About PTP on Linux Tips For easy trial or development 3 Copyright 2014 FUJITSU LIMITED

Background Event ordering is very important for incident analysis, performance analysis and so on Event ordering is based on timestamps Timestamps are collected from multiple servers Clock synchronization is important If precision and accuracy of clock synchronization are bad, event ordering can reverse against actual time Event 1 Event 2 Event 3 Server A Server B 4 Copyright 2014 FUJITSU LIMITED

NTP is not enough NTP provides millisecond level synchronization Maybe enough for remote machines, but not enough for locally cooperating machines Many events occur in a millisecond in multiple servers Event ordering will frequently reverse Need another protocol Higher precision and accuracy Not need to synchronize large area, but local servers and devices 5 Copyright 2014 FUJITSU LIMITED

Example of wrong event ordering Actual Time 2 3 4 5 6 7 8 Server A diff:-1 1 2 3 4 5 6 7 Event 1 Event 2 Event 3 Server B diff:+3 5 6 7 8 9 10 11 time Event Ordering based on Actual Time Time Event 3 Event 1 5 Event 2 7 Event 3 Event Ordering based on Timestamp Time Event 2 Event 1 6 Event 3 reverse! 8 Event 2 6 Copyright 2014 FUJITSU LIMITED

Example of correct event ordering based on better clock synchronization Actual Time 2 3 4 5 6 7 8 Server A diff:-0.001 1.999 2.999 3.999 4.999 5.999 6.999 7.999 Event 1 Event 2 Event 3 Server B diff:+0.003 2.003 3.003 4.003 5.003 6.003 7.003 8.003 time Event Ordering based on Actual Time Time Event 3 Event 1 5 Event 2 7 Event 3 Event Ordering based on Timestamp Time Event 2.999 Event 1 5.003 Event 2 6.999 Event 3 correct! 7 Copyright 2014 FUJITSU LIMITED

Agenda Background Overview of Precision Time Protocol (PTP) What s PTP Term explanation About packet timestamp About PTP on Linux Tips For easy trial or development 8 Copyright 2014 FUJITSU LIMITED

Precision Time Protocol (PTP) Standardized protocol, IEEE1588 Synchronize the clocks in local computing systems and devices Microsecond to sub-microsecond accuracy and precision Administration free Capability to autonomously decide time server(master) called Best Master Clock Algorithm (BMCA) 9 Copyright 2014 FUJITSU LIMITED

Term explanation GPS An example of PTP network 10 Copyright 2014 FUJITSU LIMITED

Term explanation GPS Grandmaster Clock (Ordinary Clock) Original time source for the PTP network Typically synchronize its clock to external time (GPS, NTP and so on) End point of PTP network is called Ordinary Clock 11 Copyright 2014 FUJITSU LIMITED

Term explanation GPS Boundary Clock Typically it s switch Synchronize its clock to a master Serve as a time source to other (slave) clocks May become Grandmaster clock if current Grandmaster is lost Master: serve as a time source Slave: synchronize to another clock 12 Copyright 2014 FUJITSU LIMITED

Term explanation GPS Slave Clock (Ordinary Clock) Synchronize its clock to a master (to the boundary clock in this example) May become Grandmaster clock if current Grandmaster is lost 13 Copyright 2014 FUJITSU LIMITED

Packet timestamp Time offset between master and slave clocks is calculated based on timestamps at packet sending and receiving offset = t2 t1 1 2 t ms + t sm = t2 t1 1 { t4 t1 t3 t2 } 2 Packet timestamp accuracy is important for PTP 15 Copyright 2014 FUJITSU LIMITED

Timestamp timing Ideally, we want timestamps of the time just sending (or receiving) packet But in reality, there is deference between timestamp timing and packet sending (or receiving) timing Ideal timestamp timing Real timestamp timing timestamp here no error timestamp here transmit here error transmit here 16 Copyright 2014 FUJITSU LIMITED

Type of timestamping Software timestamping Timestamp at Application or OS layer Get time from system clock Error is relatively huge Software Timestamping error Application OS MAC PHY timestamp transmit Sys Clock 17 Copyright 2014 FUJITSU LIMITED

To Achieve High Precision Hardware Timestamping Hardware assisted timestamp at PHY or MAC layer Get time from PTP Hardware Clock (PHC) on NIC Minimize error Software Timestamping Hardware Timestamping error Application OS MAC PHY timestamp transmit Sys Clock small error Application OS MAC PHY timestamp transmit PHC 18 Copyright 2014 FUJITSU LIMITED

Agenda Background Overview of Precision Time Protocol (PTP) About PTP on Linux Kernel features User-land application: Linuxptp Tips For easy trial or development 19 Copyright 2014 FUJITSU LIMITED

Linux kernel assists PTP The protocol itself is implemented on user-land Kernel features for PTP Socket option SO_TIMESTAMPING for packet timestamping PHC subsystem Allow to access PHC via clock_gettime/settime/adjtime system calls Some drivers support Hardware and/or Software timestamping (e.g. e1000e, igb, ixgbe, and so on) 20 Copyright 2014 FUJITSU LIMITED

The Linux PTP Project Project developing user-land applications for PTP http://linuxptp.sourceforge.net/ Maintainer: Richard Cochran He has implemented many Linux kernel features for PTP Linuxptp is reliable and correctly using the kernel features for PTP Red Hat, Intel, SUSE, Fujitsu, etc. have been participating the development 21 Copyright 2014 FUJITSU LIMITED

Linuxptp Applications ptp4l Implementation of PTP (Ordinary Clock, Boundary Clock) phc2sys Synchronize two clocks (typically PHC and system clock) pmc (PTP Management Client) Send PTP management messages to PTP nodes 22 Copyright 2014 FUJITSU LIMITED

ptp4l Implementation of PTP Ordinary / Boundary clock Hardware / Software timestamping Delay request-response / Peer delay mechanism IEEE 802.3 (Ethernet) / UDP IPv4 / UDP IPv6 network transport 23 Copyright 2014 FUJITSU LIMITED

phc2sys Synchronize two clocks (typically PHC and system clock) When you are using Hardware timestamping: ptp4l adjusts PHC phc2sys adjusts system clock ptp4l adjusts PHC phc2sys adjusts system clock 24 Copyright 2014 FUJITSU LIMITED

How about software timestamping When you are using Software timestamping: ptp4l directly adjusts system clock phc2sys is not needed ptp4l adjusts system clock 25 Copyright 2014 FUJITSU LIMITED

Typical usage of ptp4l Start as a slave node Use eth0 to send/receive messages Use /etc/ptp4l.conf as configuration file Network interface to use Specify slave only mode. Otherwise, this node can be master. # ptp4l i eth0 f /etc/ptp4l.conf s Specify configuration file to use. Otherwise, default configuration is used. 26 Copyright 2014 FUJITSU LIMITED

Observe synchronization of ptp4l Log is handed over to syslog Or, you can print it into stdout by using m option ptp4l[537888.171]: selected /dev/ptp3 as PTP clock ptp4l[537888.173]: port 1: INITIALIZING to LISTENING on INITIALIZE ptp4l[537888.174]: port 0: INITIALIZING to LISTENING on INITIALIZE ptp4l[537889.091]: port 1: new foreign master 001999.fffe.807b24-1 ptp4l[537893.091]: selected best master clock 001999.fffe.807b24 ptp4l[537893.091]: port 1: LISTENING to UNCALIBRATED on RS_SLAVE ptp4l[537894.093]: master offset -3318 s0 freq +0 path delay 600 ptp4l[537895.093]: master offset -3343 s1 freq -8378 path delay 600 ptp4l[537896.093]: master offset -2344 s2 freq -10722 path delay 600 ptp4l[537896.093]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l[537897.093]: master offset -18 s2 freq -9099 path delay 545 ptp4l[537898.093]: master offset 641 s2 freq -8446 path delay 513 ptp4l[537899.093]: master offset 570 s2 freq -8324 path delay 533 ptp4l[537900.093]: master offset 389 s2 freq -8334 path delay 533 Offset between Master and Slave(PHC) 27 Copyright 2014 FUJITSU LIMITED

Typical usage of phc2sys Adjust system clock based on eth0 s PHC Wait until ptp4l starts synchronization to the master By specifying network interface to s option, related PHC is automatically selected. Or, you can directly specify PHC like s /dev/ptp0 Wait until ptp4l s synchronization. # phc2sys s eth0 c CLOCK_REALTIME w Specify the clock you want to adjust. CLOCK_REALTIME is system clock. 28 Copyright 2014 FUJITSU LIMITED

pmc (PTP Management Client) Send PTP management messages to PTP nodes GET action: Get current values of data SET action: Update current values of variables CMD action: Initiate some events PTP management messages are specified in IEEE1588 Many PTP devices have not supported management messages yet Also linuxptp has not supported many SET and CMD messages yet 29 Copyright 2014 FUJITSU LIMITED

Typical usage of pmc Send a message to localhost s node Get values of CURRENT_DATA_SET Indicate to use Unix Domain Socket. UDS is used to receive PTP management messages from localhost. Action and Management ID. # pmc u b 0 GET CURRENT_DATA_SET -b specifies allowance number of boundary hops. In this case, management messages is sent only localhost. 30 Copyright 2014 FUJITSU LIMITED

An example of synchronization between Linux servers Directly connect two Linux servers (Grandmaster and Slave) Use hardware timestamping Setup Linux server (Grandmaster) Linux server (Slave) 31 Copyright 2014 FUJITSU LIMITED

An example of synchronization between Linux servers 1 122 243 364 485 606 727 848 969 1090 1211 1332 1453 1574 1695 1816 1937 2058 2179 2300 2421 2542 2663 2784 2905 The offsets between the PHCs, observed by ptp4l max 116 ns min -89 ns RMS 31.19 ns very stable! 1500 between GM and PHC 1000 500 offset (ns) 0-500 -1000-1500 elapsed time (s) 32 Copyright 2014 FUJITSU LIMITED

Agenda Background Overview of Precision Time Protocol (PTP) About PTP on Linux Tips Workaround against bad GM behavior Improve system clock stability For easy trial or development 34 Copyright 2014 FUJITSU LIMITED

Bad GM behavior I encountered a Grandmaster product The GM sometimes occurs a few hundred microsecond level errors Setup GM product (Grandmaster) Linux server (Slave) 35 Copyright 2014 FUJITSU LIMITED

1 127 253 379 505 631 757 883 1009 1135 1261 1387 1513 1639 1765 1891 2017 2143 2269 2395 2521 2647 2773 2899 Bad GM behavior The offsets between the GM and the Linux server s PHC, observed by ptp4l max 352129 ns (= 352 us) min -231644 ns (= -232 us) RMS 13664.71 ns (= 14 us) 400000 300000 between GM and PHC 200000 100000 offset (ns) 0-100000 -200000-300000 elapsed time (s) 36 Copyright 2014 FUJITSU LIMITED

1 127 253 379 505 631 757 883 1009 1135 1261 1387 1513 1639 1765 1891 2017 2143 2269 2395 2521 2647 2773 2899 What s happening? GM sends a timestamp including huge error It appears as a huge plus offset ptp4l changes PHC s frequency too much depending on the offset 400000 300000 between GM and PHC 200000 100000 offset (ns) 0-100000 -200000-300000 elapsed time (s) 37 Copyright 2014 FUJITSU LIMITED

1 127 253 379 505 631 757 883 1009 1135 1261 1387 1513 1639 1765 1891 2017 2143 2269 2395 2521 2647 2773 2899 What s happening? GM s next timestamp does not include so much error But, PHC s frequency was changed too much A huge minus offset appears against normal GM s timetamp 400000 300000 between GM and PHC 200000 100000 offset (ns) 0-100000 -200000-300000 elapsed time (s) 38 Copyright 2014 FUJITSU LIMITED

1 127 253 379 505 631 757 883 1009 1135 1261 1387 1513 1639 1765 1891 2017 2143 2269 2395 2521 2647 2773 2899 Observe the influence to PHC The offsets between PHC and system clock observed by phc2sys There are similar offsets Introduce worse system clock stability between PHC and sys clock 400000 300000 200000 100000 offset (ns) 0-100000 -200000-300000 How to avoid this issue? elapsed time (s) 39 Copyright 2014 FUJITSU LIMITED

ptp4l has servo mechanism ptp4l has PI (proportional-integral) controller servo A kind of feedback loop Determine frequency set to PHC SP = master s time PV = slave s time e(t) = offset MV = frequency Process = change slave s clock freq Figure: Basic block of Proportional + Integral controller. (excerpt from wikipedia) Kp and Ki are tuning parameters (proportional gain and integral gain) 40 Copyright 2014 FUJITSU LIMITED

Tuning sensitivity Anyway, by tuning the servo parameters, we can adjust how clock sensitivity react to the offset To change the configuration, edit ptp4l s configuration file pi_proportional_const for Kp pi_integral_const for Ki Default configuration file is /etc/ptp4l.conf in Fedora 42 Copyright 2014 FUJITSU LIMITED

There are two default configurations For hardware timestamping Kp 0.7 Ki 0.3 Sensitive Previous result used this configuration For software timestamping Kp 0.1 Ki 0.001 Insensitive Try this one to prevent over-reacting 43 Copyright 2014 FUJITSU LIMITED

1 127 253 379 505 631 757 883 1009 1135 1261 1387 1513 1639 1765 1891 2017 2143 2269 2395 2521 2647 2773 2899 Use software timestamping config We tried software timestamping configuration though ptp4l used hardware timestamping Minus direction offsets disappeared PHC s frequency is not changed too much between GM and PHC 130000 80000 offset (ns) 30000-20000 -70000-120000 Minus direction offsets disappeared elapsed time (s) 44 Copyright 2014 FUJITSU LIMITED

1 127 253 379 505 631 757 883 1009 1135 1261 1387 1513 1639 1765 1891 2017 2143 2269 2395 2521 2647 2773 2899 1 127 253 379 505 631 757 883 1009 1135 1261 1387 1513 1639 1765 1891 2017 2143 2269 2395 2521 2647 2773 2899 Observe from phc2sys 130000 80000 30000-20000 PHC looks stable system clock will be also stable -70000-120000 10000 between PHC and sys clock Zoom offset (ns) 8000 6000 4000 2000 0-2000 -4000-6000 -8000-10000 elapsed time (s) 45 Copyright 2014 FUJITSU LIMITED

Agenda Background Overview of Precision Time Protocol (PTP) About PTP on Linux Tips Countermeasure against bad GM behavior Improve system clock stability For easy trial or development 46 Copyright 2014 FUJITSU LIMITED

Improve system clock stability Dynamic ticks make system clock stability worse Dynamic ticks disable periodic timer tick interrupt It is a useful feature to power saving but Error correction mechanism in kernel doesn t aware dynamic ticks You can disable dynamic ticks Specify nohz=off in kernel boot option (nohz=on is default) 47 Copyright 2014 FUJITSU LIMITED

1 61 121 181 241 301 361 421 481 541 601 661 721 781 841 901 961 1021 1081 1141 1201 1261 1321 1381 1441 1 61 121 181 241 301 361 421 481 541 601 661 721 781 841 901 961 1021 1081 1141 1201 1261 1321 1381 1441 Comparison The offsets between PHC and system clock, observed by phc2sys offset (ns) 10000 between PHC and sys clock 10000 8000 6000 4000 2000 0 8000 6000 4000 2000 0-2000 -4000-6000 -8000-2000 -4000-6000 -8000 elapsed time (s) nohz=on max 9550 ns min -8134 ns RMS 1589.3 ns nohz=off max 32 ns min -26 ns RMS 9.3 ns 1000 times better! 48 Copyright 2014 FUJITSU LIMITED

1 59 117 175 233 291 349 407 465 523 581 639 697 755 813 871 929 987 1045 1103 1161 1219 1277 1335 1393 1451 1 61 121 181 241 301 361 421 481 541 601 661 721 781 841 901 961 1021 1081 1141 1201 1261 1321 1381 1441 Zoom graph of nohz=off 10000 8000 6000 4000 2000 0 nohz=off max 32 ns min -26 ns RMS 9.3 ns -2000-4000 -6000-8000 40 30 between PHC and sys clock 20 offset (ns) 10 0 Zoom -10-20 -30 elapsed time (s) 49 Copyright 2014 FUJITSU LIMITED

Attempt to fix the issue on upstream Miroslav Lichvar and John Stultz are working to fix the issue title author date 1 st patch [PATCH RFC] timekeeping: Fix clock stability with nohz 2 nd patch [PATCH] [RFC] timekeeping: Rework frequency adjustments to work better w/ nohz 3 rd patch [PATCH 0/3] timekeeping: Improved NOHZ frequency steering Miroslav Oct 2013 John Jan 2014 John Apr 2014 50 Copyright 2014 FUJITSU LIMITED

Agenda Background Overview of Precision Time Protocol (PTP) About PTP on Linux Tips Countermeasure against bad GM behavior Improve system clock stability For easy trial or development Try linuxptp on qemu-kvm 51 Copyright 2014 FUJITSU LIMITED

FYI: Running linuxptp on qemu-kvm You can try linuxptp on qemu-kvm without NICs supporting PTP Note: Run two Virtual Machines (for GM and Slave) Recommend to use OS supporting linuxptp e.g. recent Fedora, RHEL6.5, 7.0 Use virtual NIC emulating e1000 e1000 driver supports software timestamping Don t forget to define appropriate firewall rules (or disable firewalls) to allow multi-cast Don t expect high precision and accuracy 52 Copyright 2014 FUJITSU LIMITED

53