Active packet loss recovery method oriented to weak network environment
Technical Field
The invention belongs to the technical field of network communication, and particularly relates to an active packet loss recovery method for a weak network environment.
Background
With the rapid development of the internet in the 70 s of the 20 th century, the internet has now become a diversified, intelligent and globalized network platform. In the internet, wireless networks have been applied in a large number of scenarios because of their advantages of strong mobility and easy deployment, and there is a trend to gradually replace wired networks in the transmission of the last hop. Users can interact with each other through different wireless network devices of the network service provider.
But the transmission quality of the wireless network is interfered by various factors, such as the number of clients, signal quality, obstacle interference, etc., under the interference of these factors, clients often have scenes in which the quality of the network is weaker when using the wireless network. In a weak network environment, the network needs of the user cannot be satisfied by the wireless network. Since the TCP protocol is the underlying transport protocol, its transmission time is important for wireless network service performance. The significant degradation of TCP transmission performance is mostly caused by packet loss, so access delay is greatly increased. Meanwhile, the traditional TCP has poor performance in a weak network environment and is mainly characterized in that sufficient data transmission information cannot be acquired, so that packet loss detection and packet loss recovery cannot be accurately performed.
In summary, by analyzing the wireless network data, the network packet loss phenomenon is serious in the transmission process, and the transmission time is obviously increased by the TCP low-efficiency packet loss recovery mechanism. Therefore, the invention provides a more efficient active packet loss recovery method by attempting to estimate the packet loss probability in the weak network environment so as to accelerate the packet loss recovery. The method performs active recovery prior to fast recovery or timeout retransmission.
Disclosure of Invention
The invention aims to overcome the defects in the prior art, solve the problems that the traditional TCP has poor performance in the weak network environment, cannot acquire sufficient data transmission information, cannot accurately perform packet loss detection and packet loss recovery and the like, and provide an active packet loss recovery method for the weak network environment.
The invention is realized by adopting the following technical scheme:
The active packet loss recovery method for the weak network environment is characterized by comprising two parts, namely a packet loss estimation module and an active retransmission module. The packet loss rate estimating module estimates the packet loss rate by analyzing and collecting network state parameters, if the packet loss rate is greater than a certain threshold value, the number of the next packet needing one active retransmission is calculated through an active retransmission algorithm, and the packet is transmitted for a plurality of times when the next packet is transmitted;
The method comprises the following steps:
Step1, a server sends a data packet, and at the moment, records the packet number Packetnumber of the data packet and the number totalPacketsSent of the sent data packet when sending the data packet;
step 2, storing the recorded package numbers and package numbers in a structure body, connecting different package numbers by using a linked list, and recording and storing according to the package numbers from small to large;
Step3, waiting for the ACK message of the client, and recording the confirmed maximum packet number largestAckNumber and the total lost packet number lostStart according to the received ACK message;
step 4, waiting for the next ACK message, and recording the confirmed maximum packet number largestAckNumber and the total lost packet number lostEnd again according to the received ACK message;
Step 5, calculating the total lost packet number tempPacketsMarkedLost between two ACK messages received by the server side through the recorded packet numbers and the total lost packet numbers corresponding to the packet numbers;
step 6, the total number of the transmitted packets is calculated when the transmitted packets are searched in sequence in a linked list which records the packet numbers and the total number of the transmitted packets, and the total number TEMPPACKETSSENT of the packets transmitted between the two packets by the server side is calculated;
step 7, calculating a real-time packet loss rate lossrate;
step 8, calculating an average packet loss rate avg_ lossrate;
Step 9, transmitting the estimated packet loss rate to an active retransmission module, wherein the active retransmission module determines how many identical packets are transmitted once and performs active retransmission;
and step 10, the data of the confirmed maximum packet number and the total number of lost packets recorded for the second time are covered to the first time.
The method comprises the following steps:
Step1, a server sends a data packet, and at the moment, records the packet number Packetnumber of the data packet and the number totalPacketsSent of the sent data packet when sending the data packet;
step 2, storing the recorded package numbers and package numbers in a structure body, connecting different package numbers by using a linked list, and recording and storing according to the package numbers from small to large;
Step3, waiting for the ACK message of the client, and recording the confirmed maximum packet number largestAckNumber and the total lost packet number lostStart according to the received ACK message;
step 4, waiting for the next ACK message, and recording the confirmed maximum packet number largestAckNumber and the total lost packet number lostEnd again according to the received ACK message;
Step 5, calculating the total lost packet number tempPacketsMarkedLost between two ACK messages received by the server side through the recorded packet numbers and the total lost packet numbers corresponding to the packet numbers;
step 6, the total number of the transmitted packets is calculated when the transmitted packets are searched in sequence in a linked list which records the packet numbers and the total number of the transmitted packets, and the total number totalPacketsSent of the packets transmitted between the two packets by the server side is calculated;
step 7, calculating a real-time packet loss rate lossrate;
step 8, calculating an average packet loss rate avg_ lossrate;
Step 9, transmitting the estimated packet loss rate to an active retransmission module, wherein the active retransmission module determines how many identical packets are transmitted once and performs active retransmission;
and step 10, the data of the confirmed maximum packet number and the total number of lost packets recorded for the second time are covered to the first time.
Step 2 comprises the following steps:
Step 2.1, initializing a structural body ARlost;
Step 2.2, save packet number Packetnumber and already sent packet number totalPacketsSent;
Step 2.3, pointing the next pointer of the last structure body to the node;
and 2.4, setting a next pointer of the node to NULL.
Step 3 comprises the following steps:
step 3.1, waiting for the ACK message of the client, if not receiving the ACK message, entering the step 3.2, and if receiving the ACK message, entering the step 3.3;
step 3.2, waiting for an ACK message, and normally transmitting a packet in the period;
Step 3.3, recording the confirmed maximum packet number largestAckNumber1;
And 3.4, recording the total packet loss number lostStart at the moment.
Step 4 comprises the steps of:
Step 4.1, waiting for the ACK message of the client, if the ACK message is the first ACK message received by the server, entering step 4.2, and if the ACK message is not the first ACK message received by the server, entering step 4.3;
Step 4.2, waiting for the next ACK message, and normally sending a packet in the period;
step 4.3, recording the confirmed maximum packet number largestAckNumber2;
and 4.4, recording the total packet loss number lostEnd at the moment.
And 5, calculating the difference between the total number of lost packets of the server side and the total number of lost packets recorded twice between the two ACK messages.
Step 6 comprises the steps of:
step 6.1, traversing the linked list, and searching the node where the confirmed maximum packet number largestAckNumber1 recorded by the ACK message is located for the first time;
Step 6.2, obtaining the number totalPacketsSent of transmitted packets saved by the node to be totalPacketsSentStart;
Step 6.3, continuously traversing the linked list, and searching the node where the confirmed maximum packet number largestAckNumber is located, which is recorded by the ACK message received for the first time;
Step 6.4, obtaining the number totalPacketsSent of transmitted packets saved by the node to be totalPacketsSentEnd;
step 6.5, calculating the difference of the total number of the packets sent by the server end between the receipt of two ACK messages and the total number of the packets obtained from the linked list for two times;
And 6.6, releasing nodes smaller than largestAckNumber package numbers.
And 7, calculating the real-time packet loss rate as the ratio of the total number of lost packets to the total number of transmitted packets.
And 8, calculating an average packet loss rate according to different weights by the average packet loss rate and the real-time packet loss rate, wherein w is a set weight parameter, and adjusting the size of the weight parameter according to the sensitivity of different streams to packet loss, and defaulting to 0.5.
Step 9 comprises the steps of:
Step 9.1, judging whether the packet loss rate exceeds a packet loss threshold value threshold, if not, entering step 9.2, and if so, entering step 9.3;
Step 9.2, obtaining the number of the packet waiting to be sent and other related information, constructing the packet and normally sending the packet, and sending the packet only once;
step 9.3, the active recovery module calculates the transmission times of the next packet, and circularly constructs the same packet and transmits the same packet for a plurality of times;
And 9.4, after successful transmission, updating the time measurement (such as round trip time RTT, retransmission timeout time RTO and the like) related to the packet loss timeout.
Aiming at the problems that the traditional TCP has poor performance in the weak network environment and cannot accurately perform packet loss detection, packet loss recovery and the like, the invention provides an active packet loss recovery method for the weak network environment, which can reduce random packet loss in the weak network environment, perform accurate packet loss detection and packet loss recovery and meet the network requirements of users.
Drawings
Fig. 1 is a schematic diagram of an overall frame of an active packet loss recovery method for a weak network environment
Fig. 2 is a schematic diagram of a block diagram of estimating packet loss rate
Fig. 3 is a schematic diagram of an active retransmission module
Detailed Description
In order to make the purpose and technical scheme of the invention clearer and easier to understand. The invention is described in further detail below with reference to the drawings, wherein the specific embodiments are for the purpose of illustrating the invention only and not for the purpose of limiting the same.
The invention provides an active packet loss recovery method for a weak network environment. The basic idea of the invention is to estimate the packet loss rate in advance and actively retransmit, calculate the packet loss rate under the current network according to the wireless network communication parameters to measure the current network state, and actively recover the packet loss before the packet loss, thereby realizing accurate retransmission and not wasting network resources. In the running process, the invention updates the packet loss rate in real time based on the QUIC flow, and instantly adjusts the number of actively retransmitted packets, thereby not affecting network congestion, but also rapidly recovering the actively lost packets before overtime.
The system structure of the invention is as follows
Shown in fig. 1. The invention comprises two parts, namely a packet loss rate estimation module and an active retransmission module. And estimating the packet loss rate by analyzing the collected QUIC flow parameters, calculating the number of packets to be actively retransmitted next according to the packet loss rate, and taking the number as a packet loss threshold value, if the estimated packet loss rate exceeds the threshold value, transmitting the next packet for a plurality of times by an active recovery module, and if the estimated packet loss rate does not exceed the threshold value, transmitting the next packet only once.
1. Module for estimating packet loss rate
In order to realize fast sensing and retransmission of lost packets in a weak network environment, the number of total transmitted packets, the number of total lost packets and the packet number in the transmission process are taken as important bases for estimating the packet loss rate, and the calculation of the packet loss rate is divided into two parts, namely real-time packet loss rate (lossrate) calculation and average packet loss rate (avg_ lossrate) calculation, which are specific details (such as the following (additional information)
Fig. 2):
(1) Real-time packet loss rate
The real-time packet loss rate calculation does not use the fixed packet number as a calculation period, and therefore the fixed packet number is not used as a calculation period, because the sliding window can be adjusted in real time according to the network condition, the maximum acknowledgement packet number received by the opposite terminal returns at an unpredictable interval, and the one-time packet loss rate can not be calculated according to the fixed packet number in some cases. The method is characterized in that when a packet is transmitted, the packet number of each transmitted packet and the total number of transmitted packets when the packet is transmitted are recorded, the packets are stored in a structure body, the structure body is connected into a linked list by a pointer, the packet number confirmed by the opposite terminal is continuously changed in the process of continuously transmitting the packet, the maximum packet number confirmed by the opposite terminal is updated to be a calculation period, when the packet number confirmed by the opposite terminal is updated, the transmitted packet number consistent with the confirmed packet number is found according to the maximum packet number confirmed by the opposite terminal, the total number of transmitted packets when the packet number is transmitted is read (totalPacketsSentStart), and the total number of lost packets at the moment is recorded (lostStart). When the next opposite end confirms that the packet number changes, the sending packet number consistent with the confirmation packet number is found, the total number of the sending packets when the packet number is sent is read (totalPacketsSentEnd), the total number of the sending packets between the two packets is calculated, and the total number of the sending packets between the two packets is subtracted to obtain the total number of the sending packets between the two packets (tempPacketsMarkedLost). Recording the total number of lost packets (lostEnd) at the moment, and calculating the total number of lost packets between two confirmation packet numbers, wherein the ratio of the total number of lost packets to the total number of transmitted packets is the real-time packet loss rate.
The following steps are needed to be executed to estimate the real-time packet loss rate:
step 1, a server sends a data packet, at the moment, records the packet number of the data packet and the number of the data packet sent when the data packet is sent, stores the data packet in a structure body, and records and stores the data packet according to the packet number from small to large;
Step 2, waiting for the ACK message of the client, and recording the confirmed maximum packet number and the total packet loss according to the received ACK message;
Step 3, waiting for the next ACK message, and recording the confirmed maximum packet number and the total lost packet again according to the received ACK message;
step 4, calculating a real-time packet loss rate lossrate;
Further, step1 includes the steps of:
step 1.1, initializing a structural body ARlost;
Step 1.2, saving the number of the packets and the number of the transmitted packets, which are respectively recorded as ARlost-Packetnumber and ARlost-totalPacketSent;
further, ARlost → Packetnumber is derived from the following formula:
ARlost→Packetnumber=conn.Packetnumber (1)
Wherein conn is the identity of the QUIC connection, which is a single session procedure between two QUIC endpoints. The establishment of the QUIC connection involves version negotiation of the encryption algorithm with the transport layer handshake to reduce latency. The QUIC connection provides flow multiplexing, flow and connection level flow control, low latency connection setup, connection migration and NAT rebinding flexibility, and authentication, preserving a number of network basic parameters including packet numbers.
Further, ARlost → totalPacketsSent is derived from the following formula:
ARlost→totalPacketsSent=conn.totalPacketsSent (2)
Step 1.3, pointing the next pointer of the last structure body to the node;
Further, the next pointer of the last structure is updated according to the following formula:
p→next=ARlost (3)
Where p is the pointer to the last node of the linked list.
And 1.4, setting a next pointer of the node to NULL.
Further, the next pointer of the node is updated according to the following formula:
ARlost→next=NULL (4)
further, step2 includes the steps of:
Step 2.1 obtaining the maximum packet number largestAckNumber, largestAckNumber1 that has been confirmed is obtained by:
largestAckNumber1=conn.largstAcked (5)
Step 2.2, obtaining the total number of lost packets lostStart, lostStart, wherein the total number of lost packets is obtained by the following formula:
lostStart=conn.totalPacketsLost (6)
further, step 3 is similarly followed to yield largestAckNumber and LostEnd;
Further, step4 includes the steps of:
step 4.1, calculating the total lost packet tempPacketsMarkedLost, tempPacketsMarkedLost of the server side between two received ACK messages according to the recorded packet numbers and the total lost packet numbers corresponding to the packet numbers, wherein the total lost packet number tempPacketsMarkedLost, tempPacketsMarkedLost is calculated by the following formula:
tempPacketsMarkedLost=lostEnd-lostStart (7)
Step 4.2, the total number of the transmitted packets is calculated when the transmitted packets are searched in sequence in a linked list which records the packet numbers and the total number of the transmitted packets, and the total number TEMPPACKETSSENT, TEMPPACKETSSENT of the packets transmitted by the server end between the two packets is calculated by the following formula:
tempPacketsSent=totalPacketsSentEnd-totalPacketsSentStart (8)
further, totalPacketsSentStart is the total number of transmission packets stored in the node corresponding to the packet number largestAckNumber, and totalPacketsSentEnd is the total number of transmission packets stored in the node corresponding to the packet number largestAckNumber 2.
Step 4.3, calculating a real-time packet loss rate lossrate and lossrate according to the following formula:
(2) Average packet loss rate
And calculating the average packet loss rate of the flow according to the real-time packet loss rate of the flow. The average packet loss rate avg_ lossrate is obtained by iteration according to different weights from the real-time packet loss rate lossrate, wherein w is a set weight parameter, and the size of the average packet loss rate avg_ lossrate is adjusted according to the sensitivity of different streams to packet loss.
Further, avg_ lossrate is obtained by the following formula:
avg_lossrate=(1-w)·avg_lossrate+w·lossrate (10)
2. Active retransmission module
After the average packet loss rate is calculated by the packet loss rate estimation module, the active retransmission module determines how many identical packets (such as attached packets) are to be transmitted once
Fig. 3), active retransmission is performed, requiring the following steps to be performed:
Step 1, when a server sends a data packet, firstly writing data into a socket, and creating a batch writer for convenient writing;
step 2, judging whether the buffer area has data or not, if not, step 3, and if so, entering step 4;
Step 3, proving that no data packet needs to be transmitted, and directly ending the sending flow;
Step 4, sequentially obtaining the packet number of the waiting packet and other related information, judging whether the packet loss rate exceeds a packet loss threshold, if not, entering step 5, and if so, entering step 6;
step 5, obtaining the number of the packet waiting to be sent and other related information, constructing the packet and normally sending the packet, and sending the packet only once;
step 6, the active recovery module calculates the sending times of the next packet, and circularly constructs the same packet and sends the same packet for a plurality of times;
Step 7, judging whether the package is constructed successfully after the transmission is completed, if not, entering step 8, and if so, entering step 9;
Step8, jumping out of circulation after reporting errors;
step 9, updating the connection related state (such as written bit value, total number of transmitted packets, etc.).
Further, the active retransmission module in step 6 determines how many identical packets are to be transmitted at a time according to the following formula:
n=max(logavg_lossratethreshold,1) (11)
wherein n is the number of packets sent at one time, if the threshold is exceeded, the active recovery module sends the next packet n times, and if the threshold is not exceeded, the active recovery module sends the next packet only once.
The foregoing description of the specific embodiments of the invention and the accompanying drawings has been disclosed for illustrative purposes only, and is for the purpose of aiding in the understanding of the invention and its contents and for the practice thereof, it will be understood by those skilled in the art that various alternatives, modifications and variations are possible without departing from the spirit and scope of the invention and the appended claims. The invention should not be limited to the embodiments disclosed in the specification and the drawings, but the scope of the invention is defined by the claims.