Packet loss statistical method and device
By creating a virtual output queue (VOQ) for communication equipment and setting packet loss counting matching conditions, the problem of communication equipment being unable to perform fine-grained packet loss statistics is solved, enabling fine-grained packet loss statistics and efficient utilization of hardware resources, thereby improving fault location efficiency.
Patent Information
- Application Number
- CN202511393527.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-26
- Publication Date
- 2025-11-18
AI Technical Summary
Existing communication equipment cannot accurately track packet loss or quickly locate internal paths, resulting in maintenance personnel lacking precise information for troubleshooting and decision-making.
By creating a virtual output queue (VOQ) for each physical port and setting packet loss count matching conditions for each VOQ, and binding counter entries using a hardware statistics engine, fine-grained statistics on the causes of packet loss can be achieved.
It enables fine-grained packet loss statistics within the device, improves statistical granularity and matching accuracy, optimizes hardware resource utilization, and enhances fault location efficiency and maintenance convenience.
Smart Images

Figure CN120979986A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the communication technology, and in particular to a packet loss statistics method and device. BACKGROUND
[0002] In various scenarios such as enterprise networks, data centers, and carrier backbones, communication devices need to perform high-speed and accurate packet forwarding between multiple ports. In a complex network environment, the traffic paths between different ports of a communication device are extremely rich and changeable: the service traffic sent by each port of the communication device may reach via different ports of the device; similarly, the service traffic reaching each port of the communication device will be sent via different ports based on different destination addresses or strategies.
[0003] Currently, when a packet loss occurs at a certain port of a communication device, only the total number of packet losses at the port can be counted, and the packet loss situation on the specific internal path from which port to which port within the communication device cannot be refined, nor can the different packet loss reasons be finely distinguished. Therefore, the path of the packet loss occurring within the communication device cannot be quickly located; the operation and maintenance personnel lack accurate information to switch service flows or take mitigation measures, delaying the troubleshooting and decision-making opportunity. SUMMARY
[0004] The purpose of the present application is to provide a packet loss statistics method and device to realize refined packet loss statistics of internal paths of a device.
[0005] To achieve the above purpose, the present application provides a packet loss statistics method, which comprises: sequentially creating a number of N virtual output queues (VOQs) for each physical port; wherein N is the number of priority queues; recording the physical port and the priority queue mapped by each VOQ; reserving Mx(MxN) counter entries of a hardware statistics engine; allocating each segment of MxN consecutive counter entries of all the reserved counter entries to each physical port in turn and binding each VOQ one by one; setting the packet loss counting matching condition of each VOQ, and setting the packet loss counting matching condition of each VOQ in each counter entry bound one by one; locating the counter entry segment corresponding to the arrival physical port of the discarded packet; in the located counter entry segment, counter chasing the counter entry corresponding to the VOQ of the discarded packet; if the packet loss reason of the discarded packet is consistent with the packet loss counting matching condition of the counter entry, then the current counting value of the counter entry is incremented by one.
[0006] To achieve the above object, the application provides a packet loss statistics device, which comprises a setting module, which sequentially creates a number of N virtual output queues (VOQ) for each physical port; wherein N is the number of priority queues; records the physical port and the priority queue mapped by each VOQ; reserves Mx(MxN) counter entries of a hardware statistics engine; allocates each segment of MxN continuous counter entries of all the reserved counter entries to each physical port sequentially and binds each counter entry to a VOQ; sets the packet loss counting matching condition of each VOQ; and a hardware statistics engine, which locates the counter entry segment corresponding to the arrival physical port of the discarded packet; reverses the counter entry corresponding to the VOQ of the discarded packet in the located counter entry segment; and adds one to the current counting value of the reversed counter entry when the packet loss reason of the discarded packet is consistent with the packet loss counting matching condition of the reversed counter entry.
[0007] The application has the beneficial effects of realizing fine packet loss statistics in the device, improving the statistics granularity and matching accuracy, optimizing the utilization rate of hardware resources, supporting independent clearing and extended maintenance of the sub-port / sub-queue, and improving the fault positioning efficiency and operation and maintenance convenience of the network device. BRIEF DESCRIPTION OF DRAWINGS
[0008] Figure 1 The flow chart of the packet loss statistics method embodiment provided by the application;
[0009] Figures 2A-2B The schematic diagram of creating a virtual output queue for the embodiment of the application;
[0010] Figure 3 The flow chart of the method embodiment provided by the application for timing statistics of packet loss;
[0011] Figure 4 The flow chart of the packet loss statistics method embodiment provided by the application for the internal forwarding path between the ports of the communication device;
[0012] Figure 5 The flow chart of the method embodiment provided by the application for clearing the packet loss statistics value;
[0013] Figure 6 The flow chart of another method embodiment provided by the application for clearing the packet loss statistics value;
[0014] Figure 7 The schematic diagram of the packet loss statistics device embodiment provided by the application. DETAILED DESCRIPTION
[0015] The following detailed description will be provided with reference to several examples illustrated in the accompanying figures. In this detailed description, numerous specific details are used to provide a comprehensive understanding of the present application. Known methods, steps, components, and circuits are not described in detail in the examples to avoid obscuring their meaning.
[0016] In the terminology used, the term "including" means including but not limited to; the term "containing" means including but not limited to; the terms "above," "within," and "below" include the number itself; the terms "greater than" and "less than" mean not including the number itself. The term "based on" means based on at least a portion of them.
[0017] Figure 1 This is a flowchart illustrating an embodiment of the packet loss statistics method provided in this application. The embodiment includes...
[0018] Step 101: Create N virtual output queues (VOQs) for each physical port in sequence; where N is the number of priority queues.
[0019] Step 102: Record the physical port and priority queue for each VOQ mapping;
[0020] Step 103: Reserve M×(M×N) counter entries for the hardware statistics engine;
[0021] Step 104: Allocate each segment of M×N consecutive counter entries of all reserved counter entries to each physical port in sequence and bind each one to a VOQ;
[0022] Step 105: Set the packet loss count matching condition for each VOQ, and set the packet loss count matching condition for each VOQ to each bound counter entry.
[0023] Step 106: Locate the counter entry field corresponding to the physical port of the dropped packet;
[0024] Step 107: In the located counter entry segment, reverse lookup to read the priority of the dropped packet and the VOQ corresponding to the physical port it arrived at;
[0025] Step 107: If the reason for packet loss of the discarded message matches the packet loss count of the reverse VOQ, then the count value of the reverse VOQ is incremented by one.
[0026] Figure 1 The beneficial effects of this embodiment are that it enables fine-grained packet loss statistics within the device, improves statistical granularity and matching accuracy, optimizes the utilization of hardware resources, supports independent clearing and extended maintenance by port / queue, and improves the fault location efficiency and maintenance convenience of network devices.
[0027] In one example, this application embodiment is based on the PCP (Priority Code Point) bit in the VLAN tag specified by IEEE 802.1p, which has a value range of 0 to 7, or the COS (Class of Service) value obtained by mapping the IP packet's Type of Service (ToS / DSCP); and creates a VOQ (Virtual Output Queue) for each physical port.
[0028] like Figure 2A As shown, the communication device has four physical ports, port1-port4. VOQ1-VOQ8 are created for port1; VOQ9-VOQ17 are created for port2; VOQ17-VOQ24 are created for port3; and VOQ25-VOQ32 are created for port4. For example... Figure 2B As shown, the physical port and priority queue for each VOQ mapping are recorded.
[0029] In this embodiment of the application, in order to count the number of packet losses in the specific internal path from any port to any port, it is necessary to set a separate counter for each VOQ queue of ports1-port4 that are scheduled to arrive on the communication device via ports1-port4.
[0030] The total number of counters calculated by the communication equipment is 4 × (4 × 8) = 128, with 128 counter entries reserved for the hardware statistics engine. A counter entry is a separate hardware counting slot in the hardware statistics engine, identified by an index, and used to count events under specific conditions. This application uses one counter entry to count packet loss events of packets received through a certain port and scheduled to a certain VOQ.
[0031] For example, assign counter entries 1-32 to port1 and bind them to VOQ1-VO32 one by one; assign counter entries 33-64 to port2 and bind them to VOQ1-VO32 one by one; assign counter entries 65-96 to port3 and bind them to VOQ1-VO32 one by one; assign counter entries 97-128 to port4 and bind them to VOQ1-VO32 one by one.
[0032] The communication equipment assigns 32 consecutive counter entries in each segment of 128 reserved counter entries to each physical port Port1-Port4 in sequence.
[0033] The communication device assigns entries 1–32 to port 1 and binds them to VOQ1–VOQ32 respectively; assigns entries 33–64 to port 2 and binds them to VOQ1–VOQ32 respectively; assigns entries 65–96 to port 3 and binds them to VOQ1–VOQ32 respectively; and assigns entries 97–128 to port 4 and binds them to VOQ1–VOQ32 respectively.
[0034] The communication equipment sets packet loss counting matching conditions for VOQ1-VOQ32, such as buffer overflow, link congestion, ACL (Access Control List) dropping, security policy blocking, hardware anomalies, etc. For example, buffer overflow can be set as the packet loss counting matching condition for VOQ1 and VOQ2.
[0035] This application embodiment binds a single packet loss count matching condition, but in the implementation process, VOQ can also be bound to multiple packet loss count matching conditions.
[0036] For example, the communication device sets the packet loss count matching condition "buffer overflow" for VOQ1 to the corresponding bound counter entries entry1, entry33, entry65, and entry97; and sets the packet loss count matching condition "buffer overflow" for VOQ2 to the corresponding bound counter entries entry2, entry34, entry66, and entry98; and so on.
[0037] Thus, the statistical conditions corresponding to each counter (entry1, entry33, entry65, entry97) include: packets arriving at port1, scheduled to VOQ1 on port1, and lost due to buffer overflow; packets arriving at port2, scheduled to VOQ1 on port1, and lost due to buffer overflow; packets arriving at port3, scheduled to VOQ1 on port1, and lost due to buffer overflow; and packets arriving at port4, scheduled to VOQ1 on port1, and lost due to buffer overflow.
[0038] The statistical conditions corresponding to each counter (entry2, entry34, entry66, entry98) include: packets arriving at port1, scheduled to VOQ2 of port1, and lost due to buffer overflow; packets arriving at port2, scheduled to VOQ2 of port1, and lost due to buffer overflow; packets arriving at port3, scheduled to VOQ2 of port1, and lost due to buffer overflow; and packets arriving at port4, scheduled to VOQ2 of port1, and lost due to buffer overflow.
[0039] Multiple packets arriving at port1 of the communication device are scheduled to VOQ1 of port1 and VOQ25 of port4 through the switching architecture. These packets are dropped due to buffer overflow, generating a packet loss event.
[0040] The hardware statistics engine of the communication equipment's switching architecture first locates the counter entry segments entry1-entry32 based on the arrival port (ingress port) of the packet loss event. Within the counter entry segments entry1-entry32, it reverses the lookup of the corresponding counter entries entry1 and entry25 for VOQ1 and VOQ25. If the packet loss counting matching condition configured for counter entry1 matches the packet loss cause of the packet loss event, the current count value of counter entry1 is incremented by 1. If the packet loss counting matching condition for counter entry25 does not match the packet loss cause of the packet loss event, the current count value of counter entry25 is not incremented.
[0041] When multiple packets arriving at port2 of a communication device are scheduled to VOQ2 of port1 via the switching architecture, these packets are dropped due to buffer overflow, generating a packet loss event.
[0042] The hardware statistics engine of the communication equipment's switching architecture first locates the counter entry segments entry33-entry64 based on the arrival port (port2) of the packet loss event. Within these segments, it reverses the lookup to find the corresponding counter entries for VOQ1 and VOQ2, which are entry33 and entry34. If the packet loss count matching condition configured for entry33 matches the packet loss cause of the event, the current count value of entry33 is incremented by 1. If the packet loss count matching condition for entry34 matches the packet loss cause of the event, the current count value of entry34 is incremented by 1.
[0043] Figure 3 A flowchart illustrating an embodiment of a method for periodically counting packet loss, as provided in this application.
[0044] Step 301: Set a query timer to be triggered periodically for the specified packet loss count matching conditions;
[0045] Step 302: When the query timer is triggered, read the current count value of each counter entry bound to each virtual output queue (VOQ) that is bound to the specified packet loss count matching condition in sequence.
[0046] In one example, after the communication device completes setting the packet loss count matching conditions for each VOQ to each bound counter entry, a timer task can be set to count the number of packets lost due to the cause of packet loss, based on business requirements.
[0047] For example, the "hardware anomaly" counting matching condition bound to VOQ16 includes counter entries 16, 48, 80, and 112. The communication device sets a timer task with the packet loss counting matching condition of "hardware anomaly." When the timer reaches its set query period, it sends a "hardware anomaly" counting query request to the hardware statistics engine. The hardware statistics engine reads the packet loss counting matching conditions set for each counter entry (entry16, 48, 80, 112). If the packet loss counting matching condition for counter entries 16, 48, 80, and 112 is "hardware anomaly," then it reads the current count value of each counter entry (entry16, 48, 80, 112).
[0048] Figure 4 The diagram shows a flowchart of an embodiment of the packet loss statistics method for internal forwarding paths between communication device ports provided in this application. This embodiment includes...
[0049] Step 401: Obtain the specified arrival physical port and specified sending physical port carried in the packet loss statistics request;
[0050] Step 402: Among all reserved counter entries, determine the counter entry segment corresponding to the specified arrival physical port;
[0051] Step 403: In the determined counter entry segment, locate the counter entry that is bound to each VOQ for the specified sending physical port.
[0052] Step 404: Read the current count value of the counter entry bound to each VOQ of the specified sending physical port to obtain the dropped message statistics of each VOQ from the specified arriving physical port to the specified sending physical port.
[0053] In one example, when a communication device needs to count the number of packet losses arriving at port 3 and sending at port 4, the hardware statistics engine locates the counter entry segments entry65-entry96 based on the arrival port 3 of the packet loss event, and then locates entry89-entry96 based on VOQ25-VOQ32 mapped to port 4, thereby obtaining the number of packet losses already counted for arrival at port 3 and sending at port 4, that is, the number of packet losses counted according to the packet loss matching conditions of these counter entries.
[0054] Figure 5 The diagram shown is a flowchart of an embodiment of the method for clearing packet loss statistics provided in this application.
[0055] Step 501: Obtain the specified arriving physical port carried by the count clearing request;
[0056] Step 502: Among all reserved counter entries, determine the counter entry segment corresponding to the specified arrival physical port;
[0057] Step 503: Clear the current count value of all counter entries in the determined counter entry segment.
[0058] In one example, the communication device needs to clear the packet loss counts for ports 1 and 4. The hardware statistics engine locates the counter entries 1-32 based on the arrival port 1 specified in the counting request and clears the current counts for these entries.
[0059] The hardware statistics engine locates the counter entries 97-128 based on the arrival port 4 specified in the counting request and clears the current count values of these counter entries 97-128.
[0060] Figure 6 The diagram shown is a flowchart of another embodiment of the method for clearing packet loss statistics provided in this application.
[0061] Step 601: Obtain the specified physical port to send the count clearing request;
[0062] Step 602: In all reserved counter entries, clear the current count value of the counter entry bound to each VOQ for the specified sending port.
[0063] In one example, the communication device needs to clear the packet loss count for port 2. The hardware statistics engine, based on VOQ9-VOQ16 specified in the counting request for port 2, locates the corresponding counter entries bound to VOQ9-VOQ16: entries 9-16 of the counter entry segment for port 1, entries 41-48 of the counter entry segment for port 2, entries 73-80 of the counter entry segment for port 3, and entries 105-112 of the counter entry segment for port 4, and clears the current count values of these located counter entries.
[0064] Figure 7 This is a schematic diagram of an embodiment of the packet loss statistics device provided in this application. The device 70 includes a setting module 71, a hardware statistics engine 72, a timing setting module 73, and a query timer 74.
[0065] Module 71 is configured to create N virtual output queues (VOQs) for each physical port, where N is the number of priority queues; record the physical port mapped to each VOQ and the priority queue; reserve M×(M×N) counter entries for the hardware statistics engine; assign each segment of M×N consecutive counter entries from all reserved counter entries to each physical port and bind them to a VOQ; set the packet loss count matching condition for each VOQ and set the packet loss count matching condition for each VOQ to each bound counter entry.
[0066] The hardware statistics engine 72 locates the counter entry segment corresponding to the physical port of the dropped packet; in the located counter entry segment, it reverse-looks up the counter entry corresponding to the VOQ of the dropped packet in the cache; if the packet loss reason of the dropped packet matches the packet loss count matching condition of the reverse-looked counter entry, the current count value of the reverse-looked counter entry is incremented by one.
[0067] The timing setting module 73 is used to set a query timer that is triggered according to a specified query period for a specified packet loss count matching condition; the query timer 74 is used to time based on a specified query period and send a query request for the specified packet loss count matching condition when the specified query period arrives; the hardware statistics engine 72 is used to respond to the query request and sequentially read the current count value of the counter entries bound to each virtual output queue (VOQ) bound to the specified packet loss count matching condition.
[0068] The hardware statistics engine 72 is also used to obtain the specified arriving physical port and specified sending physical port carried in the packet loss statistics request; determine the counter entry segment corresponding to the specified arriving physical port among all reserved counter entries; locate the counter entry bound to each VOQ of the specified sending physical port in the determined counter entry segment; and read the current count value of the counter entry bound to each VOQ of the specified sending physical port to obtain the dropped packet statistics information of each VOQ from the specified arriving physical port to the specified sending physical port.
[0069] The hardware statistics engine 72 is also used to obtain the specified arriving physical port carried in the counter clearing request; determine the counter entry segment corresponding to the specified arriving physical port among all reserved counter entries; and clear the current count value of all counter entries in the determined counter entry segment.
[0070] The hardware statistics engine 72 is also used to obtain the specified sending physical port carried in the count clearing request; in all reserved counter entries, the current count value of the counter entry bound to each VOQ of the specified sending port is cleared.
[0071] In this application, a machine-readable storage medium can be any electronic, magnetic, optical, or other physical storage device used to store or contain information (such as executable instructions, data, etc.). For example, any machine-readable storage medium herein can be any type of random access memory (RAM), volatile memory, non-volatile memory, flash memory, storage drive (such as a hard disk drive), solid-state drive, any type of optical disc (such as an optical disc, DVD, etc.), and similar devices, or combinations thereof. Furthermore, any machine-readable storage medium herein can be a non-transitory machine-readable storage medium.
[0072] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A packet loss statistics method, characterized in that, The method includes, Create N virtual output queues (VOQs) for each physical port in sequence; where N is the number of priority queues. Record the physical port and priority queue for each VOQ mapping; M×(M×N) counter entries are reserved for the hardware statistics engine; where M is the total number of physical ports; All M×N consecutive counter entries of all reserved counter entries are sequentially assigned to each of the physical ports and bound to one of the VOQs; Set the packet loss count matching condition for each VOQ, and set the packet loss count matching condition for each VOQ to each bound counter entry; Locate the counter entry field corresponding to the physical port where the dropped packet arrived; In the located counter entry segment, reverse lookup the counter entry corresponding to the VOQ of the cached dropped message; If the reason for packet loss of the discarded message matches the packet loss count matching condition of the reverse lookup counter entry, then the current count value of the reverse lookup counter entry is incremented by one.
2. The method according to claim 1, characterized in that, The method includes, Set a query timer that is triggered periodically for a specified packet loss count matching condition; When the query timer is triggered, the current count value of each counter entry bound to each virtual output queue (VOQ) that is bound to the specified packet loss count matching condition is read sequentially.
3. The method according to claim 1, characterized in that, The method also includes, The request to obtain packet loss statistics carries the specified arrival physical port and the specified sending physical port; Among all the reserved counter entries, determine the counter entry segment corresponding to the specified arrival physical port; Within the defined counter entry segment, locate the counter entry bound to each VOQ of the specified transmit physical port; Read the current count value of the counter entry bound to each VOQ of the specified sending physical port to obtain the dropped message statistics of each VOQ from the specified arriving physical port to the specified sending physical port.
4. The method according to claim 1, characterized in that, The method also includes, Retrieve the specified arriving physical port carried by the count clearing request; Among all the reserved counter entries, determine the counter entry segment corresponding to the specified arrival physical port; Clear the current count value of all counter entries in the identified counter entry segment.
5. The method according to claim 1, characterized in that, The method also includes, Retrieve the specified physical port to send the count clearing request; In all the reserved counter entries, the current count value of the counter entry bound to each VOQ of the specified transmission port is cleared.
6. A packet loss statistics device, characterized in that, The device includes, The configuration module sequentially creates N virtual output queues (VOQs) for each physical port, where N is the number of priority queues; records the physical port mapped to each VOQ and the priority queue; reserves M×(M×N) counter entries for the hardware statistics engine; assigns each segment of M×N consecutive counter entries from all reserved counter entries to each physical port and binds them to one of the VOQs; and sets the packet loss count matching condition for each VOQ, setting the packet loss count matching condition for each VOQ to each bound counter entry. The hardware statistics engine locates the counter entry segment corresponding to the physical port to which the dropped packet arrived; in the located counter entry segment, it reverse-looks up the priority of the dropped packet and the VOQ corresponding to the physical port; if the packet loss reason of the dropped packet matches the packet loss count matching condition of the reverse-lookup VOQ, the count value of the reverse-lookup VOQ is incremented by one.
7. The device according to claim 6, characterized in that, The timer setting module is used to set a query timer that is triggered according to a specified query period for a specified packet loss count matching condition; A query timer is used to keep time based on the specified query period, and to send a query request for the specified packet loss count matching condition when the specified query period arrives. The hardware statistics engine is used to respond to the query request by sequentially reading the current count value of each counter entry bound to each virtual output queue (VOQ) that is bound to the specified packet loss count matching condition.
8. The device according to claim 6, characterized in that, The hardware statistics engine is also used to obtain the specified arrival physical port and specified sending physical port carried in the packet loss statistics request; determine the counter entry segment corresponding to the specified arrival physical port in all the reserved counter entries; locate the counter entry bound to each VOQ of the specified sending physical port in the determined counter entry segment; and read the current count value of the located counter entry bound to each VOQ of the specified sending physical port to obtain the dropped packet statistics information of each VOQ from the specified arrival physical port to the specified sending physical port.
9. The device according to claim 6, characterized in that, The hardware statistics engine is also used to obtain the specified arriving physical port carried in the counter clearing request; determine the counter entry segment corresponding to the specified arriving physical port among all the reserved counter entries; and clear the current count value of all counter entries in the determined counter entry segment.
10. The device according to claim 6, characterized in that, The hardware statistics engine is also used to obtain the specified sending physical port carried in the count clearing request; in all the reserved counter entries, the current count value of the counter entry bound to each VOQ of the specified sending port is cleared.