Method and apparatus for testing latency based on underlying communication, and electronic device
By using a data distribution service and a clock recording time stamp on a single test machine in the underlying communication, the problem of insufficient accuracy in the communication latency test of the underlying middleware is solved, and nanometer-level latency test accuracy and precision are achieved.
Patent Information
- Application Number
- CN202310784543.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-29
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2043-06-29
AI Technical Summary
Existing methods for testing the communication latency of underlying middleware cannot achieve nanometer-level precision, and the time synchronization error between test machines cannot be accurately calculated, resulting in errors in the test results.
The first test machine records the timestamp of when the data packet begins to be written and writes it into the data packet. The packet is then sent to the second test machine using the data distribution service and immediately returned to the first test machine via the data distribution service. The first test machine records the timestamp when the reception is completed and calculates the communication delay of the data packet. The timestamp recording is done using only the clock of a single test machine.
It improves the accuracy of latency testing, reduces equipment requirements, reduces the amount of test code, is suitable for sending continuous multi-packet data, conforms to actual communication conditions, and improves the accuracy of test results.
Smart Images

Figure CN116633820B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of communication latency testing, in particular to a latency testing method and device based on underlying communication, electronic equipment and computer readable storage medium. BACKGROUND
[0002] In related technologies, underlying middleware communication is widely used in industrial control, intelligent transportation, and aerospace fields. With the rapid development of technology, the indicators of middleware communication are becoming more and more stringent, and the communication latency is one of the indicators for measuring communication performance.
[0003] The existing latency testing method for testing underlying middleware communication is as follows: assuming that the time of test machine 1 and test machine 2 is already synchronized, the time delay error is 0, test machine 1 records the time stamp of the start of writing as T1, writes the data packet, and the size of the data packet is unchanged; the data packet is transmitted to test machine 2 through underlying middleware; test machine 2 records the time stamp as T1 after receiving the data packet, and parses the start time T1 in the current data packet; for the underlying middleware, the time delay required for sending the data packet is T2-T1.
[0004] However, for the underlying middleware required by high-speed products, the required time delay requires precision to reach the nanometer level, and it is necessary to ensure that the time synchronization error of test machine 1 and test machine 2 is within the precision, but it is still impossible to accurately calculate the error value. At the same time, it is necessary to ensure that test machine 1 and test machine 2 can both obtain nanometer-level time stamps, otherwise the test result will have an error.
[0005] Therefore, there is an urgent need for an underlying middleware communication latency testing method that can improve the latency testing precision and avoid the time delay error between test machines. SUMMARY
[0006] To overcome the problems in related technologies, the present disclosure provides a latency testing method and device based on underlying communication, electronic equipment and computer readable storage medium.
[0007] According to a first aspect of the embodiments of the present disclosure, a latency test method based on underlying communication is provided, which comprises: recording a timestamp of a start of writing of a data packet into a first test machine to obtain a first time, and writing the first time into the corresponding data packet, sending the data packet from the first test machine to a second test machine based on a data distribution service; the second test machine receives the data packet based on the data distribution service, and immediately returns the received data packet to the first test machine based on the data distribution service; when the first test machine receives the returned data packet based on the data distribution service, a timestamp of a completion of receiving of the data packet is recorded to obtain a second time, and a corresponding first time is obtained according to the data packet; and a communication latency corresponding to the data packet is calculated according to the second time and the first time.
[0008] In some embodiments, the communication latency corresponding to the data packet is calculated according to the second time and the first time, and the formula is:
[0009] late = (T b -T a ) / 2
[0010] In the formula, for a single data packet, late represents the communication latency, T a is the first time of recording the start of writing of the data packet, and T b is the second time of receiving the data packet by the first test machine through the second subject.
[0011] In some embodiments, the method further comprises: when a plurality of data packets are continuously sent, the communication latencies of the plurality of data packets are respectively calculated; and an average communication latency is calculated according to the communication latencies of the plurality of data packets, and the average communication latency is taken as a target communication latency.
[0012] In some embodiments, the average communication latency is calculated according to the communication latencies of the plurality of data packets, and the formula is:
[0013]
[0014] In the formula, latex1, latex2, …, and latexn are the communication latencies of single data packets in the plurality of data packets, and n is the number of the plurality of data packets.
[0015] In some embodiments, the method further comprises: when a plurality of data packets are continuously sent, an earliest timestamp and a latest timestamp in the plurality of data packets are obtained, wherein the earliest timestamp is a time of a start of writing of a first data packet in the plurality of data packets, and the latest timestamp is a time of a completion of receiving of a return of a last data packet in the plurality of data packets; a number of sent data packets is counted, and a target communication latency of a single data packet is calculated in combination with the latest timestamp and the earliest timestamp.
[0016] In some embodiments, the number of data packets sent is counted, combined with the latest timestamp and the earliest timestamp, to calculate the target communication delay of a single data packet, with the formula being:
[0017] late m =(T w -T z ) / 2m
[0018] In the formula, T w is the latest timestamp, T z is the earliest timestamp, and m is the number of data packets.
[0019] In some embodiments, the second test machine receives the data packet based on the data distribution service, and immediately returns the received data packet to the first test machine through the data distribution service, including: creating a first topic through the data distribution service, and configuring the message sending frequency of the first topic, based on the first topic, sending the data packet to the second test machine through the first test machine; creating a second topic through the data distribution service, and based on the second topic, immediately returning the received data packet to the first test machine through the second test machine.
[0020] According to a second aspect of the embodiments of the present disclosure, a latency testing device based on underlying communication is provided, including: a data packet sending module, configured to record the timestamp of the start of writing a data packet into a first test machine, to obtain a first time, and to write the first time into the corresponding data packet, and to send the data packet to a second test machine through the first test machine based on a data distribution service; a data packet returning module, configured to receive the data packet by the second test machine based on the data distribution service, and to immediately return the received data packet to the first test machine through the data distribution service; a time obtaining module, configured to record the timestamp of the completion of receiving a data packet when the first test machine receives the returned data packet based on the data distribution service, to obtain a second time, and to obtain the corresponding first time according to the data packet; and a communication delay calculating module, configured to calculate the communication delay corresponding to the data packet according to the second time and the first time.
[0021] According to a third aspect of the embodiments of the present disclosure, an electronic device is provided, including: a processor; a memory for storing executable instructions of the processor; and the processor, configured to read the executable instructions from the memory, and to execute the instructions to implement the latency testing method based on underlying communication provided by the first aspect of the present disclosure.
[0022] According to a fourth aspect of the embodiments of the present disclosure, a computer readable storage medium is provided, and the computer readable storage medium stores computer program instructions. The computer program instructions are executed by a processor to implement the steps of the method for testing communication delay based on underlying communication according to the first aspect of the present disclosure.
[0023] The technical solution provided by the embodiments of the present disclosure can have the following beneficial effects: by recording the timestamp when the data packet starts to be written into the first test machine to obtain a first time, and writing the first time into the corresponding data packet, the first test machine sends the data packet to the second test machine based on a data distribution service, the second test machine receives the data packet based on the data distribution service, and immediately returns the received data packet to the first test machine through the data distribution service, the first test machine receives the returned data packet based on the data distribution service, records the timestamp when the data packet is received, obtains a second time, and calculates the communication delay of the data packet according to the first time and the second time, only the first test machine is used to record the timestamp, the requirements of the equipment are reduced, the number of test codes is reduced, the time difference between the test machines is avoided, the accuracy of the test result is improved, the method can be applied to the transmission of continuous multiple data packets, and conforms to the actual communication situation.
[0024] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0025] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure.
[0026] FIG. 1 is a flowchart of a method for testing communication delay based on underlying communication according to an exemplary embodiment.
[0027] FIG. 2 is a flowchart of a method for testing communication delay of a single data packet according to an exemplary embodiment.
[0028] FIG. 3 is a flowchart of a method for testing communication delay of multiple data packets according to an exemplary embodiment.
[0029] FIG. 4 is a flowchart of a method for calculating communication delay of multiple data packets according to an exemplary embodiment.
[0030] FIG. 5 is a flowchart of another method for calculating communication delay of multiple data packets according to an exemplary embodiment.
[0031] FIG. 6 is a flowchart of a method for sending and receiving data packets according to an exemplary embodiment.
[0032] FIG. 7 is a block diagram of a latency test device based on underlying communication according to an example embodiment.
[0033] FIG. 8 is a block diagram of an electronic device according to an example embodiment. DETAILED DESCRIPTION
[0034] The example embodiments will be described in detail below with reference to the accompanying drawings.
[0035] It should be noted that the related embodiments and drawings are only for describing the example embodiments provided by the present disclosure, and are not all embodiments of the present disclosure, and the present disclosure should not be understood as being limited by the related example embodiments.
[0036] It should be noted that the terms "first", "second", etc. used in the present disclosure are only used to distinguish different steps, devices or modules, etc. The related terms do not represent any specific technical meaning, nor do they represent the order or interdependence between them.
[0037] It should be noted that the terms "one", "multiple", "at least one" used in the present disclosure are illustrative and not restrictive. Unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0038] It should be noted that the term "and / or" used in the present disclosure is used to describe the association between the related objects, which generally represents at least three association relationships. For example, A and / or B can represent at least three association relationships: A exists alone, A and B exist together, and B exists alone.
[0039] It should be noted that the steps described in the method embodiments of the present disclosure can be executed in different orders and / or in parallel. Unless otherwise specified, the scope of the present disclosure is not limited by the order of description of the steps in the related embodiments.
[0040] It should be noted that all actions of obtaining signals, information or data in the present disclosure are carried out in accordance with the corresponding data protection regulations and policies of the country where the device is located, and with the authorization given by the owner of the corresponding device.
[0041] Exemplary method
[0042] FIG. 1 is a flowchart of a latency test method based on underlying communication according to an example embodiment, as FIG. 1 shown, the latency test method based on underlying communication is used in underlying middleware communication, including the following steps:
[0043] In step S110, a timestamp of when the data packet starts to be written into the first test machine is recorded to obtain a first time, and the first time is written into the corresponding data packet. The data packet is sent to the second test machine through the first test machine based on the data distribution service.
[0044] In some embodiments, in order to test the latency of the underlying middleware-based communication, when the underlying middleware communication is performed, a timestamp of when the data packet starts to be written into the first test machine is recorded to obtain a first time, and the first time is written into the data packet. The size of the data packet is unchanged, and the data packet always maintains the required bandwidth of the test, which can better reflect the consistency of the test and the actual scenario. In addition, the first test machine can perform testing by sending one data packet or continuously sending multiple data packets. The continuous sending of multiple packets can be closer to the actual running scenario.
[0045] For example, based on the first topic created by the data distribution service, the data packet after the first time is sent to the second test machine. The first test machine and the second test machine have subscribed to the first topic, so that the message transmission between the first test machine and the second test machine can be performed based on the first topic.
[0046] In step S120, the second test machine receives the data packet based on the data distribution service, and immediately returns the received data packet to the first test machine through the data distribution service.
[0047] In some embodiments, the second test machine receives the data packet sent by the first test machine based on the first topic subscribed in the data distribution service, and immediately returns the received data packet to the first test machine through the second topic created by the data distribution service. Similarly, the first test machine and the second test machine have subscribed to the second topic, so that the message transmission between the first test machine and the second test machine can be performed based on the second topic created by the data distribution service.
[0048] In addition, the second test machine receives the data packet and immediately returns it to the first test machine, that is, after receiving the data packet, the data packet is returned within a very small time range, and the time range is negligible compared with the latency and is considered as immediate.
[0049] In step S130, when the first test machine receives the returned data packet based on the data distribution service, a timestamp of when the data packet is received is recorded to obtain a second time, and the corresponding first time is obtained according to the data packet.
[0050] In some embodiments, the first test machine receives the data packet returned from the second test machine based on a second topic subscribed in the data distribution service, records a timestamp when the data packet is received completely to obtain a second time, and starts a parsing process of the data packet to obtain a first time in the data packet; wherein the data packet receiving and the data packet parsing are performed simultaneously and do not affect the data packet receiving, and the accuracy of the timestamp recorded after the data packet is received completely is ensured.
[0051] In step S140, a communication delay corresponding to the data packet is calculated according to the second time and the first time.
[0052] In some embodiments, the first test machine calculates the communication delay of the data packet transmission according to the obtained second time and first time. The first time and the second time are recorded by the clock of the first test machine, that is, only one clock of the first test machine is introduced in the whole test process; rather than the absolute time of the sending end and the receiving end clock or network card in the prior art, two or more clocks are introduced, which will cause the time delay problem between the clocks, and it is difficult to ensure that the time error between the clocks is in the nanosecond level.
[0053] The present disclosure only introduces one clock of the first test machine in the whole test process, and does not need to synchronize the time of two test devices, thereby reducing the test devices, such as time synchronization devices, and reducing the device requirements due to the fact that the second test machine does not need to record the timestamp; so that the present case can have a test effect with nanosecond level precision, and is not limited to a single test packet, and through multi-packet test, the precision of the time delay test can be improved.
[0054] The formula for calculating the communication delay is:
[0055] late=(T b -T a ) / 2
[0056] In the formula, for a single data packet, late represents the communication delay, T a represents the first time when the data packet is written, and T b represents the second time when the first test machine receives the data packet through the second topic.
[0057] Specifically, since the data packet is transmitted between the first test machine and the second test machine for two rounds, the difference between the obtained second time and the first time can be divided by 2 to obtain the communication delay of a single transmission of the data packet.
[0058] The communication delay includes the packaging time of the data packet, that is, from obtaining the data packet to the end of receiving, and the same is true for the second test machine, so that the time consumption except the transmission time is symmetrical.
[0059] In the above embodiment, the first time is obtained by recording the timestamp of the time when the data packet starts to be written into the first test machine, and the first time is written into the corresponding data packet, the first test machine sends the data packet to the second test machine based on the data distribution service, the second test machine receives the data packet based on the data distribution service, and immediately returns the received data packet to the first test machine based on the data distribution service, the first test machine receives the returned data packet based on the data distribution service, records the timestamp of the time when the data packet is received, obtains the second time, and obtains the first time according to the data packet, calculates the communication delay of the data packet according to the first time and the second time, only records the timestamp by the first test machine, reduces the equipment requirements, reduces the test code quantity, avoids the time difference between the test machines, improves the precision of the test result, can be applied to the transmission of continuous multiple data packets, and conforms to the actual communication situation.
[0060] In one embodiment, as shown in FIG. 2 The steps of the single data packet delay test by the present disclosure are as follows: assuming that the time error of the first test machine and the second test machine is β, the test machine 1 records the timestamp of the time when the data packet starts to be written as T1, writes the timestamp T1 into the data packet data, and the size of the data packet is unchanged; the data packet data is transmitted to the test machine 2 through the underlying communication middleware; after the test machine 2 receives the data packet data, the timestamp T2 is recorded; the test machine 2 directly writes the data packet data, transmits it to the test machine 1 through the underlying communication middleware, records the timestamp T3 when the writing starts, and T2=T3, that is, the time difference from the time when the test machine 2 receives the data packet to the time when the data packet is sent can be ignored; after the test machine 1 receives the data packet data, the timestamp T4 is recorded; the start time T1 in the current data packet data is analyzed; therefore, for the underlying communication middleware, the communication delay of sending the data packet data is late=(T2-β)-T1, and late=T4-(T3-β); since T3=T2, the communication delay required for sending the data packet data is late=(T4-T1) / 2.
[0061] In one embodiment, as shown in FIG. 3As shown, the steps of the latency test of multiple data packets by the present disclosure are as follows: the tester 1 sends n data packets data per second, and x represents any number from 1 to n; the method and the latency test method of a single data packet are the same, and the start time T1x is written in the data; Topic1 is created using DDS, the sending frequency is set to n, and the data packet is data; the tester 2 receives the data packet data sent by the tester 1 using the Topic1 created by DDS; the tester 2 sends the received data packet data to the tester 1 through the Topic2 created by DDS; when the tester 1 receives a data packet using Topic2, the current timestamp T4x is obtained; another process is started to parse the current data packet, obtain the start time T1x in the data packet, and does not affect the current data packet receiving process; the time T4x is recorded as the end time of the data packet, and the T1x parsed by the data packet data is the start time of the data packet, so the communication latency of the xth data packet data is latex=(T4x-T1x) / 2; if n data packets are received, the latex of n data packets can be added and divided by n to obtain the average latency of the data packet.
[0062] FIG. 4 is a flow chart of a communication latency calculation method of multiple data packets according to an exemplary embodiment, as shown in FIG. 4 The communication latency calculation method of multiple data packets is used in step S104, and includes the following steps:
[0063] In step S410, when multiple data packets are continuously sent, the communication latency of multiple data packets is calculated respectively.
[0064] Specifically, the first tester can continuously send multiple data packets to the second tester through the first topic in order to better simulate the actual communication process, and based on the obtained first time and second time, the communication latency of multiple data packets is calculated respectively.
[0065] In step S420, the average communication latency is calculated according to the communication latency of multiple data packets, and the average communication latency is taken as the target communication latency.
[0066] Specifically, the average communication latency is calculated according to the obtained communication latency of multiple data packets and the number of sent data packets, and the average communication latency is taken as the target communication latency. Through the sending of multiple data packets, the test result can be closer to the actual communication situation, and the reliability of the latency test result is ensured. Of course, the communication latency of part of the data packets in multiple packets can also be taken as the calculation basis.
[0067] The formula for calculating the average communication latency is:
[0068]
[0069] In the formula, latex1, latex2…latex n is the communication delay of a single data packet in the plurality of data packets, and n is the number of the plurality of data packets.
[0070] In the embodiment, when the first test machine continuously sends the plurality of data packets, the communication delay of each data packet is calculated respectively, the average communication delay is calculated according to the communication delays of the plurality of data packets, and the average communication delay is taken as the target communication delay, so that the test result conforms to the actual situation and the reliability of the obtained delay test result is ensured.
[0071] FIG. 5 is a flowchart of another communication delay calculation method for a plurality of data packets according to an exemplary embodiment, as shown in FIG. 5 The communication delay calculation method for a single data packet in the plurality of data packets is used in step S104 and includes the following steps:
[0072] In step S510, when the plurality of data packets are continuously sent, the earliest timestamp and the latest timestamp in the plurality of data packets are obtained, wherein the earliest timestamp is the time when the first data packet in the plurality of data packets starts to be written, and the latest timestamp is the time when the last data packet in the plurality of data packets is completely received.
[0073] Specifically, in order to test the effectiveness of the test result, the first test machine can continuously send a plurality of data packets, and after the plurality of data packets are sent by the first test machine and finally received by the first test machine, the earliest timestamp and the latest timestamp recorded in the first test machine for the plurality of data packets are obtained as the basis for calculating the communication delay. The earliest timestamp is the time when the first data packet in the plurality of data packets starts to be written into the first test machine, and the latest timestamp is the time when the last data packet in the plurality of data packets is returned to the first test machine and completely received.
[0074] In step S520, the number of sent data packets is counted, and the target communication delay of a single data packet is calculated based on the latest timestamp and the earliest timestamp.
[0075] Specifically, the number of continuously sent data packets is counted, the difference between the latest timestamp and the earliest timestamp is calculated, and the target communication delay of a single data packet is obtained by dividing the number of data packets. Of course, the earliest timestamp and the latest timestamp of part of the plurality of data packets can also be obtained as the basis for calculation to obtain the corresponding target communication delay.
[0076] The calculation formula of the target communication delay of a single data packet is:
[0077] late m =(T w -Tz ) / 2m
[0078] In the formula, T w is the latest timestamp, T z is the earliest timestamp, and m is the number of data packets.
[0079] In this embodiment, a plurality of data packets are continuously sent by the first test machine, the earliest timestamp and the latest timestamp in the plurality of data packets are obtained, the number of continuously sent data packets is counted, and the target communication delay of a single data packet is calculated in combination with the latest timestamp and the earliest timestamp, so that the obtained target communication delay can be fitted to the actual situation, and the reliability of the test result is ensured.
[0080] FIG. 6 is a flowchart of a data packet sending and receiving method according to an exemplary embodiment, as shown in FIG. 6 The data packet sending and receiving method is used in step S102 and includes the following steps.
[0081] In step S610, a first topic is created by a data distribution service, and the message sending frequency of the first topic is configured, data packets are sent to the second test machine by the first test machine based on the first topic.
[0082] Specifically, when sending and receiving data packets, a first topic is created by a data distribution service, and the message sending frequency of the first topic is configured, which is used for sending continuous multiple data packets, and the first test machine sends data packets to the second test machine through the first topic, so as to realize the sending of data packets.
[0083] In step S620, a second topic is created by a data distribution service, and the received data packets are immediately returned to the first test machine by the second test machine based on the second topic.
[0084] Specifically, after the second test machine receives the data packets through the first topic, the second test machine returns the received data packets to the first test machine immediately through the second topic created by the data distribution service, so as to realize the return of the data packets, and the communication delay is calculated by recording the timestamps of the data packet sending and return.
[0085] In this embodiment, a first topic is created by a data distribution service, and the message sending frequency of the first topic is configured, the first test machine subscribes to the first topic, and the first test machine sends data packets to the second test machine through the first topic; a second topic is created by a data distribution service and subscribed, and the second test machine returns the received data packets to the first test machine immediately through the second topic, so as to realize the transmission of data packets between the first test machine and the second test machine, and the communication delay can be calculated based on the timestamps recorded in the transmission process.
[0086] Exemplary apparatus
[0087] FIG. 7 is a bottom layer communication based latency testing device block diagram shown according to an exemplary embodiment. Referring to FIG. 7 , the device 700 comprises a data packet sending module 710, a data packet returning module 720, a time obtaining module 730 and a communication latency calculating module 740.
[0088] The data packet sending module 710 is configured to record a timestamp of a data packet starting to be written into a first tester, obtain a first time, and write the first time into the corresponding data packet, and send the data packet to a second tester through the first tester based on a data distribution service;
[0089] The data packet returning module 720 is configured to receive the data packet by the second tester based on the data distribution service, and immediately return the received data packet to the first tester through the data distribution service;
[0090] The time obtaining module 730 is configured to record a timestamp of the data packet being completely received by the first tester based on the data distribution service when the data packet is received, obtain a second time, and obtain the corresponding first time according to the data packet;
[0091] The communication latency calculating module 740 is configured to calculate a communication latency corresponding to the data packet according to the second time and the first time.
[0092] In one embodiment, the device further comprises a multi-latency calculating module configured to calculate communication latencies of a plurality of data packets respectively when the plurality of data packets are continuously sent, and an average latency calculating module configured to calculate an average communication latency according to the communication latencies of the plurality of data packets, and take the average communication latency as a target communication latency.
[0093] In one embodiment, the device further comprises a first topic creating module configured to create a first topic through the data distribution service, configure a message sending frequency of the first topic, send the data packet to the second tester through the first tester based on the first topic, and a second topic creating module configured to create a second topic through the data distribution service, and immediately return the received data packet to the first tester through the second tester based on the second topic.
[0094] In the above embodiment, through the operation of the device, a bottom layer communication based latency testing method is realized, and it is ensured that the device can realize all contents of a bottom layer communication based latency testing method.
[0095] Exemplary electronic device
[0096] FIG. 8is a block diagram of an electronic device 900 according to an example embodiment. The electronic device 900 can be a vehicle controller, a vehicle terminal, a vehicle computer, or other types of electronic devices.
[0097] Referring to FIG. 8 The electronic device 900 can include at least one processor 910 and a memory 920. The processor 910 can execute instructions stored in the memory 920. The processor 910 is communicatively connected to the memory 920 through a data bus. In addition to the memory 920, the processor 910 can be communicatively connected to an input device 930, an output device 940, and a communication device 950 through the data bus.
[0098] The processor 910 can be any conventional processor, such as commercially available CPUs. The processor can also include a graphic process unit (GPU), a field programmable gate array (FPGA), a system on chip (SOC), an application specific integrated circuit (ASIC), or a combination thereof.
[0099] The memory 920 can be implemented by any type of volatile or non-volatile storage devices or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0100] In the embodiments of the present disclosure, the memory 920 stores executable instructions. The processor 910 can read the executable instructions from the memory 920 and execute the instructions to implement all or part of the steps of the underlying communication-based latency test method described in any of the above example embodiments.
[0101] Exemplary computer-readable storage medium
[0102] In addition to the above method and device, the example embodiments of the present disclosure can also be a computer program product or a computer readable storage medium storing the computer program product. The computer program product includes computer program instructions that can be executed by a processor to implement all or part of the steps described in any of the above example embodiments.
[0103] The computer program product can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages, and scripting languages (e.g., Python). The program code can execute entirely on the user's computing device, partly on the user's computing device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server. The embodiments of the application are not limited by the programming languages used to write the program code.
[0104] The computer readable storage medium can be a combination of one or more computer readable media. The computer readable media can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can include, for example, but is not limited to, static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), flash memory, magnetic storage, optical disk, or any suitable combination thereof.
[0105] Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure. Variations and modifications of the embodiments disclosed herein can be made based on the description set forth herein, without departing from the scope and spirit of the disclosure. The application is intended to cover any variations, uses or adaptations of the disclosure including such departures from the
[0106] It is to be understood that the disclosure is not limited to the precise construction described and shown in the drawings and that changes can be made to the embodiments disclosed without departing from the scope of the disclosure. The scope of the disclosure is limited only by the claims that follow.
Claims
1. A method for testing latency based on underlying communication, characterized in that, The method comprises: recording a timestamp when a data packet starts to be written into a first test machine, obtaining a first time, and writing the first time into the corresponding data packet, and sending the data packet to a second test machine through the first test machine based on a data distribution service; the second test machine receives the data packet based on the data distribution service, and immediately returns the received data packet to the first test machine through the data distribution service, comprising: creating a first topic through the data distribution service, configuring the message sending frequency of the first topic, and sending the data packet to the second test machine through the first test machine based on the first topic; creating a second topic through the data distribution service, and immediately returning the received data packet to the first test machine through the second test machine based on the second topic; when the first test machine receives the returned data packet based on the data distribution service, recording a timestamp when the data packet is received, obtaining a second time, and obtaining the corresponding first time according to the data packet; calculating the communication delay corresponding to the data packet according to the second time and the first time; when a plurality of data packets are continuously sent, the communication delays of the plurality of data packets are calculated respectively, the average communication delay is calculated according to the communication delays of the plurality of data packets, and the average communication delay is taken as the target communication delay; or, obtaining the earliest timestamp and the latest timestamp in the plurality of data packets, wherein the earliest timestamp is the time when the first data packet in the plurality of data packets starts to be written, and the latest timestamp is the time when the last data packet in the plurality of data packets is completely received; the number of sent data packets is counted, and the target communication delay of a single data packet is calculated by combining the latest timestamp and the earliest timestamp.
2. The method of claim 1, wherein, The formula for calculating the communication delay corresponding to the data packet according to the second time and the first time is: late = (T b -T a ) / 2 where, for a single data packet, late represents the communication latency, T a is the first time at which the first tester begins writing the data packet, b is the second time at which the first tester receives the data packet.
3. The method of claim 1, wherein, The formula for calculating the average communication delay according to the communication delays of the plurality of data packets is: In the formula, latex1, latex2…latex n is the communication delay of a single data packet in the plurality of data packets, and n is the number of the plurality of data packets.
4. The method of claim 1, wherein, The formula for calculating the target communication delay of a single data packet by counting the number of sent data packets and combining the latest timestamp and the earliest timestamp is: late m = (T w -T z ) / 2m In the formula, T w is the latest time stamp, T z is the earliest time stamp, and m is the number of data packets.
5. A delay test apparatus based on underlying communication, characterized by, The method comprises: a data packet sending module for recording a timestamp when a data packet starts to be written into a first test machine, obtaining a first time, and writing the first time into the corresponding data packet, and sending the data packet to a second test machine through the first test machine based on a data distribution service; a data packet returning module for the second test machine to receive the data packet based on the data distribution service, and immediately return the received data packet to the first test machine through the data distribution service, comprising: creating a first topic through the data distribution service, configuring the message sending frequency of the first topic, and sending the data packet to the second test machine through the first test machine based on the first topic; creating a second topic through the data distribution service, and immediately returning the received data packet to the first test machine through the second test machine based on the second topic; a time acquisition module, configured to record a timestamp when a data packet is received completely to obtain a second time when the first tester receives the returned data packet based on a data distribution service, and obtain a corresponding first time according to the data packet; a communication delay calculation module, configured to calculate a communication delay corresponding to the data packet according to the second time and the first time, calculate communication delays of a plurality of data packets respectively when the plurality of data packets are continuously sent, calculate an average communication delay according to the communication delays of the plurality of data packets, and take the average communication delay as a target communication delay; alternatively, obtain an earliest timestamp and a latest timestamp in the plurality of data packets, wherein the earliest timestamp is a time when a first data packet in the plurality of data packets starts to be written, and the latest timestamp is a time when a last data packet in the plurality of data packets is received completely, count a number of sent data packets, and calculate a target communication delay of a single data packet in combination with the latest timestamp and the earliest timestamp.
6. An electronic device, comprising: comprise: a processor; a memory for storing executable instructions of the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the method for testing a communication delay based on a bottom layer communication according to any one of claims 1-4.
7. A computer-readable storage medium having stored thereon computer program instructions, wherein, the program instructions are executed by the processor to implement the steps of the method for testing a communication delay based on a bottom layer communication according to any one of claims 1-4.
Citation Information
Patent Citations
Network delay measuring device and method
CN103297282A
Transmission delay probing method, device and system
CN108737207A
Network card time delay test method and device
CN115865760A