Network delay detection method and device for data transmission, electronic equipment and product
By obtaining and correcting the timestamps and time offsets of network devices, eliminating the time deviation between devices, the problem of low network delay accuracy is solved, and more accurate network delay measurement is achieved, and network performance evaluation and optimization are supported.
Patent Information
- Application Number
- CN202510257898.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-06-27
AI Technical Summary
In the prior art, since the clocks of each network device may be out of sync, the accuracy of network delay is low.
By obtaining the transmission timestamp of the first device and the time offset between the clock source and the main clock source of the first device, and the time offset between the reception timestamp of the second device and the time offset between the clock source of the second device and the time offset between the main clock source, the network delay of the data during network transmission is determined based on this information, and the time offset between the clock sources of different devices is eliminated.
It realizes a more accurate reflection of the actual delay of data during network transmission, provides a solid foundation for network performance evaluation and optimization, and improves the accuracy and reliability of network delay calculation.
Smart Images

Figure CN120223228A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of communication technologies, and particularly relates to a method, apparatus, electronic device, and product for detecting network latency in data transmission. Background Art
[0002] In a modern network environment, whether it is a data center network, a wide area network, or an industrial Internet, etc., the evaluation and optimization of network performance are crucial. As one of the key indicators for measuring network performance, network latency directly affects the quality of various network applications and the user experience.
[0003] In the prior art, network latency is usually determined based on the time difference between the transmission time when a network device sends data and the reception time when another network device receives the data.
[0004] However, since the clocks of each network device may not be synchronized, the accuracy of network latency is relatively low when calculating network latency based on the transmission time and reception time determined by each network device itself. Summary of the Invention
[0005] Embodiments of this application provide a method, apparatus, electronic device, and product for detecting network latency in data transmission, which can solve the problem of relatively low accuracy in determining network latency in the prior art.
[0006] In a first aspect, embodiments of this application provide a method for detecting network latency in data transmission, the method including:
[0007] Obtain first information when a first device sends data; the first information includes a transmission timestamp recorded by the first device when sending the data, and a first time offset between the clock source of the first device and the master clock source;
[0008] Obtain second information when a second device receives the data; the second information includes a reception timestamp recorded by the second device when receiving the data, and a second time offset between the clock source of the second device and the master clock source;
[0009] Based on the first information and the second information, determine the network latency when the data is transmitted in the network.
[0010] In one embodiment, the method includes:
[0011] Obtain clock parameters of the clock source in each network device; the network devices include switch devices and terminal devices for sending data; determine a master clock source from multiple clock sources based on the clock parameters; the network device corresponding to the master clock source is used to broadcast the timestamp of the master clock source.
[0012] In one embodiment, based on the first information and the second information, determining the network latency when the data is transmitted in the network includes:
[0013] Modify the sending timestamp based on the first time offset to obtain the first timestamp; modify the receiving timestamp based on the second time offset to obtain the second timestamp; determine the network latency based on the first timestamp and the second timestamp.
[0014] In one embodiment, determining the network latency based on the first timestamp and the second timestamp includes:
[0015] Determine the difference between the first timestamp and the second timestamp as the network latency.
[0016] In one embodiment, there are multiple pieces of data; the first information further includes a unique identifier, and each piece of data carries at least the unique identifier; the first device is used to store the corresponding first information when sending each piece of data; the second device is used to use the unique identifier, the receiving timestamp, and the second time offset as the second information and store it when receiving any piece of data;
[0017] Determining the network latency of the data during network transmission based on the first information and the second information includes:
[0018] Match the first information and the second information with the same unique identifier; for any set of matched first information and second information, determine the initial network latency of the data during network transmission based on the first information and the second information; determine the network latency based on multiple initial network latencies.
[0019] In one embodiment, determining the network latency based on multiple initial network latencies includes:
[0020] Determine the variance value of multiple initial network latencies as the network latency.
[0021] In one embodiment, the method further includes:
[0022] Obtain the first information and the second information by using the Netconf protocol.
[0023] In a second aspect, an embodiment of the present application provides a network latency detection device for data transmission, and the device includes:
[0024] A first acquisition module, configured to acquire the first information when the first device sends data; the first information includes the sending timestamp when the first device records data sending, and the first time offset between the clock source of the first device and the master clock source;
[0025] A second acquisition module, configured to acquire the second information when the second device receives data; the second information includes the receiving timestamp when the second device records data reception, and the second time offset between the clock source of the second device and the master clock source;
[0026] The first determination module is configured to determine the network delay of data during network transmission based on the first information and the second information.
[0027] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method according to the first aspect described above is implemented.
[0028] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the method according to the first aspect described above is implemented.
[0029] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when running on an electronic device, causes the electronic device to execute the method according to the first aspect described above.
[0030] The beneficial effects of the embodiments of the present application compared with the prior art are as follows: By obtaining the first information including the transmission timestamp and the first time offset from the master clock source when the first device sends data, the time deviation between the clock source of the first device and the master clock source can be accurately eliminated based on the transmission timestamp and the first time offset. Also, by obtaining the second information including the reception timestamp and the second time offset from the master clock source when the second device receives data, the time deviation between the clock source of the second device and the master clock source can be accurately eliminated based on the reception timestamp and the second time offset. Based on this, when determining the network delay of data during network transmission based on the first information and the second information, the influence of the time offset between the clock sources of different devices can be eliminated, and the time of each device can be unified to the time reference of the master clock source, avoiding measurement errors introduced by inconsistent clocks. Furthermore, based on the transmission timestamp and the reception timestamp with measurement errors eliminated, the actual delay situation of data during network transmission can be more truly and accurately reflected, providing a solid foundation for network performance evaluation and optimization. Description of the Drawings
[0031] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0032] Figure 1 It is a schematic diagram of an application scenario of a method for detecting the network delay of data transmission provided by an embodiment of the present application;
[0033] Figure 2It is a flowchart showing the implementation of a method for detecting network latency in data transmission provided by an embodiment of the present application;
[0034] Figure 3 It is a flowchart showing the implementation of a method for detecting network latency in data transmission provided by another embodiment of the present application;
[0035] Figure 4 It is a schematic structural diagram of a device for detecting network latency in data transmission provided by an embodiment of the present application;
[0036] Figure 5 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation
[0037] In the following description, specific details such as specific system architectures and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present application. However, those skilled in the art should clearly understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of the present application.
[0038] It should be understood that when used in the specification and appended claims of the present application, the term "comprising" indicates the presence of the described features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0039] It should be noted that the information collection process (such as the face image collection process, fingerprint information collection process, etc.) / feature extraction process involved in the present application is performed with the user's knowledge and permission, that is, the information collection process / feature extraction process complies with the requirements of laws and regulations and does not belong to acts that harm the public interest.
[0040] In addition, in the description of the specification and appended claims of the present application, the terms "first", "second", "third", etc. are only used for differential description and cannot be understood as indicating or implying relative importance.
[0041] In a modern network environment, whether it is a data center network, a wide area network, or an industrial Internet scenario, the evaluation and optimization of network performance are crucial. As one of the key indicators for measuring network performance, network latency directly affects the quality of various network applications and the user experience.
[0042] Exemplarily, in the field of real-time communication, such as voice calls, video conferences, etc., lower network latency can ensure the smoothness of voice and video, reducing stuttering and latency; in the financial transaction network, tiny latency differences may lead to time differences in transaction execution, thus affecting the success rate and benefits of transactions; in industrial automation scenarios, precise network latency control is crucial for ensuring the collaborative work between industrial devices and the stability of the production process.
[0043] In the prior art, network latency is usually determined based on the time difference between the transmission time when a network device sends data and the reception time when another network device receives data.
[0044] However, since the clocks of each network device may not be synchronized, the accuracy of the network latency is relatively low when calculating the network latency based on the transmission time and reception time determined by each network device itself.
[0045] Based on this, in order to improve the accuracy of network latency, the embodiments of the present application provide a method for detecting network latency of data transmission. This method can be applied to electronic devices such as laptops, ultra-mobile personal computers (UMPCs), netbooks, servers, etc. The embodiments of the present application do not impose any restrictions on the specific types of electronic devices.
[0046] For ease of explanation, in this embodiment, the server is taken as an example of the electronic device. Specifically, a network data acquisition and analysis system can be deployed in the server to periodically obtain the information sent and received by each terminal device to execute the method for detecting network latency of data transmission.
[0047] As an example, taking the determination of the network latency when each terminal device in a local area network sends data as an example, a local area network usually includes multiple terminal devices and a switch device. Generally, when a terminal device sends data to another terminal device, it needs to forward the data through the switch device.
[0048] Specifically, referring to Figure 1 , Figure 1 is a schematic diagram of an application scenario of a method for detecting network latency of data transmission provided by an embodiment of the present application. The data can be sent by terminal device 1 and sequentially pass through switch device 1 and switch device 2, and finally be transmitted to terminal device 2. Moreover, when terminal device 1 sends data, it can determine the transmission timestamp when the data is sent based on the timestamp setting module and determine the time offset between the clock source of terminal device 1 and the master clock source. Then, combined with the corresponding unique identifier, it is stored in the information storage module as the information corresponding to the data. And when the data is sent, this information or the unique identifier in this information can be carried.
[0049] Similarly, when the terminal device 2 receives data, it can determine the reception timestamp at the time of data reception based on the timestamp setting module of the terminal device 2, and determine the time offset between the clock source of the terminal device 2 and the master clock source. Then, combined with the corresponding unique identifier, it is stored in the information storage module as the information corresponding to the data.
[0050] The network data acquisition and analysis system in the server can obtain the above information from the storage modules of each terminal device to calculate the network delay.
[0051] Among them, the numbers of the above terminal devices and switch devices are only one example. In this embodiment, the numbers of terminal devices and switch devices are not limited.
[0052] As an example, the network data acquisition and analysis system can have the ability to manage and control terminal devices and switch devices in the local area network. And the network data acquisition and analysis system can use protocols such as SNMP (Simple Network Management Protocol), Netconf (Network Configuration Protocol), and MQTT (Message Queuing Telemetry Transport) to obtain corresponding information from network devices.
[0053] Exemplarily, the network data acquisition and analysis system can use the Netconf protocol to periodically obtain the following first information and second information. And use the Netconf protocol to complete the device status monitoring and data acquisition of network devices.
[0054] Among them, device status monitoring includes but is not limited to device online status, device port traffic data statistics, device memory and utilization statistics, etc. Data acquisition includes but is not limited to device port counting, device CPU memory data, device online detection, packet reception data, packet transmission data, and clock synchronization GPTP data.
[0055] In another embodiment, the network data acquisition and analysis system can also use the Netconf protocol to implement processing such as traffic information acquisition, error packet statistics, clock synchronization status, and clock synchronization parameters of network devices, which will not be elaborated here.
[0056] Among them, the period can be set according to the actual situation. For example, information acquisition is completed every 10s, which is not limited here.
[0057] In one embodiment, the above terminal device can be any device in the network, such as a computer, a server, a switch, a router, an Internet of Things terminal device, etc. In different network scenarios, the terminal device has different specific referents. For example, in an enterprise local area network, the terminal device can be an office computer; in an industrial Internet of Things scenario, it can be a sensor for collecting environmental data.
[0058] For ease of explanation, please refer to Figure 2 , Figure 2 which shows an implementation flowchart of a method for detecting network delay of data transmission provided by an embodiment of the present application. The method includes the following steps:
[0059] S201. Obtain first information when the first device sends data; the first information includes the transmission timestamp recorded by the first device when sending data, and the first time offset between the clock source of the first device and the master clock source.
[0060] In one embodiment, the above first device can be considered as Figure 1 the terminal device in
[0061] for sending data. Among them, the electronic device can obtain the first information in real time or periodically, and this is not limited.
[0062] Among them, the above data is the information carrier sent by the first device to the network and can be various types of information. For example, the types of data include but are not limited to text, pictures, videos, audio, etc. Or, the data can also be the status data of the system operation, the sensor data collected by the device, etc., and this is not limited.
[0063] The above master clock source is the clock source used as the time reference in the entire network or system. The clock sources of other network devices usually need to be synchronized with the master clock source to ensure the consistency of the entire system time. In different network environments, the selection of the master clock source is usually different. For example, in a local area network, a dedicated time server may be used as the master clock source; in a wide area network, the time provided by a GPS clock or a Network Time Protocol (NTP) server may be used as the master clock source.
[0064] Moreover, the above-mentioned transmission timestamp can be a timestamp generated by the first device based on its own clock source. The first time offset is determined based on the timestamp of its own clock source and the timestamp of the master clock source. For example, the difference between the timestamp of its own clock source and the timestamp of the master clock source can be determined as the above-mentioned first time offset.
[0065] It can be understood that due to certain errors in the clock sources of network devices, the clock source of the first device may be faster or slower than the master clock source. At this time, this difference is the above-mentioned first time offset. Through the first time offset, the timestamp of the first device can be adjusted to be consistent with the timestamp of the master clock source, ensuring consistency in the time reference.
[0066] In one embodiment, the first device can obtain the timestamp of the master clock source from the master clock source based on NTP or PTP (Precision Time Protocol). Then, calculate the above-mentioned first time offset. Alternatively, the device of the master clock source can broadcast the timestamp of the master clock source to each network device in real time, so that each first device can determine the first time offset in real time.
[0067] It can be understood that the first information will be generated correspondingly each time data is sent. Based on this, when there are multiple pieces of data, in order to be able to distinguish the first information corresponding to each piece of data, the first device can also assign a unique identifier to the first information each time the first information is generated and store the corresponding first information. That is to say, the first information not only includes the above-mentioned transmission timestamp and the first time offset, but can also include a unique identifier.
[0068] Moreover, in order to be able to obtain the second information that matches the first information from the second device subsequently, when the first device sends data, the data should at least carry a unique identifier. Then, when the second device receives the data, it can write the unique identifier in the data into the second information and store it as well.
[0069] Finally, when both the first device and the second device store multiple pieces of first information and second information correspondingly, the electronic device can also determine the matching first information and second information based on the unique identifier to determine the network delay.
[0070] In another embodiment, the data can also include the entire first information. At this time, when the second device obtains the data, it can not only generate the second information based on the unique identifier in the first information, but also directly associate and store the first information and the second information. Based on this, the electronic device can directly obtain the associated first information and second information from the second device. Furthermore, there is no need to obtain the first information and the second information from the first device and the second device respectively, and there is no need to match them one by one when there are multiple pieces of data.
[0071] In the embodiments of the present application, the quantity of data, the first information, the second information, and the corresponding acquisition methods are not limited.
[0072] In one embodiment, the electronic device may randomly determine a target network device from multiple network devices, and determine the clock source in the target network device as the master clock source. At this time, the clock sources in the remaining network devices can be regarded as slave clock sources.
[0073] However, since different network devices have different precision requirements for time, there are usually differences in the precision of the clock sources in different network devices. Therefore, if a clock source with poor precision is used as the master clock source, it will lead to a decrease in the precision of the network delay determined based on the first information and the second information subsequently.
[0074] Based on this, in order to improve the precision of the network delay, the electronic device may acquire the clock parameters of the clock sources in each network device; the network devices include switch devices and terminal devices for sending data. Then, determine the master clock source from multiple clock sources based on the clock parameters; the network device corresponding to the master clock source is used to broadcast the time stamp of the master clock source.
[0075] In one embodiment, the above clock parameters are usually used to describe the clock performance of the clock source. Therefore, the clock source with the optimal clock performance can be determined as the master clock source.
[0076] Exemplarily, the above clock parameters include but are not limited to parameters such as the priority, precision, and stability of the clock source. Taking the priority as an example, the electronic device may select the clock source with the highest priority as the master clock source. For example, if the clock sources corresponding to three network devices have priorities of 1, 3, and 2 respectively, and the larger the number, the higher the priority, then the electronic device may determine the clock source with a priority of 3 as the master clock source.
[0077] In another embodiment, when the clock parameters include multiple types, for any clock source, the electronic device may also quantify each clock parameter, and then calculate based on the quantified clock parameters to obtain a parameter value representing the performance of the clock source. Finally, determine the clock source corresponding to the maximum value of the parameter value as the master clock source. In this embodiment, the method for quantifying each clock parameter and calculating the quantified clock parameters is not limited.
[0078] It can be understood that by quantifying multiple clock parameters and calculating the multiple parameters corresponding to any clock source, a parameter value that can comprehensively and accurately evaluate its performance can be obtained. Furthermore, the one-sidedness of selecting the master clock source based only on a single parameter can be avoided, and the precision of the subsequent determined network delay can be improved.
[0079] It should be noted that after the master clock source is determined, the network device corresponding to the master clock source can broadcast the timestamp of the master clock source so that the first device can generate the first information.
[0080] As an example, IEEE802.1AS is developed based on the IEEE1588V2 precise clock synchronization protocol and is called GPTP (Generalized Precision Time Protocol). GPTP is a distributed master-slave structure that can synchronize the clocks in all GPTP networks with the master clock. First, the Best Clock Master Algrothms (BCMA) is used to establish the primary-secondary relationship, which are respectively called the Clock Master (CM) and the Clock Slave (CS). The network devices of each GPTP node can run a GPTP Engine. The PTP adopted by IEEE1588 is transmitted by the IP network of the L3 and L4 layers of the network and distributes clock information through multicast or unicast of IPv4 or IPv6. While GPTP is embedded in the MAC layer hardware and only works at L2. It can directly insert time information into the data frame and transmit it to each network device in the network along with the data frame.
[0081] It should be noted that the terminal device and the switch device support the IEEE 802.1AS protocol, which can make the timestamp reach the synchronization accuracy at the nanosecond level. Furthermore, it ensures the real-time and reliable transmission of network data.
[0082] S202. Obtain the second information when the second device receives the data; the second information includes the reception timestamp recorded by the second device when receiving the data, and the second time offset between the clock source of the second device and the master clock source.
[0083] In an embodiment, the above-mentioned second device can also be Figure 1 the terminal device in. It should be noted that the difference between the first device and the second device is only that: the first device is the data sender, and the second device is the data receiver. That is, when the second device sends data, the second device can also be regarded as the first device, and when the first device receives data, the first device can also be regarded as the second device.
[0084] Among them, the reception timestamp is similar to the above-mentioned transmission timestamp, the clock source of the second device is similar to the clock source of the above-mentioned first device, and the determination method of the second time offset is similar to the determination method of the above-mentioned first time offset, and no detailed description will be given here.
[0085] S203. Determine the network delay when the data is transmitted in the network based on the first information and the second information.
[0086] In one embodiment, since the first time offset is the time difference between the clock source of the first device and the master clock source, the electronic device can correct the transmission timestamp based on the first time offset to obtain the first timestamp. Exemplarily, the above correction methods include, but are not limited to, addition, subtraction, etc., and are not limited thereto.
[0087] As an example, the electronic device can determine the difference between the transmission timestamp and the first time offset as the above first timestamp. Similar to the method of the first timestamp, the electronic device can correct the reception timestamp based on the second time offset to obtain the second timestamp. For example, the difference between the transmission timestamp and the second time offset can also be determined as the above second timestamp. Finally, the electronic device can determine the network latency based on the first timestamp and the second timestamp.
[0088] Specifically, since the first timestamp is the time of data transmission and the second timestamp is the time of data reception, the electronic device can determine the difference between the first timestamp and the second timestamp as the network latency.
[0089] It should be noted that by correcting the transmission timestamp based on the first time offset to obtain the first timestamp, and correcting the reception timestamp based on the second time offset to obtain the second timestamp, and then determining the network latency based on the first timestamp and the second timestamp, the measurement error caused by the time offset between the clock sources of the first device and the second device and the master clock source can be effectively eliminated. The timestamps can be unified to the time reference of the master clock source, improving the accuracy and reliability of network latency calculation.
[0090] In another embodiment, when there are multiple pieces of data, the corresponding first information and second information will also be multiple. At this time, based on the explanation of the unique identifier in the above S201, the electronic device can match the first information and the second information with the same unique identifier. Then, for any set of matched first information and second information, based on the first information and the second information, determine the initial network latency when the data is transmitted over the network. Finally, determine the network latency based on multiple initial network latencies.
[0091] Among them, the method of determining the initial network latency based on the first information and the second information can be to first correct the transmission timestamp based on the first time offset to obtain the first timestamp. Then, correct the reception timestamp based on the second time offset to obtain the second timestamp. Finally, determine the initial network latency based on the first timestamp and the second timestamp.
[0092] It can be understood that since there may be multiple pieces of first information and second information that match, multiple initial network delays will be obtained. At this time, the electronic device may determine the variance value or standard deviation of the multiple initial network delays as the network delay. In this embodiment, the method for determining the network delay based on multiple initial network delays is not limited.
[0093] Exemplarily, the variance value of multiple initial network delays may be determined as the network delay. It should be noted that calculating the network delay using multiple sets of matching first information and second information can comprehensively reflect the time differences during different data transmission processes, avoid the contingency and one-sidedness of single data, and make the measurement of network delay more representative. Moreover, using the variance value as the network delay can intuitively reflect the fluctuation degree of network transmission delay. The smaller the variance, the more stable the network transmission; the larger the variance, the greater the time delay variation in network transmission.
[0094] In this embodiment, by obtaining the first information including the sending timestamp and the first time offset from the master clock source when the first device sends data, the time deviation between the clock source of the first device and the master clock source can be accurately eliminated based on the sending timestamp and the first time offset. Also, by obtaining the second information including the receiving timestamp and the second time offset from the master clock source when the second device receives data, the time deviation between the clock source of the second device and the master clock source can be accurately eliminated based on the receiving timestamp and the second time offset. Based on this, when determining the network delay of data during network transmission based on the first information and the second information, the influence of time offset between the clock sources of different devices can be eliminated, unifying the time of each device to the time reference of the master clock source, and avoiding measurement errors introduced by inconsistent clocks. Furthermore, based on the sending timestamp and the receiving timestamp with measurement errors eliminated, the actual delay situation of data during network transmission can be more truly and accurately reflected, providing a solid foundation for network performance evaluation and optimization.
[0095] To more clearly illustrate the solution in this application, the following uses specific embodiments to elaborate on the solution in this application. For details, refer to Figure 3 , which is a flowchart of the implementation of a network delay detection method for data transmission provided by another embodiment of this application. Taking the electronic device as a server as an example, the server includes a network data collection and analysis system, which can periodically obtain the information sent and received by each terminal device to execute the network delay detection method for data transmission.
[0096] Specifically, the network data collection and analysis system can obtain the clock parameters of the clock sources in each terminal device to determine the master clock source from multiple clock sources based on the clock parameters. At this time, the network device corresponding to the master clock source can broadcast the timestamp of the master clock source in real time.
[0097] After that, when the first device sends data, it can record the transmission timestamp when the data is sent, as well as the first time offset between the clock source of the first device and the master clock source. Moreover, the first device can assign a unique identifier to generate and store the first information. Meanwhile, when sending data, the unique identifier can also be written into the data.
[0098] Similar to the first information, when the second device receives data, it can record the reception timestamp when the data is received, as well as the second time offset between the clock source of the second device and the master clock source. Moreover, the second device can obtain the unique identifier from the data, and then use the reception timestamp, the second time offset, and the unique identifier as the second information and store it.
[0099] Finally, the network data acquisition and analysis system can first obtain multiple pieces of first information and second information from the first device and the second device respectively. Then, it can match the first information and the second information with the same unique identifier. Moreover, for any set of matched first information and second information, based on the first information and the second information, it can determine the initial network delay when the data is transmitted over the network. Finally, the variance value of multiple initial network delays is determined as the network delay.
[0100] In this embodiment, by adopting the above method, the influence of the time offset between the clock sources of different devices can be eliminated, the time of each device can be unified to the time reference of the master clock source, and the measurement error introduced by clock inconsistency can be avoided. Furthermore, based on the transmission timestamp and the reception timestamp with the measurement error eliminated, the actual delay situation of the data during network transmission can be reflected more truly and accurately, providing a solid foundation for network performance evaluation and optimization.
[0101] Please refer to Figure 4 , Figure 4 which is the structural block diagram of a network delay detection device for data transmission provided by an embodiment of this application. In this embodiment, each module included in the network delay detection device for data transmission is used to execute Figure 2 and Figure 3 the corresponding steps in the corresponding embodiments. Specifically, please refer to Figure 2 and Figure 3 as well as Figure 2 and Figure 3 the relevant descriptions in the corresponding embodiments. For the sake of convenience, only the parts related to this embodiment are shown. Refer to Figure 4 , the network delay detection device 400 for data transmission may include: a first acquisition module 410, a second acquisition module 420, and a first determination module 430, where:
[0102] The first acquisition module 410 is configured to acquire first information when the first device sends data; the first information includes a transmission timestamp recorded by the first device when sending the data, and a first time offset between the clock source of the first device and the master clock source.
[0103] The second acquisition module 420 is configured to acquire second information when the second device receives data; the second information includes a reception timestamp recorded by the second device when receiving the data, and a second time offset between the clock source of the second device and the master clock source.
[0104] The first determination module 430 is configured to determine the network latency when the data is transmitted over the network based on the first information and the second information.
[0105] In one embodiment, the network latency detection device 400 for data transmission includes:
[0106] The third acquisition module is configured to acquire clock parameters of the clock source in each network device; the network devices include switch devices and terminal devices for sending data.
[0107] The second determination module is configured to determine a master clock source from multiple clock sources based on the clock parameters; the network device corresponding to the master clock source is used to broadcast the timestamp of the master clock source.
[0108] In one embodiment, the first determination module 430 is further configured to:
[0109] Correct the transmission timestamp based on the first time offset to obtain a first timestamp; correct the reception timestamp based on the second time offset to obtain a second timestamp; determine the network latency based on the first timestamp and the second timestamp.
[0110] In one embodiment, the first determination module 430 is further configured to:
[0111] Determine the difference between the first timestamp and the second timestamp as the network latency.
[0112] In one embodiment, there are multiple pieces of data; the first information further includes a unique identifier, and each piece of data carries at least the unique identifier; the first device is configured to store the corresponding first information when sending each piece of data; the second device is configured to use the unique identifier, the reception timestamp, and the second time offset as the second information and store them when receiving any piece of data;
[0113] The first determination module 430 is further configured to:
[0114] Match the first information and the second information with the same unique identifier; for any set of matched first information and second information, determine an initial network latency when the data is transmitted over the network based on the first information and the second information; determine the network latency based on multiple initial network latencies.
[0115] In one embodiment, the first determination module 430 is further configured to:
[0116] Determine the variance value of multiple initial network delays as the network delay.
[0117] In one embodiment, the network delay detection device 400 for data transmission includes:
[0118] A fourth acquisition module, configured to acquire first information and second information by using the Netconf protocol.
[0119] It should be understood that Figure 4 In the structural block diagram of the network delay detection device for data transmission shown, each module is used to execute Figure 2 and Figure 3 the respective steps in the corresponding embodiments, and for Figure 2 and Figure 3 the respective steps in the corresponding embodiments have been explained in detail in the above embodiments. For details, please refer to Figure 2 and Figure 3 as well as Figure 2 and Figure 3 the relevant descriptions in the corresponding embodiments, which will not be elaborated here.
[0120] Figure 5 is the structural block diagram of an electronic device provided in an embodiment of the present application. As Figure 5 shown, the electronic device 500 in this embodiment includes: a processor 510, a memory 520, and a computer program 530 stored in the memory 520 and executable on the processor 510, such as a program for the network delay detection method for data transmission. When the processor 510 executes the computer program 530, the steps in each of the above network delay detection methods for data transmission are implemented, such as Figure 2 S201 to S203 shown. Alternatively, when the processor 510 executes the computer program 530, the functions of each module in the above Figure 4 corresponding embodiments are implemented. For example, Figure 4 the functions of each module shown. For details, please refer to Figure 4 the relevant descriptions in the corresponding embodiments.
[0121] Exemplarily, the computer program 530 can be divided into one or more modules. One or more modules are stored in the memory 520 and executed by the processor 510 to implement the network delay detection method for data transmission provided in the embodiments of the present application. One or more modules can be a series of computer program instruction segments capable of completing specific functions, and these instruction segments are used to describe the execution process of the computer program 530 in the electronic device 500. For example, the computer program 530 can implement the network delay detection method for data transmission provided in the embodiments of the present application.
[0122] The electronic device 500 may include, but is not limited to, a processor 510 and a memory 520. Those skilled in the art can understand that Figure 5 These are merely examples of the electronic device 500 and do not constitute a limitation on the electronic device 500. It may include more or fewer components than shown in the figure, or combine certain components, or have different components. For example, the electronic device may also include input / output devices, network access devices, buses, etc.
[0123] The so-called processor 510 may be a central processing unit, or may also be other general-purpose processors, digital signal processors, application-specific integrated circuits, off-the-shelf programmable gate arrays, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0124] The memory 520 may be an internal storage unit of the electronic device 500, such as the hard disk or memory of the electronic device 500. The memory 520 may also be an external storage device of the electronic device 500, such as a plug-in hard disk, smart memory card, flash memory card, etc. equipped on the electronic device 500. Further, the memory 520 may also include both the internal storage unit and the external storage device of the electronic device 500.
[0125] An embodiment of the present application provides a computer-readable storage medium, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the network delay detection method for data transmission in the above-mentioned various embodiments.
[0126] An embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, it causes the electronic device to execute the network delay detection method for data transmission in the above-mentioned various embodiments.
[0127] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for detecting network delay of data transmission, characterized in that: The method comprises: Acquire first information when the first device sends data; the first information includes a sending timestamp recorded by the first device when the data is sent, and a first time offset between a clock source of the first device and a main clock source; Acquire second information when the second device receives the data; the second information includes a receiving timestamp when the second device records the receiving of the data, and a second time offset between a clock source of the second device and the master clock source; Based on the first information and the second information, a network delay of the data during network transmission is determined.
2. The method according to claim 1, characterized in that The method comprises: Acquire clock parameters of a clock source in each network device; the network device includes a switch device and a terminal device for sending data; A master clock source is determined from the multiple clock sources based on the clock parameters; and a network device corresponding to the master clock source is used to broadcast the timestamp of the master clock source.
3. The method according to claim 1, characterized in that The determining, based on the first information and the second information, a network delay of the data during network transmission includes: Correcting the sending timestamp based on the first time offset to obtain a first timestamp; Correcting the receiving timestamp based on the second time offset to obtain a second timestamp; The network delay is determined based on the first timestamp and the second timestamp.
4. The method according to claim 3, characterized in that The determining the network delay based on the first timestamp and the second timestamp includes: A difference between the first timestamp and the second timestamp is determined as the network delay.
5. The method according to claim 1, characterized in that The data includes a plurality of items; the first information also includes a unique identifier, and each item of the data carries at least the unique identifier; the first device is used to store the corresponding first information when sending each item of the data; The second device is used to, when receiving any of the data, use the unique identifier, the receiving timestamp, and the second time offset as the second information and store them; The determining, based on the first information and the second information, a network delay of the data during network transmission includes: Matching the first information and the second information having the same unique identifier; For any set of matching first information and second information, determining an initial network delay of the data during network transmission based on the first information and the second information; The network delay is determined based on a plurality of the initial network delays.
6. The method according to claim 5, characterized in that The determining the network delay based on the multiple initial network delays comprises: The variance values of the multiple initial network delays are determined as the network delay.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: The first information and the second information are acquired using the Netconf protocol.
8. A network delay detection device for data transmission, characterized in that: The device comprises: A first acquisition module, used to acquire first information when a first device sends data; the first information includes a sending timestamp when the first device records the sending of the data, and a first time offset between a clock source of the first device and a main clock source; A second acquisition module, used to acquire second information when the second device receives the data; the second information includes a reception timestamp when the second device records the reception of the data, and a second time offset between a clock source of the second device and the master clock source; The first determination module is used to determine the network delay of the data during network transmission based on the first information and the second information.
9. An electronic device, characterized in that: The electronic device comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the electronic device implements the method as claimed in any one of claims 1 to 7.
10. A computer program product, characterized in that The invention comprises a computer program, which, when being executed, enables the method according to any one of claims 1 to 7 to be performed.