Packet loss statistics methods, devices, network equipment, storage media and software products

By setting high and low priority hardware ACL entries on the switching chip, the total number of packets reported by the switching chip to the CPU and the total number of packets processed by the CPU are statistically analyzed based on protocol type characteristics. The difference is calculated to solve the problem of inaccurate packet loss statistics in the CPU queue of the switching chip, achieving higher accuracy and lower operation and maintenance costs.

CN119341946BActive Publication Date: 2025-10-28MAIPU COMM TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411501882.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-10-28
Estimated Expiration
2044-10-25

AI Technical Summary

Technical Problem

Existing technologies cannot accurately count packet loss of different protocol messages in the CPU queue of the switching chip, resulting in high maintenance costs and an inability to quickly pinpoint which specific protocol is experiencing packet loss.

Method used

By setting high-priority and low-priority hardware ACL entries on the switching chip, packets are marked according to protocol type characteristics. The total number of packets reported by the switching chip to the CPU and the total number of packets processed by the CPU are counted, and the difference is calculated to obtain the number of packet losses for specific protocol packets.

Benefits of technology

It improves the accuracy of packet loss statistics, reduces the operation and maintenance costs of network equipment, and enhances the ease of use of network equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119341946B_ABST
    Figure CN119341946B_ABST
Patent Text Reader

Abstract

This invention proposes a packet loss statistics method, apparatus, network device, storage medium, and program product, relating to the field of data communication. The method obtains the protocol type characteristics of the protocol message to be queried; based on the protocol type characteristics, it obtains the corresponding total hardware statistics and total software statistics; the total hardware statistics are the total number of messages reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics are the total number of messages processed by the CPU based on the protocol type characteristics; the difference between the total hardware statistics and the total software statistics is calculated to obtain the total number of lost packets for the protocol message to be queried. This invention, based on protocol type characteristics, statistically analyzes the total number of messages reported to the CPU by the switching chip and the total number of messages processed by the CPU. By accurately obtaining the total number of lost packets for various protocol messages based on these total numbers, it effectively improves the accuracy of packet loss statistics and reduces network device operation and maintenance costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data communication, and more specifically, to a packet loss statistics method, apparatus, network device, storage medium, and program product. Background Technology

[0002] In a switch architecture, it typically consists of a switching chip and a CPU (processor). The switching chip is responsible for forwarding data packets, while the CPU is responsible for management and control. Packets that the switching chip cannot process need to be handed over to the CPU for processing. These include Layer 2 protocol packets such as BPDU (Bridge Protocol Data Unit), GVRP (GARP VLAN Registration Protocol), and ARP (Address Resolution Protocol); Layer 3 protocol packets such as RIP (Routing Information Protocol), PIM (Protocol Independent Multicast), OSPF (Open Shortest Path First), VRRP (Virtual Router Redundancy Protocol), IGMP (Internet Group Management Protocol), and ICMP (Internet Control Message Protocol); and data packets such as unknown unicast IP (Internet Protocol) packets, unknown multicast packets, RPF (Reverse Path Forwarding) failure packets, and various error packets. There are many ways for switching chips to send protocol messages to the CPU, such as PDU (Protocol Data Unit) control tables, Layer 2 forwarding tables, ACL (Access Control List) and other hardware table entries. Among them, the ACL method is the most widely used and the most flexible and convenient method, and it is frequently used in actual projects.

[0003] Meanwhile, some attackers often exploit the data flow forwarding principles and protocol vulnerabilities of switches. When an attack succeeds, a large number of useless or malicious packets will be sent to the CPU for processing. Due to excessive CPU utilization, the CPU cannot perform normal tasks or process normal packets. These tasks are suspended for extended periods, and packets are blocked, which can paralyze the switch, leading to network instability or even outages. Of course, normal protocol packets may also be sent to the CPU excessively due to broadcast storms or other reasons, causing the CPU to receive too many packets to process and affecting the normal operation of other programs.

[0004] To prevent the control plane of the device from being impacted and causing the CPU to be unable to process normal tasks and protocol messages, it is necessary to assign different CPU queues to each type of protocol message according to its different priority levels, and to set rate limits for each CPU queue. Attacking protocol messages can be reconfigured to low-priority queues and rate-limited, while protocols that need protection can be configured to high-priority queues to prevent critical high-priority protocols from being unable to be processed by the CPU, thus preventing network paralysis.

[0005] To ensure that the CPU processes as many protocol messages as possible within its capabilities without overloading it, message rate limiting is implemented based on the CPU port, limiting the total number of messages processed by the CPU per unit time, thus ensuring stable operation of the protocol function.

[0006] When the actual protocol message transmission rate to the CPU exceeds the CPU queue or CPU port rate limit, the switching chip will cause packet loss based on the CPU queue scheduling rate limit. Typically, during equipment maintenance, it is necessary to check which specific protocol message caused the CPU queue rate limit packet loss in order to analyze the environmental traffic situation. Therefore, packet loss statistics need to be performed based on the protocol message type.

[0007] The industry practice is to divide different types of protocol messages into different CPU queues. This way, by obtaining the packet loss statistics of a certain CPU queue of the switching chip, the packet loss statistics of the corresponding protocol message can be obtained. However, the number of CPU queue hardware resources of the switching chip is limited. If multiple protocol messages are sent through the same CPU queue and packet loss occurs in that CPU queue, it is not possible to directly distinguish which protocol message was dropped from the packet loss statistics of the switching chip's CPU queue. It can only be generally shown as the same type of drop.

[0008] Current communication networks support a wide variety of protocol message types, while the CPU queue resources of switching chips are very limited. This inevitably leads to situations where multiple protocol messages are sent to the CPU through the same CPU queue, resulting in rate-limited packet loss. Currently, there is no highly effective solution to accurately analyze packet loss based on various protocol types using a single technical mechanism. It also fails to quickly pinpoint which specific protocol is experiencing packet loss, resulting in high operational costs. Summary of the Invention

[0009] In view of this, the purpose of the present invention is to provide a packet loss statistics method, apparatus, network device, storage medium and program product, which can improve the accuracy of packet loss statistics and effectively reduce the operation and maintenance costs of network devices.

[0010] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows:

[0011] In a first aspect, the present invention provides a packet loss statistics method applied to a network device, the network device including a CPU and a switching chip, the method comprising:

[0012] Receive packet loss query instructions and obtain the protocol type characteristics of the protocol message to be queried;

[0013] Based on the protocol type characteristics, obtain the corresponding total hardware statistics and total software statistics; the total hardware statistics are the total number of packets reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics are the total number of packets processed by the CPU based on the protocol type characteristics.

[0014] The difference between the total hardware statistics and the total software statistics is calculated to obtain the total number of lost packets in the protocol message to be queried.

[0015] In an optional implementation, the switching chip is provided with a hardware ACL table, which includes a first hardware ACL entry and a second hardware ACL entry that match the protocol type characteristics. The first hardware ACL entry has a higher priority than the second hardware ACL entry. The step of obtaining the corresponding total hardware statistics and total software statistics based on the protocol type characteristics includes:

[0016] When the status of the first hardware ACL entry is determined to be valid based on the protocol type characteristics, the first hardware ACL entry is unloaded.

[0017] Obtain the current hardware statistics value corresponding to the first hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after hitting the first hardware ACL entry;

[0018] Obtain the last hardware statistics value of the protocol message to be queried that hit the second hardware ACL entry, and obtain the last software statistics value of the protocol message to be queried that was processed by the CPU after hitting the second hardware ACL entry.

[0019] The sum of the current hardware statistics value and the previous hardware statistics value is determined as the total hardware statistics value;

[0020] The sum of the current software statistics value and the previous software statistics value is determined as the total software statistics value.

[0021] In an optional implementation, the first hardware ACL entry and the second hardware ACL entry are used to mark protocol packets with the protocol type characteristics with the corresponding packet tags and then send them to the CPU; the step of obtaining the current hardware statistics value corresponding to the first hardware ACL entry, and obtaining the current software statistics value of the queried protocol packet processed by the CPU after hitting the first hardware ACL entry and reported to the CPU for processing, includes:

[0022] The current hardware statistics value is obtained by retrieving the value of the counter in the first hardware ACL entry.

[0023] When the CPU starts processing the queried protocol message with the message tag corresponding to the second hardware ACL entry, the current software statistical value is obtained by acquiring the statistical data of the queried protocol message with the message tag corresponding to the first hardware ACL entry after processing by the CPU.

[0024] In an optional implementation, the method further includes:

[0025] After obtaining the total number of lost packets of the protocol message to be queried, the current hardware statistics value is saved as the previous hardware statistics value when the protocol message to be queried hits the first hardware ACL entry; the current software statistics value is used as the previous software statistics value of the protocol message to be queried that was processed by the CPU after hitting the first hardware ACL entry.

[0026] In an optional implementation, the method further includes:

[0027] Receive the packet loss query instruction again for the protocol message to be queried;

[0028] Based on the protocol type characteristics, reinstall the first hardware ACL entry to make it effective;

[0029] Obtain the current hardware statistics value corresponding to the second hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after the second hardware ACL entry is hit;

[0030] Obtain the last hardware statistics value of the protocol message to be queried that hit the first hardware ACL entry, and obtain the last software statistics value of the protocol message to be queried that was processed by the CPU after hitting the first hardware ACL entry.

[0031] The sum of the newly acquired hardware statistics value and the newly acquired hardware statistics value from the previous period is determined as the new total hardware statistics value.

[0032] The sum of the newly acquired current software statistics value and the newly acquired previous software statistics value is determined as the new total software statistics value;

[0033] The difference between the new total hardware statistics and the new total software statistics is calculated to obtain the latest total number of lost packets for the protocol message to be queried.

[0034] In an optional implementation, the switching chip is provided with a hardware ACL table, which includes a first hardware ACL entry and a second hardware ACL entry that match the protocol type characteristics. The first hardware ACL entry has a higher priority than the second hardware ACL entry. The step of obtaining the corresponding total hardware statistics and total software statistics based on the protocol type characteristics includes:

[0035] When the status of the first hardware ACL entry is determined to be invalid based on the protocol type characteristics, the first hardware ACL entry is reinstalled to make it effective.

[0036] Obtain the current hardware statistics value corresponding to the second hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after the second hardware ACL entry is hit;

[0037] Obtain the last hardware statistics value of the protocol message to be queried that hit the first hardware ACL entry, and obtain the last software statistics value of the protocol message to be queried that was processed by the CPU after hitting the first hardware ACL entry.

[0038] The sum of the current hardware statistics value and the previous hardware statistics value is determined as the total hardware statistics value;

[0039] The sum of the current software statistics value and the previous software statistics value is determined as the total software statistics value.

[0040] In a second aspect, the present invention provides a packet loss statistics device applied to a network device, the network device including a CPU and a switching chip, the device comprising:

[0041] The processing module is used to receive packet loss query instructions and obtain the protocol type characteristics of the protocol message to be queried;

[0042] The statistics module is used to obtain the corresponding total hardware statistics and total software statistics based on the protocol type characteristics; the total hardware statistics are the total number of packets reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics are the total number of packets processed by the CPU based on the protocol type characteristics.

[0043] The calculation module is used to calculate the difference between the total hardware statistics and the total software statistics to obtain the total number of lost packets of the protocol message to be queried.

[0044] Thirdly, the present invention provides a network device including a switching chip, a processor, and a memory. The switching chip reports the total number of packets to the processor based on protocol type characteristics. The memory stores machine-executable instructions that can be executed by the processor. The processor can execute the machine-executable instructions to implement the packet loss statistics method described in any of the foregoing embodiments.

[0045] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the packet loss statistics method as described in any of the foregoing embodiments.

[0046] Fifthly, the present invention provides a program product that, when executed by a processor, implements the packet loss statistics method as described in any of the foregoing embodiments.

[0047] The packet loss statistics method, apparatus, network device, storage medium, and program product provided in this invention embodiment are based on protocol type characteristics to count the total number of packets reported by the switching chip to the CPU and the total number of packets that have been reported to the CPU for processing. Based on the total number of packets reported by the switching chip to the CPU and the total number of packets processed by the CPU, the total number of packet losses corresponding to various protocol packets can be accurately obtained, which effectively improves the accuracy of packet loss statistics, reduces the operation and maintenance cost of network devices, and enhances the usability of network devices.

[0048] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.

[0050] Figure 1 A flowchart illustrating a packet loss statistics method provided in an embodiment of the present invention is shown.

[0051] Figure 2 This diagram illustrates another flowchart of the packet loss statistics method provided in an embodiment of the present invention.

[0052] Figure 3 This diagram illustrates another flowchart of the packet loss statistics method provided in an embodiment of the present invention.

[0053] Figure 4 This diagram illustrates another flowchart of the packet loss statistics method provided in an embodiment of the present invention.

[0054] Figure 5 This diagram illustrates another flowchart of the packet loss statistics method provided in an embodiment of the present invention.

[0055] Figure 6 A block diagram of a packet loss statistics device provided in an embodiment of the present invention is shown.

[0056] Figure 7 A block diagram of a network device provided in an embodiment of the present invention is shown.

[0057] Icons: 200 - Network device; 210 - Switching chip; 220 - Processor; 230 - Memory; 300 - Packet loss statistics device; 301 - Processing module; 302 - Statistics module; 303 - Calculation module. Detailed Implementation

[0058] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0059] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0060] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0061] As the core chip of network equipment, the switching chip is mainly used to process and forward data packets. The switching chip reports packets it cannot process to the CPU for processing. The industry practice is to divide different types of protocol packets into different CPU queues, allowing for packet loss statistics based on CPU queues. However, due to the limited number of CPU queue resources on the switching chip, it's impossible to guarantee a one-to-one correspondence between each protocol packet and a CPU queue. This can result in a single CPU queue containing packets of multiple protocol types, making accurate packet loss statistics impossible for each protocol packet.

[0062] Based on this, embodiments of the present invention provide a packet loss statistics method and apparatus, which counts the total number of packets reported by the switching chip to the CPU and the total number of packets that have been reported to the CPU and processed based on protocol type characteristics. According to the total number of packets reported by the switching chip to the CPU and the total number of packets that have been reported to the CPU and processed, the total number of packet losses corresponding to various protocol packets can be accurately obtained, which effectively improves the accuracy of packet loss statistics, reduces network equipment operation and maintenance costs, and enhances the usability of network equipment.

[0063] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0064] Please refer to Figure 1 , Figure 1 This diagram illustrates a flowchart of a packet loss statistics method provided by an embodiment of the present invention. The method is applied to a network device, which includes a CPU and a switching chip, and the switching chip and CPU are connected via a network. The method includes the following steps:

[0065] Step S10: Receive packet loss query instruction and obtain the protocol type characteristics of the protocol message to be queried.

[0066] In this embodiment of the invention, when a user views packet loss statistics by specifying the type of protocol message through a CPU management command, the CPU obtains the type of protocol message from the packet loss query instruction and retrieves the corresponding protocol type characteristics based on the type of protocol message. When a user views packet loss statistics by not specifying the type of protocol message through a CPU management command, the CPU obtains all types of protocol messages supported by the network device and queries the packet loss situation based on all types of protocol messages.

[0067] Step S20: Based on the protocol type characteristics, obtain the corresponding total hardware statistics and total software statistics; the total hardware statistics are the total number of packets reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics are the total number of packets processed by the CPU based on the protocol type characteristics.

[0068] In this embodiment of the invention, the switching chip counts the total number of packets reported to the CPU for each protocol type feature, i.e., the total hardware statistics. The CPU counts the total number of packets for each processed packet feature through software, i.e., the total software statistics. When a user views packet loss statistics, the CPU sequentially obtains the total hardware statistics and total software statistics corresponding to the protocol type feature of the packet to be queried.

[0069] Step S30: Calculate the difference between the total hardware statistics and the total software statistics to obtain the total number of lost packets in the protocol messages to be queried.

[0070] In this embodiment of the invention, the CPU calculates the difference between the total hardware statistics and the total software statistics corresponding to the protocol message to be queried, and obtains the number of lost messages of the protocol message to be queried. That is, the difference between the total number of messages reported to the CPU by the switching chip and the total number of messages processed by the CPU is the number of lost messages of the protocol message to be queried in the process of reporting from the switching chip to the CPU.

[0071] In summary, the packet loss statistics method provided in this embodiment of the invention is applied to a network device, which includes a CPU and a switching chip. The method involves receiving a packet loss query command and obtaining the protocol type characteristics of the protocol message to be queried; based on the protocol type characteristics, obtaining the corresponding total hardware statistics and total software statistics; the total hardware statistics are the total number of messages reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics are the total number of messages processed by the CPU based on the protocol type characteristics; and the difference between the total hardware statistics and the total software statistics is calculated to obtain the total number of lost packets of the protocol message to be queried.

[0072] As can be seen, this invention statistically analyzes the total number of packets reported by the switching chip to the CPU and the total number of packets processed by the CPU based on protocol type characteristics. By accurately obtaining the total number of packet losses corresponding to various protocol packets based on the total number of packets reported by the switching chip to the CPU and the total number of packets reported to the CPU and processed, the accuracy of packet loss statistics can be effectively improved, the network equipment operation and maintenance costs can be reduced, and the ease of use of network equipment can be enhanced.

[0073] In this embodiment of the invention, a hardware ACL table is provided on the switching chip. The hardware ACL table includes a first hardware ACL entry and a second hardware ACL entry that match the protocol type characteristics. The first hardware ACL entry has a higher priority than the second hardware ACL entry. That is, relatively speaking, the first hardware ACL entry is a high-priority hardware ACL entry, and the second hardware ACL entry is a low-priority hardware ACL entry.

[0074] After receiving a message to be processed, the switching chip searches the hardware ACL table based on the protocol type characteristics of the message. If the status of the first hardware ACL entry with high priority is valid, the message to be processed will hit the first hardware ACL entry. The hardware statistics value in the counter corresponding to the first hardware ACL entry will increase, and the message to be processed will be reported to the CPU based on the first hardware ACL entry. The CPU processes the reported messages that have hit the first hardware ACL entry and updates the corresponding software statistics value.

[0075] When the switching chip receives a message to be processed, if the first hardware ACL entry is invalid, the message will hit a lower-priority second hardware ACL entry. The hardware statistics value in the counter corresponding to the second hardware ACL entry will increase, and the message to be processed will be reported to the CPU based on the matching second hardware ACL entry. The CPU processes the message to be processed reported after hitting the second hardware ACL entry and updates the corresponding software statistics value.

[0076] Optionally, when processing packet loss query commands, the following is a possible implementation method for obtaining total hardware and software statistics using hardware ACL tables. Please refer to... Figure 2 , Figure 1 The sub-steps of step S20 may include:

[0077] Step S200: If the status of the first hardware ACL entry is determined to be valid based on the protocol type characteristics, the first hardware ACL entry is unloaded.

[0078] In this embodiment of the invention, the protocol type feature of the protocol message to be queried is taken as the target protocol type feature. When the status of the first hardware ACL entry corresponding to the target protocol type feature is valid, it indicates that the first hardware ACL entry corresponding to the target protocol type feature is already in the loading state. The first hardware ACL entry corresponding to the target protocol type feature is unloaded so that the status of the first hardware ACL entry corresponding to the target protocol type feature changes from valid to invalid, thereby allowing the protocol message of the target protocol type feature to hit the low-priority second hardware ACL entry.

[0079] When the status of the first hardware ACL entry with high priority corresponding to the target protocol type feature becomes invalid, the switching chip will hit the second hardware ACL entry with low priority based on the target protocol type feature and report the protocol message corresponding to the target protocol type feature to the CPU.

[0080] Step S201: Obtain the current hardware statistics value corresponding to the first hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after hitting the first hardware ACL entry.

[0081] In this embodiment of the invention, when a packet loss query command is received, if the status of the first hardware ACL entry is valid, the hardware statistics value corresponding to the first hardware ACL entry can be obtained, i.e., the current hardware statistics value. The current software statistics value can be obtained by statistically analyzing the pending protocol packets that have been reported to the CPU and processed after the first hardware ACL entry was hit.

[0082] Step S202: Obtain the last hardware statistics value of the queried protocol message that hit the second hardware ACL entry, and obtain the last software statistics value of the queried protocol message that was processed by the CPU after hitting the second hardware ACL entry.

[0083] In this embodiment of the invention, the total number of lost packets of the protocol message to be queried is obtained based on the total number of protocol messages to be queried reported to the CPU by the alternating activation of the first hardware ACL entry and the second hardware ACL entry. When this packet loss query instruction is the first query, the previous hardware statistics value and the previous software statistics value are both initial values, for example, the default initial value is set to 0. Generally, initially, both the high-priority first hardware ACL entry and the low-priority second hardware ACL entry are loaded. At this time, the protocol message to be queried will only hit the high-priority first hardware ACL entry; only when the high-priority first hardware ACL entry is unloaded (in an invalid state) will the protocol message to be queried hit the low-priority second hardware ACL entry.

[0084] When this packet loss query command is not the first query and the status of the first hardware ACL entry is valid, it will generate the previous hardware statistics value corresponding to the second hardware ACL entry that is reported to the CPU, and generate the previous software statistics value corresponding to the query protocol message that is reported to the CPU and is processed by the CPU.

[0085] Step S203: The sum of the current hardware statistics value and the previous hardware statistics value is determined as the total hardware statistics value.

[0086] Step S204: The sum of the current software statistics value and the previous software statistics value is determined as the total software statistics value.

[0087] In this embodiment of the invention, the total number of packets corresponding to the query protocol messages reported by the switching chip to the CPU is recorded using both the current hardware statistics and the previous hardware statistics. The total hardware statistics can be obtained by summing the current and previous hardware statistics. Similarly, the total number of packets corresponding to the query protocol messages processed by the CPU is recorded using both the current and previous software statistics. The total software statistics can be obtained by summing the current and previous software statistics.

[0088] Optionally, in practical applications, the first and second hardware ACL entries are used to tag protocol packets with matching protocol type characteristics and then report them to the CPU. Regarding how to utilize packet tags to obtain the current software statistics, a possible implementation method is provided below. Figure 2 The sub-steps of step S201 may include:

[0089] The hardware statistics value is obtained by retrieving the counter value of the first hardware ACL entry; when the CPU starts processing the queried protocol message with the message tag corresponding to the second hardware ACL entry, the software statistics value is obtained by retrieving the queried protocol messages with the message tag corresponding to the first hardware ACL entry that have been reported to the CPU for processing.

[0090] In this embodiment of the invention, a corresponding counter is set on the switching chip for each hardware ACL entry. The counter for each hardware ACL entry is used to count the hardware statistics corresponding to the protocol messages that hit the hardware ACL entry.

[0091] After receiving a protocol message, the switching chip searches the hardware ACL table based on the protocol type characteristics of the message. When the status of the first hardware ACL entry with high priority is valid, the protocol message matches the first hardware ACL entry. The hardware statistics value of the counter corresponding to the first hardware ACL entry is increased, and the protocol message is tagged with the message tag corresponding to the first hardware ACL entry and then reported to the CPU queue.

[0092] When the first hardware ACL entry is invalid, the protocol message matches the second hardware ACL entry. The hardware statistics value of the counter corresponding to the lower priority second hardware ACL entry increases, and the protocol message is tagged with the message tag corresponding to the second hardware ACL entry and then reported to the CPU queue.

[0093] According to the queue scheduling mechanism, when scheduling and processing protocol messages in the CPU queue, the protocol message is retrieved from the CPU queue, the corresponding software statistics value is updated according to the message tag of the protocol message, and the retrieved protocol message is processed.

[0094] In this embodiment of the invention, when the total number of lost packets of the protocol message to be queried is counted and the status of the high-priority first hardware entry is valid, the counter of the first hardware ACL entry is read to obtain the current hardware statistical value. Then, when processing of the protocol message to be queried in the CPU queue that has the packet tag corresponding to the second hardware ACL entry is started, the software statistical value of the protocol message to be queried that has been reported to the CPU for processing and has the packet tag corresponding to the first hardware ACL entry is obtained to obtain the current software statistical value.

[0095] As one possible implementation, assuming the packet marker corresponding to the high-priority first hardware ACL entry is 1, and the packet marker corresponding to the low-priority second hardware ACL entry is 2, when a query protocol packet is retrieved from the CPU queue for processing, if the retrieved query protocol packet has a packet marker of 1, the software statistics value corresponding to packet marker 1 is updated. If the retrieved query protocol packet has a packet marker of 2, it indicates that the query protocol packet with packet marker 1 has already been reported to the CPU, and the software statistics value corresponding to packet marker 1 will no longer be updated. Subsequent processing of query protocol packets with packet marker 2 in the CPU queue will include them in the software statistics value corresponding to packet marker 2.

[0096] Optionally, in order to accurately count the total number of lost packets in the protocol messages to be queried, the method further includes the following steps:

[0097] After obtaining the total number of lost packets in the protocol messages to be queried, the current hardware statistics value is saved as the previous hardware statistics value when the protocol messages to be queried hit the first hardware ACL entry; the current software statistics value is reported as the previous software statistics value after CPU processing for the protocol messages to be queried that hit the first hardware ACL entry.

[0098] In this embodiment of the invention, the software saves the previous hardware statistics value of each hardware ACL entry and the previous software statistics value corresponding to the queried protocol message with the message tag. Specifically, the previous hardware statistics value of the queried protocol message hitting the first hardware ACL entry is the counter value corresponding to the time the queried protocol message hits the first hardware ACL entry. When retrieving a queried protocol message carrying the message tag corresponding to the second hardware ACL entry from the CPU queue, the current software statistics value corresponding to the queried protocol message carrying the message tag corresponding to the first hardware ACL entry is saved as the previous software statistics value corresponding to the queried protocol message tag, for use in the next query of packet loss.

[0099] Optionally, when a user initiates a packet loss query command for the protocol message to be queried again, how to count the total number of lost packets for the protocol message to be queried is provided below. Please refer to... Figure 3 The method also includes the following steps:

[0100] Step S40: Receive a packet loss query command again for obtaining the protocol message to be queried.

[0101] Step S50: Based on the protocol type characteristics, reinstall the first hardware ACL entry to make it effective.

[0102] In this embodiment of the invention, after receiving a packet loss query instruction for a protocol message to be queried, the first hardware ACL entry, which is currently valid, is unloaded. Protocol messages reported to the CPU after the first hardware ACL entry is unloaded will hit the second hardware ACL entry, thus increasing the counter value corresponding to the second hardware ACL entry. When a packet loss query instruction for a protocol message to be queried is received again, the protocol type characteristic of the protocol message to be queried is obtained, and the first hardware ACL entry corresponding to the protocol type characteristic is reinstalled, making the first hardware ACL entry valid. Protocol messages reported to the CPU will then hit the first hardware ACL entry, thus increasing the counter value corresponding to the first hardware ACL entry.

[0103] Step S60: Obtain the current hardware statistics value corresponding to the second hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after hitting the second hardware ACL entry.

[0104] In this embodiment of the invention, the value of the counter for the second hardware ACL entry corresponding to the protocol type feature is obtained to obtain a new hardware statistical value for the current operation. When the CPU starts processing a queried protocol packet with a packet tag corresponding to the first hardware ACL entry, the software statistical values ​​of the queried protocol packets with packet tags corresponding to the second hardware ACL entry that have been reported to the CPU for processing are obtained to obtain a new software statistical value for the current operation.

[0105] Step S70: Obtain the last hardware statistics value of the queried protocol message that hit the first hardware ACL entry, and obtain the last software statistics value of the queried protocol message that was processed by the CPU after hitting the first hardware ACL entry.

[0106] Step S80: The sum of the newly acquired hardware statistics value and the newly acquired previous hardware statistics value is determined as the new total hardware statistics value.

[0107] Step S90: The sum of the newly acquired current software statistics value and the newly acquired previous software statistics value is determined as the new total software statistics value.

[0108] Step S100: Calculate the difference between the new total hardware statistics and the new total software statistics to obtain the latest total number of lost packets for the protocol messages to be queried.

[0109] In this embodiment of the invention, new previous hardware statistics and new previous software statistics are obtained based on the packet tag corresponding to the first hardware ACL entry matched by the protocol packet to be queried. The sum of the new current hardware statistics and the new previous hardware statistics is calculated to obtain a new total hardware statistics value. Similarly, the sum of the new current software statistics and the new previous software statistics is calculated to obtain a new total software statistics value. The latest total packet loss count of the protocol packet to be queried is obtained based on the difference between the new total hardware statistics value and the new software statistics value.

[0110] After obtaining the latest total number of lost packets for the protocol message to be queried, the new hardware statistics value is saved as the previous hardware statistics value for the protocol message to be queried that hit the second hardware ACL entry. The new software statistics value is used as the previous software statistics value for the protocol message to be queried that was reported to the CPU after hitting the second hardware ACL entry, that is, the previous software statistics value for the protocol message to be queried that has the packet tag corresponding to the second hardware ACL entry.

[0111] Alternatively, when processing packet loss query commands, another possible implementation method is provided below for how to utilize the hardware ACL table to obtain the total hardware statistics and total software statistics. Please refer to... Figure 4 , Figure 1 The sub-steps of step S20 may include:

[0112] Step S205: If the status of the first hardware ACL entry is determined to be invalid based on the protocol type characteristics, reinstall the first hardware ACL entry to make it effective.

[0113] In this embodiment of the invention, when the status of the first hardware ACL entry corresponding to the protocol type feature is invalid, it indicates that the first hardware ACL entry corresponding to the protocol type feature has been uninstalled. The first hardware ACL entry corresponding to the protocol type feature is then reinstalled to make it effective. In other words, the status of the first hardware ACL entry corresponding to the protocol type feature is updated to valid.

[0114] Step S206: Obtain the current hardware statistics value corresponding to the second hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after hitting the second hardware ACL entry.

[0115] In this embodiment of the invention, when the first hardware ACL entry matching the protocol type characteristics is in an unloaded state, the counter of the second hardware ACL entry matching the protocol type characteristics is used to count the total number of pending protocol messages reported to the CPU. The value of the counter for the second hardware ACL entry is obtained to obtain the current hardware statistical value, and the current software statistical value is obtained according to the message tag corresponding to the second hardware ACL entry. Simultaneously, the current hardware statistical value is used as the previous hardware statistical value corresponding to the pending protocol message hitting the second hardware ACL entry. The current software statistical value is used as the previous software statistical value of the pending protocol message that has been reported to the CPU for processing after hitting the second hardware ACL entry, i.e., the previous software statistical value of the pending protocol message that has been reported to the CPU for processing after hitting the second hardware ACL entry.

[0116] Step S207: Obtain the last hardware statistics value of the queried protocol message that hit the first hardware ACL entry, and obtain the last software statistics value of the queried protocol message that was processed by the CPU after hitting the first hardware ACL entry.

[0117] Step S208: The sum of the current hardware statistics value and the previous hardware statistics value is determined as the total hardware statistics value.

[0118] Step S209: The sum of the current software statistics value and the previous software statistics value is determined as the total software statistics value.

[0119] To more clearly illustrate the packet loss statistics method provided in the embodiments of the present invention, an exemplary description is given in conjunction with the ARP protocol type.

[0120] As one implementation method, with Figure 5For example, the switching chip maintains a hardware ACL table, and the processor has three CPU queues. The hardware ACL table has a high-priority first hardware ACL entry and a low-priority second hardware ACL entry for each protocol type characteristic, and both hardware ACL entries are loaded as valid upon initialization. The processor has parameters for recording the current software statistics value (swCount), the previous software statistics value (pre_swCount), and the previous hardware statistics value (pre_hwCount), all of which are initialized to 0. The processor monitors each CPU queue, obtains the packet markers corresponding to the packets to be processed, and performs software counting based on the packet markers.

[0121] When the packet characteristics are ARP protocol, the first hardware ACL entry is ACL1, matching Ethernet type 0x0806, and the action CopyToCpu is executed to perform hardware statistics. Assume the packet is labeled 1. The second hardware ACL entry is ACL2, matching Ethernet type 0x0806, and the action CopyToCpu is executed to perform hardware statistics. Assume the packet is labeled 2.

[0122] When the processor retrieves a message to be processed from the CPU queue, the message corresponding to the message to be processed is marked as 1 or 2, and the message is counted in swCount[1] or swCount[2] according to the message mark.

[0123] When viewing ARP packet loss statistics for the first time via CPU management commands, assuming the first hardware ACL entry ACL1 is valid, ACL1 is unloaded. Although ACL1 becomes invalid, ACL2 becomes valid, and ARP packets will then be reported to the CPU via ACL2. The processor reads the hardware counter hwCount1 corresponding to ACL1 as the hardware statistic value for this instance; assuming hwCount1 is 1000.

[0124] When the processor receives an ARP protocol message marked as 2, it indicates that the ARP protocol message reported with the corresponding message mark of ACL1 has been reported to the CPU for processing. The software count swCount[1] marked as 1 is read as the current software statistics value, and pre_swCount[1] = swCount[1], pre_hwCount[1] = hwCount1 is recorded. Assume that the current software statistics value read during the packet loss statistics check is 800.

[0125] Since this is the first time checking ARP packet loss statistics, ACL1 has always been in effect. Based on packet marker 2, the previous hardware statistics value pre_hwCount[2] and the previous software statistics value pre_swCount[2] are obtained. pre_hwCount[2] and pre_swCount[2] have been initialized to 0.

[0126] Therefore, when checking the ARP packet loss statistics for the first time, the total hardware statistics reported by the switching chip are 1000, i.e., hwCount1+pre_hwCount[2]=1000+0=1000, and the total software statistics processed by the processor are 800, i.e., swCount[1]+pre_swCount[2]=800+0=800. The total software statistics are less than the total hardware statistics, indicating that ARP protocol packets are lost after entering the CPU queue from the switch. The total number of ARP protocol packet losses is 200, i.e., 1000-800=200. At the same time, the value of hwCount1 of 1000 needs to be updated to pre_hwCount[1], i.e., update pre_hwCount[1]=1000, and the value of swCount[1] of 800 needs to be updated to pre_hwCount[1], i.e., update pre_hwCount[1]=800.

[0127] When checking the packet loss statistics for ARP protocol type for the second time via CPU management commands, ACL1's status was invalid. ACL1 was reloaded to update its status to valid. The counter for ACL1 counts the total number of ARP protocol packets reported to the processor. The processor reads the hardware count hwCount2 corresponding to ACL2 from the switching chip as the hardware statistics value for this second query. Assuming that there are currently 500 ARP protocol packets that have hit ACL2, then hwCount2 will be 500.

[0128] When the processor starts to obtain an ARP protocol message marked as 1 from the CPU queue, it means that the ARP protocol message reported through ACL2 has been processed. The software count swCount[2] marked as 2 of the message is read as the software statistics value for this time. Assuming that the software statistics value read when viewing the packet loss statistics is 400.

[0129] Therefore, when checking the ARP packet loss statistics for the second time, the total hardware statistics reported by the switching chip are 1500, i.e., hwCount2+pre_hwCount[1]=500+1000=1500. The total software statistics processed by the processor are 1200, i.e., swCount[2]+pre_swCount[1]=400+800=1200. The total number of ARP protocol packet losses is 300, i.e., 1500-1200=300. At the same time, the value of hwCount2 of 500 needs to be updated to pre_hwCount[2], i.e., update pre_hwCount[2]=500, and the value of swCount[2] of 400 needs to be updated to pre_hwCount[2], i.e., update pre_hwCount[2]=400.

[0130] When the CPU management command is used to check packet loss statistics for the ARP protocol type for the third time, ACL1 is activated. ACL1 is then unloaded to disable it. The processor reads the hardware counter hwCount1 corresponding to ACL1 as the hardware statistic value for this third query. Assuming the current value of the ACL1 counter is 1600, then hwCount1 will be 1600.

[0131] When the processor retrieves the ARP protocol message with message tag 2 from the CPU queue, it indicates that the ARP protocol message reported through ACL1 has been processed. Assuming that by the third time the CPU has processed 1300 ARP protocol messages corresponding to message tag 1, then swCount[1] = 1300.

[0132] Therefore, when checking the ARP packet loss statistics for the third time, the total hardware statistics reported by the switching chip were 2100, i.e., hwCount1+pre_hwCount[2]=1600+500=2100. The total software statistics processed by the processor were 1700, i.e., swCount[1]+pre_swCount[2]=1300+400=1700. The total number of ARP protocol packet losses was 400, i.e., 2100-1700=400.

[0133] As can be seen, the embodiments of the present invention utilize first and second hardware ACL entries of different priorities to alternately and accurately count the hardware counts of various packet characteristics reported by the switching chip, and carry the packet tag corresponding to the ACL entry when reporting packets, so that the processor can quickly obtain the software counts of various protocol type characteristics based on the packet tag, thereby quickly and accurately counting the number of packet losses for each protocol packet. While reducing resource consumption, it improves the accuracy and timeliness of packet loss statistics, thereby improving the operation and maintenance efficiency of network devices, reducing operation and maintenance costs, and improving the usability of network devices.

[0134] Based on the same inventive concept, the network device provided in this embodiment of the invention has the same basic principle and technical effect in statistical packet loss as the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments.

[0135] Please refer to Figure 6 , Figure 6 This is a block diagram illustrating a packet loss statistics device 300 according to an embodiment of the present invention. The packet loss statistics device 300 is applied to a network device, which includes a CPU and a switching chip. The packet loss statistics device 300 includes a processing module 301, a statistics module 302, and a calculation module 303.

[0136] Processing module 301 is used to receive packet loss query instructions and obtain the protocol type characteristics of the protocol message to be queried;

[0137] The statistics module 302 is used to obtain the corresponding total hardware statistics and total software statistics based on the protocol type characteristics. The total hardware statistics are the total number of packets reported to the CPU by the switching chip based on the protocol type characteristics. The total software statistics are the total number of packets processed by the CPU based on the protocol type characteristics.

[0138] The calculation module 303 is used to calculate the difference between the total hardware statistics and the total software statistics to obtain the total number of lost packets of the protocol message to be queried.

[0139] In summary, the packet loss statistics device provided in this embodiment of the invention counts the total number of packets reported by the switching chip to the CPU and the total number of packets processed by the CPU based on protocol type characteristics. It can accurately obtain the total number of packet losses corresponding to various protocol packets based on the total number of packets reported by the switching chip to the CPU and the total number of packets processed by the CPU, effectively improving the accuracy of packet loss statistics, reducing network equipment operation and maintenance costs, and improving the usability of network equipment.

[0140] Optionally, the switching chip is equipped with a hardware ACL table, which includes a first hardware ACL entry and a second hardware ACL entry that match the protocol type characteristics. The first hardware ACL entry has a higher priority than the second hardware ACL entry. The statistics module 302 is specifically used to: unload the first hardware ACL entry when the status of the first hardware ACL entry is determined to be valid based on the protocol type characteristics; obtain the current hardware statistics value corresponding to the first hardware ACL entry, and obtain the current software statistics value of the query protocol message that has been reported to the CPU and processed after hitting the first hardware ACL entry; obtain the previous hardware statistics value of the saved query protocol message that hit the second hardware ACL entry, and obtain the previous software statistics value of the query protocol message that has been reported to the CPU and processed after hitting the second hardware ACL entry; determine the total hardware statistics value by summing the current hardware statistics value and the previous hardware statistics value; and determine the total software statistics value by summing the current software statistics value and the previous software statistics value.

[0141] Optionally, the first and second hardware ACL entries are used to mark protocol packets with protocol type characteristics with corresponding packet tags before sending them to the CPU. The statistics module 302 is specifically used to obtain the value of the counter in the first hardware ACL entry to obtain the current hardware statistics value; and when the CPU starts processing the query protocol packets with the packet tags corresponding to the second hardware ACL entry, it obtains the statistics of the CPU-processed query protocol packets with the packet tags corresponding to the first hardware ACL entry to obtain the current software statistics value.

[0142] Optionally, the statistics module 302 is specifically used to, after obtaining the total number of lost packets of the protocol message to be queried, save the current hardware statistics value as the previous hardware statistics value of the protocol message to be queried hitting the first hardware ACL table entry; and report the current software statistics value as the previous software statistics value after CPU processing of the protocol message to be queried that hits the first hardware ACL table entry.

[0143] Optionally, the processing module 301 is also configured to receive again a packet loss query instruction for obtaining the protocol message to be queried.

[0144] The statistics module 302 is further configured to: reinstall the first hardware ACL entry to make it effective according to the protocol type characteristics; obtain the current hardware statistics value corresponding to the second hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after hitting the second hardware ACL entry; obtain the saved previous hardware statistics value of the query protocol message hitting the first hardware ACL entry, and obtain the previous software statistics value of the query protocol message processed by the CPU after hitting the first hardware ACL entry; determine the new total hardware statistics value by summing the newly obtained current hardware statistics value and the newly obtained previous hardware statistics value; and determine the new total software statistics value by summing the newly obtained current software statistics value and the newly obtained previous software statistics value.

[0145] The calculation module 303 is also used to calculate the difference between the new total hardware statistics and the new total software statistics to obtain the latest total number of lost packets of the protocol message to be queried.

[0146] Optionally, the statistics module 302 is specifically used to: when the status of the first hardware ACL entry is determined to be invalid based on the protocol type characteristics, reinstall the first hardware ACL entry to make it effective; obtain the current hardware statistics value corresponding to the second hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after hitting the second hardware ACL entry; obtain the saved previous hardware statistics value of the query protocol message hitting the first hardware ACL entry, and obtain the previous software statistics value of the query protocol message reported to the CPU after processing by the CPU; determine the total hardware statistics value by summing the current hardware statistics value and the previous hardware statistics value; and determine the total software statistics value by summing the current software statistics value and the previous software statistics value.

[0147] Please refer to Figure 7 , Figure 7 This is a block diagram of a network device 200 provided in an embodiment of the present invention. The network device 200 includes a switching chip 210, a processor 220, and a memory 230. The switching chip 210 reports the total number of packets to the processor 220 based on protocol type characteristics.

[0148] The memory 230 is used to store programs or data. The memory 230 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0149] The processor 220 is used to read / write data or programs stored in the memory 230 and perform corresponding functions. For example, when a computer program stored in the memory 230 is executed by the processor 220, the packet loss statistics method disclosed in the above embodiments can be implemented.

[0150] It should be understood that, Figure 7 The structure shown is only a schematic diagram of network device 200. Network device 200 may also include more than [other components]. Figure 7 The more or fewer components shown, or having the same Figure 7 The different configurations shown. Figure 7 The components shown can be implemented using hardware, software, or a combination thereof.

[0151] This invention also provides a computer-readable storage medium storing a computer program that, when executed by processor 220, implements the packet loss statistics method disclosed in the above embodiments.

[0152] This invention also provides a program product that, when executed by processor 220, implements the packet loss statistics method disclosed in the above embodiments.

[0153] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0154] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0155] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0156] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A packet loss statistics method, characterized in that, The method is applied to network devices, including a CPU and a switching chip. The switching chip has a hardware ACL table, which includes a first hardware ACL entry and a second hardware ACL entry that match protocol type characteristics. The first hardware ACL entry has a higher priority than the second hardware ACL entry. Receive packet loss query instructions and obtain the protocol type characteristics of the protocol message to be queried; Based on the protocol type characteristics, obtain the corresponding total hardware statistics and total software statistics; the total hardware statistics are the total number of packets reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics are the total number of packets processed by the CPU based on the protocol type characteristics. Calculate the difference between the total hardware statistics and the total software statistics to obtain the total number of lost packets in the protocol message to be queried; The step of obtaining the corresponding total hardware statistics and total software statistics based on the protocol type characteristics includes: When the status of the first hardware ACL entry is determined to be valid based on the protocol type characteristics, the first hardware ACL entry is unloaded. Obtain the current hardware statistics value corresponding to the first hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after hitting the first hardware ACL entry; Obtain the last hardware statistics value of the protocol message to be queried that hit the second hardware ACL entry, and obtain the last software statistics value of the protocol message to be queried that was processed by the CPU after hitting the second hardware ACL entry. The sum of the current hardware statistics value and the previous hardware statistics value is determined as the total hardware statistics value; The sum of the current software statistics value and the previous software statistics value is determined as the total software statistics value.

2. The packet loss statistics method according to claim 1, characterized in that, The first hardware ACL entry and the second hardware ACL entry are used to mark protocol packets with the aforementioned protocol type characteristics with the corresponding packet tags before sending them to the CPU; obtaining the current hardware statistics value corresponding to the first hardware ACL entry, and obtaining the current software statistics value of the queried protocol packet processed by the CPU after hitting the first hardware ACL entry, includes: The current hardware statistics value is obtained by retrieving the value of the counter in the first hardware ACL entry. When the CPU starts processing the queried protocol message with the message tag corresponding to the second hardware ACL entry, the current software statistical value is obtained by acquiring the statistical data of the queried protocol messages with the message tag corresponding to the first hardware ACL entry processed by the CPU.

3. The packet loss statistics method according to claim 2, characterized in that, The method further includes: After obtaining the total number of lost packets of the protocol message to be queried, the current hardware statistics value is saved as the previous hardware statistics value when the protocol message to be queried hits the first hardware ACL entry; the current software statistics value is used as the previous software statistics value of the protocol message to be queried that was processed by the CPU after hitting the first hardware ACL entry.

4. The packet loss statistics method according to claim 3, characterized in that, The method further includes: Receive the packet loss query instruction again for the protocol message to be queried; Based on the protocol type characteristics, reinstall the first hardware ACL entry to make it effective; Obtain the current hardware statistics value corresponding to the second hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after the second hardware ACL entry is hit; Obtain the last hardware statistics value of the protocol message to be queried that hit the first hardware ACL entry, and obtain the last software statistics value of the protocol message to be queried that was processed by the CPU after hitting the first hardware ACL entry. The sum of the newly acquired hardware statistics value and the newly acquired hardware statistics value from the previous period is determined as the new total hardware statistics value. The sum of the newly acquired current software statistics value and the newly acquired previous software statistics value is determined as the new total software statistics value; The difference between the new total hardware statistics and the new total software statistics is calculated to obtain the latest total number of lost packets for the protocol message to be queried.

5. The packet loss statistics method according to claim 1, characterized in that, The step of obtaining the corresponding total hardware statistics and total software statistics based on the protocol type characteristics also includes: When the status of the first hardware ACL entry is determined to be invalid based on the protocol type characteristics, the first hardware ACL entry is reinstalled to make it effective. Obtain the current hardware statistics value corresponding to the second hardware ACL entry, and obtain the current software statistics value of the query protocol message processed by the CPU after the second hardware ACL entry is hit; Obtain the last hardware statistics value of the protocol message to be queried that hit the first hardware ACL entry, and obtain the last software statistics value of the protocol message to be queried that was processed by the CPU. The sum of the current hardware statistics value and the previous hardware statistics value is determined as the total hardware statistics value; The sum of the current software statistics value and the previous software statistics value is determined as the total software statistics value.

6. A packet loss statistics device, characterized in that, An apparatus for use in network devices, the network devices including a CPU and a switching chip, wherein the switching chip is provided with a hardware ACL table, the hardware ACL table including a first hardware ACL entry and a second hardware ACL entry matching protocol type characteristics, the first hardware ACL entry having a higher priority than the second hardware ACL entry, the apparatus comprising: The processing module is used to receive packet loss query instructions and obtain the protocol type characteristics of the protocol message to be queried; The statistics module is used to obtain the corresponding total hardware statistics and total software statistics based on the protocol type characteristics; the total hardware statistics are the total number of packets reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics are the total number of packets processed by the CPU based on the protocol type characteristics. The calculation module is used to calculate the difference between the total hardware statistics and the total software statistics to obtain the total number of lost packets in the protocol message to be queried; The statistics module is specifically configured to: unload the first hardware ACL entry when the status of the first hardware ACL entry is determined to be valid based on the protocol type characteristics; obtain the current hardware statistics value corresponding to the first hardware ACL entry, and obtain the current software statistics value of the queried protocol message processed by the CPU after hitting the first hardware ACL entry; obtain the saved previous hardware statistics value of the queried protocol message hitting the second hardware ACL entry, and obtain the previous software statistics value of the queried protocol message processed by the CPU after hitting the second hardware ACL entry; determine the total hardware statistics value by summing the current hardware statistics value and the previous hardware statistics value; and determine the total software statistics value by summing the current software statistics value and the previous software statistics value.

7. A network device, characterized in that, The device includes a switching chip, a processor, and a memory. The switching chip reports the total number of packets to the processor based on protocol type characteristics. The memory stores machine-executable instructions that can be executed by the processor. The processor can execute the machine-executable instructions to implement the packet loss statistics method according to any one of claims 1-5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the packet loss statistics method as described in any one of claims 1-5.

9. A program product, characterized in that, When the program product is executed by the processor, it implements the packet loss statistics method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Frame loss measuring method, frame loss measuring device and frame loss measuring system

    CN102546117A

  • Packet loss processing method and device, equipment and machine readable storage medium

    CN112073256A