WO2023213080A1 - Method for realizing network node time synchronization based on fpga - Google Patents
Method for realizing network node time synchronization based on fpga Download PDFInfo
- Publication number
- WO2023213080A1 WO2023213080A1 PCT/CN2022/139566 CN2022139566W WO2023213080A1 WO 2023213080 A1 WO2023213080 A1 WO 2023213080A1 CN 2022139566 W CN2022139566 W CN 2022139566W WO 2023213080 A1 WO2023213080 A1 WO 2023213080A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- message
- time
- time synchronization
- node
- timestamp value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04J—MULTIPLEX COMMUNICATION
- H04J3/00—Time-division multiplex systems
- H04J3/02—Details
- H04J3/06—Synchronising arrangements
- H04J3/0635—Clock or time synchronisation in a network
- H04J3/0638—Clock or time synchronisation among nodes; Internode synchronisation
Definitions
- the present invention relates to the technical field of communication, and in particular to a method for realizing time synchronization of network nodes based on FPGA.
- Ethernet technology has been introduced into the above applications with its advantages of high bandwidth and low cost.
- traditional Ethernet cannot meet the deterministic and low-latency transmission requirements of the above applications, and time-sensitive network technology (Time Sensitive Networking (TSN) provides an effective way to solve this problem through business scheduling and resource management and other initiatives.
- TSN Time Sensitive Networking
- IEEE The time synchronization technology provided by the 802.1 AS protocol can enable the nodes in the network that implement this protocol to achieve final time synchronization through signaling interaction, thus providing the possibility for TSN deterministic, low-latency service scheduling and resource management.
- the IEEE 802.1 AS protocol is mostly implemented through the software layer.
- a protocol implementation method based on Linux environment has been disclosed. It is driven by Intel I210 network card to obtain soft timestamps and measure the time delay when the network is under different loads.
- the measured delay value was quite different from the theoretical value.
- the soft timestamp is susceptible to network fluctuations, and its accuracy cannot be guaranteed.
- a state machine function related to path delay measurement and time synchronization is designed, and the interaction and analysis of packets in the network are realized by calling the function.
- this solution is prone to packet loss when network congestion occurs, causing problems for the network. Time synchronization brings uncertainty.
- the soft clock has low accuracy, weak stability, and is greatly affected by network fluctuations, which greatly reduces the synchronization accuracy and affects the quality of TSN communication services.
- the use of hardware to achieve clock synchronization will provide the network with high-precision (us-level synchronization error) synchronization clocks, thereby meeting more precise communication needs such as scheduling and resource management, as well as new application scenario needs (such as multi-sensor information synchronization analysis, etc.).
- Current hardware research on synchronization applications mostly uses software to process messages, and also calls Nios
- the II embedded soft core processes gPTP messages. Since its network data transmission and real-time clock use the system's own IP core, its measurement accuracy will have a large deviation.
- the above method generates timestamps at the MAC layer through the corresponding network card driver. However, the processing time of the timestamps in the MAC layer is difficult to determine, which will affect its accuracy to a certain extent.
- Nios II embedded soft core is called to process gPTP messages. Since its network data transmission and real-time clock use the system's own ip core, The measurement accuracy will have a large deviation.
- a method for realizing time synchronization of network nodes based on FPGA includes:
- the pulse synchronization module is designed
- Ethernet message frame of the path delay measurement process and time synchronization process is encapsulated
- steps of building a local clock module include:
- the designed pulse synchronization module includes:
- the pulse synchronization module is designed according to the number of bits of data sent or received in the network
- FPGA circuits at different nodes use different pulse synchronization methods to synchronize clock signals.
- Ethernet message frame encapsulating the path delay measurement process and the time synchronization process includes:
- the message type value specified by the protocol is added to the Ethernet data frame header to distinguish the message.
- the timestamp value of the time when the message was sent at the i node and the timestamp value of the time when the message was received at the i+1 node are recorded, including:
- the correctness of the data frames sent or received is checked through the CRC check module.
- the sending time synchronization message includes:
- the time synchronization offset is calculated based on the path delay measurement results.
- the method also includes: when implementing time synchronization of any two nodes and testing its time synchronization performance,
- FPGAs realize full-duplex Ethernet link communication by sending data packets point-to-point;
- the FPGAs realize full-duplex Ethernet link communication by sending data packets point-to-point, and then include:
- Two FPGA development boards record the timestamp value of the corresponding moment by sending and receiving corresponding messages
- correcting the time deviation of the two nodes to achieve time synchronization includes:
- Time synchronization accuracy is obtained through base conversion.
- the above-mentioned method for realizing network node time synchronization based on FPGA is used to implement the Ethernet network node synchronization algorithm, including the following steps: building a local clock module. Based on building the local clock module, the pulse synchronization module is designed. Based on the designed pulse synchronization module, the Ethernet message frame of the path delay measurement process and time synchronization process is encapsulated. Based on the Ethernet message frame encapsulated path delay measurement process and time synchronization process, the timestamp value of the moment when the message is sent at the i node and the timestamp value of the moment when the message is received at the i+1 node are recorded.
- the obtained timestamp value is calculated to obtain the path delay measurement result. Based on the calculated timestamp value, the path delay measurement result is obtained, and a time synchronization message is sent.
- the method of the present invention implements link delay measurement and time error correction based on FPGA devices, and provides a stable clock source to obtain a hard timestamp that is highly accurate and not affected by network fluctuations, and can provide a high-precision synchronization clock for the network. It avoids the disadvantages caused by the software layer and provides a low-cost, high-precision and stable time synchronization method for Ethernet, thereby meeting the communication needs of more accurate scheduling and resource management as well as the needs of new application scenarios.
- Figure 1 is a flow chart of a method for realizing time synchronization of network nodes based on FPGA according to an embodiment of the present invention.
- Figure 2 is an overall design diagram of the system in this embodiment.
- Figure 3 is a state machine jump flow chart of the FPGA message sending module in this embodiment.
- Figure 4 is a state machine jump flow chart of the FPGA message receiving module in this embodiment.
- Figure 5 is a flow chart of the master node obtaining timestamp state machine in this embodiment.
- Figure 6 is a flow chart of a state machine for obtaining a timestamp from a node in this embodiment.
- Figure 7 is a topology diagram of communication capabilities established by the FPGA in this embodiment.
- a method for realizing time synchronization of network nodes based on FPGA includes the following steps:
- Step S110 Build a local clock module.
- the FPGA onboard crystal oscillator is used to generate a stable clock signal to control the generation of an 80-bit counter, which serves as a local clock module in the network, including a master clock or a slave clock, to provide a stable clock source for the network.
- the master clock serves as the time base and sends time information for time correction.
- the slave clock maintains synchronization with the master clock through the received time information.
- Step S120 Design a pulse module based on building a local clock module.
- the single-bit signal is shot twice in different clock domains to synchronize the asynchronous clock, so that the data can be sampled and transmitted correctly when each clock edge arrives.
- Step S130 Based on the designed pulse module, encapsulate the Ethernet message frame of the path delay measurement process and the time synchronization process. Enable packets to interact between the measured nodes, and use the packet type value specified by the protocol to add it to the Ethernet data frame header to distinguish the packets transmitted in the network.
- Step S140 Based on the Ethernet message frame encapsulating the path delay measurement process and the time synchronization process, record the timestamp value of the time when the message is sent by the i node and the timestamp value of the time when the message is received by the i+1 node.
- the timestamp value is encapsulated into the designated empty field of the Ethernet message frame for transmission, and the correctness of the sent or received data frame is verified through the CRC check module.
- S150 Based on the timestamp value of the time when the message was sent at the i node and the timestamp value of the time when the message was received at the i+1 node, calculate the obtained timestamp value to obtain the path delay measurement result. Parse the timestamp field in the data packet, calculate the deviation of the timestamp value obtained, and obtain the path delay measurement result.
- S160 Calculate the obtained timestamp value to obtain the path delay measurement result, and send the time synchronization message. And record the timestamp of the time when the message is sent from the master node and the timestamp of the time when the message is received by the slave node. Based on the path delay measurement results, the time synchronization deviation is calculated.
- FPGAs realize full-duplex Ethernet link communication by sending data packets point-to-point. Use network packet capture software to test whether the communication is normal. If the communication is normal, perform the relevant operations from steps S110 to S160 in sequence.
- step S140 it also includes: two FPGA development boards correct the time deviation of the two nodes by sending and receiving corresponding messages and recording the timestamp value of the corresponding moment to achieve time synchronization.
- step S160 Based on step S160, it also includes: outputting the corrected time deviation to the PC through the serial port, and obtaining the time synchronization accuracy through hexadecimal conversion.
- the local clock is an 80-bit counter, which is used to record the timestamp value of the moment when a message is sent or received later.
- the pulse synchronization module handles the issue of single-bit signals crossing clock domains and generates the reception completion signal Rec_done in the receive data clock domain. This signal controls the jump of the message sending state machine in the sending clock domain.
- Rec_done _0 ⁇ Rec_done
- posedge means triggering on the rising edge of the clock
- negedge means triggering on the falling edge of reset
- the message sending module adopts a three-stage state machine design to send data messages, which includes the preamble of the message, the frame start delimiter, and the Ethernet frame header. , IP header, UDP header, sent message type header, sent message data segment and CRC check, etc.
- the types of messages sent are: Pdelay_Resp, Pdelay_Resp_Follow_Up, and Sync.
- the Pdelay_Resp and Sync messages are event type messages. The reception and sending of such messages will trigger the MAC layer to sample the local clock; the Pdelay_Resp_Follow_Up message is general. Type message, used only to carry information.
- the module design Verilog pseudo code is as follows:
- next_state Send_CRC
- next_state Send_PDResp_head or SendPDResp_Fup_data or Send_Sync_data end
- D_MAC FF_FF_FF_FF_FF_FF;//Destination MAC address//
- Lenth/Type 0x0800;//length/type//
- SendPDResp_Fup_head 0xA; //Send Pdelay_Resp_Follow_Up message header, the header type value is 0xA//
- Send_Sync_head 0x0; //Send Sync message header, the header type value is 0x0//
- SendPDResp_Fup_data TimeStamp; //Send Pdelay_Resp_Follow_Up data field, which is the timestamp value //
- Send_Sync_data TimeStamp; //Send Sync data field, which is the timestamp value //
- the message receiving module is used to receive the preamble and frame start delimiter (Recv_Preamble+SFD), Ethernet frame header (Recv_eth_head), IP header (Recv_ip_head), UDP header (Recv_udp_head), sending message type header (Recv_PDReq_head), sending message data segment (Recv_PDReq_data) and CRC check (Recv_CRC), etc.
- the type of received message is Pdelay_Req, and Pdelay_Req is an event type message.
- the signal rx_start_en is used as the trigger signal of this module to control the state machine to perform operations. In the process, the jump between each state machine is controlled by the signal Skip_en.
- the timestamp values t 1 , t 2 , t 3 , and t 4 are all cleared in the reset state, and the signal that controls the reading of the timestamp is rd_t_m is set low.
- the message receiving module receives the Pdelay_Req message, it pulls the rd_t_m control signal high to read the timestamp value t 2 of the reception moment from the local clock module.
- the rd_t_m control signal is pulled high to read the timestamp value t 3 of the sending time from the local clock module.
- the Pdelay_Resp_Follow_Up message will be sent carrying the timestamp t 3 .
- the main module sends a Sync message.
- the rd_t_m control signal will be pulled high to read the source timestamp value t s of the sending time from the local clock module. Any error in the state machine execution during reading the timestamp value will jump back to the reset state.
- the timestamp values t1 , t2 , t3 , and t4 are all cleared, and the signal rd_t_s that controls the read timestamp is set to low level.
- the rd_t_s control signal is pulled high to read the timestamp value t 1 of the sending time from the local clock module; in the S2 state machine, it is pulled high after receiving the Pdelay_Resp message.
- the rd_t_s control signal reads the timestamp value t 4 of the reception time from the local clock module, and parses the timestamp value t 2 carried in the Pdelay_Resp message; after receiving the Pdelay_Resp_Follow_Up message in the S3 state machine, it will parse the timestamp carried in the message.
- t 3 In S4 state, calculate the path delay PathDelay through the formula after obtaining four timestamps. For example, formula (1) is as follows:
- t 1 indicates that the rd_t_s control signal is raised to read the timestamp value of the sending moment from the local clock module
- t 2 indicates the timestamp value carried in the Pdelay_Resp message
- t 3 indicates that the time stamp value is received in the S3 state machine After the Pdelay_Resp_Follow_Up message, the message will be parsed and carry a timestamp
- t 4 means that after receiving the Pdelay_Resp message in the S2 state machine, the rd_t_s control signal is raised to read the timestamp value of the reception moment from the local clock module.
- the Sync message sent by the master node in the S5 state is received by the slave node, and the timestamp value tr of the reception moment is recorded in the S6 state, and the time carried in the Sync message is parsed.
- Stamp value t s and finally use the formula to calculate the time synchronization offset Offset in the S7 state and correct it.
- the formula is as follows:
- t r represents the timestamp value of the reception moment recorded in the S6 state
- t s represents the timestamp value of that moment carried in the Sync message
- PathDelay represents the PathDelay value obtained by equation (1).
- the present invention uses a 320-bit registration signal rce_time[319:0] to encapsulate the recorded timestamps t 1 , t 2 , t 3 and t 4 .
- Each time The stamp is 80 bits, and from high to low it is t 1 , t 2 , t 3 , t 4 .
- the method proposed by the present invention to test the time synchronization accuracy is: first, the time deviation module calculates and obtains the time synchronization deviation Offset, and secondly, outputs the binary value to the PC through the serial port module, and the serial port debugging assistant on the PC displays the binary value, that is, the time For synchronization accuracy, the results obtained each time are collected, processed and analyzed by MATLAB software, and a time synchronization accuracy chart is drawn.
- the 80-bit counter generated by clock signal control serves as a local clock module to provide a stable clock source for the network.
- the Ethernet data frame is encapsulated through the message sending module and the message is sent from the i node to i+1 node, and records the timestamp of the message sending moment, and encapsulates the value into a data frame for sending.
- the message receiving module receives the corresponding data frame and records the timestamp value of the reception moment. Verify messages before receiving or sending them, and set up a synchronization module to handle cross-clock domain issues.
- the timestamp value obtained by parsing the message is corrected for deviation and time synchronized, and the time synchronization accuracy is output to the PC through the serial port.
- This solution implements link delay measurement and time error correction based on FPGA hardware circuits.
- the hard timestamp obtained by the stable clock source provided by the hardware has high accuracy and is not affected by network fluctuations, and can provide high accuracy for the network (us level synchronization error) synchronizes the clock, avoiding the disadvantages caused by the software layer, and provides a low-cost, high-precision, and stable time synchronization method for Ethernet, thereby meeting the communication needs of more accurate scheduling and resource management, and New application scenarios are needed.
- the present invention provides a low-cost, high-precision and stable time synchronization method for Ethernet, thereby meeting the communication needs of more accurate scheduling and resource management and the needs of new application scenarios.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Synchronisation In Digital Transmission Systems (AREA)
- Small-Scale Networks (AREA)
Abstract
Description
本发明涉及通信的技术领域,特别是涉及一种基于FPGA实现网络节点时间同步的方法。The present invention relates to the technical field of communication, and in particular to a method for realizing time synchronization of network nodes based on FPGA.
工业物联网、自动驾驶等新型应用的发展对通信网络性能有了更高的要求,以太网技术凭借其高带宽、低成本等优势被引入到上述应用中来。然而,传统以太网无法满足上述应用对业务确定性、低时延的传输需求,而时间敏感网络技术(Time Sensitive Networking,TSN)通过业务调度与资源管理等举措为解决这一问题提供了有效途径。在TSN标准集中,IEEE 802.1 AS协议提供的时间同步技术可以使得网络中实行这一协议的节点通过信令交互而达到最终时间同步,从而为TSN确定性、低时延的业务调度与资源管理提供了可能。The development of new applications such as the Industrial Internet of Things and autonomous driving has placed higher requirements on communication network performance. Ethernet technology has been introduced into the above applications with its advantages of high bandwidth and low cost. However, traditional Ethernet cannot meet the deterministic and low-latency transmission requirements of the above applications, and time-sensitive network technology (Time Sensitive Networking (TSN) provides an effective way to solve this problem through business scheduling and resource management and other initiatives. In the TSN standards set, IEEE The time synchronization technology provided by the 802.1 AS protocol can enable the nodes in the network that implement this protocol to achieve final time synchronization through signaling interaction, thus providing the possibility for TSN deterministic, low-latency service scheduling and resource management.
目前对于IEEE 802.1 AS协议实现多通过软件层面,现公开了一种基于Linux环境下的协议实现方法,由Intel I210网卡驱动下得到软时间戳,并在网络承受不同负载情况下测得时间延迟。但在测试中发现其延迟测量值与理论值相差较大,原因之一为软时间戳易受网络波动的影响,且无法保证其精度。软件层面上设计了路径延迟测量与时间同步相关的状态机函数,通过对函数的调用来实现网络中报文的交互与解析,但此种方案在网络发生拥堵时容易产生丢包情况,给网络的时间同步带来了不确定性。软件实现虽成本低、自适应好,然而软时钟精度不高、稳定性不强、且受网络波动影响较大,这使得同步精度大打折扣,从而影响了TSN的通信服务质量。使用硬件实现时钟同步将可以为网络提供高精度(us级同步误差)同步时钟,从而满足更为精确的调度与资源管理等通信需求以及新的应用场景需要(如多传感器信息同步分析等)。目前针对同步应用的硬件研究,其对于报文的处理大多采用软件实现,还有调用Nios II嵌入式软核对gPTP报文进行处理,由于其网络数据传输及实时时钟均用系统自带ip核,所以其测量精度会有较大偏差。对于时间戳的获取,上述方法通过相应的网卡驱动在MAC层生成时间戳,但在MAC层中时间戳的处理时间难以确定,会在一定程度上对其准确度造成影响。Currently, the IEEE 802.1 AS protocol is mostly implemented through the software layer. A protocol implementation method based on Linux environment has been disclosed. It is driven by Intel I210 network card to obtain soft timestamps and measure the time delay when the network is under different loads. However, during the test, it was found that the measured delay value was quite different from the theoretical value. One of the reasons is that the soft timestamp is susceptible to network fluctuations, and its accuracy cannot be guaranteed. At the software level, a state machine function related to path delay measurement and time synchronization is designed, and the interaction and analysis of packets in the network are realized by calling the function. However, this solution is prone to packet loss when network congestion occurs, causing problems for the network. Time synchronization brings uncertainty. Although the software implementation is low-cost and self-adaptive, the soft clock has low accuracy, weak stability, and is greatly affected by network fluctuations, which greatly reduces the synchronization accuracy and affects the quality of TSN communication services. The use of hardware to achieve clock synchronization will provide the network with high-precision (us-level synchronization error) synchronization clocks, thereby meeting more precise communication needs such as scheduling and resource management, as well as new application scenario needs (such as multi-sensor information synchronization analysis, etc.). Current hardware research on synchronization applications mostly uses software to process messages, and also calls Nios The II embedded soft core processes gPTP messages. Since its network data transmission and real-time clock use the system's own IP core, its measurement accuracy will have a large deviation. For obtaining timestamps, the above method generates timestamps at the MAC layer through the corresponding network card driver. However, the processing time of the timestamps in the MAC layer is difficult to determine, which will affect its accuracy to a certain extent.
针对同步应用的硬件研究,其对于报文的处理大多采用软件实现,还有调用Nios II嵌入式软核对gPTP报文进行处理,由于其网络数据传输及实时时钟均用系统自带ip核,所以其测量精度会有较大偏差。For hardware research on synchronization applications, most of the message processing is implemented in software, and the Nios II embedded soft core is called to process gPTP messages. Since its network data transmission and real-time clock use the system's own ip core, The measurement accuracy will have a large deviation.
基于此,有必要针对上述技术问题,提供一种在FPGA硬件电路上实现系统中的报文交互及时间戳的获取且能正确转发路径延迟测量以及时间同步过程中的报文并产生精度较高的硬件时间戳的基于FPGA实现网络节点时间同步的方法。Based on this, it is necessary to address the above technical issues and provide a method that implements message interaction and timestamp acquisition in the system on the FPGA hardware circuit and can correctly forward the messages in the path delay measurement and time synchronization process and generate high-precision A method of realizing network node time synchronization based on FPGA with hardware timestamp.
一种基于FPGA实现网络节点时间同步的方法,所述方法包括:A method for realizing time synchronization of network nodes based on FPGA, the method includes:
构建本地时钟模块;Build a local clock module;
基于所述构建本地时钟模块,设计脉冲同步模块;Based on the above-mentioned construction of the local clock module, the pulse synchronization module is designed;
基于所述设计脉冲同步模块,封装路径延迟测量过程及时间同步过程的以太网报文帧;Based on the designed pulse synchronization module, the Ethernet message frame of the path delay measurement process and time synchronization process is encapsulated;
基于所述封装路径延迟测量过程及时间同步过程的以太网报文帧,记录报文在i节点发出的时刻的时间戳值和报文在i+1节点被接受到时刻的时间戳值;Based on the Ethernet message frame of the encapsulation path delay measurement process and time synchronization process, record the timestamp value of the moment when the message is sent at the i node and the timestamp value of the moment when the message is received at the i+1 node;
基于所述记录报文在i节点发出的时刻的时间戳值和报文在i+1节点被接受到时刻的时间戳值,对得到的所述时间戳值进行计算得到路径延迟测量结果;Based on the timestamp value of the time when the recorded message is sent at the i node and the timestamp value of the time when the message is received at the i+1 node, calculate the obtained timestamp value to obtain the path delay measurement result;
基于所述对得到的所述时间戳值进行计算得到路径延迟测量结果,发送时间同步报文。Calculate the path delay measurement result based on the obtained timestamp value, and send a time synchronization message.
进一步的,所述构建本地时钟模块步骤包括:Further, the steps of building a local clock module include:
利用FPGA板载晶振产生稳定时钟信号控制生成80bit计数器作为网络中的主时钟或从时钟;Use the FPGA onboard crystal oscillator to generate a stable clock signal to control the generation of an 80-bit counter as the master clock or slave clock in the network;
通过所述FPGA板载晶振选择合适的时钟频率。Select the appropriate clock frequency through the FPGA onboard crystal oscillator.
进一步的,所述设计脉冲同步模块,包括:Further, the designed pulse synchronization module includes:
所述脉冲同步模块根据网络中所发送或接收数据的bit数进行设计;The pulse synchronization module is designed according to the number of bits of data sent or received in the network;
不同节点的FPGA电路采用不同的脉冲同步方法对时钟信号进行同步处理。FPGA circuits at different nodes use different pulse synchronization methods to synchronize clock signals.
进一步的,所述封装路径延迟测量过程及时间同步过程的以太网报文帧,包括:Further, the Ethernet message frame encapsulating the path delay measurement process and the time synchronization process includes:
采用协议规定的报文类型值添加进以太网数据帧头对所述报文进行区分。The message type value specified by the protocol is added to the Ethernet data frame header to distinguish the message.
进一步的,所述记录报文在i节点发出的时刻的时间戳值和报文在i+1节点被接受到时刻的时间戳值,包括:Further, the timestamp value of the time when the message was sent at the i node and the timestamp value of the time when the message was received at the i+1 node are recorded, including:
将所述时间戳值封装进以太网报文帧指定空字段进行传输;Encapsulate the timestamp value into a designated empty field of the Ethernet message frame for transmission;
通过CRC校验模块对发送或接收的数据帧进行正确性校验。The correctness of the data frames sent or received is checked through the CRC check module.
进一步的,所述发送时间同步报文,包括:Further, the sending time synchronization message includes:
记录所述报文从主节点发出时刻的时间戳以及所述报文在从节点被接受到的时刻时间戳;Record the timestamp of the moment when the message is sent from the master node and the timestamp of the moment when the message is received by the slave node;
根据所述路径延迟测量结果计算出时间同步偏差。The time synchronization offset is calculated based on the path delay measurement results.
进一步的,所述方法还包括:当实现任意双节点的时间同步及其时间同步性能测试时,Further, the method also includes: when implementing time synchronization of any two nodes and testing its time synchronization performance,
FPGA之间通过点对点发送数据包实现全双工以太网链路通信;FPGAs realize full-duplex Ethernet link communication by sending data packets point-to-point;
通过使用网络抓包软件测试所述以太网链路通信是否正常。Test whether the Ethernet link communication is normal by using network packet capture software.
进一步的,所述FPGA之间通过点对点发送数据包实现全双工以太网链路通信,之后还包括:Further, the FPGAs realize full-duplex Ethernet link communication by sending data packets point-to-point, and then include:
两块FPGA开发板通过发送与接收相应的报文记录相应时刻的时间戳值;Two FPGA development boards record the timestamp value of the corresponding moment by sending and receiving corresponding messages;
对两个节点进行时间偏差修正从而达到时间同步。Correct the time deviation of the two nodes to achieve time synchronization.
进一步的,所述对两个节点进行时间偏差修正从而达到时间同步,之后包括:Further, correcting the time deviation of the two nodes to achieve time synchronization includes:
将修正的时间偏差通过串口输出至PC端;Output the corrected time deviation to the PC through the serial port;
通过进制转换得到时间同步精度。Time synchronization accuracy is obtained through base conversion.
上述基于FPGA实现网络节点时间同步的方法,用于以太网网络节点同步算法的实现方案,包括以下步骤:构建本地时钟模块。基于构建本地时钟模块,设计脉冲同步模块。基于设计脉冲同步模块,封装路径延迟测量过程及时间同步过程的以太网报文帧。基于封装路径延迟测量过程及时间同步过程的以太网报文帧,记录报文在i节点发出的时刻的时间戳值和报文在i+1节点被接受到时刻的时间戳值。基于记录报文在i节点发出的时刻的时间戳值和报文在i+1节点被接受到时刻的时间戳值,对得到的时间戳值进行计算得到路径延迟测量结果。基于对得到的时间戳值进行计算得到路径延迟测量结果,发送时间同步报文。The above-mentioned method for realizing network node time synchronization based on FPGA is used to implement the Ethernet network node synchronization algorithm, including the following steps: building a local clock module. Based on building the local clock module, the pulse synchronization module is designed. Based on the designed pulse synchronization module, the Ethernet message frame of the path delay measurement process and time synchronization process is encapsulated. Based on the Ethernet message frame encapsulated path delay measurement process and time synchronization process, the timestamp value of the moment when the message is sent at the i node and the timestamp value of the moment when the message is received at the i+1 node are recorded. Based on the timestamp value of the time when the message was sent at node i and the timestamp value of the time when the message was received at node i+1, the obtained timestamp value is calculated to obtain the path delay measurement result. Based on the calculated timestamp value, the path delay measurement result is obtained, and a time synchronization message is sent.
本发明的方法基于FPGA器件实现了链路时延测量以及时间误差修正,并提供稳定时钟源获得的硬时间戳准确度较高且不受网络波动的影响,可以为网络提供高精度同步时钟,避免由软件层面带来的弊端,为以太网提供了一种低成本、精度高且稳定的时间同步方法,从而满足更为精准的调度与资源管理等通信需求以及新的应用场景需要。The method of the present invention implements link delay measurement and time error correction based on FPGA devices, and provides a stable clock source to obtain a hard timestamp that is highly accurate and not affected by network fluctuations, and can provide a high-precision synchronization clock for the network. It avoids the disadvantages caused by the software layer and provides a low-cost, high-precision and stable time synchronization method for Ethernet, thereby meeting the communication needs of more accurate scheduling and resource management as well as the needs of new application scenarios.
图1为本发明中一个实施例的基于FPGA实现网络节点时间同步的方法流程图。Figure 1 is a flow chart of a method for realizing time synchronization of network nodes based on FPGA according to an embodiment of the present invention.
图2为本实施例的系统总体设计图。Figure 2 is an overall design diagram of the system in this embodiment.
图3为本实施例的FPGA报文发送模块状态机跳转流程图。Figure 3 is a state machine jump flow chart of the FPGA message sending module in this embodiment.
图4为本实施例的FPGA报文接收模块状态机跳转流程图。Figure 4 is a state machine jump flow chart of the FPGA message receiving module in this embodiment.
图5为本实施例的主节点获取时间戳状态机流程图。Figure 5 is a flow chart of the master node obtaining timestamp state machine in this embodiment.
图6为本实施例的从节点获取时间戳状态机流程图。Figure 6 is a flow chart of a state machine for obtaining a timestamp from a node in this embodiment.
图7为本实施例的FPGA建立通信实力拓扑图。Figure 7 is a topology diagram of communication capabilities established by the FPGA in this embodiment.
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地说明,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.
如图1至图2所示,在一个实施例中,一种基于FPGA实现网络节点时间同步的方法,包括以下步骤:As shown in Figures 1 to 2, in one embodiment, a method for realizing time synchronization of network nodes based on FPGA includes the following steps:
步骤S110:构建本地时钟模块。利用FPGA板载晶振产生稳定的时钟信号控制生成80bit计数器,作为网络中的本地时钟模块,包括主时钟或者从时钟,为网络提供稳定的时钟源。其中主时钟作为时间基准,发送校时用的时间信息,从时钟通过收到的时间信息,保持和主时钟的同步。Step S110: Build a local clock module. The FPGA onboard crystal oscillator is used to generate a stable clock signal to control the generation of an 80-bit counter, which serves as a local clock module in the network, including a master clock or a slave clock, to provide a stable clock source for the network. The master clock serves as the time base and sends time information for time correction. The slave clock maintains synchronization with the master clock through the received time information.
步骤S120:基于构建本地时钟模块,设计脉冲模块。将单bit信号在不同时钟域下打两拍,使异步时钟达到同步,进而在每个时钟沿到达时数据能够进行正确采样与传输。Step S120: Design a pulse module based on building a local clock module. The single-bit signal is shot twice in different clock domains to synchronize the asynchronous clock, so that the data can be sampled and transmitted correctly when each clock edge arrives.
步骤S130:基于设计脉冲模块,封装路径延迟测量过程及时间同步过程的以太网报文帧。使报文在所测量节点间进行交互,并采用协议规定的报文类型值添加进以太网数据帧头对网络中传递的报文进行区分。Step S130: Based on the designed pulse module, encapsulate the Ethernet message frame of the path delay measurement process and the time synchronization process. Enable packets to interact between the measured nodes, and use the packet type value specified by the protocol to add it to the Ethernet data frame header to distinguish the packets transmitted in the network.
步骤S140:基于封装路径延迟测量过程及时间同步过程的以太网报文帧,记录报文在i节点发出的时刻的时间戳值和报文在i+1节点被接受到时刻的时间戳值。将时间戳值封装进以太网报文帧指定空字段进行传输,通过CRC校验模块对发送或接收的数据帧进行正确性校验。Step S140: Based on the Ethernet message frame encapsulating the path delay measurement process and the time synchronization process, record the timestamp value of the time when the message is sent by the i node and the timestamp value of the time when the message is received by the i+1 node. The timestamp value is encapsulated into the designated empty field of the Ethernet message frame for transmission, and the correctness of the sent or received data frame is verified through the CRC check module.
S150:基于记录报文在i节点发出的时刻的时间戳值和报文在i+1节点被接受到时刻的时间戳值,对得到的时间戳值进行计算得到路径延迟测量结果。解析数据包中的时间戳字段,将得到的时间戳值进行偏差计算,得到路径延迟测量结果。S150: Based on the timestamp value of the time when the message was sent at the i node and the timestamp value of the time when the message was received at the i+1 node, calculate the obtained timestamp value to obtain the path delay measurement result. Parse the timestamp field in the data packet, calculate the deviation of the timestamp value obtained, and obtain the path delay measurement result.
S160:基于对得到的时间戳值进行计算得到路径延迟测量结果,发送时间同步报文。并记录报文从主节点发出时刻的时间戳以及报文在从节点被接收到时刻的时间戳。根据路径延迟测量结果,计算出时间同步偏差。S160: Calculate the obtained timestamp value to obtain the path delay measurement result, and send the time synchronization message. And record the timestamp of the time when the message is sent from the master node and the timestamp of the time when the message is received by the slave node. Based on the path delay measurement results, the time synchronization deviation is calculated.
当需要实现任意双节点的时间同步及其时间同步性能测试时,包括以下步骤:When it is necessary to implement time synchronization of any two nodes and test its time synchronization performance, the following steps are included:
FPGA之间通过点对点发送数据包实现全双工以太网链路通信,通过使用网络抓包软件测试其通信是否正常,在通信正常的情况下,顺序执行步骤S110至S160的相关操作,FPGAs realize full-duplex Ethernet link communication by sending data packets point-to-point. Use network packet capture software to test whether the communication is normal. If the communication is normal, perform the relevant operations from steps S110 to S160 in sequence.
基于步骤S140,还包括:两块FPGA开发板通过发送与接收相应的报文并记录相应时刻的时间戳值,对两个节点进行时间偏差修正从而达到时间同步。Based on step S140, it also includes: two FPGA development boards correct the time deviation of the two nodes by sending and receiving corresponding messages and recording the timestamp value of the corresponding moment to achieve time synchronization.
基于步骤S160,还包括:将修正的时间偏差通过串口输出至PC端,通过进制转换得到时间同步精度。Based on step S160, it also includes: outputting the corrected time deviation to the PC through the serial port, and obtaining the time synchronization accuracy through hexadecimal conversion.
在本实施例中,本地时钟为80bit计数器,用于后面发送或接收报文时刻的时间戳值记录。脉冲同步模块处理单bit信号跨时钟域问题,在接收数据时钟域下产生接收完成信号Rec_done,由该信号控制发送时钟域下报文发送状态机的跳转。上述功能模块均通过硬件编程语言Verilog HDL在FPGA器件上综合实现,该模块设计Verilog伪代码如下:In this embodiment, the local clock is an 80-bit counter, which is used to record the timestamp value of the moment when a message is sent or received later. The pulse synchronization module handles the issue of single-bit signals crossing clock domains and generates the reception completion signal Rec_done in the receive data clock domain. This signal controls the jump of the message sending state machine in the sending clock domain. The above functional modules are all programmed through the hardware programming language Verilog HDL is comprehensively implemented on FPGA devices. The Verilog pseudo code of this module is as follows:
//模块输入输出信号////Module input and output signals//
(1): input tx_clk; //发送数据时钟//(1): input tx_clk; //Send data clock//
input rx_clk; //接收数据时钟//input rx_clk; //Receive data clock//
input rst_n; //复位信号//input rst_n; //Reset signal//
input Rec_done; //接收数据完成信号//input Rec_done; //Receive data completion signal//
output tx_start_en; //状态机触发信号//output tx_start_en; //State machine trigger signal//
//接收数据完成信号在发送数据时钟域下进行打两拍操作////Receive data completion signal and perform two-beat operation in the sending data clock domain//
(2): always @(posedge tx_clk or negedge rst_n) //时钟上升沿触发或复位信号下降沿触发//(2): always @(posedge tx_clk or negedge rst_n) //Triggered by the rising edge of the clock or the falling edge of the reset signal//
Rec_done _0 <= Rec_done ; Rec_done _0 <= Rec_done;
Rec_done _1 <= Rec_done _0; //将Rec_done信号打一拍// Rec_done _1 <= Rec_done _0; // Beat the Rec_done signal //
Rec_done _2 <= Rec_done _1; //将Rec_done信号打两拍// Rec_done _2 <= Rec_done _1; // Beat the Rec_done signal twice //
//由打拍信号进行异或运算得到发送数据状态机触发信号tx_start_en////Exclusive OR operation is performed on the beat signal to obtain the sending data state machine trigger signal tx_start_en//
(3): assign tx_start_en = Rec_done _1 ^ Rec_done _2;(3): assign tx_start_en = Rec_done _1 ^ Rec_done _2;
其中posedge表示时钟上升沿触发,negedge表示在复位下降沿触发。Among them, posedge means triggering on the rising edge of the clock, and negedge means triggering on the falling edge of reset.
如图3所示,在本实施例中,报文发送模块采用三段式状态机设计,用于发送数据报文,其中包括发送报文的前导码、帧起始界定符、以太网帧头、IP首部、UDP首部、发送报文类型首部、发送报文数据段和CRC校验等。所发送报文的类型分别为:Pdelay_Resp、Pdelay_Resp_Follow_Up、Sync,其中Pdelay_Resp和Sync报文为事件类型报文,此类报文的接收和发送会触发MAC层对本地时钟进行采样;Pdelay_Resp_Follow_Up报文为一般类型报文,仅用来携带信息。该模块设计Verilog伪代码如下:As shown in Figure 3, in this embodiment, the message sending module adopts a three-stage state machine design to send data messages, which includes the preamble of the message, the frame start delimiter, and the Ethernet frame header. , IP header, UDP header, sent message type header, sent message data segment and CRC check, etc. The types of messages sent are: Pdelay_Resp, Pdelay_Resp_Follow_Up, and Sync. The Pdelay_Resp and Sync messages are event type messages. The reception and sending of such messages will trigger the MAC layer to sample the local clock; the Pdelay_Resp_Follow_Up message is general. Type message, used only to carry information. The module design Verilog pseudo code is as follows:
//模块主要输入输出信号////Main input and output signals of the module//
1.input tx_clk; //发送数据时钟//1.input tx_clk; //Send data clock//
input rst_n; //复位信号//input rst_n; //Reset signal//
input tx_start_en; //状态机触发信号//input tx_start_en; //State machine trigger signal//
input data; //输入的数据//input data; //Input data//
output txdata; //待发送数据//output txdata; //Data to be sent//
output txdone; //发送数据完成信号//output txdone; //Send data completion signal//
//状态机跳转////State machine jump//
2.always @(*) begin//用于状态机之间跳转的条件判断//2.always @(*) begin//Conditional judgment for jumping between state machines//
case(cur_state) //选择状态机//case(cur_state) //Select state machine//
idle : begin idle : begin
if(skip_en) //当跳转信号skip_en为高电平,跳转至下一状态//If(skip_en) //When the skip signal skip_en is high level, jump to the next state //
next_state = Send_preamble+SFD;Next_state = Send_preamble+SFD;
elseelse
next_state = idle; //否则为原状态// next_state =
end end
…….. //中间几个状态机与上述跳转方式相同//…….. //The middle state machines are the same as the above jump methods//
……..……..
……..……..
Send_ PDResp_data or SendPDResp_Fup_data or Send_Sync_data:begin//发送数据字段//Send_ PDResp_data or SendPDResp_Fup_data or Send_Sync_data:begin//Send data field//
if(skip_en) if(skip_en)
next_state = Send_CRC; next_state = Send_CRC;
elseelse
next_state=Send_PDResp_head or SendPDResp_Fup_data or Send_Sync_data end next_state=Send_PDResp_head or SendPDResp_Fup_data or Send_Sync_data end
3.always @(posedge tx_clk or negedge rst_n)begin//执行每个状态机功能//3.always @(posedge tx_clk or negedge rst_n)begin//Execute each state machine function//
(1)初始状态:(1) Initial state:
if(tx_start_en)//状态机触发信号//if(tx_start_en)//State machine trigger signal//
skip_en <= 1’b1;skip_en <= 1’b1;
(2)Send_preamble+SFD://发送前导码与帧起始界定符//(2) Send_preamble+SFD: //Send preamble and frame start delimiter//
preamble = 55-55-55-55-55-55-55;preamble = 55-55-55-55-55-55-55;
SFD = 0xd5;SFD = 0xd5;
(3)Send_eth_head://发送以太网首部//(3) Send_eth_head://Send Ethernet header//
D_MAC = FF_FF_FF_FF_FF_FF;//目的MAC地址//D_MAC = FF_FF_FF_FF_FF_FF;//Destination MAC address//
S_MAC = 00_11_22_33_44_55;//源MAC地址//S_MAC= 00_11_22_33_44_55;//Source MAC address//
Lenth/Type = 0x0800;//长度/类型//Lenth/Type = 0x0800;//length/type//
(4)Send_ip_head//发送IP首部//(4) Send_ip_head//Send IP header//
(5)Send_udp_head//发送UDP首部//(5) Send_udp_head//Send UDP header//
(6)Send_PDResp_head :0x3;//发送Pdelay_Resp报文头部,头部类型值为0x3//(6)Send_PDResp_head :0x3; //Send Pdelay_Resp message header, the header type value is 0x3//
or SendPDResp_Fup_head :0xA;//发送Pdelay_Resp_Follow_Up报文头部,头部类型值为0xA//or SendPDResp_Fup_head: 0xA; //Send Pdelay_Resp_Follow_Up message header, the header type value is 0xA//
or Send_Sync_head:0x0;//发送Sync报文头部,头部类型值为0x0//or Send_Sync_head: 0x0; //Send Sync message header, the header type value is 0x0//
(7)Send_ PDResp_data :TimeStamp;//发送Pdelay_Resp数据字段,为时间戳值//(7)Send_ PDResp_data: TimeStamp; //Send Pdelay_Resp data field, which is the timestamp value //
or SendPDResp_Fup_data :TimeStamp;//发送Pdelay_Resp_Follow_Up数据字段,为时间戳值//or SendPDResp_Fup_data: TimeStamp; //Send Pdelay_Resp_Follow_Up data field, which is the timestamp value //
or Send_Sync_data:TimeStamp;//发送Sync数据字段,为时间戳值//or Send_Sync_data: TimeStamp; //Send Sync data field, which is the timestamp value //
(8)Send_CRC: //CRC校验//(8) Send_CRC: //CRC check//
if(txdone)//发送完成信号,执行CRC校验//if(txdone)//Send completion signal and perform CRC check//
txdata <= crc_data;txdata <= crc_data;
endend
如图4所示,在本实施例中,报文接收模块用于接收报文的前导码及帧起始界定符(Recv_Preamble+SFD)、以太网帧头(Recv_eth_head)、IP首部(Recv_ip_head)、UDP首部(Recv_udp_head)、发送报文类型首部(Recv_PDReq_head)、发送报文数据段(Recv_PDReq_data)以及CRC校验(Recv_CRC)等。其中接收报文的类型为Pdelay_Req,Pdelay_Req为事件类型报文。由信号rx_start_en作为该模块的触发信号控制状态机执行操作,过程中每个状态机之间跳转由信号Skip_en控制。As shown in Figure 4, in this embodiment, the message receiving module is used to receive the preamble and frame start delimiter (Recv_Preamble+SFD), Ethernet frame header (Recv_eth_head), IP header (Recv_ip_head), UDP header (Recv_udp_head), sending message type header (Recv_PDReq_head), sending message data segment (Recv_PDReq_data) and CRC check (Recv_CRC), etc. The type of received message is Pdelay_Req, and Pdelay_Req is an event type message. The signal rx_start_en is used as the trigger signal of this module to control the state machine to perform operations. In the process, the jump between each state machine is controlled by the signal Skip_en.
假设系统中存在主从节点,如图5所示,在本实施例中,在复位状态时将时间戳值t 1、t 2、t 3、t 4均清零,将控制读时间戳的信号rd_t_m置为低电平。在S1状态,当报文接收模块接收到Pdelay_Req报文后,拉高rd_t_m控制信号从本地时钟模块读取接收时刻的时间戳值t 2。在S2状态,发送Pdelay_Resp报文后拉高rd_t_m控制信号从本地时钟模块读取发送时刻的时间戳值t 3,随后在S3状态机中Pdelay_Resp_Follow_Up报文将携带时间戳t 3发送。当路径延迟测量操作完成后,在S4状态机中,主模块发送Sync报文,此时将拉高rd_t_m控制信号从本地时钟模块读取发送时刻的源时间戳值t s。在读取时间戳值过程中任何状态机执行操作发生错误都将重新跳回复位状态。 Assume that there are master-slave nodes in the system, as shown in Figure 5. In this embodiment, the timestamp values t 1 , t 2 , t 3 , and t 4 are all cleared in the reset state, and the signal that controls the reading of the timestamp is rd_t_m is set low. In the S1 state, when the message receiving module receives the Pdelay_Req message, it pulls the rd_t_m control signal high to read the timestamp value t 2 of the reception moment from the local clock module. In the S2 state, after sending the Pdelay_Resp message, the rd_t_m control signal is pulled high to read the timestamp value t 3 of the sending time from the local clock module. Then in the S3 state machine, the Pdelay_Resp_Follow_Up message will be sent carrying the timestamp t 3 . When the path delay measurement operation is completed, in the S4 state machine, the main module sends a Sync message. At this time, the rd_t_m control signal will be pulled high to read the source timestamp value t s of the sending time from the local clock module. Any error in the state machine execution during reading the timestamp value will jump back to the reset state.
如图6所示,在本实施例中,在复位状态时将时间戳值t 1、t 2、t 3、t 4均清零,将控制读时间戳的信号rd_t_s置为低电平。在S1状态机中,当报文发送模块发送Pdelay_Req报文后,拉高rd_t_s控制信号从本地时钟模块读取发送时刻的时间戳值t 1;在S2状态机中接收到Pdelay_Resp报文后拉高rd_t_s控制信号从本地时钟模块读取接收时刻的时间戳值t 4,并解析Pdelay_Resp报文中携带的时间戳值t 2;在S3状态机中接收到Pdelay_Resp_Follow_Up报文后将解析报文携带时间戳t 3;S4状态下,在获取四个时间戳后通过公式计算路径延迟PathDelay。如公式(1)如下: As shown in Figure 6, in this embodiment, in the reset state, the timestamp values t1 , t2 , t3 , and t4 are all cleared, and the signal rd_t_s that controls the read timestamp is set to low level. In the S1 state machine, after the message sending module sends the Pdelay_Req message, the rd_t_s control signal is pulled high to read the timestamp value t 1 of the sending time from the local clock module; in the S2 state machine, it is pulled high after receiving the Pdelay_Resp message. The rd_t_s control signal reads the timestamp value t 4 of the reception time from the local clock module, and parses the timestamp value t 2 carried in the Pdelay_Resp message; after receiving the Pdelay_Resp_Follow_Up message in the S3 state machine, it will parse the timestamp carried in the message. t 3 ; In S4 state, calculate the path delay PathDelay through the formula after obtaining four timestamps. For example, formula (1) is as follows:
(1), (1),
式(1)中,t 1表示拉高rd_t_s控制信号从本地时钟模块读取发送时刻的时间戳值;t 2表示Pdelay_Resp报文中携带的时间戳值;t 3表示在S3状态机中接收到Pdelay_Resp_Follow_Up报文后将解析报文携带时间戳;t 4表示在S2状态机中接收到Pdelay_Resp报文后拉高rd_t_s控制信号从本地时钟模块读取接收时刻的时间戳值。 In formula (1), t 1 indicates that the rd_t_s control signal is raised to read the timestamp value of the sending moment from the local clock module; t 2 indicates the timestamp value carried in the Pdelay_Resp message; t 3 indicates that the time stamp value is received in the S3 state machine After the Pdelay_Resp_Follow_Up message, the message will be parsed and carry a timestamp; t 4 means that after receiving the Pdelay_Resp message in the S2 state machine, the rd_t_s control signal is raised to read the timestamp value of the reception moment from the local clock module.
在得到路径延迟结果后,在S5状态下由主节点发送的Sync报文在从节被接收,在S6状态下记录接收时刻的时间戳值t r,并解析Sync报文中携带的那个时刻时间戳值t s,最后在S7状态下利用公式计算时间同步偏差Offset并进行修正,公式如下: After obtaining the path delay result, the Sync message sent by the master node in the S5 state is received by the slave node, and the timestamp value tr of the reception moment is recorded in the S6 state, and the time carried in the Sync message is parsed. Stamp value t s , and finally use the formula to calculate the time synchronization offset Offset in the S7 state and correct it. The formula is as follows:
(2), (2),
式(2)中,t r表示在S6状态下记录接收时刻的时间戳值;t s表示Sync报文中携带的那个时刻时间戳值;PathDelay表示式(1)所求得的PathDelay值。 In equation (2), t r represents the timestamp value of the reception moment recorded in the S6 state; t s represents the timestamp value of that moment carried in the Sync message; PathDelay represents the PathDelay value obtained by equation (1).
为方便计算,在时间偏差修正模块中本发明对于记录的时间戳t 1、t 2、t 3、t 4,采用一个320位的寄存信号rce_time[319:0]对其进行封装,每个时间戳为80位,从高位到低位依次为t 1、t 2、t 3、t 4。 In order to facilitate calculation, in the time deviation correction module, the present invention uses a 320-bit registration signal rce_time[319:0] to encapsulate the recorded timestamps t 1 , t 2 , t 3 and t 4 . Each time The stamp is 80 bits, and from high to low it is t 1 , t 2 , t 3 , t 4 .
如图7所示,在本实施例中,在实现节点间互相发送报文是需保证节点间能够正常通信。首先在FPGA开发板上设置对应的源MAC地址、源IP地址、目的MAC地址、目的IP地址,其次在节点间相互发送报文,最后通过网络抓包软件对所发送的数据包进行捕获,测试通信链路的连通性。As shown in Figure 7, in this embodiment, when sending messages between nodes, it is necessary to ensure that the nodes can communicate normally. First, set the corresponding source MAC address, source IP address, destination MAC address, and destination IP address on the FPGA development board. Secondly, send messages to each other between nodes. Finally, use network packet capture software to capture the sent data packets and test Communication link connectivity.
本发明提出测试时间同步精度的方法为:首先由时间偏差模块计算获取时间同步偏差Offset,其次将此二进制数值通过串口模块输出至PC端,由PC端上的串口调试助手显示二进制数值,即时间同步精度,将每一次得到的结果进行收集,经MATLAB软件处理、分析数据,绘制出时间同步精度图。The method proposed by the present invention to test the time synchronization accuracy is: first, the time deviation module calculates and obtains the time synchronization deviation Offset, and secondly, outputs the binary value to the PC through the serial port module, and the serial port debugging assistant on the PC displays the binary value, that is, the time For synchronization accuracy, the results obtained each time are collected, processed and analyzed by MATLAB software, and a time synchronization accuracy chart is drawn.
上述基于FPGA实现网络节点时间同步的方法,由时钟信号控制产生的80bit计数器作为本地时钟模块为网络提供稳定的时钟源,通过报文发送模块封装以太网数据帧并将报文从i节点发送至i+1节点,并记录报文发送时刻的时间戳,将该值封装进数据帧中进行发送。由报文接收模块接收相应的数据帧并记录接收时刻的时间戳值。在接收或发送报文前对报文进行校验,并设置同步模块处理跨时钟域问题。最后将解析报文得到的时间戳值进行偏差修正、时间同步,并将时间同步精度通过串口输出至PC端。该方案基于FPGA硬件电路实现了链路时延测量以及时间误差修正,由硬件提供的稳定时钟源获得的硬时间戳准确度较高且不受网络波动的影响,可以为网络提供高精度(us级同步误差)同步时钟,避免了由软件层面带来的弊端,为以太网提供了一种低成本且精度高、稳定的时间同步方法,从而满足更为精确的调度与资源管理等通信需求以及新的应用场景需要。In the above-mentioned FPGA-based method for realizing network node time synchronization, the 80-bit counter generated by clock signal control serves as a local clock module to provide a stable clock source for the network. The Ethernet data frame is encapsulated through the message sending module and the message is sent from the i node to i+1 node, and records the timestamp of the message sending moment, and encapsulates the value into a data frame for sending. The message receiving module receives the corresponding data frame and records the timestamp value of the reception moment. Verify messages before receiving or sending them, and set up a synchronization module to handle cross-clock domain issues. Finally, the timestamp value obtained by parsing the message is corrected for deviation and time synchronized, and the time synchronization accuracy is output to the PC through the serial port. This solution implements link delay measurement and time error correction based on FPGA hardware circuits. The hard timestamp obtained by the stable clock source provided by the hardware has high accuracy and is not affected by network fluctuations, and can provide high accuracy for the network (us level synchronization error) synchronizes the clock, avoiding the disadvantages caused by the software layer, and provides a low-cost, high-precision, and stable time synchronization method for Ethernet, thereby meeting the communication needs of more accurate scheduling and resource management, and New application scenarios are needed.
以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation modes of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the patent scope of the present invention. It should be noted that, for those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the scope of protection of the patent of the present invention should be determined by the appended claims.
本发明为以太网提供了一种低成本、精度高且稳定的时间同步方法,从而满足更为精准的调度与资源管理等通信需求以及新的应用场景需要。 The present invention provides a low-cost, high-precision and stable time synchronization method for Ethernet, thereby meeting the communication needs of more accurate scheduling and resource management and the needs of new application scenarios.
Claims (9)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210485552.0A CN114884605A (en) | 2022-05-06 | 2022-05-06 | Method for realizing time synchronization of network nodes based on FPGA |
| CN202210485552.0 | 2022-05-06 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2023213080A1 true WO2023213080A1 (en) | 2023-11-09 |
Family
ID=82674672
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2022/139566 Ceased WO2023213080A1 (en) | 2022-05-06 | 2022-12-16 | Method for realizing network node time synchronization based on fpga |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN114884605A (en) |
| WO (1) | WO2023213080A1 (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119472390A (en) * | 2024-10-29 | 2025-02-18 | 南京南瑞继保工程技术有限公司 | A Synchronous Recording Method Considering Delay Compensation |
| CN119596802A (en) * | 2024-12-05 | 2025-03-11 | 湖南智领通信科技有限公司 | Distributed real-time control system and method based on TSN and FPGA |
| CN120238421A (en) * | 2025-06-03 | 2025-07-01 | 东方电子股份有限公司 | Distribution network fault processing method and distribution network fault processing system based on self-learning time synchronization |
| CN120993819A (en) * | 2025-08-08 | 2025-11-21 | 骆洪德 | A field logic control system based on RISC-V technology |
Families Citing this family (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114884605A (en) * | 2022-05-06 | 2022-08-09 | 上海海事大学 | Method for realizing time synchronization of network nodes based on FPGA |
| CN120357987A (en) * | 2024-01-22 | 2025-07-22 | 华为技术有限公司 | Communication method and related equipment |
| CN119834914B (en) * | 2024-12-24 | 2025-10-17 | 中国科学院精密测量科学与技术创新研究院 | A device and method for realizing wireless high-precision time synchronization based on FPGA |
| CN119652462A (en) * | 2025-02-19 | 2025-03-18 | 江苏秉信科技有限公司 | A device-free cross-region dynamic time synchronization method based on sensor network |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109818702A (en) * | 2019-03-04 | 2019-05-28 | 西安电子科技大学 | A system and method for realizing IEEE802.1AS clock synchronization function |
| CN111262796A (en) * | 2019-12-31 | 2020-06-09 | 南昌大学 | Ethernet communication system and method based on time sensitivity |
| CN113055116A (en) * | 2021-03-24 | 2021-06-29 | 电子科技大学 | High-reliability time-sensitive network time synchronization method and system |
| CN114884605A (en) * | 2022-05-06 | 2022-08-09 | 上海海事大学 | Method for realizing time synchronization of network nodes based on FPGA |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111147176A (en) * | 2019-12-04 | 2020-05-12 | 中国航空工业集团公司洛阳电光设备研究所 | High-precision time synchronization system based on IEEE1588 protocol |
-
2022
- 2022-05-06 CN CN202210485552.0A patent/CN114884605A/en active Pending
- 2022-12-16 WO PCT/CN2022/139566 patent/WO2023213080A1/en not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109818702A (en) * | 2019-03-04 | 2019-05-28 | 西安电子科技大学 | A system and method for realizing IEEE802.1AS clock synchronization function |
| CN111262796A (en) * | 2019-12-31 | 2020-06-09 | 南昌大学 | Ethernet communication system and method based on time sensitivity |
| CN113055116A (en) * | 2021-03-24 | 2021-06-29 | 电子科技大学 | High-reliability time-sensitive network time synchronization method and system |
| CN114884605A (en) * | 2022-05-06 | 2022-08-09 | 上海海事大学 | Method for realizing time synchronization of network nodes based on FPGA |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119472390A (en) * | 2024-10-29 | 2025-02-18 | 南京南瑞继保工程技术有限公司 | A Synchronous Recording Method Considering Delay Compensation |
| CN119596802A (en) * | 2024-12-05 | 2025-03-11 | 湖南智领通信科技有限公司 | Distributed real-time control system and method based on TSN and FPGA |
| CN120238421A (en) * | 2025-06-03 | 2025-07-01 | 东方电子股份有限公司 | Distribution network fault processing method and distribution network fault processing system based on self-learning time synchronization |
| CN120993819A (en) * | 2025-08-08 | 2025-11-21 | 骆洪德 | A field logic control system based on RISC-V technology |
Also Published As
| Publication number | Publication date |
|---|---|
| CN114884605A (en) | 2022-08-09 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2023213080A1 (en) | Method for realizing network node time synchronization based on fpga | |
| US11588568B2 (en) | Packet processing method and network device | |
| CN112385183B (en) | Apparatus, method and microcontroller for performing PHY level hardware timestamp and time synchronization | |
| CN102237997B (en) | Method for real-time synchronization and dynamic compensation between chain Ethernet nodes | |
| CN103929293B (en) | Asymmetric delay time synchronization method and system | |
| CN101447861A (en) | IEEE 1588 time synchronization system and implementation method thereof | |
| TW201921892A (en) | Indirect packet classification timestamping system and method | |
| CN102244603B (en) | Method, device and system for transmitting time-bearing message | |
| KR101290643B1 (en) | Method and system for bearing time synchronization protocol in optical transport network | |
| CN103138887B (en) | A kind of processing method and system of 1588 event message | |
| JP2015506626A (en) | Method and apparatus for communicating time information between time recognition devices | |
| CN112583477B (en) | A delay measurement method, system and storage medium | |
| CN109818702A (en) | A system and method for realizing IEEE802.1AS clock synchronization function | |
| CN111262796A (en) | Ethernet communication system and method based on time sensitivity | |
| Kyriakakis et al. | Hardware assisted clock synchronization with the ieee 1588-2008 precision time protocol | |
| US20140226683A1 (en) | Network adapter with high performance in-line timestamp | |
| WO2015131626A1 (en) | Time synchronization method and apparatus for network devices and time synchronization server | |
| CN112583509B (en) | Method and device for acquiring time stamp of data stream, storage medium and electronic device | |
| CN101765199B (en) | Communication network system and time synchronization method in system and OTN equipment | |
| CN117614580A (en) | An adaptive master-slave switching time synchronization method and its system | |
| CN111628914A (en) | Periodic communication network link delay measurement method and system and FPGA | |
| Lu et al. | Improving the real-time performance of Ethernet for plant automation (EPA) based industrial networks | |
| CN102983959B (en) | Method for realizing one-step mode and two-step mode for PTP (precision time synchronization protocol) in a plurality of MAC | |
| Zhang et al. | Design considerations for hardware implementation of nanoseconds time synchronization low-cost system based on precise time protocol | |
| CN112825493A (en) | Timestamp configuration method and device and clock synchronization method and device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22940774 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 22940774 Country of ref document: EP Kind code of ref document: A1 |