A method and apparatus for measuring packet loss and delay.

By setting up a coprocessor in the forwarding device to periodically update the status table, precisely control the switching of the L flag bit and uniformly configure the D flag bit, the problem of inaccurate packet loss and delay measurement under CPU control is solved, and accurate and flexible packet loss and delay measurement is achieved.

CN116827827BActive Publication Date: 2026-07-17SUZHOU CENTEC COMM CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SUZHOU CENTEC COMM CO LTD
Filing Date
2023-08-07
Publication Date
2026-07-17

AI Technical Summary

Technical Problem

In existing technologies, the switching of L and D flags controlled by the CPU is inaccurate, leading to inaccurate packet loss and latency measurements, especially with large latency measurement errors in high-traffic networks.

Method used

By setting up a coprocessor in the forwarding device, periodically updating the status table, precisely controlling the switching of the L flag bit, and uniformly configuring the value of the D flag bit, accurate measurement of packet loss and latency can be achieved.

Benefits of technology

It achieves both accuracy and flexibility in packet loss and delay measurement, avoids delay measurement errors caused by configuring the D flag bit for multiple messages simultaneously, and improves measurement accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116827827B_ABST
    Figure CN116827827B_ABST
Patent Text Reader

Abstract

This invention discloses a method and apparatus for measuring packet loss and latency, belonging to the field of network communication technology. The method includes matching incoming packets, obtaining a basic pointer to the incoming statistics table and a state table pointer, further looking up the state table based on the state table pointer to obtain the values ​​of the L flag and D flag, and further performing incoming packet statistics based on the L flag and the basic pointer to the incoming statistics table. In the outgoing packet matching process, the method obtains the basic pointer to the outgoing statistics table and matches the D flag, determines whether to obtain the current timestamp based on the matching result, further performing outgoing packet statistics based on the L flag and the basic pointer to the outgoing statistics table, and reporting the obtained current timestamp. Finally, the method performs packet editing and forwarding based on the L flag and the D flag. This invention can precisely control the periodic switching of the L flag value and uniformly configure the D flag value, achieving accurate measurement of packet loss and latency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network communication technology, and in particular to a method for measuring packet loss and latency, as well as an apparatus for implementing the method. Background Technology

[0002] Network measurement is crucial for in-depth research and analysis of network performance indicators and operating parameters. Therefore, it is necessary to measure packet loss and latency in network traffic.

[0003] Packet loss measurement refers to the virtual segmentation of traffic into contiguous blocks, each block representing a measurable entity that all network devices can clearly identify. By calculating the number of data packets in each block and comparing the values ​​measured by different network devices along the path, data packet loss occurring in any single block between any two points can be measured. Block creation typically involves "coloring" the traffic (e.g., using two colors to distinguish them), with data packets belonging to different contiguous blocks having different colors. Whenever a color changes, the previous block terminates, and a new block begins. Therefore, all data packets belonging to the same block will have the same color, while data packets from different contiguous blocks will have different colors.

[0004] Latency measurement includes single-marking, double-marking, and alternating-marking methods. The single-marking method refers to using color alternation as a time reference for calculating latency. Whenever a color changes (meaning a new block has started), the network device can store the timestamp of the first datagram in the new block. This timestamp can be compared with the timestamp of the same datagram on a second router to calculate the datagram latency. This single-marking method is very sensitive to out-of-order datagram reception. To obtain more information about latency and resolve out-of-order issues, the double-marking method is typically used.

[0005] The dual-marking method refers to using a first mark to create a backup flow, and then using a second mark within this flow to select datagrams for latency measurement. The first mark is used for packet loss measurement. The second mark creates a new set of marked datagrams that are fully identifiable on the network, allowing network devices to store their timestamps. These timestamps can be compared to the timestamps of the same datagrams on a second router to calculate the latency of each datagram. The number of measurements can be easily increased by varying the frequency of the second mark. However, the frequency of the second mark cannot be too high to avoid out-of-order issues. This requires a safe time interval between datagrams with the second mark (e.g., this interval should at least be the average network latency calculated using the previous method) to avoid out-of-order problems and to have a number of rate-independent measurement datagrams. If a second-marked packet is lost, the latency measurement of the block being considered corrupted should be discarded.

[0006] The alternating marking method refers to marking the L and D flags in a message according to an alternating marking period (L flag is a color marker for packet loss measurement, and D flag is a color marker for delay measurement) to facilitate packet loss and delay measurement. In practice, the CPU controls the configuration of the L and D flags; that is, for the L flag, the CPU periodically sets it to 1 or 0, and for the D flag, the CPU sets it to 1 at a certain point in time and sets it to 0 when a message is sent. However, because the time interval controlled by the CPU is relatively coarse, there is a certain degree of error in accuracy. More importantly, because the traffic passing through the switching chip is very large, the CPU needs a message to pass before setting the D flag to 0, which can lead to multiple consecutive messages with the D flag simultaneously appearing, ultimately resulting in inaccurate delay measurements.

[0007] The information disclosed in this background section is intended only to enhance the understanding of the overall background of the invention and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention

[0008] The purpose of this invention is to provide a method and apparatus for measuring packet loss and delay, which can precisely control the periodic switching of the value of the L flag bit and uniformly configure the value of the D flag bit to achieve accurate and flexible measurement of packet loss and delay.

[0009] To achieve the above objectives, embodiments of the present invention provide a method for measuring packet loss and latency, the method comprising:

[0010] In the inbound direction, match the packets and obtain the basic pointer to the inbound statistics table and the pointer to the status table; look up the periodically updated status table according to the pointer to obtain the values ​​of the L flag and the D flag, and configure the D flag to zero after reading; perform inbound packet statistics according to the L flag and the basic pointer to the inbound statistics table.

[0011] In the outbound direction, match the message, obtain the basic pointer of the outbound statistics table, and match the D flag bit. Determine whether to obtain the current timestamp based on the matching result. Perform outbound message statistics based on the L flag bit and the basic pointer of the outbound statistics table, and report the obtained current timestamp when it is determined to obtain the current timestamp. Edit and forward the message based on the L flag bit and the D flag bit.

[0012] In one or more embodiments of the present invention, the state table is updated through the following steps:

[0013] a) When the scheduled time arrives, determine whether the item is being scanned for the first time based on the scanning parameters;

[0014] b. In response to the judgment result, configure the value of the L flag bit to the value corresponding to the corresponding period, or configure the value of the D flag bit to the first preset value;

[0015] c. Determine if the next entry is the last entry in the status table;

[0016] d, in response to the judgment result, directly return to execute step a, or perform a remainder operation between the current number of scans and the number of packets that need to be time-delayed and assign the remainder result to the scan parameters, and start executing step a from the first entry.

[0017] In one or more embodiments of the present invention, the state table is updated using a timer.

[0018] In one or more embodiments of the present invention, the status table pointers corresponding to several data streams with the same L flag value switching period are the same.

[0019] In one or more embodiments of the present invention, performing inbound packet statistics based on the L flag and the basic pointer of the inbound statistics table includes:

[0020] Add the value of the L flag bit to the base pointer of the inbound statistics table to obtain the pointer of the inbound statistics table, and increment the number of messages in the statistics table corresponding to the pointer of the inbound statistics table by one.

[0021] In one or more embodiments of the present invention, outbound message statistics based on the L flag and the outbound direction statistics table base pointer include:

[0022] Add the value of the L flag bit to the outbound statistics table base pointer to obtain the outbound statistics table pointer, and increment the message count in the statistics table corresponding to the outbound statistics table pointer by one.

[0023] In one or more embodiments of the present invention, message editing and forwarding based on the L flag bit and the D flag bit includes:

[0024] Match messages to obtain message editing information;

[0025] Edit the L and D flag bits into the message according to the message editing information and forward it.

[0026] In one or more embodiments of the present invention, the state table is updated periodically by a coprocessor.

[0027] Embodiments of the present invention provide an apparatus for measuring packet loss and latency, the apparatus comprising:

[0028] The inbound processing module is used to match packets in the inbound direction, obtain the basic pointer of the inbound statistics table and the pointer of the status table, further look up the periodically updated status table according to the pointer of the status table, obtain the values ​​of the L flag and the D flag, and further perform inbound packet statistics according to the L flag and the basic pointer of the inbound statistics table, wherein the D flag is configured to zero after reading.

[0029] The outbound processing module is used to match packets in the outbound direction, obtain the basic pointer of the outbound statistics table, and match the D flag. Based on the matching result, it determines whether to obtain the current timestamp. Further, it performs outbound packet statistics based on the L flag and the basic pointer of the outbound statistics table. When it is determined to obtain the current timestamp, it reports the obtained current timestamp. Further, it edits and forwards the packet based on the L flag and the D flag.

[0030] In one or more embodiments of the present invention, the apparatus further includes:

[0031] A coprocessor is used to periodically update the state table.

[0032] Compared with existing technologies, the present invention can not only precisely control the periodic switching of the value of the L flag bit, but also uniformly configure the value of the D flag bit, so as to achieve accurate and flexible measurement of packet loss and delay. Attached Figure Description

[0033] Figure 1 This is a flowchart of inbound message processing according to an embodiment of the present invention;

[0034] Figure 2 This is a schematic diagram of a forwarding device processing packets according to an embodiment of the present invention;

[0035] Figure 3 This is a flowchart of outbound message processing according to an embodiment of the present invention;

[0036] Figure 4 This is a flowchart of the state table update according to an embodiment of the present invention;

[0037] Figure 5 This is a schematic diagram of the state table structure according to an embodiment of the present invention;

[0038] Figure 6 This is a structural diagram of an apparatus for measuring packet loss and delay according to an embodiment of the present invention. Detailed Implementation

[0039] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings, but it should be understood that the scope of protection of the present invention is not limited to the specific embodiments.

[0040] Unless otherwise expressly stated, throughout the specification and claims, the term "comprising" or its variations such as "including" or "comprises" shall be understood to include the stated elements or components without excluding other elements or other components.

[0041] like Figures 1 to 3 As shown, a method for measuring packet loss and delay according to a preferred embodiment of the present invention can not only precisely control the periodic switching of the value of the L flag bit, but also uniformly configure the value of the D flag bit, thereby achieving accurate and flexible measurement of packet loss and delay. Specifically, the method for measuring packet loss and delay includes an inbound processing procedure and an outbound processing procedure. Here, the inbound processing procedure refers to a series of processing procedures taken by the forwarding device for the packet after it enters the forwarding device, and the outbound processing procedure refers to a series of processing procedures taken by the forwarding device for the packet when it is about to be forwarded to the outside.

[0042] Combination Figure 1 and Figure 2 As shown, the infeed direction processing includes the following steps:

[0043] S10, Receive and match messages, and obtain the basic pointer to the inbound statistics table and the pointer to the status table;

[0044] Specifically, when a forwarding device (such as a switch or router) receives a packet, it performs matching processing based on the information carried in the packet to filter out packets that require packet loss or latency measurement. For the filtered packets that require packet loss or latency measurement, the corresponding inbound statistics table base pointer (statsPtrBase) and status table pointer can be obtained. This information includes, but is not limited to, 5-tuple information, which includes the source IP address, source port, destination IP address, destination port, and transport layer protocol. In practical implementation, packets are matched using access control lists to filter out packets that require packet loss or latency measurement, thereby obtaining the corresponding inbound statistics table base pointer and status table pointer. Figure 2 As shown, after a packet enters the forwarding device, the IACL module (IngressACL, Inbound Access Control List) performs five-tuple information matching, and finally obtains the basic pointer of the inbound statistics table and the pointer of the status table corresponding to the packet.

[0045] S20, look up the state table according to the state table pointer to obtain the values ​​of the L flag and the D flag;

[0046] Specifically, such as Figure 2 As shown, the forwarding device is configured with a status table, which is used to store or configure the values ​​of the L and D flag bits. This status table includes several entries, each containing two bits for the L and D flag bits, respectively, allowing for the storage of their values. Each entry also corresponds to a status table pointer, which is used to look up the corresponding entry to retrieve the corresponding L and D flag bit values. This status table is updated periodically. In practical implementation, a coprocessor can be configured in the packet processing chip of the forwarding device to perform periodic updates to the status table. By using a coprocessor to update the status table, the periodic switching of the L flag bit value can be precisely controlled, and the D flag bit can be configured evenly.

[0047] In this embodiment, after the value of the D flag bit in the status table is read, the value of the D flag bit is further configured to 0. That is, the D flag bit in the status table adopts a read-clear design, which can ensure that multiple packets are marked on average within one cycle for delay measurement, avoiding the problem in the prior art where the D flag bit in multiple packets is configured at the same time for delay measurement.

[0048] like Figure 4 As shown, the coprocessor updates the state table through the following steps:

[0049] a) When the scheduled time arrives, determine whether the item is being scanned for the first time based on the scanning parameters;

[0050] Specifically, in implementation, the L and D flag bits are updated using a timer. This timer can be configured according to actual needs. For example, if the status table includes 8000 entries, the scan period is configured to be 10 seconds, and the time delay measurement is required for 4 packets within one period, i.e., the D flag bit of 4 packets is configured. In this case, the timer is configured as 10 / 8000 / 4 = 0.0003125 seconds, that is, one entry is scanned every 312.5µs.

[0051] Furthermore, a scanning parameter `round` is configured to record the number of scans. Therefore, when the timer expires, it can be determined whether it is the first scan by checking if the value of the scanning parameter `round` is a preset value. In this embodiment, when the value of the scanning parameter `round` is 0, it indicates the first scan; while when the value of the scanning parameter `round` is non-zero, it indicates that it is not the first scan.

[0052] b. When it is determined that this is the first scan, the value of the L flag is configured to the value corresponding to the period. For example, when the period is A, the value of the L flag is configured to 1; when the period is B, the value of the L flag is configured to 0.

[0053] When it is determined that this is not the first scan, the value of the D flag is configured to a first preset value. This first preset value indicates that a time delay measurement is required. For example, the value of the D flag is configured to 1 to indicate that a time delay measurement is required.

[0054] c. Determine if the next entry is the last entry in the status table;

[0055] In practice, the pointer (ScanPtr) corresponding to the currently configured entry can be incremented by one, and the result can be compared with the pointer corresponding to the last entry. If the result matches the pointer (MaxPtr) corresponding to the last entry, it indicates that the next entry is the last entry in the state table. If the result does not match the pointer, it indicates that the next entry is not the last entry in the state table.

[0056] d. If the next entry is not the last entry in the state table, return to step a. If the next entry is the last entry in the state table, perform a remainder operation between the current scan count and the number of packets that need to be time-delayed and assign the remainder result to the scan parameter, i.e., round = (round + 1) % N, and start executing step a from the first entry, where N is the number of packets that need to be time-delayed.

[0057] Specifically, when it is determined that the next entry is not the last entry in the state table, the process directly returns to step a; however, when it is determined that the next entry is the last entry in the state table, the current scan count is moduloed by the number of packets requiring delay marking, and the modulo result is assigned to the scan parameter, i.e., round = (round + 1) % N. Simultaneously, the scan pointer is set to the first entry (ScanPtr = 0), and steps a through d continue from the first entry. As described above, the state table contains 8000 entries, the scan period is configured to be 10 seconds, and it is configured that delay measurement is performed on 4 packets within one period, i.e., the D flag bit of 4 packets is configured. In this case, the timer is configured to 10 / 8000 / 4 = 0.0003125 seconds, i.e., one entry is scanned every 312.5 µs. Using the above scheme, the value of the L flag bit can be periodically switched, and the value of the D flag bit can be evenly configured, allowing 4 packets to be used for delay measurement.

[0058] Furthermore, to reduce the complexity of updating the state table by the coprocessor, the same timer can be used to update both the L and D flags. For example... Figure 5 As shown, to further reduce the complexity of coprocessor updates, access control lists can be configured so that several data streams with the same L flag switching period correspond to the same state table pointer. In other words, several data streams with the same L flag switching period, after being matched through their respective access control lists, will obtain the same state table pointer, such as... Figure 5 As shown, the L flag switching cycles corresponding to the data streams matched by access control list entries 0 and 1 are the same. In this case, they can correspond to the same state table pointer to point to the same state table entry.

[0059] S30, Perform inbound packet statistics based on the L flag and the basic pointer of the inbound statistics table.

[0060] Specifically, after obtaining the value of the L flag, the incoming packet count is further performed using this value and the obtained base pointer to the incoming packet statistics table. During the incoming packet count, the value of the L flag is added to the base pointer to the incoming packet statistics table to obtain the actual incoming packet statistics table pointer (StatsPtr). Once the actual pointer is obtained, the packet count in the corresponding statistics table is incremented by one, thus achieving the counting of incoming packets.

[0061] like Figure 3 As shown, after the inbound processing is completed, the values ​​of the L and D flags obtained during the inbound processing are passed to the outbound processing. This allows the outbound processing to use these values ​​for outbound message statistics and timestamp acquisition, etc. Figure 2 As shown, the inbound direction processing module passes the obtained values ​​of the L and D flag bits to the outbound direction processing module. Specifically, the outbound direction processing includes the following steps:

[0062] S10': Match the message, obtain the basic pointer of the outbound statistics table, and match the D flag bit. Determine whether to obtain the current timestamp based on the matching result.

[0063] Specifically, when processing a message in the outbound direction, the process first involves matching the information carried in the message to obtain the basic pointer to the outbound statistics table corresponding to the message. This information includes, but is not limited to, 5-tuple information, which is detailed above and will not be repeated here. In practice, the basic pointer to the outbound statistics table corresponding to the message can be obtained by matching the message using an access control list. For example... Figure 2 As shown, in the outbound processing module, the five-tuple information is matched through the EACL module (EgressACL, outbound access control list), and finally the basic pointer of the outbound statistics table corresponding to the packet can be obtained.

[0064] Furthermore, the D flag is matched to determine whether the current timestamp needs to be obtained. If the D flag matches the first preset value, the current timestamp needs to be obtained; if the D flag matches the second preset value, the current timestamp does not need to be obtained. In implementation, matching can also be performed using the EACL module (EgressACL, outbound access control list) to determine whether the current timestamp needs to be obtained based on the matching results.

[0065] S20', perform outbound message statistics based on the L flag and the outbound direction statistics table base pointer, and report the obtained current timestamp when it is determined to obtain the current timestamp;

[0066] Specifically, after obtaining the L flag bit acquired during the inbound processing, the value of the L flag bit and the obtained outbound statistics table base pointer are used to perform outbound message statistics. During outbound message statistics, the value of the L flag bit is added to the outbound statistics table base pointer to obtain the actual outbound statistics table pointer. Once the actual outbound statistics table pointer is obtained, the message count in the corresponding statistics table is incremented by one, thus achieving the counting of outbound messages.

[0067] Furthermore, when it is determined that the current timestamp needs to be obtained, the obtained timestamp and the corresponding message are simultaneously reported to the CPU for subsequent delay calculations, etc.

[0068] S30': Edit and forward the message according to the L flag and D flag.

[0069] Specifically, after completing the outbound message statistics and reporting the obtained current timestamp when it is determined, the message is further edited and forwarded based on the L and D flag bits transmitted from the inbound direction.

[0070] When editing a message, it is also necessary to perform matching processing based on the information carried in the message to obtain message editing information. This message editing information includes, but is not limited to, the flow ID and the editing index. In implementation, access control lists can be used to match messages to obtain the corresponding message editing information. After obtaining the message editing information, message editing is performed using this information, and the L and D flags are added to the message.

[0071] like Figure 6 As shown, an apparatus for measuring packet loss and latency according to a preferred embodiment of the present invention can achieve the method described above. It can not only precisely control the periodic switching of the L flag value, but also uniformly configure the D flag value, thus achieving accurate and flexible measurement of packet loss and latency. The apparatus includes an inbound processing module and an outbound processing module.

[0072] The inbound processing module is used to match packets in the inbound direction, obtain the basic pointer of the inbound statistics table and the pointer of the status table, further look up the periodically updated status table according to the pointer of the status table, obtain the values ​​of the L flag and the D flag, and further perform inbound packet statistics according to the L flag and the basic pointer of the inbound statistics table, wherein the D flag is configured to zero after reading.

[0073] The outbound processing module is used to match packets in the outbound direction, obtain the basic pointer of the outbound statistics table, and match the D flag. Based on the matching result, it determines whether to obtain the current timestamp. Furthermore, it performs outbound packet statistics based on the L flag and the basic pointer of the outbound statistics table, and reports the obtained current timestamp when it is determined to obtain the current timestamp. It further edits and forwards the packet based on the L flag and the D flag.

[0074] The specific implementation of the inbound and outbound processing modules is detailed above and will not be repeated here.

[0075] Furthermore, the device also includes a coprocessor for periodically updating the state table. Details on how the state table is updated are described above and will not be repeated here.

[0076] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0077] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0078] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0079] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0080] The foregoing description of specific exemplary embodiments of the invention is for illustrative and explanatory purposes. These descriptions are not intended to limit the invention to the precise forms disclosed, and it will be apparent that many changes and variations can be made in accordance with the foregoing teachings. The exemplary embodiments were chosen and described in order to explain the specific principles of the invention and its practical application, thereby enabling those skilled in the art to implement and utilize various different exemplary embodiments of the invention, as well as various different choices and variations. The scope of the invention is intended to be defined by the claims and their equivalents.

Claims

1. A method for measuring packet loss and delay, characterized in that, The method includes: In the inbound direction, match packets and obtain the basic pointer to the inbound statistics table and the pointer to the status table; look up the status table updated periodically by a timer based on the status table pointer to obtain the values ​​of the L flag and the D flag, with the D flag set to zero after reading; perform inbound packet statistics based on the L flag and the basic pointer to the inbound statistics table, wherein the status table is updated through the following steps: a) When the scheduled time arrives, determine whether the item is being scanned for the first time based on the scanning parameters; b. In response to the judgment result, configure the value of the L flag bit to the value corresponding to the corresponding period, or configure the value of the D flag bit to the first preset value; c. Determine if the next entry is the last entry in the state table; d. In response to the judgment result, directly return to execute step a, or perform a remainder operation between the current number of scans and the number of packets that need to be time-delayed and assign the remainder result to the scan parameters, and start executing step a from the first entry; In the outbound direction, match the message, obtain the basic pointer of the outbound statistics table, and match the D flag bit. Determine whether to obtain the current timestamp based on the matching result. Perform outbound message statistics based on the L flag bit and the basic pointer of the outbound statistics table, and report the obtained current timestamp when it is determined to obtain the current timestamp. Edit and forward the message based on the L flag bit and the D flag bit.

2. The method as described in claim 1, characterized in that, The status table pointers corresponding to several data streams with the same L flag value switching cycle are the same.

3. The method as described in claim 1, characterized in that, Incoming packet statistics are performed based on the L flag and the basic pointer of the incoming direction statistics table, including: Add the value of the L flag bit to the base pointer of the inbound statistics table to obtain the pointer of the inbound statistics table, and increment the number of messages in the statistics table corresponding to the pointer of the inbound statistics table by one.

4. The method as described in claim 1, characterized in that, The outbound message statistics are performed based on the L flag and the basic pointer of the outbound direction statistics table, including: Add the value of the L flag bit to the outbound statistics table base pointer to obtain the outbound statistics table pointer, and increment the message count in the statistics table corresponding to the outbound statistics table pointer by one.

5. The method as described in claim 1, characterized in that, Message editing and forwarding based on the L and D flags includes: Match messages to obtain message editing information; Edit the L and D flag bits into the message according to the message editing information and forward it.

6. The method as described in claim 1, characterized in that, The state table is updated periodically using a coprocessor.

7. A device for measuring packet loss and delay, characterized in that, The device includes: The inbound processing module is used to match packets in the inbound direction, obtain the basic pointer of the inbound statistics table and the state table pointer, further look up the state table updated periodically by a timer according to the state table pointer, obtain the values ​​of the L flag and D flag, and further perform inbound packet statistics according to the L flag and the basic pointer of the inbound statistics table. The D flag is configured to zero after reading. The state table update includes: when the timer arrives, judging whether the entry is the first scan according to the scanning parameters, and according to the judgment result, configuring the value of the L flag to the value corresponding to the corresponding period or configuring the value of the D flag to the first preset value; further judging whether the next entry is the last entry in the state table, and according to the judgment result, directly executing the judgment whether the entry is the first scan according to the scanning parameters when the timer arrives, or taking the remainder of the current number of scans and the number of packets that need to be delayed and assigning the remainder result to the scanning parameters, and starting from the first entry, executing the judgment whether the entry is the first scan according to the scanning parameters when the timer arrives. The outbound processing module is used to match packets in the outbound direction, obtain the basic pointer of the outbound statistics table, and match the D flag. Based on the matching result, it determines whether to obtain the current timestamp. Further, it performs outbound packet statistics based on the L flag and the basic pointer of the outbound statistics table. When it is determined to obtain the current timestamp, it reports the obtained current timestamp. Further, it edits and forwards the packet based on the L flag and the D flag.

8. The apparatus as claimed in claim 7, characterized in that, The device further includes: A coprocessor is used to periodically update the state table.