Round-trip delay determination method, electronic equipment and computer readable storage medium
Calculating RTT by storing the interval timestamp of the cache interval, the problem of RTT calculation in the prior art consumes a lot of storage resources, and the effect of reducing storage resource consumption is achieved.
Patent Information
- Application Number
- CN202311706033.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-12
- Publication Date
- 2025-06-13
AI Technical Summary
The existing RTT calculation methods require a lot of storage resources, especially when high traffic or large RTT.
RTT is calculated by storing the interval timestamps of each cache interval instead of the timestamp of each data packet.
Reduces the timestamp data that needs to be cached during RTT calculation, and reduces the consumption of storage resources.
Smart Images

Figure CN120151245A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network communication technologies, and in particular, to a method for determining round-trip delay, an electronic device, and a computer-readable storage medium. Background Art
[0002] Round Trip Time (RTT) is one of the important metrics for measuring network transmission performance in network communication.
[0003] Generally, the calculation of RTT depends on the timestamp and sequence number (seq) of data packets, as well as the timestamp and sequence number of the corresponding Acknowledgement (Ack) packets. In a specific application, the system stores both the sequence number and timestamp of data packets in a cache. When an Ack packet is received, it searches for the data packet corresponding to the sequence number of the Ack packet in the cache, and calculates the RTT value based on the timestamp of the found data packet and the timestamp of the Ack packet.
[0004] In the above RTT calculation method, it is necessary to store the timestamp and sequence number of each data packet in the cache, and the timestamp and sequence number of unacknowledged data packets will be cached until the corresponding Ack packet is received. In this way, a large amount of storage resources are required to store relevant information such as the timestamp and sequence number of data packets, especially in the case of high traffic or a large RTT. Summary of the Invention
[0005] Embodiments of this application provide a method for determining round-trip delay, an electronic device, and a computer-readable storage medium, which can solve the problem that the existing RTT calculation method requires a large amount of storage resources.
[0006] In a first aspect, an embodiment of this application provides a method for determining round-trip delay, which is applied to an electronic device. In this method for determining round-trip delay, the electronic device obtains the first timestamp and the first sequence number of each data packet; for each data packet, determines the cache interval to which the data packet belongs according to the first timestamp and the interval width of the cache interval, and stores the first sequence number in the cache, where each cache interval corresponds to an interval timestamp, and the interval timestamp is used to represent the timestamp of the data packets belonging to the cache interval; obtains the second timestamp and the second sequence number of the acknowledgement packet; if a target first sequence number is found in the cache, obtains the interval timestamp of the stored target cache interval, where the target first sequence number is the same first sequence number as the second sequence number, and the target cache interval is the cache interval to which the data packet corresponding to the target first sequence number belongs; determines the round-trip delay value according to the interval timestamp of the target cache interval and the second timestamp.
[0007] As can be seen from the above, in the embodiments of the present application, by storing the interval timestamps of each cache interval, instead of caching the timestamp of each data packet, that is, instead of caching the timestamp of each data packet, the interval timestamps of each cache interval are stored, so as to represent the timestamps of all data packets in the cache interval through the interval timestamps of the cache interval. Furthermore, the RTT can be calculated based on the interval timestamp of the cache interval to which the data packet belongs and the timestamp of the corresponding acknowledgment packet. In this way, it is not necessary to cache the timestamps of data packets one by one, reducing the timestamp data that needs to be cached in the RTT calculation process, and thus reducing the storage resources consumed in the RTT calculation process.
[0008] In some possible implementation manners of the first aspect, the interval timestamp is the first timestamp of the first data packet entering the cache interval. That is, the timestamp of the first data packet entering the cache interval is used as the timestamp of the cache interval, which can further improve the RTT calculation accuracy.
[0009] In some possible implementation manners of the first aspect, when the electronic device determines the cache interval to which the data packet belongs according to the first timestamp and the interval width of the cache interval, for each cache interval in the used state, if the difference between the first timestamp and the interval timestamp of the cache interval is less than the interval width, it is determined that the data packet belongs to the cache interval; if the difference between the first timestamp and the interval timestamp of the cache interval is greater than or equal to the interval width, it is determined that the data packet does not belong to the cache interval.
[0010] In some possible implementation manners of the first aspect, if the difference between the first timestamp of the current data packet and the interval timestamps of all cache intervals in the used state is greater than or equal to the interval width, and the number of cache intervals in the used state is less than the total number of cache intervals, the electronic device can create a new cache interval and determine that the data packet belongs to the new cache interval, and the interval timestamp of the new cache interval is the first timestamp of the current data packet.
[0011] In some possible implementation manners of the first aspect, for each cache interval in the used state, if all acknowledgment packets corresponding to the data packets belonging to the cache interval have been received, the electronic device can delete the cache interval and the interval timestamp of the cache interval. This can timely delete the unused cache intervals and the corresponding timestamps to release the storage resources in a timely manner.
[0012] In some possible implementation manners of the first aspect, the first timestamp of the data packet is the time when the sending end sends the data packet, and the second timestamp is the time when the sending end receives the acknowledgment packet; or, the first timestamp of the data packet is the time when the measuring device receives the data packet, and the second timestamp is the time when the measuring device receives the acknowledgment packet.
[0013] In some possible implementations of the first aspect, if the difference between the first timestamp of the current data packet and the interval timestamps of each cache interval in the used state is greater than or equal to the interval width, and the number of cache intervals in the used state is equal to the total number of cache intervals, the electronic device increases the interval width of the cache interval; and / or, if the number of cache intervals in the used state is less than a preset threshold within a continuous preset number of data packets or a continuous preset time period, the electronic device reduces the interval width of the cache interval, where the preset threshold is less than the total number of cache intervals. That is, the electronic device can increase or decrease the interval width according to the current situation to further improve the RTT calculation accuracy.
[0014] In some possible implementations of the first aspect, the reduced interval width is the ratio between the interval width and the total number of cache intervals.
[0015] In a second 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 described in any one of the above first aspects is implemented.
[0016] In a third 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 described in any one of the above first aspects is implemented.
[0017] In a fourth aspect, an embodiment of the present application provides a chip system, which includes a processor. The processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the method described in any one of the above first aspects. The chip system can be a single chip or a chip module composed of multiple chips.
[0018] 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 described in the above first aspect.
[0019] It can be understood that the beneficial effects of the above second to fifth aspects can refer to the relevant descriptions in the above first aspect and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a schematic diagram of the RTT calculation process provided by an embodiment of the present application;
[0021] Figure 2A It is a schematic block diagram of RTT measurement provided by an embodiment of the present application;
[0022] Figure 2BAnother schematic diagram of the RTT calculation process provided by the embodiment of the present application;
[0023] Figure 3 A flowchart block diagram of a method for determining round-trip delay provided by the embodiment of the present application;
[0024] Figure 4 A schematic diagram of the cache interval provided by the embodiment of the present application;
[0025] Figure 5 A schematic diagram of RTT calculation based on data packets and acknowledgment packets provided by the embodiment of the present application;
[0026] Figure 6 A schematic diagram of a process for adjusting the interval width provided by the embodiment of the present application;
[0027] Figure 7 A schematic diagram of the interval adjustment process provided by the embodiment of the present application;
[0028] Figure 8A A schematic diagram of an RTT calculation scenario provided by the embodiment of the present application;
[0029] Figure 8B A schematic diagram of the working process of the measuring device provided by the embodiment of the present application;
[0030] Figure 9 A schematic diagram of the structure of a round-trip delay determination device provided by the embodiment of the present application;
[0031] Figure 10 A schematic diagram of the structure of an electronic device provided by the embodiment of the present application. Detailed implementation manners
[0032] In the following description, specific details such as specific system structures and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present application.
[0033] Generally, RTT refers to the time elapsed from when a data packet is sent from the sender to when the sender receives an Ack packet from the receiver, that is, RTT = the reception time of the Ack packet - the transmission time of the data packet.
[0034] Exemplarily, refer to Figure 1 A schematic diagram of the RTT calculation process provided by the embodiment of the present application shown in the figure. The sender sends a data packet to the receiver, and the data packet carries a sequence number. After receiving the data packet, the receiver generates an Ack packet corresponding to the data packet and sends the Ack packet to the sender. The sequence number carried by the Ack packet is the same as the sequence number of the corresponding data packet.
[0035] In the above process, when the sender sends a data packet, it records the sending time of each data packet and uses this sending time as the timestamp of the data packet. In addition, for subsequent RTT calculation, it also stores the sending time and sequence number of each data packet in its own cache. When the sender receives an Ack packet returned by the receiver, it also records the receiving time of the Ack packet and uses this receiving time as the timestamp of the Ack packet.
[0036] After the sender receives the Ack packet, it compares the sequence number of the Ack packet with the sequence numbers of the data packets in its own cache one by one to determine whether there is a data packet sequence number in the cache that is the same as the sequence number of the Ack packet. If a data packet sequence number that is the same as the Ack packet is found in the cache, it obtains the sending time of the data packet corresponding to this data packet sequence number from the cache, and subtracts the sending time of the corresponding data packet from the receiving time of the Ack packet to obtain the RTT value between the sender and the receiver. As Figure 1 shown, assume that the sending time of the data packet recorded by the sender is T1, and the receiving time of the Ack packet corresponding to the recorded data packet is T2. At this time, RTT = T2 - T1.
[0037] It can be understood that the cache of the sender includes the sending times and sequence numbers of multiple data packets. Before receiving the corresponding Ack packet (i.e., not being confirmed), the sender will always store the relevant information such as the sending time and sequence number of the data packet in the cache until it receives the corresponding Ack packet and calculates the RTT value.
[0038] In some cases, a measuring device can be set on the transmission path between the sender and the receiver to measure the RTT through this measuring device. For example, in the scenario of the Transmission Control Protocol (TCP), the sender and the receiver usually communicate through a TCP connection. To measure the RTT of the TCP connection, a monitoring point can be set at a certain position on the TCP link between the sender and the receiver, and a measuring device can be set at this monitoring point.
[0039] At this time, the RTT can refer to the time elapsed from the time when the measuring device receives the data packet to the time when the measuring device receives the Ack packet from the receiver, that is, RTT = the receiving time of the Ack packet - the receiving time of the data packet.
[0040] Exemplarily, see Figure 2AThe schematic block diagram of RTT measurement provided by the embodiment of the present application shown below shows a measurement device is set between the sending end and the receiving end. After the sending end sends a data packet, since the measurement device is located on the transmission path between the sending end and the receiving end, the measurement device can receive the data packet; after the measurement device receives the data packet, it forwards the data packet to the receiving end; after the receiving end receives the data packet, it generates an Ack packet corresponding to the data packet and sends the Ack packet, and the Ack packet carries the same sequence number as the data packet; after the measurement device receives the Ack packet sent by the receiving end, it forwards the Ack packet to the sending end again.
[0041] In the above process, when the measurement device receives a data packet, it will record the reception time of each data packet and use the reception time as the timestamp of the data packet; in addition, for subsequent RTT calculation, it will also store the reception time and sequence number of each data packet in its own cache. When the measurement device receives an Ack packet, it will also record the reception time of the Ack packet and use the reception time as the timestamp of the Ack packet.
[0042] After the measurement device receives the Ack packet, it compares the Ack packet sequence number with the data packet sequence numbers in its own cache one by one to determine whether there is a data packet sequence number in the cache that is the same as the Ack packet sequence number. If a data packet sequence number that is the same as the Ack packet sequence number is found in the cache, it obtains the reception time of the data packet corresponding to the data packet sequence number from the cache, and subtracts the reception time of the corresponding data packet from the reception time of the Ack packet to obtain the RTT value. At this time, the RTT value can be regarded as the RTT value between the measurement device and the receiving end. See Figure 2B Another schematic diagram of the RTT calculation process provided by the embodiment of the present application shown below. Assume that the reception time of the data packet recorded by the measurement device is T3, and the reception time of the corresponding Ack packet is T4. At this time, RTT = T4 - T3.
[0043] It can be understood that the cache of the measurement device includes the reception times and sequence numbers of multiple data packets. Before receiving the corresponding Ack packet (i.e., not being confirmed), the measurement device will always store the relevant information such as the reception time and sequence number of the data packet in the cache until it receives the corresponding Ack packet and calculates the RTT value.
[0044] In the long-term research process, the inventors found that in the RTT calculation process shown above, it is necessary to cache the relevant information of each data packet one by one, which has a high dependence on the size of the device cache space. The relevant information of a large number of data packets needs to occupy a large amount of cache, so that the sending end or the measurement device needs to consume a large amount of storage resources to store the relevant information of the unacknowledged data packets. Especially in the case of high-speed traffic or a very large RTT value, the sending end or the measurement device needs to cache the relevant information of a larger number (more than 100) of data packets, and more storage resources are required. However, the storage resources of devices such as measurement devices are limited, and the RTT calculation process consumes a large amount of storage resources, which imposes certain limitations on the design of devices such as measurement devices.
[0045] In addition, in the current network RTT measurement, the data plane is usually used to offload and accelerate the network performance statistics. However, it is difficult for the data plane to provide sufficient cache to ensure a large RTT calculation (such as scenarios like high-speed long-distance transmission, core network, and cloud computing).
[0046] In view of the above-mentioned related problems, the embodiments of the present application provide a round-trip delay determination scheme, which reduces the timestamp data to be stored by storing the timestamps of each storage cache interval instead of caching the timestamp of each data packet, thereby reducing the storage resource consumption in the RTT calculation process.
[0047] Each cache interval corresponds to a timestamp (i.e., the interval timestamp). An interval timestamp can represent the timestamps of all data packets within the cache interval. Therefore, when it is necessary to record the timestamps of each data packet, instead of storing the timestamp of each data packet, the interval timestamps of each cache interval can be stored to represent (or record) the timestamps of the data packets within each cache interval.
[0048] For example, a certain cache interval includes 10 data packets, that is, 10 data packets belong to this cache interval. If the timestamps of each data packet are cached one by one, 10 timestamp data need to be stored. However, the embodiments of the present application only need to cache the interval timestamp of the cache interval to which these 10 data packets belong, that is, only 1 timestamp data needs to be stored, reducing the timestamp data to be stored in the RTT calculation process.
[0049] Please refer to Figure 3 , which is a schematic flowchart of a round-trip delay determination method provided by the embodiments of the present application. The method may include the following steps:
[0050] Step S301: The electronic device obtains the first timestamp and the first sequence number of each data packet.
[0051] In some embodiments, the electronic device may be a sending-end device, such as Figure 1The sender in the RTT calculation scenario shown. At this time, when the sender sends a data packet, it records the sending time of each data packet, and then obtains the first timestamp of each data packet. That is, the first timestamp can refer to the time when the sender sends the data packet.
[0052] In some other embodiments, the electronic device can also be a measuring device, such as Figure 2A and Figure 2B the measuring device in the RTT calculation scenario shown. At this time, when the measuring device receives the data packet sent by the sender, it records the receiving time of each data packet, and then obtains the first timestamp of each data packet. That is, the first timestamp can refer to the time when the measuring device receives the data packet sent by the sender.
[0053] It can be understood that the sender will send multiple data packets in sequence, and the electronic device can obtain the first timestamp or and the first sequence number of multiple data packets in sequence. For example, each TCP data stream packet has multiple data packets. Starting from the first packet of the TCP data stream sent unidirectionally, the sender or the measuring device will obtain the first timestamp and the first sequence number of multiple data packets in sequence.
[0054] The first sequence number refers to the packet sequence number of the data packet.
[0055] Step S302: For each data packet, the electronic device determines the cache interval to which the data packet belongs according to the first timestamp and the interval width of the cache interval, and stores the first sequence number in the cache, where each cache interval corresponds to an interval timestamp, and the interval timestamp is used to represent the timestamp of the data packet belonging to the cache interval.
[0056] The interval width of the cache interval refers to the time length of the cache interval. For example, the interval width of each cache interval is 10 ms.
[0057] In the embodiments of the present application, the cache can be divided into N equal cache intervals based on the time scale, and the interval width of each cache interval is T. N can be a positive integer greater than or equal to 1, and T>0.
[0058] For example, referring to Figure 4 the cache interval schematic diagram provided by the embodiments of the present application shown, the cache is divided into 10 cache intervals, specifically cache interval 1 to cache interval 10. The interval width of each cache interval is 10 ms. That is, N = 10, T = 10 ms.
[0059] During the process of continuously sending data packets at the sending end or continuously receiving data packets sent by the sending end at the measuring device, for each data packet, first obtain the first timestamp and the first sequence number of the data packet, and then determine which cache interval the data packet enters based on the first timestamp and the first sequence number of the data packet, that is, determine which cache interval the data packet belongs to.
[0060] In some embodiments, for each cache interval in the used state, the electronic device can first calculate the difference between the interval timestamp of the cache interval and the first timestamp of the data packet, and then determine the size relationship between the difference and the interval width. If the difference is less than the interval width, it is considered that the current data packet belongs to this cache interval; otherwise, if the difference is greater than or equal to the interval width, it is considered that the current data packet does not belong to this cache interval. There can be one or more cache intervals in the used state.
[0061] If the electronic device determines that the current data packet does not belong to any of the cache intervals in the used state, that is, the difference between the first timestamp of the current data packet and the interval timestamps of all the cache intervals in the used state is greater than or equal to the interval width, then it is determined that the number of cache intervals in the current used state is less than the total number of cache intervals.
[0062] If it is determined that the number of cache intervals in the current used state is less than the total number of cache intervals, the electronic device can create a new cache interval and consider that the current data packet belongs to this new cache interval. At this time, the interval timestamp of this new cache interval can be the first timestamp of the current data packet, that is, the first timestamp of the first data packet entering the cache interval can be used as the interval timestamp of the cache interval.
[0063] It should be noted that using the first timestamp of the first data packet entering the cache interval as the interval timestamp of the cache interval can reduce the RTT calculation error.
[0064] For each data packet, after the sending end or the measuring device determines the cache interval to which the current data packet belongs, that is, it is considered that the current data packet enters the belonging cache interval, and the first sequence number of the current data packet belongs to the cache interval to which the data packet belongs, then store the first sequence number of the current data packet in the cache and associate the first sequence number of the current data packet with the cache interval to which the data packet belongs. That is, there is an association relationship between the first sequence number of the current data packet and the cache interval, and the cache interval corresponding to the first sequence number can be determined through this association relationship. For example Figure 4As shown, buffer ranges 1 to 10 include multiple serial numbers from the starting serial number to the ending serial number. After associating the first serial number of the data packet with the buffer range, sorting is performed according to the size of the first serial number. The starting serial number can be considered the smallest first serial number among all the first serial numbers belonging to the buffer range, and the ending serial number can be considered the largest first serial number among all the first serial numbers belonging to the buffer range. In addition, buffer ranges 1 to 10 also include a status field for identifying whether the buffer range is valid. For example, when the status field (valid) is equal to 1, it indicates that the buffer range is valid, and when it is equal to 0, it indicates that the buffer range is invalid.
[0065] It can be understood that at this time, instead of storing the first timestamp of the current data packet in the buffer, the interval timestamps of each buffer range are stored, and the interval timestamp of the buffer range to which the current data packet belongs is used to represent the timestamp of the current data packet.
[0066] Step S303: The electronic device obtains the second timestamp and the second serial number of the acknowledgment packet.
[0067] In some embodiments, when the electronic device is a sending device, when the sending device receives an acknowledgment packet (i.e., an Ack packet), it records the reception time of each acknowledgment packet, and thus obtains the second timestamp of each acknowledgment packet. That is, the second timestamp can refer to the time when the sending device receives the acknowledgment packet.
[0068] In other embodiments, when the electronic device is a measuring device, when the measuring device receives the acknowledgment packet sent by the receiving end, it records the reception time of each acknowledgment packet, and thus obtains the second timestamps of each acknowledgment packet. That is, the second timestamp can refer to the time when the measuring device receives the acknowledgment packet sent by the receiving end.
[0069] The second serial number refers to the packet serial number of the acknowledgment packet. Usually, after the receiving end receives a data packet, it uses the packet serial number of the data packet as the packet serial number of the acknowledgment packet. Therefore, the packet serial numbers of the data packet and the acknowledgment packet corresponding to this data packet are the same.
[0070] Step S304: If the electronic device finds the target first serial number in the buffer, it obtains the interval timestamp of the target buffer range that has been stored. The target first serial number is the same first serial number as the second serial number, and the target buffer range is the buffer range to which the data packet corresponding to the target first serial number belongs.
[0071] For each acknowledgment message, the electronic device determines whether a target first sequence number exists in the cache, that is, determines whether there is a first sequence number in the cache that is the same as the second sequence number of the current acknowledgment message; if the target first sequence number can be found in the cache, it is considered that the current acknowledgment message is the Ack message corresponding to the data message corresponding to the target first sequence number; further, according to the association relationship between the first sequence number and the cache interval, the cache interval to which the target first sequence number belongs is determined. The cache interval to which the target first sequence number belongs is the target cache interval; finally, according to the timestamps of the stored cache intervals, the interval timestamp of the target cache interval is obtained.
[0072] Step S305, the electronic device determines the round-trip delay value according to the interval timestamp of the target cache interval and the second timestamp.
[0073] In the embodiment of the present application, the interval timestamp of the target cache interval is used as the timestamp of the data message corresponding to the acknowledgment message. Therefore, RTT = the timestamp of the acknowledgment message - the timestamp of the target cache interval, that is, RTT = the second timestamp - the timestamp of the target cache interval.
[0074] For example, referring to Figure 5 FIG. shows a schematic diagram of calculating an RTT based on data messages and acknowledgment messages provided by an embodiment of the present application, which shows data messages 0 to 4, and acknowledgment messages 0, 1, 2, and 4.
[0075] As Figure 5 shown, the sequence number (seq) of data message 0 is 0, and the timestamp (timestamp, ts) is 0 ms; the sequence number of data message 1 is 1, and the timestamp is 4 ms; the sequence number of data message 2 is 2, and the timestamp is 8 ms; the sequence number of data message 3 is 3, and the timestamp is 12 ms; the sequence number of data message 4 is 4, and the timestamp is 16 ms.
[0076] The sequence number of acknowledgment message 0 is 0, and the timestamp is 3 ms; the sequence number of acknowledgment message 1 is 1, and the timestamp is 9 ms; the sequence number of acknowledgment message 2 is 2, and the timestamp is 10 ms; the sequence number of acknowledgment message 4 is 4, and the timestamp is 18 ms.
[0077] At this time, based on Figure 4 the cache interval shown, assuming that the interval width of the cache interval is 10 ms and the total number of cache intervals is 10. Each data message enters according to the following rules Figure 4The cache interval shown, and the rule is as follows: Determine whether the difference between the timestamp of the current data packet and the interval timestamp of the current cache interval is less than the interval width; if the difference is less than the interval width, the current data packet enters the current cache interval, that is, it is considered that the current data packet belongs to the current cache interval; if the difference is greater than or equal to the interval width, it is considered that the current data packet does not belong to the current cache interval, create a new cache interval as the new current cache interval, and consider that the current data packet belongs to the newly created cache interval, that is, the current data packet enters the new current cache interval.
[0078] In Figure 2A and Figure 2B the RTT measurement scenarios shown, the working process of the measurement device can be as follows:
[0079] When the measurement device receives data packet 0 sent by the sender, it records the reception time of data packet 0 and uses this reception time as the timestamp of data packet 0. At this time, since the current cache interval is cache interval 1, the status field (valid) of cache interval 1 = 1, and data packet 0 is the first data packet to enter cache interval 1, it is determined that data packet 0 belongs to cache interval 1, and the timestamp of data packet 0 is used as the interval timestamp of cache interval 1. That is, the interval timestamp of cache interval 1 is 0 ms. The starting sequence number of cache interval 1 is 0, that is, the sequence number of data packet 0 belongs to cache interval 1. Therefore, the measurement device stores the sequence number of data packet 0 in the cache and stores the interval timestamp of cache interval 1.
[0080] After the measurement device receives data packet 0, it sends data packet 0 to the receiver. In response to this data packet 0, the receiver generates acknowledgment packet 0 and sends this acknowledgment packet 0 to the receiver.
[0081] After the measurement device receives acknowledgment packet 0, it records the reception time of acknowledgment packet 0 and uses this reception time as the timestamp of acknowledgment packet 0. At this time, the sequence number of acknowledgment packet 0 is 0, and it is found from the cache that the sequence number 0 belongs to cache interval 1, so the RTT is calculated based on the interval timestamp of cache interval 1 and the timestamp of acknowledgment packet 0, that is, RTT0 = 3 ms - 0 ms = 3 ms.
[0082] After the measurement device receives acknowledgment packet 0, it receives data packet 1 sent by the sender. The measurement device records the reception time of data packet 1 and uses this reception time as the timestamp of data packet 1. At this time, the current cache interval is cache interval 1, and the difference between the timestamp of data packet 1 and the interval timestamp of cache interval 1 is 4 ms, which is less than 10 ms, so data packet 1 enters cache interval 1, and the sequence number of data packet 1 belongs to cache interval 1. Therefore, the measurement device stores the sequence number of data packet 1 in the cache, but does not store the timestamp of data packet 1.
[0083] After the measuring device receives data packet 1, it then receives data packet 2 sent by the sending end. The measuring device records the reception time of data packet 2 and uses this reception time as the timestamp of data packet 2. At this time, the current cache interval is cache interval 1. The difference between the timestamp of data packet 2 and the interval timestamp of cache interval 1 is 8 ms, which is less than 10 ms. Therefore, data packet 2 enters cache interval 1, and the sequence number of data packet 2 belongs to cache interval 1. Thus, the measuring device stores the sequence number of data packet 2 in the cache, but does not store the timestamp of data packet 2.
[0084] After the measuring device receives data packet 2, it then receives acknowledgment packet 1 returned by the receiving end. The measuring device records the reception time of acknowledgment packet 1 and uses this reception time as the timestamp of acknowledgment packet 1. At this time, the sequence number of acknowledgment packet 1 is 1. Looking up in the cache, it is found that sequence number 1 belongs to cache interval 1. Then, the RTT is calculated based on the interval timestamp of cache interval 1 and the timestamp of acknowledgment packet 1, that is, RTT1 = 9 ms - 0 ms = 9 ms.
[0085] After the measuring device receives acknowledgment packet 1, it then receives acknowledgment packet 2 returned by the receiving end. The measuring device records the reception time of acknowledgment packet 2 and uses this reception time as the timestamp of acknowledgment packet 2. At this time, the sequence number of acknowledgment packet 2 is 2. Looking up in the cache, it is found that sequence number 2 belongs to cache interval 1. Then, the RTT is calculated based on the interval timestamp of cache interval 1 and the timestamp of acknowledgment packet 2, that is, RTT2 = 10 ms - 0 ms = 10 ms.
[0086] After the measuring device receives acknowledgment packet 2, it then receives data packet 3 sent by the sending end. The measuring device records the reception time of data packet 3 and uses this reception time as the timestamp of data packet 3. At this time, the current cache interval is cache interval 1. The difference between the timestamp of data packet 3 and the interval timestamp of cache interval 1 is 12 ms, which is greater than 10 ms. Then, it can be determined that data packet 3 does not belong to cache interval 1. Therefore, a new cache interval (i.e., cache interval 2) is created, and cache interval 2 is used as the new current cache interval. Data packet 3 enters cache interval 2, and since data packet 3 is the first data packet to enter cache interval 2, the timestamp of data packet 3 is used as the interval timestamp of cache interval 2, that is, the interval timestamp of cache interval 2 is 12 ms. The sequence number of data packet 3 belongs to cache interval 2, that is, the starting sequence number of cache interval 2 is 3. Thus, the measuring device stores the sequence number of data packet 3 in the cache and also stores the interval timestamp of cache interval 2.
[0087] After receiving data packet 3, the measurement device received data packet 4 sent by the sender. The measurement device records the reception time of data packet 4 and uses this reception time as the timestamp of data packet 4. At this time, the current cache interval is cache interval 2. The difference between the timestamp of data packet 4 and the interval timestamp of cache interval 2 is 4 ms, which is less than 10 ms. Therefore, data packet 4 enters cache interval 2, and the sequence number of data packet 4 belongs to cache interval 2. Thus, the measurement device stores the sequence number of data packet 4 in the cache but does not store the timestamp of data packet 4.
[0088] After receiving data packet 4, the measurement device received acknowledgment packet 4 returned by the receiver. The measurement device records the reception time of acknowledgment packet 4 and uses this reception time as the timestamp of acknowledgment packet 4. At this time, the sequence number of acknowledgment packet 4 is 4. It is found from the cache that the sequence number 4 belongs to cache interval 2. Then, the RTT is calculated based on the interval timestamp of cache interval 2 and the timestamp of acknowledgment packet 4, that is, RTT4 = 18 ms - 12 ms = 6 ms.
[0089] In the above process, the measurement device did not receive the acknowledgment packet corresponding to data packet 3 but received acknowledgment packet 4 corresponding to data packet 4. In the embodiment of the present application, the RTT of data packet 3 can be calculated using acknowledgment packet 4. At this time, RTT3 = the timestamp of acknowledgment packet 4 - the interval timestamp of cache interval 2, that is, RTT3 = 18 - 12 = 6 ms.
[0090] After receiving acknowledgment packet 4, since the RTT values of all packets (i.e., data packet 0, data packet 1, and data packet 2) in cache interval 1 have been calculated, the status field (i.e., valid) of the cache interval can be set to 0 to set cache interval 1 to an invalid state.
[0091] Furthermore, to release storage resources in a timely manner, the sequence numbers and interval timestamps of cache interval 1 can be deleted, that is, the sequence numbers of data packet 0, data packet 1, and data packet 2, as well as the interval timestamps, are deleted from the cache.
[0092] That is to say, in some possible implementation manners, for each cache interval in the use state, if the electronic device has received all the acknowledgment packets corresponding to the data packets belonging to the cache interval, the cache interval, as well as the sequence numbers of the cache interval and the interval timestamp of the cache interval in the cache, can be deleted to timely delete the unused cache interval and the corresponding timestamps so as to release storage resources in a timely manner.
[0093] In the embodiments of the present application, by storing the interval timestamps of each cache interval, instead of caching the timestamp of each data packet, that is, without caching the timestamp of each data packet and without caching the timestamps of data packets one by one, the timestamp data that needs to be cached in the RTT calculation process is reduced, thereby reducing the storage resources consumed in the RTT calculation process.
[0094] The inventors found in further research that in the RTT calculation process, by using the interval timestamp of the cache interval to represent the timestamps of all data packets in the cache interval, although the timestamp data that needs to be cached in the RTT calculation process can be reduced, the RTT calculation accuracy will be reduced.
[0095] For example, taking Figure 5 data packet 2 and acknowledgment packet 2 shown as an example, if the RTT is calculated by caching the timestamp of each data packet, RTT2 = the timestamp of acknowledgment packet 2 - the timestamp of data packet 2, that is, RTT2 = 10 - 8 = 2ms. If the method provided by the embodiments of the present application is used for RTT calculation, RTT2 = the timestamp of acknowledgment packet 2 - the interval timestamp of cache interval 1, that is, RTT2 = 10 - 0 = 10ms. In this way, there will be an 8ms error in RTT.
[0096] It should be noted that although the RTT calculation method provided by the embodiments of the present application will reduce the RTT calculation accuracy to a certain extent, the RTT calculation accuracy is still within an acceptable range.
[0097] In the embodiments of the present application, the interval width of the cache interval can be adjusted to improve the RTT calculation accuracy while reducing the timestamp data that needs to be cached in the RTT calculation process.
[0098] The adjustment of the interval width can be divided into passive adjustment and active adjustment. Passive adjustment means that the electronic device receives a new interval width parameter from an external device and adjusts the interval width of the cache interval according to the new interval width parameter. For example, the original interval width of the cache interval is 10ms, and the user inputs a new interval width of 8ms for the cache interval to the electronic device through the external device, and the electronic device adjusts the interval width of the cache interval from 10ms to 8ms according to the new interval width of the cache interval.
[0099] It can be understood that the adjustment of the interval width can refer to increasing the interval width or decreasing the interval width.
[0100] Active adjustment means that the electronic device calculates a new interval width by itself and adjusts the interval width of the cache interval according to the new interval width.
[0101] Exemplarily, refer to Figure 6A schematic diagram of the interval width adjustment process provided by the embodiment of the present application is shown. The adjustment process may include the following steps:
[0102] Step S601: If the electronic device determines that the difference between the first timestamp of the current data packet and the interval timestamps of all the cache intervals in the used state is greater than the interval width, and the number of cache intervals in the used state is equal to the total number of cache intervals, then increase the interval width of the cache intervals.
[0103] It can be understood that when determining the cache interval to which the current data packet belongs, if the difference between the first timestamp of the current data packet and the interval timestamps of all the cache intervals in the used state is greater than the interval width, then a new cache interval needs to be created.
[0104] When creating a new cache interval, it is also necessary to be restricted by the total number of cache intervals, that is, the number of cache intervals in the used state should be less than or equal to the total number of cache intervals. For example, when the total number of cache intervals is 10.
[0105] If, when creating a new cache interval, the number of currently used cache intervals is equal to the total number of cache intervals, it is considered that all the cache intervals are full, indicating that the current RTT > the interval width of the cache interval * the total number of sampling intervals. At this time, it can be considered that the interval width of the cache interval is small, and the interval width of the cache interval needs to be expanded by x times.
[0106] In specific applications, x can be set according to the actual situation. For example, x can be equal to the total number of cache intervals, or equal to half of the total number of cache intervals.
[0107] For example, the interval width of the cache interval is 10 ms, and the total number of cache intervals is 10; the current cache interval is cache interval 10, and the interval timestamp of cache interval 10 is 92 ms. The measuring device newly receives a data packet, and the timestamp of this data packet is 103 ms; at this time, since the difference between the timestamp of the current data packet and the interval timestamp of the current cache interval is 11 ms, which is greater than 10 ms, it is considered that the current data packet does not belong to cache interval 10, and a new cache interval needs to be created. When creating a new cache interval, since the currently used cache intervals are 10, which is already equal to the total number of cache intervals, it is considered that the 10 cache intervals are full. At this time, the interval width of the cache interval can be expanded by 5 times or 10 times, that is, the adjusted interval width of the cache interval is 50 ms or 100 ms.
[0108] It can be understood that when the measurement device receives a data packet with a timestamp of 103 ms, buffer ranges 1 to 10 are all in use. The fact that buffer range 1 is in use means that there are unacknowledged data packet sequence numbers in buffer range 1, that is, the acknowledgment packet for the last data packet in buffer range 1 has not been received yet. Because if the acknowledgment packet for the last data packet in buffer range 1 has been received, it means that all the acknowledgment packets for the data packets in buffer range 1 have been received, and buffer range 1 can be deleted.
[0109] For the unacknowledged data packets in buffer range 1, if the current RTT is > 100 s, it can be considered that the current RTT value is very large. At this time, the width of the buffer range is 10 ms, but the RTT is greater than 100 ms, and the buffer range is full. Using the original width of the buffer range will increase the RTT calculation error. At this time, to reduce the RTT calculation error, the width of the buffer range can be increased, and the increased width can be used for RTT calculation.
[0110] It should be noted that since the RTT is large at this time, the error percentage brought by increasing the width of the buffer range is within an acceptable range.
[0111] And / or, in step S602, if the electronic device determines that the number of buffer ranges in use is less than a preset threshold during a continuous preset number of data packets or a continuous preset time period, the width of the buffer range is reduced, and the preset threshold is less than the total number of buffer ranges.
[0112] In addition to increasing the width of the buffer range according to the actual situation, the electronic device can also reduce the width of the buffer range.
[0113] The preset number and the preset time period can be set according to the actual situation. Usually, the preset threshold is less than the total number of buffer ranges, so that the number of buffer ranges in use is much less than the total number of buffer ranges.
[0114] When, within a period of time, the number of buffer ranges in use is much less than the total number of buffer ranges, it means that the width of the buffer range is large, and the current RTT is much smaller than the width of the buffer range, which will cause a large RTT calculation error. At this time, to reduce the RTT calculation error, the width of the buffer range can be reduced. For example, the width of the buffer range can be reduced to the ratio between the width of the buffer range and the total number of buffer ranges, that is, the reduced width of the buffer range is the ratio between the width of the buffer range and the total number of buffer ranges. Suppose the original width of the buffer range is 10 ms and the total number of buffer ranges is 10, the reduced width of the buffer range is 10 / 10 = 1 ms.
[0115] For example, the interval width T of the buffer interval is 10 ms, and the total number N of buffer intervals is 10. Suppose that within a certain period of time, the measurement device determines that for M consecutive data packets or within a certain period of time, the number of buffer intervals in the used state is only K (K << N). Then it is considered that the current RTT value is very small, much smaller than the current interval width, so the interval width of the buffer interval is reduced. The values of M and K can be set according to the actual situation.
[0116] For example, the measurement device receives a data packet every 1 microsecond, but the interval width is 10 ms. Therefore, when determining the buffer interval into which each data packet enters according to the above rules, 100 consecutive data packets all enter buffer interval 1. That is, within the time of 100 consecutive data packets, only buffer interval 1 is in the used state, or it can be said that within a certain period of time, only one buffer interval has data packets. In this case, the RTT of the data packet is very small, but the interval width is relatively large, resulting in a large RTT calculation error. At this time, the interval width of the buffer interval is reduced from 10 ms to 1 ms.
[0117] To better introduce the interval adjustment scheme provided by the embodiments of the present application, the following will be described in conjunction with Figure 7 the schematic diagram of the interval adjustment process provided by the embodiments of the present application shown in
[0118] As Figure 7 shown, the total number of buffer intervals is 10, the interval width of the buffer interval is 10 ms, and the status fields of the current buffer intervals 1 to 9 are all 1, that is, buffer intervals 1 to 9 are all in the used state. The status field of buffer interval 10 is 0.
[0119] In addition, the timestamp of data packet n is ams, and the sequence number is n; the timestamp of data packet n + 1 is a + 4 ms, and the sequence number is n + 1; the timestamp of data packet n + 2 is a + 8 ms, and the sequence number is n + 2; the timestamp of data packet n + 3 is a + 12 ms, and the sequence number is n + 3; the timestamp of data packet n + 4 is a + 16 ms, and the sequence number is n + 4.
[0120] In Figure 2A and Figure 2B the RTT measurement scenario shown, the working process of the measurement device can be as follows:
[0121] When the measurement device receives the data packet n sent by the sending end, it records the reception time of the data packet n and uses this reception time as the timestamp of the data packet n. At this time, since the current buffer interval is buffer interval 10 and the data packet n is the first data packet to enter buffer interval 10, it is determined that the data packet n belongs to buffer interval 10, and the timestamp of the data packet n is used as the interval timestamp of buffer interval 10. That is, the interval timestamp of buffer interval 10 is ams. The starting sequence number of buffer interval 10 is n, that is, the sequence number of the data packet n belongs to buffer interval 10. The measurement device stores the sequence number of the data packet n in the buffer and stores the interval timestamp of buffer interval 10.
[0122] When the measurement device receives the data packet n + 1 sent by the sending end, it records the reception time of the data packet n + 1 and uses this reception time as the timestamp of the data packet n + 1. At this time, the current buffer interval is buffer interval 10, and the difference between the timestamp of the data packet n + 1 and the interval timestamp of buffer interval 10 is 4ms, which is less than 10ms. Therefore, the data packet n + 1 enters buffer interval 10, and the sequence number of the data packet n + 1 belongs to buffer interval 10. Therefore, the measurement device stores the sequence number of the data packet n + 1 in the buffer but does not store the timestamp of the data packet n + 1.
[0123] When the measurement device receives the data packet n + 2 sent by the sending end, it records the reception time of the data packet n + 2 and uses this reception time as the timestamp of the data packet n + 2. At this time, the current buffer interval is buffer interval 10, and the difference between the timestamp of the data packet n + 2 and the interval timestamp of buffer interval 10 is 8ms, which is less than 10ms. Therefore, the data packet n + 2 enters buffer interval 10, and the sequence number of the data packet n + 2 belongs to buffer interval 10. Therefore, the measurement device stores the sequence number of the data packet n + 2 in the buffer but does not store the timestamp of the data packet n + 2.
[0124] When the measurement device receives the data packet n + 3 sent by the sending end, it records the reception time of the data packet n + 3 and uses this reception time as the timestamp of the data packet n + 3. At this time, the current buffer interval is buffer interval 10, and the difference between the timestamp of the data packet n + 3 and the interval timestamp of buffer interval 10 is 12ms, which is greater than 10ms, and a new buffer interval needs to be created. However, at this time, the number of buffer intervals has reached 10, that is, the buffer interval is full.
[0125] In this case, the measuring device automatically adjusts the interval width of the buffer interval, and creates a new buffer interval after adjusting the interval width. Specifically, the interval width of the buffer interval is adjusted to 100 ms, and then the existing buffer intervals 1 to 10 are merged into a new buffer interval 1. The starting sequence number of the new buffer interval 1 is the starting sequence number of the original buffer interval 1, and the interval timestamp is the timestamp of the original buffer interval 1. Then, a new buffer interval 2 is created, and the interval width of the new buffer interval 2 is 100 ms. At this time, if the current buffer interval is the new buffer interval 2, and the data packet n + 3 is the first data packet to enter the new buffer interval 2, it is determined that the data packet n + 3 belongs to the new buffer interval 2, and the timestamp of the data packet n + 3 is used as the interval timestamp of the new buffer interval 2. That is, the interval timestamp of the new buffer interval 2 is a + 12 ms. The starting sequence number of the new buffer interval 2 is n + 3, that is, the sequence number of the data packet n + 3 belongs to the new buffer interval 2. The measuring device stores the sequence number of the data packet n + 3 in the buffer and stores the interval timestamp of the new buffer interval 2.
[0126] After the measuring device automatically adjusts the interval width and receives the data packet n + 4 sent by the sending end, it records the reception time of the data packet n + 4 and uses this reception time as the timestamp of the data packet n + 4. At this time, the current buffer interval is the new buffer interval 2, and the difference between the timestamp of the data packet n + 4 and the interval timestamp of the new buffer interval 2 is 4 ms, which is less than 100 ms. Therefore, the data packet n + 4 enters the new buffer interval 2, and the sequence number of the data packet n + 4 belongs to the new buffer interval 2. Thus, the measuring device stores the sequence number of the data packet n + 4 in the buffer, but does not store the timestamp of the data packet n + 4.
[0127] It should be noted that Figure 7 the status field of the buffer interval 10 can also be 1. That is to say, the interval width can be expanded when the data packet can still enter the buffer interval 10. For example, when the data packets n + 2 and n + 1, the data packet can still enter the buffer interval 10, and at this time the interval width is expanded; it can also be expanded when the data packet cannot enter the buffer interval 10. For example, when the data packets n + 3 and n + 4, the data packet can no longer enter the buffer interval, and at this time the interval width is expanded.
[0128] For the buffer interval with the status field of 0, the buffer interval can be actively deleted, or it can not be actively deleted, but can be directly overwritten in the subsequent process.
[0129] In the embodiments of the present application, the interval width of the cache interval can vary dynamically according to the real-time status of the traffic, which can adapt to different traffic and improve the RTT calculation accuracy. In addition, automatically adjusting the cache interval can also compensate for the error caused by using the interval timestamp of the cache interval to replace the timestamp of each data packet.
[0130] For example, the interval width of the cache interval is 10 ms. The measuring device receives a data packet at 9 ms, that is, the reception time of the data packet is 9 ms, so the timestamp of the data packet is 9 ms. The data packet enters cache interval 1, and the interval timestamp of cache interval 1 is 0 ms.
[0131] The measuring device receives the acknowledgment packet of the data packet and determines that the timestamp of the acknowledgment packet is 20 ms.
[0132] If the RTT is calculated according to the original timestamp of the packet, RTT = 20 - 11 = 9 ms.
[0133] If the RTT is calculated according to the interval timestamp and the timestamp of the acknowledgment packet, RTT = 20 - 0 = 20 ms.
[0134] It can be seen that compared with calculating the RTT using the original timestamp of the packet, calculating the RTT using the interval timestamp will introduce an RTT calculation error of 20 - 11 = 9 ms. That is, although the RTT calculation scheme of the embodiments of the present application can reduce the storage resource consumption in the RTT calculation process, it will introduce a certain RTT calculation error.
[0135] If the scheme of automatically adjusting the interval width provided by the embodiments of the present application is adopted, assume that at a certain moment, the interval width of the cache interval is adjusted from 10 ms to 5 ms. After the interval width is adjusted, the interval width of each cache interval is 5 ms, and the data packet with a timestamp of 9 ms falls into cache interval 2. Assume that the interval timestamp of cache interval 2 is 6 ms. At this time, when calculating the RTT according to the interval timestamp and the timestamp of the acknowledgment packet, RTT = 20 - 6 = 14 ms.
[0136] It can be seen that compared with calculating the RTT using the original timestamp of the packet, the RTT calculation error after the interval width is adjusted is 14 - 9 = 5 ms.
[0137] By comparison, it can be known that the RTT calculation error before the interval width is adjusted is 9 ms, and the RTT calculation error after the interval width is adjusted is 5 ms, reducing the RTT calculation error by 4 ms, thereby improving the RTT calculation accuracy and compensating for the error caused by using the interval timestamp of the cache interval to replace the timestamp of each data packet.
[0138] It can be understood that by continuously increasing or decreasing the interval width through the interval width dynamic adjustment solution of the embodiments of the present application, the interval width will ultimately be within a reasonable range.
[0139] To better introduce the technical solutions provided by the embodiments of the present application, the following will be described in conjunction with Figure 8A and Figure 8B for illustration. Figure 8A FIG. is a schematic diagram of the RTT calculation scenario provided by the embodiments of the present application, Figure 8B and FIG. is a schematic diagram of the working process of the measurement device provided by the embodiments of the present application.
[0140] As Figure 8A shown, this scenario includes a server 81, a measurement device 82, and a client 83. The measurement device 82 can be, for example, a switch device.
[0141] The server 81 and the client 83 transmit data packets and acknowledgment packets. The measurement device 82 located on the transmission path between the server 81 and the client 83 can receive the data packets and acknowledgment packets. When the measurement device 82 receives a packet, it works according to the Figure 8B logic shown. As Figure 8B shown, this process can include the following steps:
[0142] Step 1: Determine whether the received packet is an acknowledgment packet or a data packet. If it is a data packet, go to Step 2; if it is an acknowledgment packet, go to Step 8.
[0143] Step 2: Determine whether the sequence number of the current packet belongs to the current cache interval. If it is, go to Step 3; if not, go to Step 4.
[0144] Step 3: Represent the timestamp of the packet with the interval timestamp of the current cache interval.
[0145] Step 4: Determine whether all cache intervals are in use, that is, determine whether the current cache interval of the device is full. If it is, go to Step 6; if not, go to Step 5.
[0146] Step 5: Create a new cache interval and then return to Step 3.
[0147] Step 6: Determine whether the device supports interval width adjustment. If it does, go to Step 7; if not, go to Step 13.
[0148] Step 7: Adjust the interval width of the cache interval and then return to Step 5.
[0149] Step 8: Determine whether the data packet corresponding to the acknowledgment packet is in a certain cache interval. If it is, go to Step 9; if not, go to Step 13.
[0150] Step 9: Calculate the RTT using the interval timestamp of this cache interval.
[0151] Step 10: Determine whether the number of cache intervals in the idle state is greater than the threshold, that is, determine whether only a small number of cache intervals are in use and most cache intervals are in the idle state. If not, proceed to Step 13; if so, proceed to Step 11.
[0152] Step 11: Determine whether the device supports interval width adjustment. If so, proceed to Step 12; if not, proceed to Step 13.
[0153] Step 12: Adjust the interval width of the cache interval.
[0154] Step 13: End the process.
[0155] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
[0156] Next, the round-trip delay determination device provided by the embodiments of the present application will be introduced.
[0157] Figure 9 is a schematic structural diagram of the round-trip delay determination device provided by the embodiments of the present application. The round-trip delay determination device 900 can be deployed in the electronic device (such as the sending device or the measurement device) in the foregoing embodiments. Refer to Figure 9 The round-trip delay determination device 900 may include: a first acquisition module 901, a storage module 902, a second acquisition module 903, and an RTT calculation module 904.
[0158] Among them, the first acquisition module 901 is used to execute step S301 in the foregoing embodiments; the storage module 902 is used to execute step S302 in the foregoing embodiments; the second acquisition module 903 is used to execute step S303 in the foregoing embodiments; the RTT calculation module 904 is used to execute step S304 and step S305 in the foregoing embodiments.
[0159] Optionally, the interval timestamp is the first timestamp of the data packet that first enters the cache interval.
[0160] Optionally, the storage module 902 is specifically configured to: for each cache interval in the used state, if the difference between the first timestamp and the interval timestamp of the cache interval is less than the interval width, determine that the data packet belongs to the cache interval; if the difference between the first timestamp and the interval timestamp of the cache interval is greater than or equal to the interval width, determine that the data packet does not belong to the cache interval.
[0161] Optionally, the storage module 902 is further configured to: if the difference between the first timestamp of the current data packet and the interval timestamps of all the cache intervals in the used state is greater than or equal to the interval width, and the number of cache intervals in the used state is less than the total number of cache intervals, create a new cache interval, and determine that the data packet belongs to the new cache interval, where the interval timestamp of the new cache interval is the first timestamp of the data packet.
[0162] Optionally, the storage module 902 is further configured to: for each cache interval in the used state, if all the acknowledgment packets corresponding to the data packets belonging to the cache interval have been received, delete the cache interval and the interval timestamp of the cache interval.
[0163] Optionally, the first timestamp of the data packet is the time when the sending end sends the data packet, and the second timestamp is the time when the sending end receives the acknowledgment packet;
[0164] Alternatively, the first timestamp of the data packet is the time when the measuring device receives the data packet, and the second timestamp is the time when the measuring device receives the acknowledgment packet.
[0165] Optionally, the device further includes an interval width adjustment module 905, and the interval width adjustment module is configured to execute step S601 and / or step S602 in the foregoing embodiment.
[0166] Optionally, the reduced interval width is the ratio between the interval width and the total number of cache intervals.
[0167] It should be noted that the division of modules in the various round-trip delay determination devices provided in the foregoing embodiments is illustrative, and is only a logical function division. In actual implementation, there may be other division methods. In addition, in each embodiment of the present application, the various functional modules may be integrated in one processor, may also exist separately physically, or two or more modules may be integrated into one module. The above integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0168] When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions to enable a computer device or a processor to execute all or part of the steps of the method in the various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.
[0169] The above round-trip delay determination device has the function of implementing the round-trip delay determination method of the above electronic device. This function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above function, and the module can be software and / or hardware.
[0170] In addition, the round-trip delay determination device provided in the above embodiment and the embodiment of the round-trip delay determination method belong to the same concept. For its specific functions and the technical effects brought, the specific implementation process can be seen in the method embodiment, and will not be elaborated here.
[0171] Figure 10 It is a schematic structural diagram of the electronic device provided in the embodiments of the present application. As Figure 10 shown, the electronic device includes: at least one processor 1001 (only one is shown in the figure), a memory 1002, a computer program 1003 stored in the memory 1002 and executable on the at least one processor 1001, and a communication module 1004. When the processor 1001 executes the computer program 1003, it implements the steps in the above various method embodiments. For example, when executing Figure 3 or Figure 6 the specific steps of the method embodiments.
[0172] The electronic device includes but is not limited to the processor 1001 and the memory 1002. Those skilled in the art can understand that Figure 10 is only an example of the electronic device and does not constitute a limitation on the electronic device. It may include more or fewer components than shown in the figure, or combine some components, or different components. For example, it may also include input / output devices, network access devices, etc.
[0173] The so-called processor 1001 may be a Central Processing Unit (CPU), and the processor 1001 may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), 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.
[0174] In some embodiments, the memory 1002 may be an internal storage unit of the electronic device, such as the hard disk or memory of the electronic device. In other embodiments, the memory 1002 may also be an external storage device of the electronic device, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. equipped on the electronic device. Further, the memory 1002 may also include both the internal storage unit and the external storage device of the electronic device. The memory 1002 is used to store an operating system, application programs, a BootLoader, data, and other programs, such as the program code of the computer program, etc. The memory 1002 may also be used to temporarily store data that has been output or will be output.
[0175] The communication module 1004 can be used for receiving and sending data. For example, when the electronic device is a sending-end device, data packets and acknowledgment packets are sent through the communication module 1004. When the electronic device is a measuring device, data packets and acknowledgment packets can be received through the communication module 1004, and the data packets are forwarded to the receiving end and the acknowledgment packets are forwarded to the sending end.
[0176] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of the functional units and modules are only for the convenience of mutual distinction and do not limit the protection scope of this application. The specific working processes of the units and modules in the above system can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated here.
[0177] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, to implement all or part of the processes in the above method embodiments of this application, a computer program can be used to instruct the relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the photographing device / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disc, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable medium cannot be an electrical carrier signal and a telecommunication signal.
[0178] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, or by a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0179] In the embodiments provided in this application, it should be understood that the disclosed devices, electronic devices, and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling, direct coupling, or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the devices or units can be in electrical, mechanical, or other forms.
[0180] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0181] The electronic device provided in the embodiments of this application may include 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 method in any one of the above method embodiments.
[0182] The embodiments of this application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by the processor, it can implement the steps in the above various method embodiments.
[0183] The embodiments of this application provide a computer program product. When the computer program product runs on an electronic device, it causes the electronic device to execute and implement the steps in the above various method embodiments.
[0184] The embodiments of this application also provide a chip system. The chip system includes a processor. The processor is coupled to the memory. The processor executes the computer program stored in the memory to implement the method described in the above various method embodiments. The chip system can be a single chip or a chip module composed of multiple chips.
[0185] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For parts not detailed or recorded in a certain embodiment, reference may be made to the relevant descriptions of other embodiments. It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application. In addition, in the description of the specification and the appended claims of the present application, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first", "second", "third", "fourth" may explicitly or implicitly include one or more of such features. In addition, it should be understood that at least one involved in the embodiments of the present application includes one or more; among them, multiple means greater than or equal to two. In the embodiments of the present application, "and / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article generally represents an "or" relationship between the associated objects before and after.
[0186] The reference to "one embodiment" or "some embodiments" etc. described in the specification of the present application means that a specific feature, structure or characteristic described in combination with the embodiment is included in one or more embodiments of the present application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments" etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
[0187] Finally, it should be noted that the above are only specific implementation manners of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method for determining round-trip delay, characterized in that, the method includes: Obtaining the first timestamp and the first sequence number of each data packet; For each of the data packets, determining the cache interval to which the data packet belongs according to the first timestamp and the interval width of the cache interval, and storing the first sequence number in the cache; wherein, each cache interval corresponds to an interval timestamp, and the interval timestamp is used to represent the timestamp of the data packets belonging to the cache interval; Obtaining the second timestamp and the second sequence number of the acknowledgment packet; If the target first sequence number is found in the cache, obtaining the interval timestamp of the target cache interval that has been stored, where the target first sequence number is the same first sequence number as the second sequence number, and the target cache interval is the cache interval to which the data packet corresponding to the target first sequence number belongs; Determining the round-trip delay value according to the interval timestamp of the target cache interval and the second timestamp.
2. The method according to claim 1, characterized in that, the interval timestamp is the first timestamp of the first data packet entering the cache interval.
3. The method according to claim 1, characterized in that, Determining the cache interval to which the data packet belongs according to the first timestamp and the interval width of the cache interval, includes: For each cache interval in the used state, if the difference between the first timestamp and the interval timestamp of the cache interval is less than the interval width, determining that the data packet belongs to the cache interval; if the difference between the first timestamp and the interval timestamp of the cache interval is greater than or equal to the interval width, determining that the data packet does not belong to the cache interval.
4. The method according to claim 3, characterized in that, the method further includes: If the difference between the first timestamp of the current data packet and the interval timestamps of all the cache intervals in the used state is greater than or equal to the interval width, and the number of cache intervals in the used state is less than the total number of cache intervals, creating a new cache interval, and determining that the data packet belongs to the new cache interval, and the interval timestamp of the new cache interval is the first timestamp of the data packet.
5. The method according to claim 3, characterized in that, the method further includes: For each cache interval in the used state, if all the acknowledgment packets corresponding to the data packets belonging to the cache interval have been received, deleting the cache interval and the interval timestamp of the cache interval.
6. The method according to claim 1, characterized in that, the first timestamp of the data packet is the time when the sending end sends the data packet, and the second timestamp is the time when the sending end receives the acknowledgment packet; Or, the first timestamp of the data packet is the time when the measuring device receives the data packet, and the second timestamp is the time when the measuring device receives the acknowledgment packet.
7. The method according to any one of claims 1 to 6, characterized in that, the method further includes: If the difference between the first timestamp of the current data packet and the interval timestamps of all the cache intervals in the used state is greater than or equal to the interval width, and the number of cache intervals in the used state is equal to the total number of cache intervals, then increase the interval width of the cache interval; and / or, if the number of cache intervals in the used state is less than a preset threshold within a continuous preset number of data packets or within a continuous preset time period, then reduce the interval width of the cache interval, where the preset threshold is less than the total number of cache intervals.
8. The method according to claim 7, wherein, the reduced interval width is the ratio between the interval width and the total number of cache intervals.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein, when the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
10. A computer-readable storage medium storing a computer program, wherein, when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.