Packet loss statistical method and device, network equipment, storage medium and program product
By setting a hardware ACL table on the switching chip of the network device to count the number of lost packets of each protocol message, the problem of inaccurate packet loss statistics in the existing technology is solved, and more efficient operation and maintenance and lower operation and maintenance are achieved. cost.
Patent Information
- Application Number
- CN202411501882.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-10-25
AI Technical Summary
The prior art is difficult to quickly and accurately count the packet loss of each protocol packet in network equipment using a technical means, resulting in high operation and maintenance costs and it is difficult to quickly locate packet loss of specific protocols.
By setting a hardware ACL table on the switching chip, the total hardware statistics and software statistics are obtained based on the protocol type characteristics, and the difference between the two is calculated to obtain the total number of lost packets for each protocol.
It improves the accuracy of packet loss statistics, reduces the operation and maintenance costs of network equipment, and improves the ease of use of network equipment.
Smart Images

Figure CN119341946A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data communication, and in particular to a packet loss statistics method, device, network equipment, storage medium and program product. Background Art
[0002] In the switch structure, it is usually composed of a switching chip and a CPU (processor). The switching chip is responsible for forwarding data packets, and the CPU is responsible for management and control. Messages that the switching chip cannot process need to be submitted to the CPU for processing, such as Layer 2 protocol messages such as BPDU (Bridge Protocol Data Unit), GVRP (GARP VLAN Registration Protocol), and ARP (Address Resolution Protocol); Layer 3 protocol messages 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); data messages such as unknown unicast IP (Internet Protocol) messages, unknown multicast messages, RPF (Reverse path forwarding) failure messages, and various error messages. There are many ways for the switching chip to identify protocol messages and send them to the CPU, such as PDU (Protocol Data Unit) control table, Layer 2 forwarding table, ACL (Access Control List) and other hardware table items. Among them, ACL is the most widely used and flexible way, and is often used in actual projects.
[0003] At the same time, some attackers often take advantage of the data flow forwarding principle and protocol defects of the switch to launch attacks. When the attack is successful, a large number of useless or malicious messages in the switch will be sent to the CPU for processing. The CPU cannot perform normal tasks and process normal messages due to excessive utilization. These tasks are suspended for a long time and the messages are blocked, which will cause the switch to paralyze and cause network oscillation or even interruption. Of course, normal protocol messages may also be sent to the CPU due to broadcast storms and other reasons. The flow is too large, resulting in too many messages received by the CPU to be processed, affecting the normal operation of other programs.
[0004] To prevent the control plane of the device from being impacted by this, causing the CPU to be unable to process normal tasks and protocol packets, it is necessary to specify different CPU queues for each protocol packet according to the different priority levels of the protocol, and set the rate limit for each CPU queue. The attack protocol packets can be reconfigured to the low-priority queue and the rate can be limited, and the protocols that need to be protected can be configured in the high-priority queue to prevent the high-priority key protocols from not being processed by the CPU and causing network paralysis.
[0005] In order to ensure that the CPU can process as many protocol messages as possible within its capabilities without overloading the CPU, message rate limiting is also performed based on the CPU port to limit the total number of all messages processed by the CPU per unit time, so that the protocol functions can run stably.
[0006] When the actual rate at which protocol packets are sent to the CPU is greater than the CPU queue or CPU port rate limit, the switching chip will cause packet loss based on the CPU queue scheduling rate limit. Usually, during device maintenance, you need to check which specific protocol packets of the current device have caused CPU queue rate limit packet loss to analyze the environment traffic situation. Therefore, you need to perform packet loss statistics based on protocol packet types.
[0007] The common practice in the industry is to divide different types of protocol packets into different CPU queues, so that the corresponding protocol packet loss statistics can be obtained by obtaining the packet loss statistics of a CPU queue of the switching chip. However, the number of CPU queue hardware resources of the switching chip is limited. If multiple protocol packets are sent through the same CPU queue and packet loss occurs in the CPU queue, it is not possible to directly distinguish which protocol packet is discarded through the packet loss statistics of the CPU queue of the switching chip. It can only be generally displayed as the same discard type.
[0008] The current communication network supports a large number of protocol message types, and the CPU queue resources of the switching chip are very limited. It is inevitable that the above-mentioned multiple protocol messages are sent to the CPU through the same switching chip CPU queue, and packet loss occurs due to speed limit. For the existing technology, there is no very effective solution that can use a technical processing mechanism to more accurately count packet loss based on various protocol types, and it is impossible to quickly locate which specific protocol has packet loss, and the operation and maintenance cost is high. Summary of the invention
[0009] In view of this, an object of the present invention is to provide a packet loss statistics method, apparatus, network equipment, storage medium and program product, which can improve the accuracy of packet loss statistics and effectively reduce the operation and maintenance costs of network equipment.
[0010] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:
[0011] In a first aspect, the present invention provides a packet loss statistics method, which is applied to a network device, wherein the network device includes a CPU and a switching chip, and the method includes:
[0012] Receive a packet loss query instruction and obtain the protocol type characteristics of the protocol message to be queried;
[0013] According to the protocol type characteristics, the corresponding total hardware statistics and total software statistics are obtained; 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;
[0014] 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.
[0015] In an optional implementation, a hardware ACL table is provided on the switching chip, the hardware ACL table includes a first hardware ACL table item and a second hardware ACL table item that match the protocol type feature, the priority of the first hardware ACL table item is higher than the priority of the second hardware ACL table item, and the obtaining of the corresponding total hardware statistics and total software statistics according to the protocol type feature includes:
[0016] When determining, according to the protocol type feature, that the state of the first hardware ACL entry is valid, uninstalling the first hardware ACL entry;
[0017] Acquire the current hardware statistics corresponding to the first hardware ACL entry, and acquire the current software statistics of the protocol message to be queried and processed by the CPU after hitting the first hardware ACL entry;
[0018] Obtain the saved hardware statistics of the last time the protocol message to be queried hits the second hardware ACL entry, and obtain the last software statistics of the protocol message to be queried processed by the CPU after hitting the second hardware ACL entry;
[0019] Determine the sum of the current hardware statistics value and the previous hardware statistics value 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 manner, the first hardware ACL table entry and the second hardware ACL table entry are used to add corresponding message tags to the protocol message with the protocol type feature and then send the message to the CPU; the obtaining of the current hardware statistical value corresponding to the first hardware ACL table entry, and obtaining the current software statistical value of the protocol message to be queried after hitting the first hardware ACL table entry and being processed by the CPU and reported to the CPU for processing, includes:
[0022] Obtaining the value of the counter of the first hardware ACL table entry to obtain the current hardware statistics value;
[0023] When the CPU starts to process the protocol message to be queried with the message mark corresponding to the second hardware ACL table entry, the protocol message to be queried with the message mark corresponding to the first hardware ACL table entry processed by the CPU is obtained to obtain the current software statistical value.
[0024] In an optional embodiment, the method further comprises:
[0025] After obtaining the total number of packet losses of the protocol message to be queried, the current hardware statistical value is saved as the last hardware statistical value of the protocol message to be queried hitting the first hardware ACL table item; the current software statistical value is used as the last software statistical value of the protocol message to be queried processed by the CPU after hitting the first hardware ACL table item.
[0026] In an optional embodiment, the method further comprises:
[0027] Receiving again a packet loss query instruction for obtaining the protocol message to be queried;
[0028] Reinstall the first hardware ACL entry to make it effective according to the protocol type characteristics;
[0029] Acquire the current hardware statistics corresponding to the second hardware ACL entry, and acquire the current software statistics of the protocol message to be queried and processed by the CPU after hitting the second hardware ACL entry;
[0030] Obtain the saved hardware statistics of the last time the protocol message to be queried hits the first hardware ACL entry, and obtain the last software statistics of the protocol message to be queried processed by the CPU after hitting the first hardware ACL entry;
[0031] The sum of the newly obtained hardware statistics value of this time and the newly obtained hardware statistics value of the previous time is determined as the new total hardware statistics value;
[0032] The sum of the newly obtained current software statistics value and the newly obtained last software statistics value is determined as a new total software statistics value;
[0033] The difference between the new total hardware statistics value and the new total software statistics value is calculated to obtain the latest total packet loss quantity of the protocol message to be queried.
[0034] In an optional implementation, a hardware ACL table is provided on the switching chip, the hardware ACL table includes a first hardware ACL table item and a second hardware ACL table item that match the protocol type feature, the priority of the first hardware ACL table item is higher than the priority of the second hardware ACL table item, and the obtaining of the corresponding total hardware statistics and total software statistics according to the protocol type feature includes:
[0035] When determining, according to the protocol type feature, that the state of the first hardware ACL entry is invalid, reinstalling the first hardware ACL entry to make it effective;
[0036] Acquire the current hardware statistics corresponding to the second hardware ACL entry, and acquire the current software statistics of the protocol message to be queried and processed by the CPU after hitting the second hardware ACL entry;
[0037] Obtain the saved hardware statistics of the last time the protocol message to be queried hits the first hardware ACL entry, and obtain the last software statistics of the protocol message to be queried processed by the CPU after hitting the first hardware ACL entry;
[0038] Determine the sum of the current hardware statistics value and the previous hardware statistics value 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, which is applied to a network device, wherein the network device includes a CPU and a switching chip, and the device includes:
[0041] A processing module, used for receiving a packet loss query instruction and obtaining a protocol type feature of a protocol message to be queried;
[0042] A statistics module, used for obtaining corresponding total hardware statistics and total software statistics according to the protocol type characteristics; the total hardware statistics is the total number of messages reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics is the total number of messages 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 packet loss number of the protocol message to be queried.
[0044] In a third aspect, the present invention provides a network device, comprising a switching chip, a processor and a memory, wherein the switching chip reports the total number of packets to the processor based on protocol type feature statistics, the memory stores machine executable instructions that can be executed by the processor, and the processor can execute the machine executable instructions to implement the packet loss statistics method described in any of the aforementioned implementations.
[0045] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the packet loss statistics method as described in any one of the aforementioned embodiments is implemented.
[0046] In a fifth aspect, the present invention provides a program product, which, when executed by a processor, implements the packet loss statistics method as described in any one of the aforementioned embodiments.
[0047] The packet loss statistics method, device, network device, storage medium and program product provided by the embodiments of the present invention count the total number of messages reported by the switching chip to the CPU and the total number of messages reported to the CPU for processing based on protocol type characteristics. The total number of packet losses corresponding to various protocol messages can be accurately obtained according to the total number of messages reported by the switching chip to the CPU and the total number of messages processed by the CPU, thereby effectively improving the accuracy of packet loss statistics, reducing the operation and maintenance costs of network devices, and improving the usability of network devices.
[0048] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0050] Figure 1 A schematic diagram of a flow chart of a packet loss statistics method provided by an embodiment of the present invention is shown.
[0051] Figure 2 Another schematic flow chart of a packet loss statistics method provided in an embodiment of the present invention is shown.
[0052] Figure 3 Another schematic flow chart of a packet loss statistics method provided in an embodiment of the present invention is shown.
[0053] Figure 4 Another schematic flow chart of a packet loss statistics method provided in an embodiment of the present invention is shown.
[0054] Figure 5 Another schematic flow chart of a packet loss statistics method provided in an embodiment of the present invention is shown.
[0055] Figure 6 A block diagram of a packet loss statistics device provided by an embodiment of the present invention is shown.
[0056] Figure 7 A block diagram of a network device provided by 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 DESCRIPTION
[0058] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0059] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.
[0060] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0061] As the core chip of network equipment, the switching chip is mainly used to process and forward data packets. The switching chip reports the packets that it cannot process to the CPU for processing. The common practice in the industry is to divide different types of protocol packets into different CPU queues, so that the number of protocol packet losses can be counted according to the CPU queue. However, due to the limited number of CPU queue resources of the switching chip, it is impossible to ensure that each protocol packet corresponds to the CPU queue one by one. There may be a situation where multiple protocol type packets are stored in a CPU queue, which will make it impossible to perform accurate packet loss statistics based on each protocol packet.
[0062] Based on this, an embodiment of the present invention provides a packet loss statistics method and device, which counts the total number of messages reported by the switching chip to the CPU and the total number of messages reported to the CPU and processed based on protocol type characteristics. According to the total number of messages reported by the switching chip to the CPU and the total number of messages reported to the CPU and processed, the total number of packet losses corresponding to various protocol messages can be accurately obtained, which effectively improves the accuracy of packet loss statistics, reduces the operation and maintenance costs of network equipment, and improves the usability of network equipment.
[0063] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0064] Please refer to Figure 1 , Figure 1 A schematic flow chart of a packet loss statistics method provided by an embodiment of the present invention is shown, and the method is applied to a network device, the network device includes a CPU and a switching chip, and the switching chip and the CPU are connected to a network. The method includes the following steps:
[0065] Step S10: receiving a packet loss query instruction and obtaining a protocol type feature of the protocol message to be queried.
[0066] In an embodiment of the present invention, when a user specifies the type of protocol message to view packet loss statistics through a CPU management command, the CPU obtains the type of protocol message from the packet loss query instruction, and obtains the corresponding protocol type feature according to the type of protocol message. When a user does not specify the type of protocol message to view packet loss statistics through a CPU management command, the CPU obtains the types of all protocol messages supported by the network device, and queries the packet loss situation based on the types of all protocol messages.
[0067] Step S20, according to the protocol type characteristics, obtain the corresponding total hardware statistics and total software statistics; the total hardware statistics is the total number of messages reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics is the total number of messages processed by the CPU based on the protocol type characteristics.
[0068] In the embodiment of the present invention, the switching chip counts the total number of messages reported to the CPU for each protocol type feature, that is, the total hardware statistics. The CPU counts the total number of messages processed for each message feature through software, that is, the total software statistics. When the user checks the packet loss statistics, the CPU sequentially obtains the total hardware statistics and total software statistics corresponding to the protocol type feature of the protocol message to be queried.
[0069] Step S30, calculating the difference between the total hardware statistics and the total software statistics to obtain the total packet loss number of the protocol message to be queried.
[0070] In the embodiment of the present 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 message losses of the protocol message to be queried. That is, the difference between the total number of messages reported by the switching chip to the CPU and the total number of messages processed by the CPU is the number of messages lost in the process of the protocol message to be queried being reported by the switching chip to the CPU.
[0071] In summary, the packet loss statistics method provided by the embodiment of the present invention is applied to a network device, and the network device includes a CPU and a switching chip. A packet loss query instruction is received to obtain the protocol type characteristics of the protocol message to be queried; according to the protocol type characteristics, the corresponding total hardware statistics and total software statistics are obtained; 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 packet losses of the protocol message to be queried.
[0072] It can be seen that the present invention counts the total number of messages reported by the switching chip to the CPU and the total number of messages processed by the CPU based on the protocol type characteristics. According to the total number of messages reported by the switching chip to the CPU and the total number of messages reported to the CPU and processed by the CPU, the total number of packet losses corresponding to various protocol messages can be accurately obtained, which effectively improves the accuracy of packet loss statistics, reduces the operation and maintenance costs of network equipment, and improves the usability of network equipment.
[0073] In the embodiment of the present invention, a hardware ACL table is provided on the switching chip, and the hardware ACL table includes a first hardware ACL table item and a second hardware ACL table item that match the protocol type characteristics, and the priority of the first hardware ACL table item is higher than the priority of the second hardware ACL table item. That is, relatively speaking, the first hardware ACL table item is a high-priority hardware ACL table item, and the second hardware ACL table item is a low-priority hardware ACL table item.
[0074] After receiving the message to be processed, the switching chip searches the hardware ACL table according to the protocol type characteristics of the message to be processed. When it is determined that the status of the first hardware ACL entry with a high priority is valid, the message to be processed will hit the first hardware ACL entry, the hardware statistics 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 message to be processed after hitting the first hardware ACL entry and updates the corresponding software statistics.
[0075] After the switching chip receives the message to be processed, when the state of the first hardware ACL entry is invalid, the message to be processed will hit the second hardware ACL entry with a low priority, the hardware statistics 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.
[0076] Optionally, when processing a packet loss query instruction, the following provides a possible implementation method for obtaining total hardware statistics and total software statistics using the hardware ACL table. Figure 2 , Figure 1 The sub-steps of step S20 may include:
[0077] Step S200: when it is determined that the state of the first hardware ACL entry is valid according to the protocol type characteristics, the first hardware ACL entry is uninstalled.
[0078] In an embodiment of the present invention, the protocol type feature of the protocol message to be queried is used as the target protocol type feature. When the state of the first hardware ACL table item corresponding to the target protocol type feature is valid, it indicates that the first hardware ACL table item corresponding to the target protocol type feature is already in a loaded state. The first hardware ACL table item corresponding to the target protocol type feature is unloaded, so that the state of the first hardware ACL table item corresponding to the target protocol type feature is changed from valid to invalid, so that the protocol message of the target protocol type feature will hit the second hardware ACL table item with a low priority.
[0079] When the state of the high-priority first hardware ACL entry corresponding to the target protocol type feature becomes invalid, the switching chip will hit the low-priority second hardware ACL entry based on the target protocol type feature to report the protocol message corresponding to the target protocol type feature to the CPU.
[0080] Step S201 : obtaining the current hardware statistics corresponding to the first hardware ACL entry, and obtaining the current software statistics of the protocol message to be queried that is processed by the CPU after hitting the first hardware ACL entry.
[0081] In the embodiment of the present invention, when receiving the packet loss query instruction, if the state of the first hardware ACL table item is valid, the hardware statistics corresponding to the first hardware ACL table item can be obtained, that is, the current hardware statistics. The current software statistics can be obtained by counting the protocol packets to be queried and processed by the CPU after the hit first hardware ACL table item is obtained.
[0082] Step S202, obtaining the last hardware statistics value of the protocol message to be queried hitting the second hardware ACL entry, and obtaining the last software statistics value of the protocol message to be queried processed by the CPU after hitting the second hardware ACL entry.
[0083] In an embodiment of the present invention, the total number of packet losses of the protocol message to be queried is obtained by counting the total number of protocol messages to be queried and reported to the CPU based on the alternating effectiveness of the first hardware ACL entry and the second hardware ACL entry. When the packet loss query instruction is the first query, the last hardware statistical value and the last software statistical value are both initial values, for example, the default initial value is set to 0. Generally, the first hardware ACL entry with a high priority and the second hardware ACL entry with a low priority are both loaded initially, at which time the protocol message to be queried will only hit the first hardware ACL entry with a high priority; only when the first hardware ACL entry with a high priority is unloaded (in an invalid state), the protocol message to be queried will hit the second hardware ACL entry with a low priority.
[0084] When this packet loss query instruction is not the first query and the status of the first hardware ACL table item is valid, the last hardware statistical value corresponding to the second hardware ACL table item hit by the protocol message to be queried reported to the CPU will be generated, and the last software statistical value corresponding to the protocol message to be queried that hits the second hardware ACL table item and has been reported to the CPU for processing will be generated.
[0085] Step S203: determine the sum of the current hardware statistics value and the previous hardware statistics value as the total hardware statistics value.
[0086] Step S204: determine the sum of the current software statistics value and the previous software statistics value as the total software statistics value.
[0087] In an embodiment of the present invention, the total number of messages corresponding to the protocol messages to be queried reported by the switching chip to the CPU is recorded using the current hardware statistics and the previous hardware statistics, and the total hardware statistics can be obtained based on the sum of the current hardware statistics and the previous hardware statistics. The total number of messages corresponding to the protocol messages to be queried processed by the CPU is recorded using the current software statistics and the previous software statistics, and the total software statistics can be obtained based on the sum of the current software statistics and the previous software statistics.
[0088] Optionally, in actual application, the first hardware ACL entry and the second hardware ACL entry are used to add corresponding message tags to protocol messages with matching protocol type characteristics and then report them to the CPU. Regarding how to use message tags to obtain the current software statistics, a possible implementation is provided below. Figure 2 The sub-steps of step S201 may include:
[0089] The value of the counter of the first hardware ACL table item is obtained to obtain the hardware statistical value of this time; when the CPU starts to process the protocol message to be queried with the message mark corresponding to the second hardware ACL table item, the statistical protocol message to be queried with the message mark corresponding to the first hardware ACL table item that has been reported to the CPU for processing is obtained to obtain the software statistical value of this time.
[0090] In the embodiment of the present invention, a corresponding counter is set for each hardware ACL entry on the switching chip. The counter of each hardware ACL entry is used to count the hardware statistics corresponding to the protocol message hitting the hardware ACL entry.
[0091] After the switching chip receives the protocol message, it searches the hardware ACL table according to the protocol type characteristics of the protocol message. When the status of the first hardware ACL entry with a high priority is valid, the protocol message matches the first hardware ACL entry, and the hardware statistical value of the counter corresponding to the first hardware ACL entry increases. The protocol message is marked with the message mark corresponding to the first hardware ACL entry and reported to the CPU queue.
[0092] When the state of the first hardware ACL entry is invalid, the protocol message matches the second hardware ACL entry, the hardware statistical value of the counter corresponding to the second hardware ACL entry with a low priority is increased, and the protocol message is marked with the message mark corresponding to the second hardware ACL entry and reported to the CPU queue.
[0093] When scheduling and processing the protocol messages in the CPU queue according to the queue scheduling mechanism, the protocol messages are taken out from the CPU queue, the corresponding software statistics are updated according to the message tags corresponding to the protocol messages, and the taken out protocol messages are processed.
[0094] In the embodiment of the present invention, when the total number of lost packets of the protocol message to be queried is counted and the state of the first hardware entry with a high priority is valid, the counter of the first hardware ACL entry is read to obtain the hardware statistical value of this time. When the protocol message to be queried with the message mark corresponding to the second hardware ACL entry in the CPU queue begins to be processed, the software statistical value of the protocol message to be queried with the message mark corresponding to the first hardware ACL entry that has been reported to the CPU for processing is obtained by software statistics to obtain the software statistical value of this time.
[0095] As a possible implementation method, assuming that the message mark corresponding to the first hardware ACL table item with a high priority is 1, and the message mark corresponding to the second hardware ACL table item with a low priority is 2, when the protocol message to be queried is obtained from the CPU queue for processing, when the message mark corresponding to the obtained protocol message to be queried is 1, the software statistics corresponding to the message mark 1 are updated. When the message mark corresponding to the obtained protocol message to be queried is 2, it means that the protocol message to be queried with the message mark 1 has been reported to the CPU, and the software statistics corresponding to the message mark 1 will no longer be updated. When the protocol message to be queried with the message mark 2 in the CPU queue is subsequently processed, it will be counted in the software statistics corresponding to the message mark 2.
[0096] Optionally, in order to accurately count the total number of lost packets of the protocol messages to be queried, the method further includes the following steps:
[0097] After obtaining the total number of packet losses of the protocol message to be queried, the current hardware statistics value is saved as the last hardware statistics value of the protocol message to be queried hitting the first hardware ACL entry; the current software statistics value is used as the last software statistics value of the protocol message to be queried hitting the first hardware ACL entry after being reported to the CPU for processing.
[0098] In an embodiment of the present invention, the software saves the last hardware statistics of each hardware ACL table item and the last software statistics corresponding to the protocol message to be queried with the message tag. Among them, the last hardware statistics of the protocol message to be queried hitting the first hardware ACL table item is the statistics of the corresponding counter when the protocol message to be queried hits the first hardware ACL table item. When the message tag corresponding to the second hardware ACL table item in the protocol message to be queried is taken out from the CPU queue, the current software statistics corresponding to the protocol message to be queried carrying the message tag corresponding to the first hardware ACL table item is saved as the last software statistics corresponding to the protocol message tag to be queried, so as to query the packet loss situation next time.
[0099] Optionally, when the user initiates a packet loss query instruction for the protocol message to be queried again, how to count the total packet loss number of the protocol message to be queried? The following provides a possible implementation method. Figure 3 , the method further comprises the following steps:
[0100] Step S40: receiving a packet loss query instruction for obtaining the protocol message to be queried again.
[0101] Step S50: reinstall the first hardware ACL entry to make it effective according to the protocol type characteristics.
[0102] In the embodiment of the present invention, after receiving the packet loss query instruction of the protocol message to be queried last time, the first hardware ACL table item with a valid status is uninstalled, and the protocol message to be queried reported to the CPU after uninstalling the first hardware ACL table item will hit the second hardware ACL table item, so that the count value of the counter corresponding to the second hardware ACL table item increases. When the packet loss query instruction of the protocol message to be queried is received again, the protocol type feature of the protocol message to be queried is obtained, and the first hardware ACL table item corresponding to the protocol type feature is reinstalled to make the status of the first hardware ACL table item valid, and the protocol message to be queried reported to the CPU will hit the first hardware ACL table item, so that the count value of the counter corresponding to the first hardware ACL table item increases.
[0103] Step S60, obtaining the current hardware statistics corresponding to the second hardware ACL entry, and obtaining the current software statistics of the protocol message to be queried that is processed by the CPU after hitting the second hardware ACL entry.
[0104] In the embodiment of the present invention, the value of the counter of the second hardware ACL table item corresponding to the protocol type feature is obtained to obtain a new hardware statistical value for this time. When the CPU starts to process the protocol message to be queried with the message mark corresponding to the first hardware ACL table item, the software statistical value of the protocol message to be queried with the message mark corresponding to the second hardware ACL table item that has been reported to the CPU for processing is obtained to obtain a new software statistical value for this time.
[0105] Step S70, obtaining the last hardware statistics value of the protocol message to be queried hitting the first hardware ACL entry, and obtaining the last software statistics value of the protocol message to be queried processed by the CPU after hitting the first hardware ACL entry.
[0106] Step S80: Determine the sum of the newly acquired current hardware statistics value and the newly acquired last hardware statistics value as a new total hardware statistics value.
[0107] Step S90: Determine the sum of the newly acquired current software statistics value and the newly acquired last software statistics value as a new total software statistics value.
[0108] Step S100, calculating the difference between the new total hardware statistics value and the new total software statistics value to obtain the latest total packet loss number of the protocol message to be queried.
[0109] In an embodiment of the present invention, a new last hardware statistic and a new last software statistic are obtained according to the message tag corresponding to the first hardware ACL table entry hit by the protocol message to be queried. The sum of the new hardware statistic of this time and the new hardware statistic of the last time is calculated to obtain a new total hardware statistic, and the sum of the new software statistic of this time and the new software statistic of the last time is calculated to obtain a new total software statistic. According to the difference between the new total hardware statistic and the new software statistic, the latest total packet loss number of the protocol message to be queried is obtained.
[0110] After obtaining the latest total packet loss number of the protocol message to be queried, the new hardware statistics value is saved as the last hardware statistics value of the protocol message to be queried hitting the second hardware ACL entry. The new software statistics value is used as the last software statistics value of the protocol message to be queried that was processed and reported to the CPU after hitting the second hardware ACL entry, that is, the last software statistics value corresponding to the protocol message to be queried with the message tag corresponding to the second hardware ACL entry.
[0111] Optionally, when processing a packet loss query instruction, another possible implementation method is provided below for how to use the hardware ACL table to obtain the total hardware statistics and total software statistics. Figure 4 , Figure 1 The sub-steps of step S20 may include:
[0112] Step S205: when it is determined that the state of the first hardware ACL entry is invalid according to the protocol type characteristics, the first hardware ACL entry is reinstalled to make it effective.
[0113] In the embodiment of the present invention, when the state of the first hardware ACL table item corresponding to the protocol type feature is invalid, it means that the first hardware ACL table item corresponding to the protocol type feature has been in an uninstalled state, and the first hardware ACL table item corresponding to the protocol type feature is reinstalled to make it effective. In other words, the state of the first hardware ACL table item corresponding to the protocol type feature is updated to be valid.
[0114] Step S206, obtaining the current hardware statistics corresponding to the second hardware ACL entry, and obtaining the current software statistics of the protocol message to be queried that is processed by the CPU after hitting the second hardware ACL entry.
[0115] In an embodiment of the present invention, when the first hardware ACL table item that matches the protocol type feature is in an unloaded state, the total number of protocol messages to be queried that are reported to the CPU using the counter of the second hardware ACL table item that matches the protocol type feature is counted. The value of the counter of the second hardware ACL table item 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 table item. At the same time, the current hardware statistical value is used as the last hardware statistical value corresponding to the protocol message to be queried hitting the second hardware ACL table item. The current software statistical value is used as the last software statistical value of the protocol message to be queried that has been reported to the CPU for processing after hitting the second hardware ACL table item, that is, the last software statistical value reported to the CPU for processing after the protocol message to be queried hits the second hardware ACL table item.
[0116] Step S207, obtaining the last hardware statistics value of the protocol message to be queried hitting the first hardware ACL entry, and obtaining the last software statistics value of the protocol message to be queried processed by the CPU after hitting the first hardware ACL entry.
[0117] Step S208: determine the sum of the current hardware statistics value and the previous hardware statistics value as the total hardware statistics value.
[0118] Step S209: determine the sum of the current software statistics value and the previous software statistics value as the total software statistics value.
[0119] In order to more clearly illustrate the packet loss statistics method provided by the embodiment of the present invention, an exemplary description is given in combination with the ARP protocol type.
[0120] As an implementation method, Figure 5For example, a hardware ACL table is maintained on the switching chip, and three CPU queues are set on the processor. The hardware ACL table is set with a high-priority first hardware ACL entry and a low-priority second ACL entry for each protocol type feature, and both hardware ACL entries can be loaded as valid during initialization. The processor is set with a parameter swCount for recording the current software statistics value, a parameter pre_swCount for the previous software statistics value, and a parameter pre_hwCount for the previous hardware statistics value. The current software statistics value parameter, the previous software statistics parameter, and the previous hardware statistics value parameter are all initialized to 0. The processor monitors each CPU queue, obtains the message tag corresponding to the message to be processed, and counts the software count according to the message tag.
[0121] When the message feature is ARP protocol, the first hardware ACL entry is ACL1, matching Ethernet type 0x0806, executing the action CopyToCpu, performing hardware statistics, assuming that the message tag is 1. The second hardware ACL entry is ACL2, matching Ethernet type 0x0806, executing the action CopyToCpu, performing hardware statistics, assuming that the message tag is 2.
[0122] When the processor obtains a to-be-processed message from the CPU queue, the message tag corresponding to the obtained to-be-processed message is 1 or 2, and is counted in swCount[1] or swCount[2] according to the message tag.
[0123] When checking the packet loss statistics of the ARP protocol type through the CPU management command for the first time, assuming that the status of the first hardware ACL table item ACL1 is valid, ACL1 is uninstalled. Although the status of ACL1 is invalid, the status of ACL2 is valid, and then the ARP message will be reported to the CPU through ACL2. The processor reads the hardware count hwCount1 corresponding to ACL1 as the hardware statistics value of this time, assuming that hwCount1 is 1000.
[0124] When the processor obtains an ARP protocol packet with a packet tag of 2, it indicates that the ARP protocol packet reported with the packet tag corresponding to ACL1 has been reported to the CPU for processing. The software count swCount[1] with a packet tag of 1 is read as the current software statistics value, and pre_swCount[1] = swCount[1] and pre_hwCount[1] = hwCount1 are recorded. Assume that when checking the packet loss statistics this time, the software statistics value read is 800.
[0125] Since this is the first time to check ARP packet loss statistics, ACL1 has been in effect. The last hardware statistics value pre_hwCount[2] and the last software statistics value pre_swCount[2] are obtained according to packet tag 2. 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 switch chip is 1000, that is, hwCount1+pre_hwCount[2]=1000+0=1000, and the total software statistics processed by the processor is 800, that is, swCount[1]+pre_swCount[2]=800+0=800. The total software statistics value is less than the total hardware statistics value, 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, that is, 1000-800=200. At the same time, the value of hwCount1 (1000) needs to be updated to pre_hwCount[1], that is, update pre_hwCount[1]=1000, and the value of swCount[1] (800) needs to be updated to pre_hwCount[1], that is, update pre_hwCount[1]=800.
[0127] When you use the CPU management command to check the packet loss statistics of the ARP protocol type for the second time, the status of ACL1 is invalid. Reload ACL1 to update the status of ACL1 to valid. The counter of 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 the second query. Assuming that the number of ARP protocol packets that currently hit ACL2 is 500, hwCount2 is 500.
[0128] When the processor starts to obtain the ARP protocol message with message tag 1 from the CPU queue, it indicates that the ARP protocol message reported by ACL2 is processed. The software count swCount[2] of message tag 2 is read as the current software statistics value. Assume that when checking the packet loss statistics, the current software statistics value read is 400.
[0129] Therefore, when checking the ARP packet loss statistics for the second time, the total hardware statistics reported by the switch chip is 1500, that is, hwCount2+pre_hwCount[1]=500+1000=1500. The total software statistics processed by the processor is 1200, that is, swCount[2]+pre_swCount[1]=400+800=1200. The total number of ARP protocol packet losses is 300, that is, 1500-1200=300. At the same time, the value of hwCount2 (500) needs to be updated to pre_hwCount[2], that is, update pre_hwCount[2]=500, and the value of swCount[2] (400) needs to be updated to pre_hwCount[2], that is, update pre_hwCount[2]=400.
[0130] When the CPU management command is used to check the packet loss statistics of the ARP protocol type for the third time, ACL1 takes effect and ACL1 is uninstalled to make ACL1 invalid. The processor reads the hardware count hwCount1 corresponding to ACL1 as the hardware statistics value of the third query. Assuming that the current counter value of ACL1 is 1600, hwCount1 is 1600.
[0131] When the processor obtains the ARP protocol message with message tag 2 from the CPU queue, it indicates that the ARP protocol message reported by ACL1 has been processed. Assuming that the number of ARP protocol messages corresponding to message tag 1 processed by the CPU is 1300 by the third time, then swCount[1] = 1300.
[0132] Therefore, when checking the ARP packet loss statistics for the third time, the total hardware statistics reported by the switch chip is 2100, that is, hwCount1+pre_hwCount[2]=1600+500=2100. The total software statistics processed by the processor is 1700, that is, swCount[1]+pre_swCount[2]=1300+400=1700. The total number of ARP protocol packet losses is 400, that is, 2100-1700=400.
[0133] It can be seen that the embodiment of the present invention utilizes the first hardware ACL table item and the second hardware ACL table item of different priorities to alternately and accurately count the hardware counts of various message features reported by the switching chip, and carries the message tag corresponding to the ACL table item when reporting the message, so that the processor can quickly obtain the software counts of various protocol type features according to the message tag, thereby quickly and accurately counting the number of packet loss of each protocol message, while reducing resource consumption, improving the accuracy and timeliness of packet loss statistics, thereby improving the operation and maintenance efficiency of network equipment, reducing operation and maintenance costs, and improving the usability of network equipment.
[0134] Based on the same inventive concept, the basic principle and technical effect of the network device provided in the embodiment of the present invention when counting packet loss are the same as those in the above embodiment. For the sake of brief description, for parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above embodiment.
[0135] Please refer to Figure 6 , Figure 6 A block diagram of a packet loss statistics device 300 is provided for an embodiment of the present invention. The packet loss statistics device 300 is applied to a network device, and the network device 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] The processing module 301 is used to receive a packet loss query instruction and obtain a protocol type feature of a protocol message to be queried;
[0137] The statistics module 302 is used to obtain the corresponding total hardware statistics and total software statistics according to the protocol type characteristics; the total hardware statistics is the total number of messages reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics is the total number of messages 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 packet loss number of the protocol message to be queried.
[0139] In summary, the packet loss statistics device provided in the embodiment of the present invention counts the total number of messages reported by the switching chip to the CPU and the total number of messages processed by the CPU based on protocol type characteristics. According to the total number of messages reported by the switching chip to the CPU and the total number of messages processed by the CPU, the total number of packet losses corresponding to various protocol messages can be accurately obtained, thereby effectively improving the accuracy of packet loss statistics, reducing the operation and maintenance costs of network equipment, and improving the usability of network equipment.
[0140] Optionally, a hardware ACL table is provided on the switching chip, and the hardware ACL table includes a first hardware ACL table item and a second hardware ACL table item that match the protocol type feature, and the priority of the first hardware ACL table item is higher than the priority of the second hardware ACL table item. The statistical module 302 is specifically used to uninstall the first hardware ACL table item when it is determined that the state of the first hardware ACL table item is valid according to the protocol type feature; obtain the current hardware statistical value corresponding to the first hardware ACL table item, and obtain the current software statistical value of the protocol message to be queried that has been reported to the CPU for processing after hitting the first hardware ACL table item; obtain the last hardware statistical value of the saved protocol message to be queried that hits the second hardware ACL table item, and obtain the last software statistical value of the protocol message to be queried that has been reported to the CPU for processing after hitting the second hardware ACL table item; determine the sum of the current hardware statistical value and the last hardware statistical value as the total hardware statistical value; determine the sum of the current software statistical value and the last software statistical value as the total software statistical value.
[0141] Optionally, the first hardware ACL table item and the second hardware ACL table item are used to add corresponding message tags to the protocol message with the protocol type feature and then send it to the CPU. The statistical module 302 is specifically used to obtain the value of the counter of the first hardware ACL table item to obtain the current hardware statistical value; when the CPU starts to process the protocol message to be queried with the message tag corresponding to the second hardware ACL table item, the protocol message to be queried with the message tag corresponding to the first hardware ACL table item processed by the CPU is obtained to obtain the current software statistical value.
[0142] Optionally, the statistical module 302 is specifically used to save the current hardware statistical value as the last hardware statistical value of the protocol message to be queried hitting the first hardware ACL table item after obtaining the total packet loss number of the protocol message to be queried; and use the current software statistical value as the last software statistical value reported to the CPU after the protocol message to be queried hitting the first hardware ACL table item.
[0143] Optionally, the processing module 301 is further configured to receive again a packet loss query instruction for obtaining a protocol message to be queried.
[0144] The statistical module 302 is further used to reinstall the first hardware ACL table item to make it effective according to the protocol type characteristics; obtain the current hardware statistical value corresponding to the second hardware ACL table item, and obtain the current software statistical value of the protocol message to be queried processed by the CPU after hitting the second hardware ACL table item; obtain the last hardware statistical value of the saved protocol message to be queried hitting the first hardware ACL table item, and obtain the last software statistical value of the protocol message to be queried processed by the CPU after hitting the first hardware ACL table item; determine the sum of the newly obtained current hardware statistical value and the newly obtained last hardware statistical value as a new total hardware statistical value; determine the sum of the newly obtained current software statistical value and the newly obtained last software statistical value as a new total software statistical value.
[0145] The calculation module 303 is further used to calculate the difference between the new total hardware statistics value and the new total software statistics value to obtain the latest total packet loss number of the protocol message to be queried.
[0146] Optionally, the statistical module 302 is specifically used to reinstall the first hardware ACL item to make it effective when it is determined that the status of the first hardware ACL item is invalid based on the protocol type characteristics; obtain the current hardware statistical value corresponding to the second hardware ACL item, and obtain the current software statistical value of the protocol message to be queried processed by the CPU after hitting the second hardware ACL item; obtain the last hardware statistical value of the saved protocol message to be queried hitting the first hardware ACL item, and obtain the last software statistical value of the protocol message to be queried of the first hardware ACL item after being reported to the CPU for processing; determine the sum of the current hardware statistical value and the last hardware statistical value as the total hardware statistical value; determine the sum of the current software statistical value and the last software statistical value as the total software statistical value.
[0147] Please refer to Figure 7 , Figure 7 A block diagram of a network device 200 provided by 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 messages to the processor 220 based on the protocol type feature statistics.
[0148] The memory 230 is used to store programs or data. The memory 230 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an 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 execute corresponding functions. For example, when the 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 the structure of the network device 200. The network device 200 may also include Figure 7 More or fewer components as shown, or with Figure 7 Different configurations are shown. Figure 7 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0151] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by the processor 220, the packet loss statistics method disclosed in the above embodiments is implemented.
[0152] The embodiment of the present invention further provides a program product, which, when executed by the processor 220, implements the packet loss statistics method disclosed in the above embodiments.
[0153] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0154] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0155] If the functions are implemented in the form of software function 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 the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0156] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A packet loss statistics method, characterized in that: Applied to a network device, the network device includes a CPU and a switching chip, and the method includes: Receive a packet loss query instruction and obtain the protocol type characteristics of the protocol message to be queried; According to the protocol type characteristics, the corresponding total hardware statistics and total software statistics are obtained; 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 of the protocol message to be queried.
2. The packet loss statistics method according to claim 1, characterized in that: The switching chip is provided with a hardware ACL table, wherein the hardware ACL table includes a first hardware ACL table item and a second hardware ACL table item that match the protocol type feature, wherein the priority of the first hardware ACL table item is higher than the priority of the second hardware ACL table item, and the acquiring the corresponding total hardware statistics and total software statistics according to the protocol type feature includes: When determining, according to the protocol type feature, that the state of the first hardware ACL entry is valid, uninstalling the first hardware ACL entry; Acquire the current hardware statistics corresponding to the first hardware ACL entry, and acquire the current software statistics of the protocol message to be queried and processed by the CPU after hitting the first hardware ACL entry; Obtain the saved hardware statistics of the last time the protocol message to be queried hits the second hardware ACL entry, and obtain the last software statistics of the protocol message to be queried processed by the CPU after hitting the second hardware ACL entry; Determine the sum of the current hardware statistics value and the previous hardware statistics value 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.
3. The packet loss statistics method according to claim 2, characterized in that: The first hardware ACL table item and the second hardware ACL table item are used to add corresponding message tags to the protocol message with the protocol type feature and then send it to the CPU; the obtaining of the current hardware statistics corresponding to the first hardware ACL table item and the obtaining of the current software statistics of the protocol message to be queried processed by the CPU after hitting the first hardware ACL table item include: Obtaining the value of the counter of the first hardware ACL table entry to obtain the current hardware statistics value; When the CPU starts to process the protocol message to be queried with the message mark corresponding to the second hardware ACL table entry, the current software statistical value is obtained by obtaining the statistics of the protocol message to be queried with the message mark corresponding to the first hardware ACL table entry processed by the CPU.
4. The packet loss statistics method according to claim 3, characterized in that: The method further comprises: After obtaining the total number of packet losses of the protocol message to be queried, the current hardware statistical value is saved as the last hardware statistical value of the protocol message to be queried hitting the first hardware ACL table item; the current software statistical value is used as the last software statistical value of the protocol message to be queried processed by the CPU after hitting the first hardware ACL table item.
5. The packet loss statistics method according to claim 4, characterized in that: The method further comprises: Receiving again a packet loss query instruction for obtaining the protocol message to be queried; Reinstall the first hardware ACL entry to make it effective according to the protocol type characteristics; Acquire the current hardware statistics corresponding to the second hardware ACL entry, and acquire the current software statistics of the protocol message to be queried and processed by the CPU after hitting the second hardware ACL entry; Obtain the saved hardware statistics of the last time the protocol message to be queried hits the first hardware ACL entry, and obtain the last software statistics of the protocol message to be queried processed by the CPU after hitting the first hardware ACL entry; The sum of the newly obtained hardware statistics value of this time and the newly obtained hardware statistics value of the previous time is determined as the new total hardware statistics value; The sum of the newly obtained current software statistics value and the newly obtained last software statistics value is determined as a new total software statistics value; The difference between the new total hardware statistics value and the new total software statistics value is calculated to obtain the latest total packet loss quantity of the protocol message to be queried.
6. The packet loss statistics method according to claim 1, characterized in that: The switching chip is provided with a hardware ACL table, wherein the hardware ACL table includes a first hardware ACL table item and a second hardware ACL table item that match the protocol type feature, wherein the priority of the first hardware ACL table item is higher than the priority of the second hardware ACL table item, and the acquiring the corresponding total hardware statistics and total software statistics according to the protocol type feature includes: When determining, according to the protocol type feature, that the state of the first hardware ACL entry is invalid, reinstalling the first hardware ACL entry to make it effective; Acquire the current hardware statistics corresponding to the second hardware ACL entry, and acquire the current software statistics of the protocol message to be queried and processed by the CPU after hitting the second hardware ACL entry; Obtain the saved hardware statistics of the last time the protocol message to be queried hits the first hardware ACL table item, and obtain the software statistics of the last time the protocol message to be queried of the first hardware ACL table item is processed by the CPU; Determine the sum of the current hardware statistics value and the previous hardware statistics value 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.
7. A packet loss statistics device, characterized in that: Applied to a network device, the network device includes a CPU and a switching chip, and the device includes: A processing module, used for receiving a packet loss query instruction and obtaining a protocol type feature of a protocol message to be queried; A statistics module, used for obtaining corresponding total hardware statistics and total software statistics according to the protocol type characteristics; the total hardware statistics is the total number of messages reported to the CPU by the switching chip based on the protocol type characteristics; the total software statistics is the total number of messages 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 packet loss number of the protocol message to be queried.
8. A network device, characterized in that: It includes a switching chip, a processor and a memory, the switching chip reports the total number of messages to the processor based on protocol type feature statistics, the memory stores machine executable instructions that can be executed by the processor, and the processor can execute the machine executable instructions to implement the packet loss statistics method described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the packet loss statistics method according to any one of claims 1 to 6 is implemented.
10. A program product, characterized in that When the program product is executed by a processor, the packet loss statistics method according to any one of claims 1 to 6 is implemented.
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
Message anti-attack method and equipment
CN112367313A
Protocol message processing method and device, equipment and medium
CN112468415A
Packet loss processing method, device and equipment and computer readable storage medium
CN112637083A