Method and device for testing network performance based on UDP (User Datagram Protocol) bagging, processor and computer readable storage medium thereof
By calculating the round-trip and one-way latency between the client and server through UDP packet injection and timestamp exchange, the problem of existing tools being unable to measure application layer latency is solved, enabling accurate testing and real-time feedback of network performance.
Patent Information
- Application Number
- CN202511198034.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-26
- Publication Date
- 2026-01-06
AI Technical Summary
Existing network performance testing tools such as Iperf and Ping cannot effectively measure application layer latency and window size performance, and client-server time synchronization is difficult to achieve at the microsecond level, making one-way latency measurement difficult.
By using a UDP packet injection method, the client and server exchange timestamp information, calculate round-trip and one-way latency, and combine the time difference to calculate variance, thereby achieving accurate measurement of application layer latency and window size.
It provides a network performance testing method with low latency, simple operation and wide applicability, and can provide real-time feedback on the network status between the client and the server, supporting long-term network operation.
Smart Images

Figure CN121283904A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication testing, and more particularly to the field of UDP transmission. Specifically, it relates to a method, apparatus, processor, and computer-readable storage medium for testing network performance based on UDP packet injection. Background Technology
[0002] In communication testing, data traffic is frequently required to test the overall performance from client to server. In practical applications, application-layer latency is a crucial evaluation metric, especially in special scenarios using UDP transmission such as live streaming and real-time gaming.
[0003] How can we conveniently obtain network performance metrics? Traditional network performance testing tools include iperf, which can evaluate network performance metrics such as bandwidth, latency, and packet loss rate by simulating data transmission. iperf's packet flooding principle tests network transmission capacity by establishing a TCP or UDP connection between the client and server and sending a large number of data packets. However, it does not display a crucial application-layer metric: application-layer latency or variance. While Ping can also test latency, it only provides feedback on low-level latency, not application-layer latency, and it also fails to provide feedback on window size performance. The solution introduced in this article provides excellent testing feedback in both of these aspects.
[0004] Because the client and server times are not synchronized (or it is difficult to achieve synchronization at the microsecond level), there is currently no good way to measure one-way latency. Here we will calculate one-way latency using round-trip latency. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method, apparatus, processor and computer-readable storage medium for testing network performance based on UDP packet injection, which has the advantages of low latency, simple operation and wide applicability.
[0006] To achieve the above objectives, the present invention provides a method, apparatus, processor, and computer-readable storage medium for testing network performance based on UDP packet injection, as follows:
[0007] The main feature of this method for testing network performance based on UDP packet injection is that the method includes the following steps:
[0008] (1) The client obtains the timestamp CT1 when the client sends the data packet, encapsulates it into a UDP data packet, and sends it to the server;
[0009] (2) The server receives UDP packets sent by the client and records the server's timestamp ST1 when the server receives the packets;
[0010] (3) The server parses the UDP data packet, adds the timestamp ST2 when the server sends the data packet, assembles the packet and sends it to the client;
[0011] (4) The client receives the UDP data packet returned by the server, parses the packet content, and obtains the timestamp CT2 when the client received the data packet;
[0012] (5) Calculate the round-trip delay CST and the one-way delay CT from the client to the server.
[0013] Preferably, step (1) specifically includes the following steps:
[0014] (1.1) The client obtains the timestamp CT1 when the client sends the data packet, encapsulates it into a UDP packet with sequence number N, and adds the packet sequence number and timestamp;
[0015] (1.2) The client sends a packet with sequence number N to the server.
[0016] Preferably, the calculation of the round-trip time CST from the client to the server in step (5) is specifically as follows:
[0017] Calculate the round-trip latency CST from the client to the server using the following formula:
[0018] Round-trip time CST = (CT2 – CT1) – (ST2 – ST1);
[0019] One-way delay CT = CST / 2.
[0020] The main feature of this device for testing network performance based on UDP packet injection is that the device includes:
[0021] A processor is configured to execute computer-executable instructions;
[0022] The memory stores one or more computer-executable instructions, which, when executed by the processor, implement the steps of the method described above for testing network performance based on UDP packet injection.
[0023] The processor for testing network performance based on UDP packet injection is characterized in that the processor is configured to execute computer-executable instructions, and when the computer-executable instructions are executed by the processor, the various steps of the above-described method for testing network performance based on UDP packet injection are implemented.
[0024] The main feature of this computer-readable storage medium is that it stores a computer program thereon, which can be executed by a processor to implement the various steps of the above-described method for testing network performance based on UDP packet injection.
[0025] The present invention employs a method, apparatus, processor, and computer-readable storage medium for testing network performance based on UDP packet injection. By sending and receiving packets, the latency variance between the client and the server is obtained. Uninterrupted pulse-style packet sending and receiving can provide real-time feedback on the network status between the client and the server, providing technical information support for long-term network operation. Attached Figure Description
[0026] Figure 1 This is a flowchart of the method for testing network performance based on UDP packet injection according to the present invention. Detailed Implementation
[0027] To more clearly describe the technical content of the present invention, the following description is provided in conjunction with specific embodiments.
[0028] The method for testing network performance based on UDP packet injection of the present invention includes the following steps:
[0029] (1) The client obtains the timestamp CT1 when the client sends the data packet, encapsulates it into a UDP data packet, and sends it to the server;
[0030] (2) The server receives UDP packets sent by the client and records the server's timestamp ST1 when the server receives the packets;
[0031] (3) The server parses the UDP data packet, adds the timestamp ST2 when the server sends the data packet, assembles the packet and sends it to the client;
[0032] (4) The client receives the UDP data packet returned by the server, parses the packet content, and obtains the timestamp CT2 when the client received the data packet;
[0033] (5) Calculate the round-trip delay CST and the one-way delay CT from the client to the server.
[0034] In a preferred embodiment of the present invention, step (1) specifically includes the following steps:
[0035] (1.1) The client obtains the timestamp CT1 when the client sends the data packet, encapsulates it into a UDP packet with sequence number N, and adds the packet sequence number and timestamp;
[0036] (1.2) The client sends a packet with sequence number N to the server.
[0037] In a preferred embodiment of the present invention, the calculation of the round-trip time CST from the client to the server in step (5) is specifically as follows:
[0038] Calculate the round-trip latency CST from the client to the server using the following formula:
[0039] Round-trip time CST = (CT2 – CT1) – (ST2 – ST1);
[0040] One-way delay CT = CST / 2.
[0041] The apparatus for testing network performance based on UDP packet injection of the present invention includes:
[0042] A processor is configured to execute computer-executable instructions;
[0043] The memory stores one or more computer-executable instructions, which, when executed by the processor, implement the steps of the method described above for testing network performance based on UDP packet injection.
[0044] The present invention discloses a processor for testing network performance based on UDP packet injection, wherein the processor is configured to execute computer-executable instructions, and when the computer-executable instructions are executed by the processor, the various steps of the above-described method for testing network performance based on UDP packet injection are implemented.
[0045] The computer-readable storage medium of the present invention stores a computer program thereon, which can be executed by a processor to implement the various steps of the above-described method for testing network performance based on UDP packet injection.
[0046] In a specific embodiment of this invention, the test plan involves the client obtaining the current system timestamp, assembling a UDP packet, adding the packet sequence number and timestamp, and sending it to the server. When the server receives the UDP packet from the client, it records the received timestamp, parses the UDP data packet, assembles the packet, adds the server's received and sent timestamps to the original UDP content, and sends the packet to the client. When the client receives the UDP data packet returned by the server, it parses the packet content, thus obtaining the time consumed by the entire process from sending to returning the UDP data packet, which allows for the calculation of the round-trip latency.
[0047] Wherein, CT1 represents the system time when the client sends the data packet, CT2 represents the system time when the client receives the data packet, ST1 represents the server's system time when the server receives the data packet, and ST2 represents the server's system time when sending the data packet.
[0048] The present invention provides a method for testing network performance based on UDP packet injection, comprising the following steps:
[0049] 3.1 Client-side:
[0050] 1) The client obtains the timestamp CT1 when the client sends the data packet and encapsulates it into a UDP packet with sequence number N;
[0051] 2) The client sends a packet with sequence number N to the server;
[0052] 3) The server receives the UDP packet from the client and simultaneously records the server's timestamp ST1 when the data packet is received;
[0053] 4) The server parses the UDP packet and sends a response packet back to the client. The response packet contains the timestamp ST2 of when the server sent the data packet.
[0054] 5) When the client receives the response packet returned by the server, it obtains the timestamp CT2 when the client received the data packet;
[0055] 6) Calculate the one-way latency (CT) and round-trip latency (CST) from the client to the server;
[0056] Round-trip time CST = (CT2 – CT1) – (ST2 – ST1);
[0057] One-way delay CT = CST / 2.
[0058] 7) Calculate the variance rtt_jitter;
[0059] Time difference diff_time = CT2 – CT1
[0060] Previous time difference: prev_diff_time
[0061] 7.1) The timestamp of the next client data packet sent is system time CT3, and the timestamp of the data packet received is CT4. The time difference diff_time can be obtained:
[0062] diff_time = CT4 – CT3;
[0063] 7.2) The time difference between the previous client data packet transmission and reception, prev_diff_time:
[0064] prev_diff_time = CT2 – CT1;
[0065] 7.3) Calculate the absolute value of the time difference offset d:
[0066] d = diff_time - prev_diff_time
[0067] if (d < 0)
[0068] d = -d;
[0069] 7.4) Calculate the average value rAverage based on the total number of packages iTotalCount:
[0070] iTotalValue += d * 1000;
[0071] double rAverage=iTotalValue*1.0 / iTotalCount;
[0072] 7.5) Calculate the variance rtt_jitter:
[0073] rTotalValue=rTotalValue+(iKey-rAverage);
[0074] rtt_jitter=rTotalValue / iTotalCount;
[0075] 3.2 Server-side
[0076] 1) When the server receives a UDP packet, it also records the server's timestamp ST1 when the packet is received.
[0077] 2) Parse the data packet and send a response packet back to the client. The response packet contains the timestamp ST2 of when the server sent the data packet.
[0078] For the specific implementation scheme of this embodiment, please refer to the relevant descriptions in the above embodiments, which will not be repeated here.
[0079] It is understood that the same or similar parts in the above embodiments can be referred to each other, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.
[0080] It should be noted that in the description of this invention, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this invention, unless otherwise stated, "a plurality of" means at least two.
[0081] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.
[0082] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution device. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0083] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The corresponding program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.
[0084] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0085] The storage media mentioned above can be read-only memory, disk, or optical disk, etc.
[0086] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0087] The present invention employs a method, apparatus, processor, and computer-readable storage medium for testing network performance based on UDP packet injection. By sending and receiving packets, the latency variance between the client and the server is obtained. Uninterrupted pulse-style packet sending and receiving can provide real-time feedback on the network status between the client and the server, providing technical information support for long-term network operation.
[0088] In this specification, the invention has been described with reference to specific embodiments thereof. However, it will be apparent that various modifications and variations can be made without departing from the spirit and scope of the invention. Therefore, the specification and drawings should be considered illustrative rather than restrictive.
Claims
1. A method for testing network performance based on UDP flooding, characterized in that, The method comprises the following steps: (1) The client acquires a timestamp CT1 when the client sends a data packet, encapsulates the timestamp into a UDP data packet, and sends the data packet to the server; (2) The server receives the UDP data packet sent by the client, and records a timestamp ST1 of the server when the server receives the data packet; (3) The server parses the UDP data packet, adds a timestamp ST2 of the server when the server sends the data packet, assembles the data packet, and sends the data packet to the client; (4) The client receives the UDP data packet returned by the server, parses the content of the data packet, and acquires a timestamp CT2 when the client receives the data packet; (5) The round-trip delay CST from the client to the server and the one-way delay CT are calculated.
2. The method for testing network performance based on UDP flooding according to claim 1, wherein, The step (1) specifically comprises the following steps: (1.1) The client acquires a timestamp CT1 when the client sends a data packet, encapsulates the timestamp into a UDP data packet with a sending serial number N, and adds a packet serial number and the timestamp; (1.2) The client sends the packet with the serial number N to the server.
3. The method for testing network performance based on UDP flooding according to claim 1, wherein, In the step (5), the round-trip delay CST from the client to the server is calculated, and specifically: The round-trip delay CST from the client to the server is calculated according to the following formula: Round-trip delay CST = (CT2-CT1)-(ST2-ST1); One-way delay CT = CST / 2.
4. A device for testing network performance based on UDP packet injection, characterized in that, The device comprises: a processor configured to execute computer executable instructions; a memory storing one or more computer executable instructions, which, when executed by the processor, implement each step of the method for testing network performance based on UDP packet stuffing according to any one of claims 1 to 3.
5. A processor for testing network performance based on UDP packet injection, characterized in that, The processor is configured to execute computer executable instructions, which, when executed by the processor, implement each step of the method for testing network performance based on UDP packet stuffing according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, The computer program stored thereon can be executed by the processor to implement each step of the method for testing network performance based on UDP packet stuffing according to any one of claims 1 to 3.