A message processing method and network device

By receiving and diversion of PTP messages in network devices and dynamically selecting the target CPU for processing according to CPU idle situation, especially using parallel processing of multiple cores or multiple target CPUs for Announce messages, it solves the problem of not processing timely when the device CPU is busy. The time stability problems caused by PTP Announce packets have achieved more efficient PTP time synchronization.

CN115459872BActive Publication Date: 2025-02-11新华三技术有限公司合肥分公司
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210886341.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-26
Publication Date
2025-02-11
Estimated Expiration
2042-07-26

AI Technical Summary

Technical Problem

In a network environment, when the device CPU handles special events or is busy with services, it may fail to process PTP Announce packets in time for more than 375ms, resulting in 1588PTP clock source switching, time jumps, affecting the stability of the device time.

Method used

By receiving and obtaining PTP messages from them, they are diverted to the CPU specified by the administrator or the target CPU dynamically selected according to the CPU idle situation for processing. For Announce packets, a parallel processing method of multiple cores or multiple target CPUs is adopted to improve processing efficiency.

Benefits of technology

It effectively improves the stability of the PTP time of the device, avoids clock source switching and time jump problems caused by insufficient CPU resources or busyness, and improves the processing efficiency of PTP packets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115459872B_ABST
    Figure CN115459872B_ABST
Patent Text Reader

Abstract

The present specification provides a message processing method and a network device, the method comprising: receiving a target message, obtaining a PTP message from the target message, and shunting the PTP message to a target CPU so that the target CPU processes the PTP message. The method can improve the stability of the PTP time of the device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] NP: Network Processors

[0003] PTP: Precision Time Protocol high-precision time synchronization protocol

[0004] FDIR: Flow Director Flow Direction Technology

[0005] Cgroups: control groups

[0006] The 1588 protocol defines a precision time protocol PTP (Precision Time Protocol), which can achieve sub-microsecond synchronization of network environment devices. The PTP protocol stipulates master and slave devices. At the beginning, the master-slave relationship is established between the devices through the Announce message. After the relationship is established, in each subsequent time synchronization cycle (usually 1 second), the slave device interacts with the master device through the PTP protocol message, calculates the time difference, and performs time synchronization between the master and slave devices. At the same time, the master-slave relationship is maintained and updated between the slave device and the master device through the Announce message. When the slave device does not receive the previous Announce message from the master device, it will determine that the current master-slave relationship has changed and that the master device clock source is lost. The slave device will recalculate the master-slave relationship and re-establish the master-slave relationship to ensure the switching of the new clock source in the link.

[0007] In the 1588 design, the minimum sending cycle of the Announce message is 1 / 8 second, and the default receiving timeout interval is 3, that is, when the slave device does not receive the next Announce message for more than 375ms, it will re-elect and switch the clock source. When the CPU of a general device is processing some special events or busy business, it is easy to exceed the time limit. When the CPU processes the event for more than 375ms before processing the PTP Announce message, it will cause the 1588PTP clock source to switch, the clock state will change, the time will jump, and the stability of the device time will be affected. Summary of the invention

[0008] The embodiments of the present disclosure provide a message processing method and a network device, by which the stability of the PTP time of the device can be improved.

[0009] The present disclosure provides a method for processing a message, the method comprising:

[0010] Receive target message;

[0011] A PTP message is obtained from the target message, and the PTP message is shunted to a target CPU so that the target CPU processes the PTP message.

[0012] The target CPU is a CPU designated by an administrator, or the target CPU is an idle CPU selected by the system according to the idle status of each CPU at present.

[0013] Wherein, obtaining the PTP message from the target message includes:

[0014] The message header of the target message is obtained, and the PTP message is obtained according to the PTP message identifier carried in the message header.

[0015] Wherein, after the PTP message is shunted to the target CPU, the method further includes:

[0016] Determine whether the PTP message is an Announce message, and if it is an Announce message, send the PTP message to multiple cores of the target CPU or to some cores of multiple target CPUs for parallel processing;

[0017] If it is not an Announce message, the PTP message is sent to the target core in the target CPU for processing.

[0018] Wherein, the determining whether the PTP message is an Announce message includes:

[0019] The NP header of the PTP message is removed, and the message with the NP header removed is parsed to determine whether it is an Announce message based on the parsing result.

[0020] It can be seen from the above embodiments that the PTP message can be separated from other messages and sent to the target CPU for processing. The target CPU can be dynamically selected according to the resources of the CPU, so that the CPU can process the PTP message in time and improve the stability of the device PTP time.

[0021] The present disclosure also provides a network device, the network device comprising:

[0022] A receiving module, used for receiving a target message;

[0023] The processing module is used to obtain a PTP message from a target message, and to shunt the PTP message to a target CPU so that the target CPU processes the PTP message.

[0024] Wherein, the network device further includes: an acquisition module,

[0025] The acquisition module acquires the target CPU specified by the administrator, or,

[0026] The acquisition module is used to select an idle CPU as a target CPU according to the current idle status of each CPU.

[0027] The processing module is specifically used to obtain a message header of a target message, and obtain a PTP message according to a PTP message identifier carried in the message header.

[0028] Wherein, the processing module is further used to determine whether the PTP message belongs to an Announce message, and if it belongs to an Announce message, send the PTP message to multiple cores of the target CPU or to some cores of multiple target CPUs for parallel processing;

[0029] If it is not an Announce message, the PTP message is sent to the target core in the target CPU for processing.

[0030] The processing module is further used to remove the NP header of the PTP message, and parse the message with the NP header removed, and determine whether it is an Announce message according to the parsing result. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0032] Figure 1 A flowchart of a method for processing a message provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0033] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0034] The terms used in this specification are only for the purpose of describing specific embodiments and are not intended to limit this specification. The singular forms of "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in this article refers to and includes any or all possible combinations of one or more associated listed items.

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

[0036] In the present disclosure, a network device is a network device that supports the PTP function, such as a switch, a router, a server, a home / mobile wireless product, etc.

[0037] In order to solve the existing technical problems, the present disclosure provides a method for processing a message, such as Figure 1 As shown, the method includes:

[0038] S101 receives the target message;

[0039] S102 obtains a PTP message from the target message, and distributes the PTP message to the target CPU, so that the target CPU processes the PTP message.

[0040] In this embodiment, when receiving the target message, the NP encapsulates the PTP message with an NP message header of a fixed length according to the characteristics of the PTP message (for example, PTP port number 319, 320 and a specific PTP MAC address 01-80-C2-00-00-0E or 01-1B-19-00-00-00, etc.), and sets a PTP message identifier at a specified address in the message header. For non-PTP messages, other message tags are set in the message header of the message.

[0041] In step S102, when receiving the target message, the network card parses the NP message header of the target message through the Flow Director of the network card to determine whether there is a PTP message identifier, and if so, it is determined to be a PTP message.

[0042] At this point, the PTP message can be diverted to the target CPU for processing.

[0043] In one embodiment, the target CPU may be a CPU specified by an administrator. For example, the administrator identifies the target CPU through a control command.

[0044] In another embodiment, the target CPU can be dynamically selected by the system. The system can query the resource status of each CPU in the network device and select the CPU with the most resources as the target CPU. In this embodiment, due to the method of dynamically selecting the target CPU, it is possible to avoid the waste of resources caused by the fixed CPU not processing the PTP message. At the same time, it is also possible to avoid the situation where the fixed CPU is insufficient in resources and cannot process the PTP message in time.

[0045] In this embodiment, the above-mentioned diversion can become a first-level diversion, mainly diverting PTP messages and non-PTP messages. Since PTP messages currently mainly include two types, one is a timing-restricted PTP message. This type of message is affected by the previous and next timings. When the target CPU processes it, it needs to process it in the order of the PTP message; the other is an Announce message. The Announce message has no timing and time restrictions, so the Announce message can be processed in parallel. At this time, in step S102, when the PTP message is identified as an Announce message, the Announce message can be sent to multiple cores of the target CPU or to some cores of multiple target CPUs for parallel processing, thereby effectively improving the processing efficiency of the PTP message.

[0046] In this embodiment, the secondary shunting mainly divides PTP into two categories, Announce messages and other timing messages, according to the timing requirements, and performs different shunting schemes according to these two types of messages. By using different target CPUs to separately process PTP messages and Announce messages that may take a long time, the effect of no packet loss of Announce messages is achieved.

[0047] In one example, after removing the NP header, the network device parses the PTP message type according to the message format of different network types. If it is an Announce message, it is written into queue 1; if it is another type of message, it is written into queue 2.

[0048] Among them, queue 1 is processed in parallel by multiple target CPUs, and queue 2 is processed by a certain target CPU.

[0049] In this embodiment, the processing mechanisms of different types of PTP messages are also listed. This part of the processing uses the load balancing processing of the multi-core CPU and the allocation mechanism of the CPU scheduler to achieve the goal of sending PTP messages in real time. The two parts of processing are as follows:

[0050] 1.Announce message processing module

[0051] The implementation mechanism of this module mainly includes an Announce message queue, message processing tasks on 3 (or more) different CPUs, and a queue lock.

[0052] First, a task is started on each of the three CPUs to read queue 1. When queue 1 is empty, the task goes to sleep to free the CPU to handle other business.

[0053] When CPU1 writes the PTP Announce message to queue 1, it wakes up tasks on all CPUs. When reading queue 1, the task will first obtain the concurrent lock. The initial state of the lock is unlocked. When the first task obtains the lock, it finds that the lock state is unlocked, so it marks the lock as locked and reads the message of queue 1. After the reading process is completed, the lock state is restored to unlocked. When reading queue 1, the tasks on other CPUs also first obtain the concurrent lock. When the concurrent lock is locked, they enter sleep and let the CPU process other tasks. If the lock becomes unlocked, they also mark the lock as locked and read the message of queue 1. After the reading process is completed, the lock state is restored to unlocked. In this way, as long as one of the multiple CPUs is idle, it can process the Announce message, avoiding the problem that a single CPU cannot process the Announce message in time when it is occupied by other tasks. At the same time, multiple CPUs process in parallel, which improves the processing speed and efficiency of PTP messages.

[0054] 2. Other PTP message processing modules

[0055] Other PTP message processing modules cannot be processed in parallel by multiple CPUs due to timing requirements. Through CGROUP settings, the PTP message processing tasks are bound to multiple CPUs at the beginning. When there is a message written to queue 2, the kernel directly schedules the message processing task to an idle CPU for processing, preventing the problem that a single CPU is temporarily unable to process due to being occupied by other tasks.

[0056] It can be seen from the above embodiments that by identifying the PTP message, the PTP message can be sent to the target CPU for processing, thereby avoiding the inability to process the PTP message in time due to insufficient CPU resources. At the same time, in the present disclosure, the PTP message belonging to the Announce message can be sent to multiple target CPUs (multiple cores) for parallel processing, thereby improving the processing efficiency of the PTP message.

[0057] Based on the above method embodiment, the present disclosure further provides a network device, which includes:

[0058] A receiving module, used for receiving a target message;

[0059] The processing module is used to obtain a PTP message from a target message, and to shunt the PTP message to a target CPU so that the target CPU processes the PTP message.

[0060] Wherein, the network device further includes: an acquisition module,

[0061] The acquisition module acquires the target CPU specified by the administrator, or,

[0062] The acquisition module is used to select an idle CPU as a target CPU according to the current idle status of each CPU.

[0063] The processing module is specifically used to obtain the message header of the target message, and obtain the PTP message according to the PTP message identifier carried in the message header.

[0064] The processing module is further configured to determine whether the PTP message is an Announce message, and if so, to send the PTP message to multiple cores of a target CPU or to some cores of multiple target CPUs for parallel processing;

[0065] If it is not an Announce message, the PTP message is sent to the target core in the target CPU for processing.

[0066] The processing module is further used to remove the NP header of the PTP message, and parse the message with the NP header removed, and determine whether it is an Announce message according to the parsing result.

[0067] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0068] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0069] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

[0070] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.

Claims

1. A method for processing a message, characterized in that: The method comprises: Receive target message; Acquire a PTP message from a target message, and shunt the PTP message to a target CPU so that the target CPU processes the PTP message; The target CPU is a CPU specified by an administrator, or the target CPU is an idle CPU selected by the system as the target CPU according to the idle status of each CPU at present; Wherein, after the PTP message is shunted to the target CPU, the method further includes: Determine whether the PTP message is an Announce message, and if it is an Announce message, send the PTP message to multiple cores of the target CPU or to some cores of multiple target CPUs for parallel processing; If it is not an Announce message, the PTP message is sent to the target core in the target CPU for processing.

2. The method according to claim 1, characterized in that The obtaining of the PTP message from the target message includes: The message header of the target message is obtained, and the PTP message is obtained according to the PTP message identifier carried in the message header.

3. The method according to claim 1, characterized in that The determining whether the PTP message is an Announce message includes: The NP header of the PTP message is removed, and the message with the NP header removed is parsed to determine whether it is an Announce message based on the parsing result.

4. A network device, characterized in that: The network equipment includes: A receiving module, used for receiving a target message; A processing module, used for obtaining a PTP message from a target message, and shunting the PTP message to a target CPU so that the target CPU processes the PTP message; Wherein, the network device further includes: an acquisition module, The acquisition module acquires the target CPU specified by the administrator, or, The acquisition module is used to select an idle CPU as a target CPU according to the current idle status of each CPU; Wherein, the processing module is further used to determine whether the PTP message belongs to an Announce message, and if it belongs to an Announce message, send the PTP message to multiple cores of the target CPU or to some cores of multiple target CPUs for parallel processing; If it is not an Announce message, the PTP message is sent to the target core in the target CPU for processing.

5. The network device according to claim 4, characterized in that: The processing module is specifically used to obtain the message header of the target message, and obtain the PTP message according to the PTP message identifier carried in the message header.

6. The network device according to claim 4, characterized in that: The processing module is further used to remove the NP header of the PTP message, and parse the message with the NP header removed, and determine whether it is an Announce message according to the parsing result.

Citation Information

Patent Citations

  • Message forwarding method and device under numa architecture, storage medium and electronic equipment

    CN108363621A