Method and device for setting timeout time of short connection based on connectionless transport protocol
By using the historical round trip time factor and real-time update method in the historical connection information table in the application layer protocol of the connectionless transmission protocol, the problem of inaccurate time estimation in scenarios with large short connection jitter is solved, and the accuracy of timeout retransmission and the utilization efficiency of transmission bandwidth are improved.
Patent Information
- Application Number
- CN202510324336.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-06-03
AI Technical Summary
In scenarios with large short connection jitter, the existing timeout retransmission mechanism relies on RTT estimation, resulting in high or low estimation of timeout time, affecting bandwidth and retransmission efficiency.
When initialized in the application layer protocol without connection transmission protocol, the timeout time is set using the historical round trip time factor in the historical connection information table, and the round trip time factor is updated in real time during message reception, correcting the historical data so that other connections can use the latest round trip time factor.
Improve the accuracy of timeout retransmission, reduce pseudo-retransmission and delay, and improve the efficiency of transmission bandwidth utilization.
Smart Images

Figure CN120090772A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and in particular, to a method and apparatus for setting a timeout period for a short connection based on a connectionless transport protocol. Background Art
[0002] A connectionless transport protocol, such as UDP (User Datagram Protocol), is a connectionless communication protocol located at the transport layer of the OSI (Open Systems Interconnection). Different from TCP (Transmission Control Protocol), the connectionless transport protocol cannot provide guarantees of reliability, data order, and flow control. The bare connectionless transport protocol is suitable for scenarios where the transmission rate needs to be guaranteed and partial data loss can be tolerated, or for customizing a reliable transport protocol different from TCP at the application layer for transmission through the connectionless transport protocol. Based on the connectionless transport protocol, many reliable transport protocols at the user layer are constructed, such as QUIC (Quick UDP Internet Connections), KCP (Kairos CProtocol), etc. The above reliable transport protocols are provided with their own timeout retransmission mechanisms.
[0003] However, the existing timeout retransmission mechanism depends on RTT (Round-trip time). After being biased based on the RTT, it is used as the RTO (Retransmission Timeout) or PTO (Probe Timeout). When a certain data packet does not receive an acknowledgment message from the peer after exceeding the RTO or PTO time after being sent, retransmission is required. The estimation of the RTT is very important in the timeout retransmission mechanism. Too low will result in too many false retransmissions, and too high will result in too late retransmission, increasing the time that the receiving window of the peer is blocked by the unreceived packet, thereby dragging down the transmission bandwidth. Especially in scenarios with large jitter in short connections, since the communication rounds of short connections are relatively short, historical RTT information outside the connection cannot be referred to for estimation. When the actual RTT jitters greatly, it is easy to overestimate or underestimate the timeout time, resulting in reduced bandwidth or false retransmissions, affecting the timeout retransmission. Summary of the Invention
[0004] In view of the above problems, embodiments of this application are proposed to provide a method and apparatus for setting a timeout period for a short connection based on a connectionless transport protocol that overcome the above problems or at least partially solve the above problems.
[0005] According to the first aspect of the embodiments of the present application, a method for setting the timeout of a short connection based on a connectionless transport protocol is provided, which includes:
[0006] Initialize the application layer protocol of the connectionless transport protocol, create a session instance, and look up the historical connection information table according to the connection information to obtain the historical round-trip time factor of the connection information, and assign it to the round-trip time factor of the current connection;
[0007] According to the received first packet, determine the round-trip time, update the round-trip time factor of the current connection to determine the timeout time, and update the historical connection information table according to the updated round-trip time factor;
[0008] When the session of the application layer protocol of the connectionless transport protocol ends, update the real-time round-trip time factor of the current connection to the historical connection information table and release the session resources.
[0009] Optionally, the method further includes:
[0010] Pre-build a historical connection information table that is global in memory; the historical connection information table includes connection information and historical round-trip time factors; the connection information is the index of the historical connection information table; the connection information includes the source address and the destination address; the historical connection information table is built based on the least recently used linked list.
[0011] Optionally, looking up the historical connection information table according to the connection information and obtaining the historical round-trip time factor of the connection information further includes:
[0012] Obtain the connection information based on the connectionless transport protocol;
[0013] Judge whether the connection information exists in the historical connection information table;
[0014] If so, obtain the historical round-trip time factor corresponding to the connection information.
[0015] Optionally, if the connection information does not exist in the historical connection information table, the method further includes:
[0016] Assign the round-trip time factor of the current connection to a preset initial value.
[0017] Optionally, according to the received first packet, determining the round-trip time, updating the round-trip time factor of the current connection to determine the timeout time, and updating the historical connection information table according to the updated round-trip time factor further includes:
[0018] Based on the connectionless transport protocol packet received by the receive function, judge whether it is the first packet;
[0019] If so, calculate the round-trip time according to the difference between the reflection timestamp and the current timestamp of the first packet;
[0020] Calculate and update the round-trip time factor for this connection based on the round-trip time, and determine the timeout period according to the updated round-trip time factor;
[0021] Update the historical round-trip time factor corresponding to the connection information stored in the historical connection information table according to the updated round-trip time factor, so that other sessions of the connection information can obtain the updated historical round-trip time factor.
[0022] Optionally, when the application layer protocol session of the connectionless transport protocol ends, update the real-time round-trip time factor of this connection to the historical connection information table. Releasing session resources further includes:
[0023] Determine whether the application layer protocol of the connectionless transport protocol has ended its session;
[0024] If so, obtain the real-time round-trip time factor of this connection, and update the historical round-trip time factor corresponding to the connection information stored in the historical connection information table according to the real-time round-trip time factor;
[0025] End the session based on the destruction function to release session resources.
[0026] Optionally, the round-trip time factor includes the round-trip time estimate and the standard deviation of the round-trip offset time;
[0027] Calculating and updating the round-trip time factor for this connection based on the round-trip time, and determining the timeout period according to the updated round-trip time factor further includes:
[0028] Determine whether the round-trip time estimate is a preset initial value;
[0029] If so, update the round-trip time estimate and the standard deviation of the round-trip offset time according to the first update rule;
[0030] If not, update the round-trip time estimate and the standard deviation of the round-trip offset time according to the second update rule. Determine the timeout period according to the updated round-trip time estimate and the standard deviation of the round-trip offset time;
[0031] Updating the historical round-trip time factor corresponding to the connection information stored in the historical connection information table according to the updated round-trip time factor, so that other sessions of the connection information can obtain the updated historical round-trip time factor further includes:
[0032] Obtain the historical round-trip time factor corresponding to the connection information stored in the historical connection information table;
[0033] Based on the historical round-trip time factor and the updated round-trip time factor, calculate a new historical round-trip time factor based on weights, and update the historical round-trip time factor stored in the historical connection information table according to the new historical round-trip time factor.
[0034] According to the second aspect of the embodiments of the present application, there is provided a timeout setting device for short connections based on a connectionless transport protocol, which includes:
[0035] An initialization module, adapted to initialize the application layer protocol of the connectionless transport protocol, create a session instance, look up the historical connection information table according to the connection information, obtain the historical round-trip time factor of the connection information, and assign it to the round-trip time factor of the current connection;
[0036] A packet receiving module, adapted to determine the round-trip time according to the received first packet, update the round-trip time factor of the current connection to determine the timeout time, and update the historical connection information table according to the updated round-trip time factor;
[0037] A session end module, adapted to update the real-time round-trip time factor of the current connection to the historical connection information table and release the session resources when the application layer protocol session of the connectionless transport protocol ends.
[0038] According to the third aspect of the embodiments of the present application, there is provided a computing device, including: a processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface complete communication with each other through the communication bus;
[0039] The memory is used to store at least one executable instruction, and the executable instruction causes the processor to perform the operations corresponding to the above-mentioned timeout setting method for short connections based on a connectionless transport protocol.
[0040] According to the fourth aspect of the embodiments of the present application, there is provided a computer storage medium, and at least one executable instruction is stored in the storage medium, and the executable instruction causes the processor to perform the operations corresponding to the above-mentioned timeout setting method for short connections based on a connectionless transport protocol.
[0041] According to the fifth aspect of the embodiments of the present application, there is provided a computer program product, including at least one executable instruction, and the executable instruction causes the processor to perform the operations corresponding to the above-mentioned timeout setting method for short connections based on a connectionless transport protocol.
[0042] The timeout time setting method and device for short connections based on the connectionless transport protocol provided by the present application, when initializing the establishment of a connection, query and obtain the historical round-trip time factor in the historical connection information table with the connection information as the granularity. The current connection directly applies the historical round-trip time factor without using a preset initial value for estimation, improving the accuracy of timeout retransmission in the initialization stage. During the process of receiving a message, after determining the round-trip time according to the message, the round-trip time factor of the current connection is updated in real time, and the historical round-trip time factor in the historical connection information table is updated based on the updated round-trip time factor, realizing the correction of historical data based on the current actual connection situation for other connections to use the latest round-trip time factor, improving the accuracy of estimating timeout retransmission. At the end of the session, the real-time round-trip time factor of the current connection is updated to the historical connection information table, providing the historical round-trip time factor as data support for subsequent connections.
[0043] The above description is only an overview of the technical solution of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present application more obvious and understandable, the specific embodiments of the present application are specifically exemplified below. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present application. And throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0045] Figure 1 The flowchart of the timeout time setting method for short connections based on the connectionless transport protocol according to an embodiment of the present application is shown;
[0046] Figure 2 The flowchart of the timeout time setting method for short connections based on the connectionless transport protocol according to another embodiment of the present application is shown;
[0047] Figure 3 The structural schematic diagram of the timeout time setting device for short connections based on the connectionless transport protocol according to an embodiment of the present application is shown;
[0048] Figure 4 The structural schematic diagram of a computing device according to an embodiment of the present application is shown. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0049] Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present application can be more thoroughly understood and the scope of the present application can be fully conveyed to those skilled in the art.
[0050] First, the noun terms related to one or more embodiments of the present application are explained.
[0051] UDP: User Datagram Protocol, a connectionless communication protocol located in the transport layer of OSI (Open Systems Interconnection). UDP does not provide guarantees for reliability, data order, and flow control.
[0052] TCP: Transmission Control Protocol, a streaming transport protocol located in the transport layer of OSI that guarantees reliable transmission. Its reliability is ensured through designs such as connection establishment handshakes, sequence-numbered data packets, and timeout retransmission mechanisms.
[0053] Reliable transport protocol: A protocol that ensures data can be reliably transmitted from the sender to the receiver through mechanisms such as acknowledgment responses, timeout retransmissions, and sequence control during data transmission. Compared with UDP, reliable transport protocols usually need to add additional control information to ensure data integrity and order, such as the TCP protocol.
[0054] QUIC: Quick UDP Internet Connections, an HTTP transport protocol based on UDP. It combines the reliability features of TCP and the security of TLS (Transport Layer Security), and has characteristics such as fast connection establishment, low latency, multiplexing, data retransmission, and congestion control, and is widely used in efficient and secure communication scenarios for network transmission.
[0055] KCP: Kairos C Protocol, a reliable transport protocol based on UDP, which has characteristics such as low latency and configurable flow control compared with TCP.
[0056] LRU: A cache eviction algorithm used to determine which data should be removed to make room for new data when the cache space is limited, and preferentially evict the least recently used cache data, that is, assuming that data that has not been used recently has a lower probability of being used in the future.
[0057] RTT: Round-trip time, the time it takes from when the sender starts sending data until the sender receives the acknowledgment message from the receiver. RTT is one of the important metrics for measuring network transmission performance and can reflect the speed and stability of data transmission in the network. Generally, the shorter the RTT, the faster the network transmission speed, and vice versa.
[0058] RTO: Retransmission Timeout, which refers to the time the sender waits for the receiver to acknowledge the data packet. If no acknowledgment is received within this time, the sender will retransmit the data packet.
[0059] PTO: Probe Timeout. When acknowledgments for some data packets are not received within the expected time, the probe timeout mechanism is initiated to trigger retransmission or use unsent new data packets as probe packets for timeout detection.
[0060] Figure 1 The flowchart of the timeout setting method for a short connection based on a connectionless transport protocol according to an embodiment of the present application is shown, as Figure 1 shown, the method includes the following steps:
[0061] Step S101, initialize the application layer protocol of the connectionless transport protocol, create a session instance, and look up the historical connection information table according to the connection information to obtain the historical round-trip time factor of the connection information, and assign it to the round-trip time factor of the current connection.
[0062] For the connectionless transport protocol, since it does not have a timeout retransmission mechanism itself, an application layer protocol needs to be built on top of the connectionless transport protocol to implement the timeout retransmission function. This embodiment can be applied to various application layer protocols of the connectionless transport protocol, such as application layer protocols of connectionless transport protocols like KCP and QUIC, which are not limited here.
[0063] For the short connection scenario, a new connection needs to be established and disconnected for each communication. In a short connection, after each data transmission is completed, the connection is closed, and a new connection needs to be established for the next communication. The communication rounds of short connections are relatively short. When the RTT jitters greatly, it is easy to cause problems such as overestimation or underestimation of subsequent timeout times (such as timeout retransmission time, timeout detection time, etc.), affecting the retransmission effect. In the prior art, in the short connection scenario, the setting of timeout retransmission depends on the round-trip time factor. However, for most short connections, due to the relatively short communication rounds, historical data information outside the connection cannot be referred to for estimation, and the round-trip time factor is often set to the initial value, resulting in inaccurate estimation of the timeout time in the initialization stage of the connection and affecting data retransmission.
[0064] Based on the above problems, in the initialization stage of the application layer protocol of the connectionless transport protocol, historical data is applied to the round-trip time factor, and the accuracy of timeout time estimation is improved by referring to historical data, avoiding ineffective retransmission.
[0065] Specifically, when initializing the application layer protocol of the connectionless transport protocol, a session instance is created to establish a connection between the source (such as a server) and the target (such as a client). When connecting, taking the connection information as the granularity, that is, taking the overall source address and target address as the granularity, the historical connection information table is searched to obtain the historical round-trip time factor corresponding to the connection information for application. The round-trip time factor of this connection can be assigned based on the historical round-trip time factor, so that in the short connection scenario, the round-trip time factor of the historical connection can be directly applied to this connection, avoiding adjusting the round-trip factor starting from the preset initial value, and the accuracy of timeout retransmission can be improved more accurately in a shorter time.
[0066] Furthermore, the historical connection information table records the historical connection information and the corresponding historical round-trip time factor, and the historical connection information corresponds to the historical round-trip time factor. The source address and target address in the connection information determine the connecting party and the connected party. The historical round-trip time factor is determined based on the actual connection situation during the connection of the short connection corresponding to the connection information, and it is the basis for realizing timeout retransmission based on the real connection situation between the connecting party and the connected party. Compared with the preset initial value, it is more in line with the requirements of the connection, optimizes the setting of the round-trip time factor in the initialization stage, and improves the accuracy of timeout retransmission in the initialization stage.
[0067] Step S102: Determine the round-trip time according to the received first packet, update the round-trip time factor of this connection to determine the timeout time, and update the historical connection information table according to the updated round-trip time factor.
[0068] After establishing the connection, the connection source sends a packet to the target end and waits to receive the packet from the target end. After receiving the packet from the target end, the packet is judged. If it is the first packet, such as an ack confirmation character packet, the round-trip time can be determined according to the first packet. If it is a packet of other types, it is processed according to the processing logic of packets of other types, which will not be elaborated here.
[0069] The real-time round-trip time RTT of this connection can be determined based on the reflection timestamp of the first message and the current timestamp. According to the round-trip time RTT, the round-trip time factor of this connection can be updated correspondingly, so that the round-trip time factor better fits the time connection situation. Thus, the timeout determined based on the updated round-trip time factor of this connection conforms to the actual connection, avoiding problems such as being too high or too low. After determining the timeout, it can be determined whether to retransmit the data packet or send a new data packet to detect the timeout based on the timeout. For example, when a certain data packet has not received the confirmation information from the target end after exceeding the timeout since it was sent, the data packet is immediately retransmitted, and the timeout retransmission timer is refreshed for monitoring; or, when the data packet has not received the confirmation information from the target end after exceeding the timeout since it was sent, an unsent new data packet is used as a probe packet for timeout detection. The setting of the timeout can be calculated based on the round-trip time factor, such as calculated with different weights. The specific calculation can be set according to the actual situation and is not limited here.
[0070] Considering the situation of multiple connections during connection, that is, there may be multiple connections between the source and the target in addition to this connection. For example, new connections may be created after this connection. After updating the round-trip time factor of this connection, the historical round-trip time factors stored in the historical connection information table can be updated based on the updated round-trip time factor, that is, the historical round-trip time factors are corrected according to the actual situation of this connection. On the basis of the historical round-trip time factors, using the updated round-trip time factor for correction can better conform to the actual situation. In the case of multiple connections, it is convenient for the historical round-trip time factors obtained from the historical connection information table to be closer to the actual situation of the current connection, and better guarantee the accuracy of timeout retransmission.
[0071] Step S103, when the application layer protocol session of the connectionless transport protocol ends, update the real-time round-trip time factor of this connection to the historical connection information table and release the session resources.
[0072] After the message parsing is completed, this connection can be judged. When it is judged that this connection ends, that is, when the application layer protocol session of the connectionless transport protocol ends, update the real-time round-trip time factor of this connection to the historical connection information table, use the real-time round-trip time factor of this connection to update the historical round-trip time factor in the historical connection information table, and store the latest round-trip time factor in the historical connection information table. When creating a connection later, a round-trip time factor closer to the current connection time can be used. After updating the historical connection information table, release the session resources and end the session.
[0073] According to the timeout setting method for short connections based on the connectionless transport protocol provided by this application, when initializing the establishment of a connection, the historical round-trip time factor in the historical connection information table is queried and obtained in terms of connection information granularity. The historical round-trip time factor is directly applied to this connection during initialization, without the need to estimate using a preset initial value, improving the accuracy of timeout retransmission in the initialization phase. During the process of receiving a message, after determining the round-trip time based on the message, the round-trip time factor of this connection is updated in real time, and the historical round-trip time factor in the historical connection information table is updated based on the updated round-trip time factor, realizing the correction of historical data based on the current actual connection situation for other connections to use the latest round-trip time factor, improving the accuracy of estimating timeout retransmission. At the end of the session, the real-time round-trip time factor of this connection is updated to the historical connection information table, providing the historical round-trip time factor as data support for subsequent connections.
[0074] Figure 2 The flowchart of the timeout setting method for short connections based on the connectionless transport protocol according to an embodiment of this application is shown, as Figure 2 shown, and this method includes the following steps:
[0075] Step S201, pre-construct a historical connection information table that is global in memory.
[0076] Timeout retransmission depends on the round-trip time factor. However, in the existing short connection scenario of the connectionless transport protocol, the round-trip time factor is set to a preset initial value, such as 0, during the initialization phase, and historical data outside the connection cannot be referenced, resulting in inaccurate estimation of the timeout time in the initialization phase. In this embodiment, a historical connection information table that is global in memory is pre-constructed, which can conveniently refer to the historical round-trip time factor based on the connection information. The historical round-trip time factor can be applied during the initialization phase, improving the accuracy of the timeout time.
[0077] Specifically, the historical connection information table can be constructed based on the least recently used linked list, such as the LRU linked list. When a piece of data in the historical connection information table is accessed, its position in the linked list will be updated, such as remaining at the front of the linked list, facilitating quick search and update of this data during subsequent message reception, thereby improving the search and update speed and optimizing the memory usage efficiency. The historical connection information table includes connection information and the historical round-trip time factor. The connection information is the index of the historical connection information table, and the corresponding value includes the historical round-trip time factor.
[0078] It is convenient to quickly search based on the connection information in terms of connection information granularity. The connection information includes the source address and the destination address. For connections based on the same source and destination, the connection information is the same.
[0079] The historical connection information table is a memory global table, which is convenient for different connections to search for the historical connection information table and find the historical round-trip time factor of the same connection information from it for reference. The capacity of the historical connection information table can be set according to the implementation situation and is not limited here.
[0080] Step S202, initialize the application layer protocol of the connectionless transport protocol, create a session instance, obtain connection information based on the connectionless transport protocol, and determine whether there is connection information in the historical connection information table.
[0081] For any application layer protocol of the connectionless transport protocol, when initializing it, create a session instance and create connections for the source and the destination. Taking UDP as an example for the connectionless transport protocol and KCP protocol as an example for the application layer protocol of the connectionless transport protocol, the ikcp_create function is used for initialization. After creating the connection, obtain connection information based on the connectionless transport protocol, such as obtaining the source address, destination address, etc. from the data received by the socket, such as the source address IP, destination address IP, etc. According to the obtained connection information, taking the source address + destination address as a whole, query the historical connection information table to determine whether there is connection information in the historical connection information table. If the corresponding connection information is found in the query, execute step S203. If there is no corresponding connection information, it means that the connection of the source address + destination address is a first connection, and execute step S204.
[0082] Step S203, obtain the historical round-trip time factor corresponding to the connection information and assign it to the round-trip time factor of this connection.
[0083] If there is connection information of this time in the historical connection information table, modify the initialization process of the ikcp_create function. Based on the connection information, using the connection information as the query condition, obtain the historical round-trip time factor in the historical connection information table corresponding to the connection information, and directly assign the historical round-trip time factor to the round-trip time factor of this connection, so as to realize the application of the historical round-trip time factor in the initialization stage.
[0084] The round-trip time factor includes the round-trip time estimate value and the standard deviation of the round-trip offset time, both of which are determined based on the round-trip time. The historical round-trip time factor is determined based on the round-trip time during the historical connection. Compared with the preset initial value, it is more in line with the actual connection situation. Directly assigning the historical round-trip time factor to the round-trip time factor of this connection can improve the accuracy of setting the round-trip time factor in the initialization stage.
[0085] Step S204, assign the round-trip time factor of this connection to the preset initial value.
[0086] If the connection information for this time does not exist in the query history connection information table, it indicates that the connection between the source and the target has not been established yet. Therefore, when the ikcp_create function is initialized, the round-trip time factor for this connection is assigned a preset initial value, such as 0, and the round-trip time factor is updated based on the round-trip time subsequently.
[0087] Step S205: Based on the connectionless transport protocol packet received by the receive function, determine whether it is the first packet.
[0088] During the connection process, based on the connectionless transport protocol packet sent by the target end received by the receive function, parse the connectionless transport protocol packet and determine whether it is the first packet. If it is, execute Step S206 to determine the round-trip time, etc. If not, execute the corresponding processing logic according to the corresponding packet type. Taking KCP as an example, when the ikcp_input receive function receives a connectionless transport protocol packet, the first packet is an ACK confirmation character packet. When it is determined that the connectionless transport protocol packet is an ACK confirmation character packet, execute Step S206. When it is other types of packets, execute the processing logic of that type of packet correspondingly.
[0089] Step S206: Calculate the round-trip time based on the difference between the reflection timestamp and the current timestamp of the first packet. Based on the round-trip time, calculate and update the round-trip time factor for this connection, and determine the timeout time based on the updated round-trip time factor.
[0090] For the first packet, obtain the reflection timestamp of the first packet and the current timestamp. Calculate the difference between the current timestamp and the reflection timestamp of the first packet, and the result is the round-trip time.
[0091] The round-trip time factor can be updated according to the round-trip time. The round-trip time factor includes the estimated round-trip time and the standard deviation of the round-trip offset time. When updating the round-trip time factor, first determine whether the estimated round-trip time is the preset initial value, and select different update rules according to the preset initial value to update the estimated round-trip time and the standard deviation of the round-trip offset time. If the estimated round-trip time is the preset initial value, it means that the current packet is the first packet, and the estimated round-trip time is still the preset initial value during initialization and has not been updated based on the round-trip time. Then, update the estimated round-trip time and the standard deviation of the round-trip offset time according to the first update rule. For example, if the round-trip time RTT is parsed from the first ACK packet, the estimated round-trip time srtt is assigned the round-trip time RTT, and the standard deviation of the round-trip offset time rttval is assigned half of the round-trip time RTT, that is, RTT / 2. If the estimated round-trip time is not the preset initial value, then update the estimated round-trip time and the standard deviation of the round-trip offset time according to the second update rule. For example, update the estimated round-trip time and the standard deviation of the round-trip offset time in the way of exponential weighted moving average. The estimated round-trip time srtt = 7 / 8srtt + 1 / 8RTT, and the standard deviation of the round-trip offset time rttval = 3 / 4rttval + 1 / 4 * |RTT - rttval|. The above first update rule and second update rule are for illustrative purposes and are specifically set according to the implementation situation and are not limited here.
[0092] After updating the estimated round-trip time and the standard deviation of the round-trip offset time, determine the timeout according to the updated estimated round-trip time and the standard deviation of the round-trip offset time. For example, the timeout = srtt + 4 * rttval. Determine whether to retransmit the data packet according to the calculated timeout. For example, when a certain data packet has not received the confirmation information from the destination end after exceeding the timeout after being sent, the data packet is immediately retransmitted, and the timeout retransmission timer is refreshed for monitoring. The timeout is calculated according to the estimated round-trip time and the standard deviation of the round-trip offset time, and the specific calculation method is set according to the implementation situation and is not limited here.
[0093] Step S207: Obtain the historical round-trip time factor corresponding to the connection information stored in the historical connection information table. Based on the historical round-trip time factor and the updated round-trip time factor, calculate the new historical round-trip time factor based on the weight, so as to update the historical round-trip time factor stored in the historical connection information table according to the new historical round-trip time factor.
[0094] After updating the round-trip time estimate value and the standard deviation of the round-trip offset time, after the receiving function finishes parsing the first message, in this embodiment, the receiving function also adds an update to the historical round-trip time factor stored in the historical connection information table to correct the historical round-trip time factor according to the current real-time connection situation to cope with the multi-connection situation. When there are multiple connections, the connections with the same connection information can obtain the data after modifying the historical round-trip time factor, that is, obtain the historical round-trip time factor that is more consistent with the current connection situation, which is convenient for multiple connections to more accurately estimate the timeout time in the initialization stage.
[0095] When correcting the historical round-trip time factor, the historical round-trip time factor corresponding to the connection information stored in the historical connection information table can be obtained according to the connection information first, and the historical round-trip time factor and the updated round-trip time factor are used to calculate a new round-trip time factor based on the weight. For example, if the historical round-trip time estimate value in the historical round-trip time factor is srtt_store and the standard deviation of the historical round-trip offset time is rttval_store, then based on the weight calculation, the new historical round-trip time estimate value is 7 / 8*srtt_store + 1 / 8*srtt, and the new standard deviation of the historical round-trip offset time is 3 / 4*rttval_store + 1 / 4*rttval. The historical round-trip time factor stored in the historical connection information table is updated with the new historical round-trip time factor to complete the correction of the historical round-trip time factor stored in the historical connection information table. The above weights are for illustrative purposes and are specifically set according to the implementation situation and are not limited here.
[0096] Furthermore, in addition to the round-trip time estimate value and the standard deviation of the round-trip offset time, the historical round-trip time factor can also include connection status information, such as historical message information, etc. When updating the historical round-trip time factor, the real-time message information can be used to update the historical message information to update the corresponding connection status information, which is convenient for subsequent confirmation of the connection status according to the historical connection information table.
[0097] The correction of the historical round-trip time factor stored in the historical connection information table can be applied to the multi-connection scenario. When this connection is not ended, the round-trip time factor is updated based on the real-time round-trip time RTT of this connection, and the updated round-trip time factor is used to perform weighted correction on the historical round-trip time factor, which can combine history and reality, so that in the multi-connection scenario, a more reasonable historical round-trip time factor can be obtained.
[0098] Step S208, determine whether the application layer protocol of the connectionless transport protocol has ended the session.
[0099] After the receiving function parses the completion message, it determines whether the application layer protocol of the connectionless transport protocol has ended the session, that is, whether it still needs to continue waiting for the received message. If there is no need to wait, that is, the session ends, step S209 is executed. Otherwise, it continues to wait for the received message, performs corresponding operations according to the message, and executes steps S205 - S207 until it determines that the session ends. When continuing to receive the message, if the message is the first message, the round-trip time is determined based on the first message, and the round-trip time factor is continuously updated based on the round-trip time, etc.
[0100] Step S209, obtain the real-time round-trip time factor of this connection, update the historical round-trip time factor corresponding to the connection information stored in the historical connection information table according to the real-time round-trip time factor, and end the session based on the destruction function to release the session resources.
[0101] When it is determined that the session ends, taking KCP as an example, call the ikcp_release destruction function to end the session. Before ending the session, obtain the real-time round-trip time factor of this connection. If the first message is received only once, the round-trip time factor is the data updated after the first message. If the first message is received multiple times, the round-trip time factor is the data updated after multiple messages. Use the real-time round-trip time factor to directly update the historical round-trip time factor corresponding to the connection information stored in the historical connection information table, and update the historical round-trip time factor to the real-time round-trip time factor for use in the next connection.
[0102] After updating the historical round-trip time factor, the destruction function ends the session, releases the session resources, and ends this connection. The historical connection information table stores the connection information of this connection and the corresponding real-time round-trip time factor as the historical round-trip time factor, and saves the information for subsequent connections to apply historical data. Based on the connection information, the historical round-trip time factor can be obtained from the historical connection information table and assigned to the round-trip time factor of the connection, realizing the application of the round-trip time factor in the initialization stage, etc.
[0103] According to the timeout time setting method for short connections based on the connectionless transport protocol provided by this application, construct a global historical connection information table in memory to store the connection information and the corresponding historical round-trip time factor, which is convenient for obtaining the corresponding historical round-trip time factor for application with the connection information as the granularity when connecting. By referring to the historical round-trip time factor, the problem of overestimating or underestimating the timeout retransmission can be greatly reduced. Further, during the message receiving process, after the round-trip time factor is updated in real time, the historical round-trip time factor is corrected according to the updated round-trip time factor, and the historical data is corrected using the actual connection situation, ensuring that in a multi-connection scenario, a historical round-trip time factor closer to the connection situation can be obtained, improving the accuracy.
[0104] Figure 3The figure shows a schematic structural diagram of a timeout setting device for short connections based on a connectionless transport protocol provided by an embodiment of the present application. As Figure 3 shown, the device includes:
[0105] An initialization module 310, adapted to initialize the application layer protocol of the connectionless transport protocol, create a session instance, look up the historical connection information table according to the connection information, obtain the historical round-trip time factor of the connection information, and assign it to the round-trip time factor of the current connection;
[0106] A message receiving module 320, adapted to determine the round-trip time according to the received first message, update the round-trip time factor of the current connection to determine the timeout time, and update the historical connection information table according to the updated round-trip time factor;
[0107] A session end module 330, adapted to update the real-time round-trip time factor of the current connection to the historical connection information table and release the session resources when the application layer protocol session of the connectionless transport protocol ends.
[0108] Optionally, the device further includes: a table module 340, adapted to pre-build a historical connection information table that is globally stored in memory; the historical connection information table includes connection information and a historical round-trip time factor; the connection information is the index of the historical connection information table; the connection information includes a source address and a destination address; the historical connection information table is built based on a least recently used linked list.
[0109] Optionally, the initialization module 310 is further adapted to:
[0110] Obtain connection information based on the connectionless transport protocol;
[0111] Determine whether the historical connection information table contains the connection information;
[0112] If so, obtain the historical round-trip time factor corresponding to the connection information.
[0113] Optionally, if the historical connection information table does not contain the connection information, the device further includes: an initial assignment module 350, adapted to assign the round-trip time factor of the current connection to a preset initial value.
[0114] Optionally, the message receiving module 320 is further adapted to:
[0115] Based on the connectionless transport protocol message received by the receive function, determine whether it is the first message;
[0116] If so, calculate the round-trip time according to the difference between the reflection timestamp and the current timestamp of the first message;
[0117] Calculate and update the round-trip time factor of the current connection according to the round-trip time, and determine the timeout time according to the updated round-trip time factor;
[0118] Update the historical round-trip time factor corresponding to the connection information stored in the historical connection information table according to the updated round-trip time factor, so that other sessions of the connection information can obtain the updated historical round-trip time factor.
[0119] Optionally, the session end module 330 is further adapted to:
[0120] Determine whether the application layer protocol of the connectionless transport protocol has ended the session;
[0121] If so, obtain the real-time round-trip time factor of this connection, and update the historical round-trip time factor corresponding to the connection information stored in the historical connection information table according to the real-time round-trip time factor;
[0122] End the session based on the destruction function to release the session resources.
[0123] Optionally, the round-trip time factor includes a round-trip time estimate value and a standard deviation of the round-trip offset time;
[0124] The message receiving module 320 is further adapted to:
[0125] Determine whether the round-trip time estimate value is a preset initial value;
[0126] If so, update the round-trip time estimate value and the standard deviation of the round-trip offset time according to the first update rule;
[0127] If not, update the round-trip time estimate value and the standard deviation of the round-trip offset time according to the second update rule, and determine the timeout time according to the updated round-trip time estimate value and the standard deviation of the round-trip offset time;
[0128] Obtain the historical round-trip time factor corresponding to the connection information stored in the historical connection information table;
[0129] Based on the historical round-trip time factor and the updated round-trip time factor, calculate a new historical round-trip time factor based on the weight, so as to update the historical round-trip time factor stored in the historical connection information table according to the new historical round-trip time factor.
[0130] The descriptions of the above modules refer to the corresponding descriptions in the method embodiments, and will not be repeated here.
[0131] According to the timeout setting device for short connections based on the connectionless transport protocol provided by the present application, when initializing the establishment of a connection, the historical round-trip time factor in the historical connection information table is queried and obtained in terms of connection information granularity. For this connection, the historical round-trip time factor is directly applied, without the need to estimate using a preset initial value, which improves the accuracy of timeout retransmission in the initialization stage. During the process of receiving a message, after determining the round-trip time based on the message, the round-trip time factor of this connection is updated in real time, and the historical round-trip time factor in the historical connection information table is updated based on the updated round-trip time factor, realizing the correction of historical data based on the current actual connection situation, so that other connections can use the latest round-trip time factor, improving the accuracy of estimating timeout retransmission. At the end of the session, the real-time round-trip time factor of this connection is updated to the historical connection information table, providing the historical round-trip time factor as data support for subsequent connections.
[0132] The present application also provides a non-volatile computer storage medium, and the computer storage medium stores at least one executable instruction, and the executable instruction can perform the operations corresponding to the timeout setting method for short connections based on the connectionless transport protocol in any of the above method embodiments.
[0133] The present application also provides a computer program product, and the computer program product includes at least one executable instruction or computer program, and the executable instruction or computer program can enable the processor to perform the operations corresponding to the timeout setting method for short connections based on the connectionless transport protocol in any of the above method embodiments.
[0134] Figure 4 The structural schematic diagram of a computing device according to an embodiment of the present application is shown, and the specific implementation of the computing device is not limited in the specific embodiments of the present application.
[0135] As Figure 4 shown, the computing device may include: a processor 402, a communication interface 404, a memory 406, and a communication bus 408.
[0136] Among them:
[0137] The processor 402, the communication interface 404, and the memory 406 communicate with each other through the communication bus 408.
[0138] The communication interface 404 is used to communicate with network elements of other devices such as clients or other servers.
[0139] The processor 402 is used to execute the program 410, and specifically can execute the relevant steps in the above embodiments of the timeout setting method for short connections based on the connectionless transport protocol.
[0140] Specifically, the program 410 may include program code that includes computer operation instructions.
[0141] The processor 402 may be a central processing unit (CPU), or a specific integrated circuit (ASIC) (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the present application. One or more processors included in the computing device may be of the same type of processor, such as one or more CPUs; or may be of different types of processors, such as one or more CPUs and one or more ASICs.
[0142] The memory 406 is used to store the program 410. The memory 406 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk memory.
[0143] The program 410 may specifically be used to cause the processor 402 to execute the method for setting the timeout period of the short connection based on the connectionless transport protocol in any of the above method embodiments. For the specific implementation of each step in the program 410, reference may be made to the corresponding steps and units in the above embodiments of setting the timeout period of the short connection based on the connectionless transport protocol, which will not be elaborated here. Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the above-described devices and modules may refer to the corresponding process descriptions in the foregoing method embodiments, which will not be repeated here.
[0144] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems may also be used in conjunction with the teachings provided herein. Based on the above description, the structure required to construct such a system is obvious. In addition, the present application is not directed to any specific programming language. It should be understood that the content of the present application described herein can be implemented using various programming languages, and the description of a specific language above is for disclosing the preferred embodiments of the present application.
[0145] In the specification provided herein, a large number of specific details are set forth. However, it can be understood that the embodiments of the present application may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0146] Similarly, it should be understood that, for the purpose of streamlining this application and assisting in understanding one or more of the various inventive aspects, in the foregoing description of the exemplary embodiments of this application, the various features of this application are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be construed as reflecting an intention that the claimed application requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, the inventive aspects lie in less than all the features of the single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate embodiment of this application.
[0147] Those skilled in the art can understand that the modules in the devices in the embodiments can be adaptively changed and disposed in one or more devices different from the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and in addition, they can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all the features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all the processes or units of any method or device so disclosed. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) can be replaced by an alternative feature that provides the same, equivalent, or similar purpose.
[0148] In addition, those skilled in the art can understand that although some of the embodiments herein include certain features included in other embodiments rather than other features, the combination of the features of different embodiments means that it is within the scope of this application and forms different embodiments. For example, in the following claims, any one of the claimed embodiments can be used in any combination.
[0149] The various component embodiments of this application can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all of the functions of some or all of the components according to this application. This application can also be implemented as a device or device program for executing part or all of the methods described herein (for example, a computer program and a computer program product). Such a program for implementing this application can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0150] It should be noted that the above embodiments are illustrative of the present application rather than limiting the present application, and those skilled in the art can design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in the claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present application can be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In a unit claim listing several devices, several of these devices may be embodied by the same item of hardware. The use of the words first, second, and third, etc. does not denote any order. These words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order of execution.
Claims
1. A method for setting a timeout for a short connection based on a connectionless transmission protocol, comprising: Initialize the application layer protocol of the connectionless transmission protocol, create a session instance, and search the historical connection information table according to the connection information to obtain the historical round-trip time factor of the connection information, and assign it to the round-trip time factor of this connection; Determine the round-trip time according to the received first message, update the round-trip time factor of the current connection to determine the timeout time, and update the historical connection information table according to the updated round-trip time factor; When the application layer protocol session of the connectionless transmission protocol ends, the real-time round-trip time factor of this connection is updated to the historical connection information table to release the session resources.
2. The method according to claim 1, wherein: The method further comprises: A global historical connection information table is pre-built in memory; the historical connection information table includes connection information and historical round-trip time factors; the connection information is an index of the historical connection information table; the connection information includes a source address and a target address; the historical connection information table is built based on a least recently used linked list.
3. The method according to claim 1 or 2, wherein: The step of searching the historical connection information table according to the connection information to obtain the historical round-trip time factor of the connection information further comprises: Obtain connection information based on connectionless transmission protocol; Determine whether the connection information exists in the historical connection information table; If so, obtain the historical round-trip time factor corresponding to the connection information.
4. The method according to claim 3, wherein: If the historical connection information table does not contain the connection information, the method further includes: Assign the round trip time factor of this connection to the preset initial value.
5. The method according to claim 1, wherein: The step of determining the round trip time according to the received first message, updating the round trip time factor of the current connection to determine the timeout time, and updating the historical connection information table according to the updated round trip time factor further comprises: Based on the connectionless transmission protocol message received by the receiving function, determining whether it is the first message; If yes, the round trip time is calculated based on the difference between the reflection timestamp of the first message and the current timestamp; According to the round trip time, a round trip time factor for updating the current connection is calculated, and a timeout period is determined according to the updated round trip time factor; According to the updated round-trip time factor, the historical round-trip time factor corresponding to the connection information stored in the historical connection information table is updated, so that other sessions of the connection information can obtain the updated historical round-trip time factor.
6. The method according to any one of claims 1 to 5, wherein: When the application layer protocol session of the connectionless transmission protocol ends, updating the real-time round-trip time factor of the current connection to the historical connection information table, and releasing the session resources further comprises: Determine whether the application layer protocol session of the connectionless transmission protocol is ended; If yes, obtain the real-time round-trip time factor of this connection, and update the historical round-trip time factor corresponding to the connection information stored in the historical connection information table according to the real-time round-trip time factor; Based on the destruction function, end the session to release session resources.
7. The method according to claim 5, wherein: The round trip time factor includes a round trip time estimate and a round trip offset time standard deviation; The step of calculating and updating the round trip time factor of the current connection according to the round trip time, and determining the timeout time according to the updated round trip time factor further includes: Determining whether the round-trip time estimate is a preset initial value; If so, updating the round-trip time estimate and the round-trip offset time standard deviation according to a first updating rule; If not, update the round trip time estimate and the round trip offset time standard deviation according to the second update rule Determine a timeout period according to the updated round-trip time estimate and the round-trip offset time standard deviation; The updating of the historical round-trip time factor corresponding to the connection information stored in the historical connection information table according to the updated round-trip time factor so that other sessions of the connection information can obtain the updated historical round-trip time factor further includes: Obtaining a historical round-trip time factor corresponding to the connection information stored in the historical connection information table; According to the historical round-trip time factor and the updated round-trip time factor, a new historical round-trip time factor is obtained based on weight calculation, so as to update the historical round-trip time factor stored in the historical connection information table according to the new historical round-trip time factor.
8. A timeout setting device for a short connection based on a connectionless transmission protocol, comprising: An initialization module, adapted to initialize the application layer protocol of the connectionless transmission protocol, create a session instance, and search the historical connection information table according to the connection information, obtain the historical round-trip time factor of the connection information, and assign it to the round-trip time factor of this connection; A message receiving module, adapted to determine a round trip time according to a received first message, update a round trip time factor of the current connection to determine a timeout time, and update the historical connection information table according to the updated round trip time factor; The session ending module is adapted to update the real-time round trip time factor of the current connection to the historical connection information table when the application layer protocol session of the connectionless transmission protocol ends, thereby releasing the session resources.
9. A computing device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the method for setting a timeout period for a short connection based on a connectionless transmission protocol as described in any one of claims 1 to 7.
10. A computer storage medium, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute operations corresponding to the method for setting a timeout period for a short connection based on a connectionless transmission protocol as described in any one of claims 1 to 7.
11. A computer program product, comprising at least one executable instruction, wherein the executable instruction enables a processor to execute operations corresponding to the method for setting a timeout period for a short connection based on a connectionless transmission protocol as described in any one of claims 1 to 7.