Yin Et Al. - 2018 - The Implementation of IEEE 1588 Clock Synchronization Protocol Base
Yin Et Al. - 2018 - The Implementation of IEEE 1588 Clock Synchronization Protocol Base
Abstract—IEEE 1588 defines a precision time protocol, which mechanism, PTP is more appropriate for precise measurement
is widely used in distributed test and measurement systems. It is and control in a local area network (LAN) [10-11]. PTP provides
very important to capture the timestamps of the location that can a mean by slave clocks, which can estimate their offset from
affect the synchronization accuracy seriously in the master clock to ensure every node in the distributed system,
synchronization process. In this paper, we proposed a method to achieve the precise synchronization [12]. PTP implementations
capture the timestamps based on specialized hardware Field typically have a clock servo which uses a series of time offset
Programmable Gate Array (FPGA) between the physical layer estimates coordinate the local slave clock with the reference
and MAC layer. We designed IEEE 1588 message detection master clock [13]. Precise time coordination with PTP relies on
module and frequency compensation clock to detect IEEE 1588
precise estimates of the send and receive times (time stamps) of
message and record the timestamps, respectively. This method
can eliminate the delay jitter which is caused by the network
messages exchanged between the master and slaves.
protocol stack to improve the synchronization accuracy. The test There is an open resource software Precision Time Protocol
experiments results show that 97.76% of the synchronization daemon (PTPd), which is a pure software implementation of
deviation is located within ±40nS. PTP [14] and can only achieve the precision of the time
coordination between networked test and measurement systems
Keywords—IEEE 1588; FPGA; Synchronization on the order of microseconds [15]. It can capture the timestamps
in the application layers of the network protocol stack, which
I. INTRODUCTION introduces large degrees of non-determinism in the time stamp
The capacity of many control applications in distributed latencies, known as jitter [16]. In order to achieve high precision
systems has been greatly enhanced such as measurement and time stamps, it should draw the support of specialized hardware
control system, network communication systems, certain interfaces in the physical layer of the network. Figure.1
telecommunication systems, and et al[1-2]. High-speed data illustrates the various places in a network communication
transmission between network nodes could not achieve high protocol where time stamping can occur. The synchronization
performance in measurement and control systems without the precision is affected by the location of time stamps
accuracy and precision of time synchronization because the significantly.
network has the character of uncertainty and lack of real time.
The system needs a unified reference time to coordinate with
other subsystems.
The network time synchronization technology, Network
Time Protocol (NTP) was proposed to solve the problem of
lack real time in the network. The moderate achievable
accuracy of NTP is the range of millisecond which is not
sufficient for measurement and control systems[3]. It needs
synchronized clocks for distributed and correlated data
collection[4-5]. Synchronized clocks are used to coordinate
medium access in real-time networks or highly dynamic
applications such as time trigger control in measurement and
control systems[6-8]. Accuracies in the millisecond or even
microsecond range are often desired and node number would
be hundreds. To meet these constraints, the Precision Time
Protocol (PTP) was designed.
PTP, formerly IEEE 1588, is normally preferred in Fig. 1. Possible locations and relevant implementations for time stamping in
Ethernet-based local networks, mainly for measurement and a network-communication protocol.
control networks[9]. Compared with NTP synchronization
one_way_delay =
(Ts1
− Tm1 ) + (Tm 2 − Ts 2 )
(7)
2
Authorized licensed use limited to: Xian Jiaotong University. Downloaded on January 22,2021 at 06:43:42 UTC from IEEE Xplore. Restrictions apply.
synchronization accuracy will be higher. In this paper, we
captured the timestamp between MAC layer and physical layer
with the help of FPGA. So the message transmission delay is
only caused by the physical network transmission, and it can
achieve sub-microsecond synchronization accuracy.
In our hardware design, an ARM processor is used as the
processing core and a FPGA is used to capture timestamps and
detect PTP messages, the hardware part would complete a
frequency adjustable real time clock, detect PTP messages,
record or insert timestamps. The software part runs on the
ARM platform equipped with Linux operation system to
manage the process of synchronization, calculate the offset and
adjust the hardware clock in FPGA, etc.
ARM
MAC Layer
The structure of our model is shown in Figure 3. FPGA is A. Receive/send Messages Module
connected to the independent media Interface (MII) which is
Receive/send messages module are designed to detect and
between the Ethernet physical layer (PHY) and MAC layer it
store the PTP messages which are transmitted on the MII.
can detect every message passing through the MII interface.
Because the two modules are almost the same, we only
There are two modules in FPGA which are Message Detection
introduce the receive messages module. The detection module
Module and Clock Module. When the message detection
realizes PTP messages detection by listening and analyzing the
module detects the PTP messages, FPGA will record the
received and sent messages on the MII. The detection module
received or sent time as the timestamps and store the PTP
detects whether the message is PTP message by comparing
messages in First Input First Output register (FIFO). Then
only the following fields in the transmitting messages.
FPGA generates an interrupt signal to inform ARM to fetch the
timestamps. After gets the timestamps, the ARM calculates the (1) Type: this field explains the protocol type of the
offset and FreqCompValue using the timestamps and then Ethernet data packet. PTP adopts UDP/IP protocol, and its field
sends them to FPGA to adjust the hardware clock. ARM and should be IP.
FPGA realize data communication through the external bus
interface (EBI). (2) IP version: PTP messages use IPV4 version.
(3) Protocol: PTP messages use UDP protocol, so this
IV. THE LOGIC DESIGN OF THE FPGA field should be UDP.
The logic design is accomplished in the FPGA, it is mainly (4) Destination Port Number: PTP messages are
responsible for capturing the timestamps, detecting the PTP transmitted by event port, which port number is 319.
messages and generating a frequency adjustable real-time clock.
If it is PTP Sync message or Delay_Req message, the
The overall structure of the FPGA module is shown in Figure 4:
receive message module generates Rrdtime signal to read the
clock time as the timestamp and stores the message and
timestamp in FIFO1. FIFO1 will be cleared if an error occurred
Authorized licensed use limited to: Xian Jiaotong University. Downloaded on January 22,2021 at 06:43:42 UTC from IEEE Xplore. Restrictions apply.
during the message transmission, otherwise the message and counter value adds an increment in the next oscillator cycle,
timestamp in FIFO1 will be stored in FIFO2. Then the receive otherwise, the clock counter value keeps unchanged. The
message module generates interrupt signal R0. The module number of the clock counter value increases in unit time is the
design is shown in Figure 5. count frequency FreqCnt which is decided by FreqCompValue
and FreqOsc.
FreqOsc (9)
FreqDivRatio =
FreqCnt
2q (10)
FreqCompValue =
FreqDivRatio
Fig. 5. Receive message module.
Through formula (9) and (10), we can observe that when
the actual frequency changes, we must adjust FreqDivRation
B. The clock module by adjusting FreqCompValue to keep the FreqCnt unchanged.
The function of the clock module is to generate an
adjustable frequency real-time clock. The structure of the real- V. SOFTWARE DESIGN
time clock is shown in Figure 6.
The software runs based on the UDP/IP protocol. We
download the software to ARM platform which is implemented
in Linux application programs. The software is designed
according to IEEE 1588 and runs the protocol engine while the
system is powered on, which will always be running unless a
system error occurs. The function definition and interface of
every unit is shown in figure 7.
Authorized licensed use limited to: Xian Jiaotong University. Downloaded on January 22,2021 at 06:43:42 UTC from IEEE Xplore. Restrictions apply.
Fig. 9. Main flowchart of software implementation.
Authorized licensed use limited to: Xian Jiaotong University. Downloaded on January 22,2021 at 06:43:42 UTC from IEEE Xplore. Restrictions apply.
VII. CONCLUSION Handbook, Part II (Industrial Information Technology), Section 7
(Integration Technologies). Boca Raton, FL: CRC Press, 2005, 106:1-
In this paper, we design an IEEE 1588 standard 15.
synchronization structure based on FPGA. The timestamps can [7] H. Hansson, M. Nolin. Real-time systems [M]. in The Industrial
be captured between the physical layer and MAC layer. It can Information Technology Handbook, Part II (Industrial Information
eliminate the delay jitter which is caused by the network Technology), Section 6 (Real-Time Embedded Systems). Boca Raton,
FL: CRC Press, 2005, 81:1-28.
protocol stack to improve the synchronization accuracy. The
deviation of the IEEE 1588 clock synchronization can be [8] P. Ferrari, A. Flammini. IEEE 1588-based synchronization system for a
displacement sensor network [J]. IEEE Trans. Instrument. Meas., 2008,
limited into ±40nS with a rate of 97.76%, when the master 57:254-260.
clock and slave clock are connected by a crossover cable [9] D. L. Mills. Internet time synchronization: The network time protocol
directly. [J]. IEEE Trans. Commun., 1991, 39(10):1482-1493.
[10] Network Time Protocol (version 3): Specification, Implementation and
REFERENCES Analysis, 1992, RFC 1305.
[11] Kendall Correll, Nick Barendt. Design Considerations for Software Only
Implementations of the IEEE 1588 Precision Time Protocol [J].
[1] R. Subrahmanyan. Timing recovery for IEEE 1588 applications in Automation instrumentation, 2005, 26(4): 1-3.
elecommunications [J]. IEEE Trans. Instrum. Meas., 2009, 58(6):1858-
[12] Lee Barford, Jeff Burch. Fourier Analysis From Networked
1868.
Measurements Using Time Synchronization [J]. IEEE Transaction on
[2] J. Han, D. K. Jeong. Practical considerations in the design and Instrumentation and Measurement, 2007, 56(5): 1601-1604.
implementation of time synchronization systems using IEEE 1588 [J].
[13] Lee, Edward. Timeliness in Networked Embedded Systems [J]. IEEE
IEEE Commun. Mag., 2009, 47(11):164-170.
Computer, 2005, 38(7): 85-87.
[3] D. L. Mills. Internet time synchronization: The network time protocol
[14] Hller R., Santer T.. Embedded Sync UTC and IEEE1588 clock
[J]. IEEE Trans. Commun., 1991, 39(10):1482-1493.
synchronization for industrial Ethernet [J]. Proceedings of Emerging
[4] P. Loschmidt, G. Gaderer. White Rabbit- Sensor/actuator protocol for Technologies and Factory Automation, 2003, 1: 422-426.
the CERN LHC particle accelerator [C]. in Proc. 2009 IEEE Sensors
[15] Dirk S. Mohl. IEEE 1588 Precise Time Synchronization as the Basis for
Conf., 2009:781-786.
Real Time Applications in Automation [R]. Industrial Networking
[5] T. Sauter. Fieldbus systems-Embedded networks for automation [M]. in Solutions, 2003: 110-113.
Networked Embedded Systems Handbook. Boca Raton, FL: CRC Press,
[16] Roland Holler, Georg Gaderer. Chip Design Building Blocks for
2009, 20:1-64.
Precision Clock Synchronization [R]. IEEE 1588 Annual, 2005: 78-79.
[6] R. W. Brennan, J. H. Christensen. Holonic manufacturing systems: A
technical overview [M]. in The Industrial Information Technology
Authorized licensed use limited to: Xian Jiaotong University. Downloaded on January 22,2021 at 06:43:42 UTC from IEEE Xplore. Restrictions apply.