A message processing method and device

By managing the cache status according to the incoming port and type of PTP packets in the IEEE1588 protocol, the time stamp storage sequence problem caused by the difference in processing speed of FPGA and NP chips is solved, ensuring the correct sequential storage of PTP packets and improving time synchronization accuracy and network experience.

CN115580389BActive Publication Date: 2024-12-06新华三技术有限公司合肥分公司

Patent Information

Application Number
CN202211158907.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-22
Publication Date
2024-12-06
Estimated Expiration
2042-09-22

AI Technical Summary

Technical Problem

In the IEEE1588 protocol, due to the different speed of processing packets between the FPGA chip and the NP chip, the second designated CPU core may cause the second PTP message to be stored in memory, but the first designated CPU core has not yet stored the first PTP message. Time stamps, resulting in the inability to calculate the average path delay and time offset, affecting time synchronization and network experience.

Method used

When reading PTP messages, determine their incoming port and message type, determine the message type and set the corresponding buffer status to ensure that the sequence of PTP messages is stored in memory, including marking the buffer area as occupied or not Takes up the status and query the sub-buffer area if necessary to maintain the correct order of message sequence numbers and timestamps.

Benefits of technology

Ensure the correct order storage of PTP packets in the slave clock network node memory, improve the accuracy and network experience of time synchronization, and avoid time synchronization failure caused by messy message processing order.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115580389B_ABST
    Figure CN115580389B_ABST
Patent Text Reader

Abstract

The present application provides a message processing method and device. In this method, for any CPU core in a network node as a slave clock, when a PTP message whose input port is a port on the network node for time synchronization with the network node as a master clock is read, it will be decided whether to perform relevant cache processing based on the message type of the PTP message and the situation of carrying a timestamp, or only based on the message type of the PTP message, and when relevant cache processing is required, by setting the occupancy status of the cache area corresponding to the sequence preservation identifier corresponding to the message type of the PTP message, the cache status of the relevant sub-cache area in the cache area, and cache-related information, the order of the PTP messages stored in the designated storage space in the memory of the network node as a slave clock is guaranteed, so as to complete the time synchronization operation in time, thereby improving the network experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a message processing method and device. Background Art

[0002] With the rapid development of network communication technology, a large number of applications in factory automation, test and measurement, and communications require very precise time synchronization. In the communications field, even microsecond-level time synchronization requirements have been put forward. As a result, the Institute of Electrical and Electronics Engineers (IEEE) 1588 has emerged.

[0003] IEEE 1588 stands for IEEE Standard for a Precision Clock Synchronization Protocol for Networked Measurement and Control Systems, also known as Precision Time Protocol (PTP). This protocol is designed to synchronize time between different network nodes (such as routers) in an Ethernet network with microsecond accuracy.

[0004] Currently, the first network node, which serves as a slave clock, usually uses a delay request-response mechanism or a peer delay mechanism to calculate the average path delay and time offset between the second network node, which serves as a master clock, and the first network node to correct the local time and synchronize the time between the second network node and the first network node.

[0005] Taking the delayed request-response mechanism as an example, when the Field-Programmable Gate Array (FPGA) chip in the first network node receives the first PTP message sent by the network node serving as the master clock through the port on the first network node that performs time synchronization with the second network node, the FPGA chip records the first timestamp when the first PTP message is received, and notifies the first designated central processing unit (CPU) core in the network node serving as the slave clock to read the first PTP message and the first timestamp; when the second PTP message sent by the network node serving as the master clock is received through the port, the second PTP message is transparently transmitted to the network processor (NP) chip in the network node serving as the slave clock, and the NP chip notifies the second designated CPU core (which may be the same as or different from the first designated CPU core) in the network node serving as the slave clock to read the second PTP message.

[0006] Here, the first PTP message may be a PTP message of a synchronization (Sync) message or a delay request (Delay_Req) ​​message type; the second PTP message may be a PTP message of a follow (Follow_Up) message or a delay response (Delay_Resp) message type.

[0007] Subsequently, when the first designated CPU core reads the first PTP message whose input and output port is the slave port, it directly stores the first PTP message and the timestamp associated with the first PTP message read out to the designated storage space in the memory of the network node serving as the slave clock and waits for processing; when the second designated CPU core reads the second PTP message whose input and output port is the slave port, it also directly stores the second PTP message to the designated storage space and waits for processing, so that the third CPU core (which can be the first designated CPU core, the second designated CPU core, or other CPU core) responsible for calculating the average path delay and time offset between the second network node and the first network node calls the relevant calculation instructions to calculate the corresponding average path delay and time offset based on the relevant timestamps stored in the designated storage space, thereby completing the time synchronization operation.

[0008] However, in this message processing process, due to the different message processing speeds of the FPGA chip and the NP chip, it may happen that the second designated CPU core has stored the relevant second PTP message (for example, the corresponding message type is a Delay_Resp message) in the designated storage space, but the first designated CPU core has not yet stored the first PTP message that should precede the relevant second PTP message (for example, the corresponding message type is a Delay_Req message) and the timestamp associated with this first PTP message in the storage space, causing the third CPU core to perform packet loss processing, and then fail to calculate the corresponding average path delay and time offset, resulting in time synchronization failure and affecting the network experience. Summary of the Invention

[0009] In order to overcome the problems existing in the related art, the present application provides a message processing method and device.

[0010] According to a first aspect of an embodiment of the present application, a message processing method is provided. The method is applied to any CPU core in a network node serving as a slave clock, and the method includes:

[0011] When reading out the PTP message, if it is determined that the inbound port of the PTP message is a port on the network node that performs time synchronization with the network node serving as the master clock, then determining the message type of the PTP message;

[0012] If the determined message type is the first message type and the PTP message carries an invalid timestamp, or if the determined message type is the second message type, marking a cache area corresponding to an order preservation identifier corresponding to the determined message type in a memory in the network node as occupied, wherein the PTP message is read by the CPU core from the FPGA chip in the network node;

[0013] In all sub-buffers within the buffer, query whether there is a first sub-buffer that caches the message sequence number of the PTP message and whose cache state is ready;

[0014] When the query result is yes, the PTP message and the read timestamp associated with the PTP message are first stored in the first designated storage space in the memory, and then the PTP message with a valid timestamp cached in the first sub-buffer area is stored in the first designated storage space for processing, and the cache state of the first sub-buffer area is changed to an unused state, and the cache area is marked as unoccupied, wherein the third message type of the PTP message cached in the first sub-buffer area corresponds to the same sequence preservation identifier as the determined message type;

[0015] When the query result is no, the PTP message and the read timestamp associated with the PTP message are stored in the first designated storage space to wait for processing, and the message sequence number and the cache timestamp when the message sequence number is cached are cached in a second sub-buffer area in the buffer area whose cache state is unused, the cache state of the second sub-buffer area is changed to a waiting state, and the buffer area is marked as unoccupied;

[0016] If the determined message type is the third message type, marking the buffer area as occupied, wherein the PTP message is read by the CPU core from the NP chip in the network node;

[0017] In all sub-buffers within the buffer, query whether there is a third sub-buffer that has cached the message sequence number and is in a waiting state;

[0018] When the query result is yes, the PTP message is stored in the first designated storage space for processing, the third sub-buffer area is cleared, its cache state is changed to an unused state, and the buffer area is marked as unoccupied;

[0019] When the query result is no, cache the PTP message, the message sequence number, and a cache timestamp when the message sequence number is cached in a fourth sub-buffer area in the buffer area whose cache state is unused, change the cache state of the fourth sub-buffer area to a ready state, and mark the buffer area as unoccupied;

[0020] Wherein, when the first message type is a Sync message, the third message type is a Follow_Up message, or,

[0021] When the first message type is a Pdelay_Resp message, the third message type is a Pdelay_Resp_Follow_Up message;

[0022] When the second message type is a delay request Delay_Req message, the third message type is a delay response Delay_Resp message;

[0023] Furthermore, the first message type and the second message type correspond to different sequence preservation identifiers.

[0024] According to a second aspect of an embodiment of the present application, a message processing device is provided. The device is applied to any CPU core in a network node serving as a slave clock, and the device includes:

[0025] A determination module for, when reading a PTP message, determining a message type of the PTP message if it is determined that an inbound port of the PTP message is a port on the network node that performs time synchronization with a network node serving as a master clock;

[0026] The first processing module is used to mark the cache area corresponding to the sequence preservation identifier corresponding to the determined message type in the memory of the network node as occupied if the message type determined by the determination module is the first message type and the PTP message carries an invalid timestamp, or if the determined message type is the second message type, wherein the PTP message is read out by the CPU core from the FPGA chip in the network node; inquire whether there is a first sub-cache area in all sub-cache areas in the cache area that has the message sequence number of the PTP message cached and the cache state is ready; when the query result is yes, first store the PTP message and the read timestamp associated with the PTP message in the first designated storage space in the memory, and then cache the first sub-cache area. The PTP message carrying a valid timestamp is stored in the first designated storage space and waits for processing, and the cache state of the first sub-cache area is changed to an unused state, and the cache area is marked as an unoccupied state, wherein the third message type of the PTP message cached in the first sub-cache area corresponds to the same sequence preservation identifier as the determined message type; when the query result is no, the PTP message and the read timestamp associated with the PTP message are stored in the first designated storage space and wait for processing, and the message sequence number and the cache timestamp when the message sequence number is cached are cached in a second sub-cache area in the cache area whose cache state is unused, the cache state of the second sub-cache area is changed to a waiting state, and the cache area is marked as an unoccupied state;

[0027] A second processing module is configured to mark the buffer area as occupied if the message type determined by the determination module is the third message type, wherein the PTP message is read by the CPU core from the NP chip in the network node; query whether there is a third sub-buffer area in all sub-buffer areas within the buffer area that has the message sequence number cached and whose cache state is in a waiting state; if the query result is yes, store the PTP message in the first designated storage space to wait for processing, empty the third sub-buffer area, change its cache state to an unused state, and mark the buffer area as unoccupied; if the query result is no, cache the PTP message, the message sequence number, and the cache timestamp when caching the message sequence number in a fourth sub-buffer area in the buffer area whose cache state is unused, change the cache state of the fourth sub-buffer area to a ready state, and mark the buffer area as unoccupied;

[0028] Wherein, when the first message type is a Sync message, the third message type is a Follow_Up message, or,

[0029] When the first message type is a Pdelay_Resp message, the third message type is a Pdelay_Resp_Follow_Up message;

[0030] When the second message type is a delay request Delay_Req message, the third message type is a delay response Delay_Resp message;

[0031] Furthermore, the first message type and the second message type correspond to different sequence preservation identifiers.

[0032] The technical solutions provided by the embodiments of the present application may have the following beneficial effects:

[0033] In an embodiment of the present application, for any CPU core in a network node serving as a slave clock, when a PTP message whose input port is a port on the network node for time synchronization with the network node serving as the master clock is read, a decision will be made whether relevant cache processing is required based on the message type of the PTP message and the situation of carrying a timestamp, or only based on the message type of the PTP message. When relevant cache processing is required, the occupancy status of the cache area corresponding to the sequence preservation identifier corresponding to the message type of the PTP message, the cache status of the relevant sub-buffer area within the cache area, and cache-related information are set to ensure the order of the PTP messages stored in the designated storage space in the memory of the network node serving as the slave clock, so as to complete the time synchronization operation in a timely manner, thereby improving the network experience.

[0034] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0036] Figure 1 A flowchart of a message processing method provided in an embodiment of the present application;

[0037] Figure 2 A schematic diagram of the structure of a message processing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0039] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. As used in this application and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0040] It should be understood that although the terms first, second, third, etc. may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words "if" or "if" as used herein may be interpreted as "when" or "when".

[0041] Next, the embodiments of the present application are described in detail.

[0042] The embodiment of the present application provides a message processing method, which is applied to any CPU core in a network node serving as a slave clock. The network node may include only one CPU core or multiple CPU cores, such as Figure 1 As shown, the method may include the following steps:

[0043] S11. When reading out the PTP message, if it is determined that the input port of the PTP message is a port on the network node that performs time synchronization with the network node serving as the master clock, the message type of the PTP message is determined.

[0044] S12. If the determined message type is the first message type and the PTP message carries an invalid timestamp, or if the determined message type is the second message type, the cache area corresponding to the sequence preservation identifier corresponding to the determined message type in the memory of the network node is marked as occupied.

[0045] In this step, the PTP message is read by the CPU core from the FPGA chip in the network node. Furthermore, the invalid timestamp can be presented in various existing ways, such as using 0 to represent an invalid timestamp. That is, when the value in the timestamp field of the PTP message is 0, it means that the PTP message carries an invalid timestamp.

[0046] S13. In all sub-buffers within the buffer, query whether there is a first sub-buffer that has a message sequence number of the PTP message cached and is in a ready state; if the query result is yes, execute step S14; if the query result is no, execute step S15.

[0047] S14: First, the PTP message and the read timestamp associated with the PTP message are stored in the first designated storage space in the memory, and then the PTP message with a valid timestamp cached in the first sub-buffer area is stored in the first designated storage space to wait for processing, and the cache state of the first sub-buffer area is changed to an unused state, and the cache area is marked as unoccupied.

[0048] In this step, the PTP message cached in the first sub-buffer area may be cached in various ways, for example, the complete PTP message may be cached, or the message address corresponding to the PTP message may be cached, and so on.

[0049] S15: Store the PTP message and the read timestamp associated with the PTP message in a first designated storage space for waiting for processing, cache the message sequence number and the cache timestamp when the message sequence number is cached in a second sub-buffer area in the cache area whose cache status is unused, change the cache status of the second sub-buffer area to a waiting state, and mark the cache area as unoccupied.

[0050] In this step, the third message type of the PTP message buffered in the first sub-buffer area and the determined message type correspond to the same sequence preservation identifier.

[0051] S16: If the determined message type is the third message type, mark the buffer area as occupied.

[0052] In this step, the PTP message is read by the CPU core from the NP chip in the network node.

[0053] S17. Inquire among all sub-buffers in the buffer whether there is a third sub-buffer that has a message sequence number cached and is in a waiting state; if the query result is yes, execute step S18; if the query result is no, execute step S19.

[0054] S18: Store the PTP message in the first designated storage space to wait for processing, clear the third sub-buffer area, change its buffer state to an unused state, and mark the buffer area as unoccupied.

[0055] S19: Cache the PTP message, the message sequence number, and the cache timestamp when the message sequence number is cached in a fourth sub-buffer area in the cache area whose cache status is unused, change the cache status of the fourth sub-buffer area to a ready state, and mark the cache area as unoccupied.

[0056] It should be noted that, in the embodiment of the present application, when the first message type is a Sync message, the third message type is a Follow_Up message, or,

[0057] When the first message type is a Pdelay_Resp message, the third message type is a Pdelay_Resp_Follow_Up message.

[0058] When the second message type is a Delay_Req message, the third message type is a Delay_Resp message.

[0059] Furthermore, the first message type and the second message type correspond to different sequence preservation identifiers.

[0060] In addition, in an embodiment of the present application, for the CPU core, when reading a PTP message from the FPGA chip or NP chip in the network node, it will determine whether the input port of the PTP message is a port on the network node serving as a slave clock that is synchronized with the network node serving as a master clock for time, and when the judgment result is no, the CPU core will process it according to the existing processing flow, that is, directly store the PTP message in the second designated storage space and wait for processing; when the judgment result is yes, the CPU core will use the existing message type determination method to determine the message type of the PTP message.

[0061] Here, the CPU core may determine the message type of the PTP message according to a message type field in the message payload.

[0062] Specifically, when the message Type field is 0x00, it is determined that the message type of the PTP message is a Sync message.

[0063] When the message Type field is 0x01, it is determined that the message type of the PTP message is a Delay_Req message.

[0064] When the message Type field is 0x02, it is determined that the message type of the PTP message is a PDelay_Req message.

[0065] When the message Type field is 0x03, it is determined that the message type of the PTP message is a Pdelay_Resp message.

[0066] When the message Type field is 0x08, it is determined that the message type of the PTP message is a Follow_Up message.

[0067] When the message Type field is 0x09, it is determined that the message type of the PTP message is a Delay_Resp message.

[0068] When the message Type field is 0x0A, it is determined that the message type of the PTP message is a Pdelay_Resp_Follow_Up message.

[0069] It should be further explained that in the embodiment of the present application, in order not to affect the time synchronization operation of the network node, for the port on the network node as the slave clock that performs time synchronization with the network node as the master clock, the administrator has in advance assigned a unique sequence preservation identifier to each pair of message types that enter from the port and need to maintain the order of the PTP messages stored in the above-mentioned first designated storage space. The specific presentation method can be set according to the actual needs of the administrator, for example, sequence preservation 1, sequence preservation 2, etc., and stored in the memory of the network node. The administrator also allocates corresponding cache areas for these sequence preservation identifiers. By caching the relevant information of the PTP messages that need to be stored first or caching the PTP messages that need to be stored later in the corresponding cache areas, the order of the PTP messages stored in the above-mentioned first designated storage space can be guaranteed, the time synchronization operation is completed in time, and the network experience is improved.

[0070] Here, the Sync message and the Follow_Up message are a pair of message types. The PTP message corresponding to the Sync message carries an invalid timestamp, and the PTP message corresponding to the Follow_Up message carries a valid timestamp. The PTP messages corresponding to this pair of message types have the same message sequence numbers.

[0071] The Delay_Req message and the Delay_Resp message are a pair of message types. The PTP message corresponding to the Delay_Req message can carry an invalid timestamp or a valid timestamp (that is, the timestamp when the network node where the CPU core is located sends the Delay_Req message to the network node serving as the master clock). The PTP message corresponding to the Delay_Resp message carries a valid timestamp. The PTP messages corresponding to this pair of message types have the same message sequence number.

[0072] The Pdelay_Resp message and the Pdelay_Resp_Follow_Up message are a pair of message types. The PTP message corresponding to the Pdelay_Resp message carries an invalid timestamp, while the PTP message corresponding to the Pdelay_Resp_Follow_Up message carries a valid timestamp. The PTP messages corresponding to this pair of message types have the same message sequence numbers.

[0073] For example, the sequence identifier corresponding to the Sync message and the Follow_Up message is sequence 1, the sequence identifier corresponding to the Delay_Req message and the Delay_Resp message is sequence 2, and the sequence identifier corresponding to the Pdelay_Resp message and the Pdelay_Resp_Follow_Up message is sequence 3. Here, the message sequence numbers of the PTP messages corresponding to all pairs of message types can be exactly the same, partially the same, or completely different.

[0074] Of course, the sequence preservation identifier corresponding to each pair of message types mentioned above can also be presented in other ways, which are not listed here one by one.

[0075] In addition, whether in the above step S12 or in the above step S16, the CPU core will mark the cache area as occupied, mainly to ensure that the CPU core performs relevant cache operations and subsequent aging operations in an orderly manner, and also ensures that when the network node includes multiple CPU cores, only one CPU core processes the above cache area at the same time to ensure that the PTP messages stored in the first designated storage space are not disordered, so that the CPU core responsible for calculating the relevant average path delay and time offset (which may be the above CPU core or not) can promptly call the calculation instruction to calculate the corresponding average path delay and time offset based on the relevant timestamps stored in the first designated storage space, and complete time synchronization in a timely manner.

[0076] Furthermore, in the embodiment of the present application, in order to avoid occupying the cache area in the memory for a long time, the CPU core may further perform the following operations:

[0077] When the preset aging period arrives, for each cache area corresponding to the order preservation identifier, if the cache area is marked as occupied, no aging operation is performed;

[0078] If the buffer area is marked as unoccupied, the buffer area is marked as occupied, and it is determined whether there is a sub-buffer area in all sub-buffer areas corresponding to the buffer area, the buffer state of which is in the waiting state or the ready state, and the difference between the current timestamp and the cached timestamp is not less than the set threshold;

[0079] If the result of the judgment is yes, clear the sub-cache area whose cache state is in the waiting state or the ready state and the difference between the current timestamp and the cached timestamp is not less than the set threshold, change its cache state to the unused state, and mark the cache area as unoccupied;

[0080] When the judgment result is no, no aging operation is performed, and the cache area is marked as unoccupied.

[0081] Here, the CPU core can start an aging timer (the corresponding timeout duration is the duration of the preset aging cycle) to monitor the cache area corresponding to each sequence preservation identifier. Once the aging timer times out, the above operation process will be started to optimize the cache space in a timely manner.

[0082] That is to say, once the preset aging cycle is reached, for each cache area corresponding to the sequence-preserving identifier, the CPU core will determine whether the cache area is marked as unoccupied or occupied. If it is determined that the cache area is marked as unoccupied, then the CPU core will perform relevant aging operations under the condition that the cache area is marked as unoccupied; if it is determined that the cache area is marked as occupied, then the CPU core will not perform any aging operations and will wait until the next preset aging cycle arrives before making another judgment. Until a certain preset aging cycle is reached and the cache area is found to be unoccupied, then the relevant aging operations under the condition that the cache area is marked as unoccupied are performed.

[0083] It should be noted that the above-mentioned preset aging period can be set according to the actual requirements of the network where the network node is located.

[0084] The above message processing method is described in detail below with reference to specific embodiments.

[0085] Assume that the CPU core 1 in the network node serving as the slave clock first reads PTP message 1 from the NP chip in the network node, and finds that the input port of PTP message 1 is the port on the network node that is synchronized with the network node serving as the master clock (for example, port 1). At this time, the CPU core 1 determines the message type of PTP message 1.

[0086] Assuming that the determined message type is a Follow_Up message, CPU core 1 marks the cache area (eg, cache area 1) corresponding to the sequence preservation identifier (eg, sequence preservation 1) corresponding to the Follow_Up message in the memory of the network node as occupied.

[0087] Next, CPU core 1 checks all sub-buffers within buffer 1 to see whether there is a sub-buffer that has cached the message sequence number of PTP message 1 (for example, message sequence number 1) and is in the Wait state.

[0088] Assume that the query result is no, which means that the message type is a Sync message and the PTP message carrying an invalid timestamp has not been stored in the designated storage space in the memory. In this case, CPU core 1 caches PTP message 1, message sequence number 1, and a cache timestamp when the message sequence number 1 is cached in a sub-buffer (for example, sub-buffer 1) in cache area 1 whose cache status is unused, changes the cache status of sub-buffer 1 to Ready, and marks cache area 1 as unoccupied.

[0089] Subsequently, it is assumed that CPU core 1 reads PTP message 2 from the FPGA chip in the network node and finds that the inbound port of PTP message 2 is also port 1. At this time, CPU core 1 determines the message type of PTP message 2.

[0090] Assuming that the determined message type is a Sync message, and it is found that PTP message 2 carries an invalid timestamp (for example, 0), at this time, CPU core 1 marks the cache area (i.e., cache area 1) corresponding to the sequence preservation identifier (i.e., sequence preservation 1) corresponding to the Sync message in the memory of the network node as occupied.

[0091] Next, CPU core 1 queries all sub-buffers in buffer 1 to see whether there is a sub-buffer that has cached the message sequence number of PTP message 2 (ie, message sequence number 1) and is in the Ready state.

[0092] Since the message sequence number 1 is cached in the sub-buffer area 1 and the cache status is Ready, the query result is yes. At this time, the CPU core 1 first stores the PTP message 2 and the read timestamp associated with the PTP message 2 (that is, the timestamp when the above-mentioned FPGA chip receives the PTP message 2, for example, timestamp 2) in the designated storage space, and then stores the PTP message 1 cached in the sub-buffer area 1 (carrying a valid timestamp, for example, timestamp 1) in the designated storage space for processing, and changes the cache status of the sub-buffer area 1 to an unused state, and marks the cache area 1 as unoccupied for subsequent use.

[0093] Assume again that CPU core 1 reads PTP message 3 from the FPGA chip in the network node and finds that the inbound port of PTP message 3 is port 1. At this time, CPU core 1 determines the message type of PTP message 3.

[0094] Assuming that the determined message type is a Delay_Req message, CPU core 1 marks the cache area (eg, cache area 2) corresponding to the sequence preservation identifier (eg, sequence preservation 2) corresponding to the Delay_Req message in the memory of the network node as occupied.

[0095] Next, CPU core 1 checks all sub-buffers within buffer 2 to see whether there is a sub-buffer that has cached the message sequence number of PTP message 3 (for example, message sequence number 2) and is in the Ready state.

[0096] Assume that the query result is no, which means that the PTP message of the message type Delay_Resp message has not been stored in the designated storage space in the memory. In this case, the CPU core 1 stores the PTP message 3 and the read timestamp associated with the PTP message 3 (i.e., the timestamp when the FPGA chip receives the PTP message 3) in the designated storage space and waits for processing, and caches the message sequence number 2 and the cache timestamp when the message sequence number 2 is cached in a sub-buffer area (for example, sub-buffer area 2) in the cache area 2 whose cache status is unused, changes the cache status of the sub-buffer area 2 to the Wait state, and marks the cache area 2 as unoccupied.

[0097] It is subsequently assumed that the CPU core 1 reads the PTP message 4 from the NP chip in the network node and finds that the inbound port of the PTP message 4 is also port 1. At this time, the CPU core 1 determines the message type of the PTP message 4.

[0098] Assuming that the determined message type is a Delay_Resp message, CPU core 1 marks the cache area (ie, cache area 2) corresponding to the sequence preservation identifier (ie, sequence preservation 2) corresponding to the Delay_Resp message in the memory of the network node as occupied.

[0099] CPU core 1 checks all sub-buffers in cache 2 to see whether there is a sub-buffer that has cached message sequence number 2 and is in the Wait state.

[0100] Since message sequence number 2 is cached in sub-buffer 2 and the cache state is Wait state, the query result is yes. At this time, CPU core 1 stores PTP message 4 (carrying a valid timestamp, for example, timestamp 2) in the designated storage space and waits for processing, and clears sub-buffer 2, changes its cache state to unused state, and marks cache 2 as unoccupied.

[0101] Subsequently, the CPU core responsible for calculating the average path delay and time offset between the network node and the network node serving as the master clock (for example, CPU core 1 can call relevant calculation instructions based on the relevant timestamps stored in the designated storage space (the order of these timestamps is consistent with the order of the relevant PTP messages received by the network node) to calculate the corresponding average path delay and time offset to complete time synchronization in a timely manner. Here, the specific calculation process is prior art and will not be described in detail here.

[0102] It can be seen from the above technical solution that in an embodiment of the present application, for any CPU core in a network node serving as a slave clock, when a PTP message whose input port is the port on the network node for time synchronization with the network node serving as the master clock is read, a decision will be made whether relevant cache processing is required based on the message type of the PTP message and the timestamp carried, or only based on the message type of the PTP message. When relevant cache processing is required, the occupancy status of the cache area corresponding to the sequence preservation identifier corresponding to the message type of the PTP message, the cache status of the relevant sub-cache area within the cache area, and cache-related information are set to ensure the order of the PTP messages stored in the designated storage space in the memory of the network node serving as the slave clock, so as to complete the time synchronization operation in a timely manner, thereby improving the network experience.

[0103] Based on the same inventive concept, the present application also provides a message processing device, which is applied to any CPU core in a network node serving as a slave clock. The network node may include only one CPU core or multiple CPU cores. The structural diagram of the CPU core is shown in FIG. Figure 2 As shown, specifically including:

[0104] A determination module 21 is configured to, when reading a PTP message, determine a message type of the PTP message if it is determined that the inbound port of the PTP message is a port on the network node that is time synchronized with the network node serving as the master clock;

[0105] The first processing module 22 is used for marking the cache area corresponding to the sequence preservation identifier corresponding to the determined message type in the memory of the network node as occupied if the message type determined by the determination module 21 is the first message type and the PTP message carries an invalid timestamp, or if the determined message type is the second message type, wherein the PTP message is read out by the CPU core from the FPGA chip in the network node; inquiring whether there is a first sub-cache area in all sub-cache areas in the cache area that has the message sequence number of the PTP message cached and the cache state is ready; when the query result is yes, first storing the PTP message and the read timestamp associated with the PTP message in the first designated storage space in the memory, and then marking the cache area corresponding to the sequence preservation identifier corresponding to the determined message type in the memory of the network node as occupied. The cached PTP message carrying a valid timestamp is stored in the first designated storage space and waits for processing, and the cache state of the first sub-cache area is changed to an unused state, and the cache area is marked as an unoccupied state, wherein the third message type of the PTP message cached in the first sub-cache area corresponds to the same sequence preservation identifier as the determined message type; when the query result is no, the PTP message and the read timestamp associated with the PTP message are stored in the first designated storage space and wait for processing, and the message sequence number and the cache timestamp when the message sequence number is cached are cached in a second sub-cache area in the cache area whose cache state is unused, the cache state of the second sub-cache area is changed to a waiting state, and the cache area is marked as an unoccupied state;

[0106] A second processing module 23 is configured to, if the message type determined by the determining module 21 is the third message type, mark the buffer area as occupied, wherein the PTP message is read by the CPU core from the NP chip in the network node; query among all the sub-buffers in the buffer area whether there is a third sub-buffer area that caches the message sequence number and whose cache state is in a waiting state; if the query result is yes, store the PTP message in the first designated storage space to wait for processing, empty the third sub-buffer area, change its cache state to an unused state, and mark the buffer area as unoccupied; if the query result is no, cache the PTP message, the message sequence number, and the cache timestamp when caching the message sequence number in a fourth sub-buffer area in the buffer area whose cache state is unused, change the cache state of the fourth sub-buffer area to a ready state, and mark the buffer area as unoccupied;

[0107] Wherein, when the first message type is a Sync message, the third message type is a Follow_Up message, or,

[0108] When the first message type is a Pdelay_Resp message, the third message type is a Pdelay_Resp_Follow_Up message;

[0109] When the second message type is a delay request Delay_Req message, the third message type is a delay response Delay_Resp message;

[0110] Furthermore, the first message type and the second message type correspond to different sequence preservation identifiers.

[0111] Preferably, the device further comprises:

[0112] The third processing module ( Figure 2 (not shown) is used to directly store the PTP message in the second designated storage space and wait for processing when it is determined that the input port of the PTP message is not the port on the network node serving as the slave clock for time synchronization with the network node serving as the master clock.

[0113] Preferably, the device further comprises:

[0114] The fourth processing module ( Figure 2 (not shown) is used for, after the determination module determines the message type of the PTP message, if the determined message type is a Sync message or a Pdelay_Resp message, and the PTP message carries a valid timestamp, or if the determined message type is a Pdelay_Req message, directly storing the PTP message in the first designated storage space and waiting for processing.

[0115] Preferably, the device further comprises:

[0116] Aging treatment module ( Figure 2 ), which is used for, when the preset aging period arrives, for the cache area corresponding to each sequence identifier, if the cache area is marked as occupied, no aging operation is performed; if the cache area is marked as unoccupied, the cache area is marked as occupied, and it is determined whether there is a sub-cache area in all sub-cache areas corresponding to the cache area whose cache status is waiting state or ready state, and the difference between the current timestamp and the cache timestamp of the cache is not less than the set threshold; when the judgment result is yes, the sub-cache area whose cache status is waiting state or ready state, and the difference between the current timestamp and the cache timestamp of the cache is not less than the set threshold is cleared, and its cache status is set to unused state, and the cache area is marked as unoccupied; when the judgment result is no, no aging operation is performed, and the cache area is marked as unoccupied.

[0117] It can be seen from the above technical solution that in an embodiment of the present application, for any CPU core in a network node serving as a slave clock, when a PTP message whose input port is the port on the network node for time synchronization with the network node serving as the master clock is read, a decision will be made whether relevant cache processing is required based on the message type of the PTP message and the timestamp carried, or only based on the message type of the PTP message. When relevant cache processing is required, the occupancy status of the cache area corresponding to the sequence preservation identifier corresponding to the message type of the PTP message, the cache status of the relevant sub-cache area within the cache area, and cache-related information are set to ensure the order of the PTP messages stored in the designated storage space in the memory of the network node serving as the slave clock, so as to complete the time synchronization operation in a timely manner, thereby improving the network experience.

[0118] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A message processing method, characterized in that: The method is applied to any central processing unit (CPU) core in a network node as a slave clock, and the method comprises: When reading out a Precision Time Protocol (PTP) message, if it is determined that an inbound port of the PTP message is a port on the network node that performs time synchronization with a network node serving as a master clock, determining a message type of the PTP message; If the determined message type is the first message type and the PTP message carries an invalid timestamp, or if the determined message type is the second message type, a cache area corresponding to an order preservation identifier corresponding to the determined message type in a memory in the network node is marked as occupied, wherein the PTP message is read by the CPU core from a field programmable gate array FPGA chip in the network node; In all sub-buffers in the buffer, query whether there is a first sub-buffer that has a message sequence number of the PTP message cached and whose cache state is in a ready state; When the query result is yes, first store the PTP message and the read timestamp associated with the PTP message in the first designated storage space in the memory, then store the PTP message carrying the valid timestamp cached in the first sub-buffer area in the first designated storage space to wait for processing, and change the cache state of the first sub-buffer area to an unused state, and mark the cache area as unoccupied, wherein the third message type of the PTP message cached in the first sub-buffer area corresponds to the same sequence preservation identifier as the determined message type; When the query result is no, the PTP message and the read timestamp associated with the PTP message are stored in the first designated storage space to wait for processing, and the message sequence number and the cache timestamp when the message sequence number is cached are cached in a second sub-buffer area in the buffer area whose cache state is unused, the cache state of the second sub-buffer area is changed to a waiting state, and the buffer area is marked as unoccupied; If the determined message type is the third message type, marking the cache area as occupied, wherein the PTP message is read by the CPU core from the network processor NP chip in the network node; In all sub-buffers in the buffer, query whether there is a third sub-buffer that has the message sequence number cached and whose cache state is in a waiting state; When the query result is yes, the PTP message is stored in the first designated storage space to wait for processing, and the third sub-buffer area is cleared, its cache state is changed to an unused state, and the cache area is marked as unoccupied; When the query result is no, cache the PTP message, the message sequence number and the cache timestamp when the message sequence number is cached in a fourth sub-buffer area in the buffer area whose cache state is unused, change the cache state of the fourth sub-buffer area to a ready state, and mark the buffer area as unoccupied; Wherein, when the first message type is a Sync message, the third message type is a Follow_Up message, or, When the first message type is a Pdelay_Resp message, the third message type is a terminal delayed response following a Pdelay_Resp_Follow_Up message; When the second message type is a delay request Delay_Req message, the third message type is a delay response Delay_Resp message; Furthermore, the first message type and the second message type correspond to different sequence preservation identifiers.

2. The method according to claim 1, characterized in that: The method further comprises: When it is determined that the inbound port of the PTP message is not a port on the network node as a slave clock that performs time synchronization with the network node as a master clock, the PTP message is directly stored in the second designated storage space to wait for processing.

3. The method according to claim 1, characterized in that The method further comprises: After determining the message type of the PTP message, if the determined message type is a Sync message or a Pdelay_Resp message and the PTP message carries a valid timestamp, or if the determined message type is a terminal delay request Pdelay_Req message, the PTP message is directly stored in the first designated storage space and waits for processing.

4. The method according to claim 1, characterized in that: The method further comprises: When the preset aging period arrives, for the cache area corresponding to each sequence preservation identifier, if the cache area is marked as occupied, no aging operation is performed; If the buffer area is marked as unoccupied, the buffer area is marked as occupied, and it is determined whether there is a sub-buffer area in all sub-buffer areas corresponding to the buffer area whose buffer state is in a waiting state or a ready state, and the difference between the current timestamp and the cached timestamp is not less than a set threshold; When the judgment result is yes, clear the sub-buffer area whose cache state is in the waiting state or the ready state and whose difference between the current timestamp and the cached cache timestamp is not less than the set threshold, set its cache state to an unused state, and mark the cache area as unoccupied; When the judgment result is no, no aging operation is performed, and the cache area is marked as unoccupied.

5. A message processing device, characterized in that: The device is applied to any central processing unit (CPU) core in a network node serving as a slave clock, and comprises: A determination module, configured to determine the message type of the PTP message when reading a Precision Time Protocol (PTP) message, if it is determined that the inbound port of the PTP message is a port on the network node that performs time synchronization with the network node serving as the master clock; The first processing module is used for marking the cache area corresponding to the sequence preservation identifier corresponding to the determined message type in the memory of the network node as occupied if the message type determined by the determination module is the first message type and the PTP message carries an invalid timestamp, or if the determined message type is the second message type, wherein the PTP message is read out by the CPU core from the field programmable gate array FPGA chip in the network node; querying among all the sub-buffers in the cache area whether there is a first sub-buffer that caches the message sequence number of the PTP message and whose cache state is ready; when the query result is yes, first storing the PTP message and the read timestamp associated with the PTP message in a first designated storage space in the memory, and then storing the first sub-buffer in the cache. The PTP message carrying a valid timestamp cached in the area is stored in the first designated storage space to wait for processing, and the cache state of the first sub-buffer area is changed to an unused state, and the cache area is marked as an unoccupied state, wherein the third message type of the PTP message cached in the first sub-buffer area corresponds to the same sequence preservation identifier as the determined message type; when the query result is no, the PTP message and the read timestamp associated with the PTP message are stored in the first designated storage space to wait for processing, and the message sequence number and the cache timestamp when the message sequence number is cached are cached in a second sub-buffer area in the cache area whose cache state is an unused state, the cache state of the second sub-buffer area is changed to a waiting state, and the cache area is marked as an unoccupied state; A second processing module is configured to mark the cache area as occupied if the message type determined by the determination module is the third message type, wherein the PTP message is read by the CPU core from the network processor NP chip in the network node; query whether there is a third sub-cache area in all sub-cache areas in the cache area that caches the message sequence number and whose cache state is in a waiting state; when the query result is yes, store the PTP message in the first designated storage space to wait for processing, empty the third sub-cache area, change its cache state to an unused state, and mark the cache area as unoccupied; when the query result is no, cache the PTP message, the message sequence number, and the cache timestamp when caching the message sequence number in a fourth sub-cache area in the cache area whose cache state is unused, change the cache state of the fourth sub-cache area to a ready state, and mark the cache area as unoccupied; Wherein, when the first message type is a Sync message, the third message type is a Follow_Up message, or, When the first message type is a Pdelay_Resp message, the third message type is a terminal delayed response following a Pdelay_Resp_Follow_Up message; When the second message type is a delay request Delay_Req message, the third message type is a delay response Delay_Resp message; Furthermore, the first message type and the second message type correspond to different sequence preservation identifiers.

6. The device according to claim 5, characterized in that The device also includes: The third processing module is used to directly store the PTP message in the second designated storage space for processing when it is determined that the input port of the PTP message is not the port on the network node serving as the slave clock for time synchronization with the network node serving as the master clock.

7. The device according to claim 5, characterized in that The device also includes: The fourth processing module is used to, after the determination module determines the message type of the PTP message, if the determined message type is a Sync message or a Pdelay_Resp message and the PTP message carries a valid timestamp, or if the determined message type is an end delay request Pdelay_Req message, directly store the PTP message in the first designated storage space and wait for processing.

8. The device according to claim 5, characterized in that The device also includes: An aging processing module is used for, when a preset aging period arrives, for each cache area corresponding to the sequence preservation identifier, if the cache area is marked as occupied, no aging operation is performed, and when the cache area is marked as unoccupied, the step of marking the cache area as occupied is started; If the cache area is marked as unoccupied, the cache area is marked as occupied, and it is determined whether there is a sub-cache area in all sub-cache areas corresponding to the cache area whose cache state is waiting state or ready state, and the difference between the current timestamp and the cache timestamp of the cache is not less than the set threshold; when the judgment result is yes, the sub-cache area whose cache state is waiting state or ready state, and the difference between the current timestamp and the cache timestamp of the cache is not less than the set threshold is cleared, and its cache state is set to unused state, and the cache area is marked as unoccupied; when the judgment result is no, no aging operation is performed, and the cache area is marked as unoccupied.

Citation Information

Patent Citations

  • Time delay eliminating method and device for PTP data packet when converted between Ethernet and E1 protocol

    CN103684647A

  • Method for realizing IEEE1588 master clock

    CN103701581A

  • Airborne network IEEE1588 protocol master-slave clock port synchronization method

    CN105577349A

  • Clock synchronization method and device

    CN106533600A

  • Method and system for precise-clock synchronization, and device for precise-clock frequency / time synchronization

    US20100098111A1

Cited By

  • Method and a system for creating multi-port network synchronization bridge

    US12739045B2

  • Method and a system for creating multi-port network synchronization bridge

    US20250226904A1