CN108418656B - LwIP delay ACK timer period self-adaption method based on data statistics - Google Patents

LwIP delay ACK timer period self-adaption method based on data statistics Download PDF

Info

Publication number
CN108418656B
CN108418656B CN201810044900.4A CN201810044900A CN108418656B CN 108418656 B CN108418656 B CN 108418656B CN 201810044900 A CN201810044900 A CN 201810044900A CN 108418656 B CN108418656 B CN 108418656B
Authority
CN
China
Prior art keywords
period
timer
ack timer
delayed ack
lwip
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810044900.4A
Other languages
Chinese (zh)
Other versions
CN108418656A (en
Inventor
林志祥
张天宏
孙庆彪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing University of Aeronautics and Astronautics
Original Assignee
Nanjing University of Aeronautics and Astronautics
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing University of Aeronautics and Astronautics filed Critical Nanjing University of Aeronautics and Astronautics
Priority to CN201810044900.4A priority Critical patent/CN108418656B/en
Publication of CN108418656A publication Critical patent/CN108418656A/en
Application granted granted Critical
Publication of CN108418656B publication Critical patent/CN108418656B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/0001Systems modifying transmission characteristics according to link quality, e.g. power backoff
    • H04L1/0033Systems modifying transmission characteristics according to link quality, e.g. power backoff arrangements specific to the transmitter
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/12Arrangements for detecting or preventing errors in the information received by using return channel

Abstract

The invention discloses a cycle self-adaptive method of a LwIP delay ACK timer based on data statistics, which is characterized by comprising the following steps of: step 1) a delayed ACK timer is independent from a fast timer of LwIP; step 2) judging whether the period of the timer is appropriate or not by a period judging method based on data statistics; step 3) carrying out corresponding processing on the value of the timer period according to the period judgment result; and 4) resetting the delayed ACK timer period based on the inertia principle. The invention achieves the following beneficial effects: the invention can be directly applied to Ethernet communication of an embedded system, the sending period of a sending end is self-adapted in 1s, the real-time performance of communication can be greatly improved on the premise of ensuring the use efficiency of an embedded CPU, the communication period can be reduced to 1ms, and the communication delay is within 1 ms.

Description

LwIP delay ACK timer period self-adaption method based on data statistics
Technical Field
The invention relates to a LwIP delay ACK timer period self-adaptive method based on data statistics, and belongs to the technical field of Ethernet communication of an embedded system.
Background
The access of the embedded device to the internet is a big trend which cannot be blocked in the internet of things. The lightweight TCP/IP protocol stack can adapt to very limited storage capacity and computing resources in an embedded environment, realizes the basic functions of the TCP/IP protocol stack, and provides high-quality service for network connection of equipment.
Regardless of the size of application data, each data packet of the TCP/IP protocol needs to add a 40-byte data packet header before the data, a large amount of short frame data exists in embedded system communication, if the data is directly transmitted, a large amount of short frame data packets will be filled in the communication, and under a sliding window mechanism, receiving and transmitting windows will become very small, which not only greatly reduces the communication efficiency, but also easily causes network congestion. In order to avoid communication congestion, a Nagle algorithm is adopted at a sending end of a TCP/IP protocol to prevent data segments from being sent one by one, a delayed ACK strategy is adopted at a receiving end to delay the reply of an ACK packet, the data segments needing to be sent are stored in a cache by the sending end to form a large data packet, and the data packet is sent until the ACK packet is received. Therefore, the number of short frame data packets in communication can be greatly reduced, and the communication efficiency of the Ethernet is improved. Like a TCP/IP protocol stack, the LwIP protocol stack also adopts a Nagle algorithm and a delayed ACK strategy, but embedded Ethernet communication is mainly based on short frame data packets, and the Nagle algorithm and the delayed ACK strategy can greatly reduce the real-time performance of communication, which is particularly obvious in the application of unidirectional data transmission.
Chinese patent publication No. CN102413503A discloses a method for adaptive acknowledgement packet delay transmission of Semi-TCP, which designs an algorithm to calculate ACK delay interval and adaptively determine the time for sending the acknowledgement packet of the received data packet. But the purpose is to improve communication efficiency, avoid communication congestion instead of improving communication real-time, and the method is based on Semi-TCP instead of LwIP protocol stack.
Disclosure of Invention
In order to solve the defects of the prior art, the invention aims to provide a LwIP delay ACK timer period self-adaptive method based on data statistics, which improves the real-time performance of Ethernet communication on the premise of occupying the use efficiency of an embedded CPU as little as possible.
In order to achieve the above object, the present invention adopts the following technical solutions:
a self-adaptive method for delaying the period of an ACK timer based on data statistics is characterized by comprising the following steps:
step 1) a delayed ACK timer is independent from a fast timer of LwIP;
step 2) judging whether the period of the timer is appropriate or not by a period judging method based on data statistics;
step 3) carrying out corresponding processing on the value of the timer period according to the period judgment result;
and 4) resetting the delayed ACK timer period based on the inertia principle.
The self-adaptive method for the LwIP delayed ACK timer period based on data statistics is characterized in that the specific steps of the step 1) are as follows:
11) setting the period of a delayed ACK timer as a variable;
12) the function of sending delayed ACK packets is transferred to the delayed ACK timer handling function.
The LwIP delayed ACK timer period adaptive method based on data statistics is characterized in that the specific steps in the step 2) are as follows:
21) inquiring the working state of the Ethernet communication block when a delayed ACK timer processing function is entered, if the Ethernet communication block is in the delayed ACK state, setting Flag to 1, otherwise, setting Flag to 0;
22) get a new Flag when entering the delayed ACK timer handling function n +1 timesn+1Then Flagn+1The mark with the length of m is added into a mark storage sequence, the whole former mark is translated to the outlet end, and Flagn-mRemoving the fiber from the outlet end, wherein when n is 0, 1, 2, and n is less than or equal to m, the fiber is not removed from the outlet end;
23) and solving the sum of the current mark storage sequence, wherein if the sum of the sequences is equal to m, the period of the delayed ACK timer is over long, and if the sum of the sequences is less than the parameter l, the period of the delayed ACK timer is over short.
The self-adaptive method for delaying the ACK timer period based on the data statistics LwIP is characterized in that the specific content of the step 3) is as follows:
if the timer period is judged to be too long, dividing the value of the timer period by 2;
if the period of the timer is judged to be too short, if the period is not more than 20ms, adding 1 to the value of the period, and if the period is more than 20ms, adding 10 percent of the period.
The LwIP delayed ACK timer period adaptive method based on data statistics is characterized in that the specific content of the step 4) is as follows:
41) obtaining a new timing period T when entering the delayed ACK timer processing function n +1 timesn+1Then T isn+1Will be added to the periodic save sequence of length k, with all previous parameters shifted overall towards the exit, Tn-kRemoving from the outlet end, wherein when n is 0, 1, 2, …, and n is less than or equal to k, the removing from the outlet end does not occur;
42) and calculating the average value of the stored sequence in the current period, wherein all parameter types in the sequence are shaped, rounding the sequence average value, and setting the period of the delayed ACK timer as the current average value.
The LwIP delayed ACK timer cycle based on data statisticsThe phase self-adaption method is characterized in that the length m of the mark storage sequence ranges from 10 to 15, and the parameter l takes the value of
Figure BDA0001550608060000031
And l is an integer.
The LwIP delay ACK timer period self-adaptive method based on data statistics is characterized in that the length k of the period storage sequence ranges from 4 to 5.
The invention achieves the following beneficial effects: the invention can be directly applied to Ethernet communication of an embedded system, the sending period of a sending end is self-adapted in 1s, the real-time performance of communication can be greatly improved on the premise of ensuring the use efficiency of an embedded CPU, the communication period can be reduced to 1ms, and the communication delay is within 1 ms.
Drawings
FIG. 1 is a flow chart of a cycle determination method based on data statistics;
FIG. 2 is a schematic diagram of the update mode of the flag holding sequence;
FIG. 3 is a delayed ACK timer cycle processing flow diagram;
FIG. 4 is a flow diagram of a delayed ACK timer period reset based on inertial principles;
FIG. 5 is a diagram of the structure of an experimental system;
fig. 6(a) is a graph of the communication effect of a sine wave signal of an original LwIP protocol stack, and fig. 6(b) is a graph of the communication effect of a square wave signal of the original LwIP protocol stack;
fig. 7(a) is a diagram showing the effect of communication of a sine wave signal using the LwIP protocol stack of the present invention, and fig. 7(b) is a diagram showing the effect of communication of a square wave signal using the LwIP protocol stack of the present invention.
Detailed Description
The invention is further described below with reference to the accompanying drawings. The following examples are only for illustrating the technical solutions of the present invention more clearly, and the protection scope of the present invention is not limited thereby.
The inertia principle in the invention means that when the communication is stable, the period of the delayed ACK timer can not generate instantaneous rapid fluctuation, so that the current communication period can be calculated according to the period storage sequence in the latest period, and the period can not generate instantaneous rapid fluctuation when the communication is stable.
The method comprises the steps of judging whether a period is proper or not by a delay ACK timer of an independent LwIP protocol stack and adding a period judging method based on data statistics into the timer, correspondingly processing the value of the period of the timer according to a period judging result, and finally resetting the period of the delay ACK timer by utilizing an inertia principle. The LwIP protocol stack can greatly improve the real-time performance of communication on the premise of ensuring the use efficiency of the embedded CPU, the communication period can be reduced to 1ms, and the communication delay is within 1 ms.
The invention is further explained with reference to the specific embodiments, and the adaptive process of the LwIP delayed ACK timer period based on data statistics is as follows:
the structure diagram of the experimental system is shown in fig. 5, and mainly includes a signal generator, an oscilloscope, an embedded system a and an embedded system B. The embedded system ARM adopts a TM4C1294NCPDT processor, and an Ethernet physical layer is integrated in the processor, so that Ethernet communication is facilitated. The embedded system A acquires an analog signal provided by the signal generator through AD conversion, transmits data to the embedded system B through an RJ45 network port, converts the received data DA into the analog signal by the embedded system B, and finally demonstrates the communication effect by comparing the analog signal generated by the signal generator and the embedded system B on the oscilloscope.
Step 1) separating a delayed ACK timer in an LwIP protocol stack from a fast timer, resetting the period of the delayed ACK timer as a variable, and transferring the function of sending the delayed ACK packet to a processing function of the delayed ACK timer.
Step 21) inquiring the working state of the Ethernet communication block every time when a delayed ACK timer processing function is entered, if the Ethernet communication block is in the delayed ACK state, setting Flag to 1, otherwise, setting Flag to 0;
step 22) get a new Flag when entering the delayed ACK timer handling function n +1 timesn+1Then Flagn+1Adding the mark with the length of 10 to a storage sequence of the mark, and leading the whole of the former mark to an outletEnd translation, Flagn-10Removed from the outlet end.
Step 23) obtaining the sum of the current mark storage sequences, if the sum of the sequences is equal to 10, the period of the delayed ACK timer is too long, and if the sum of the sequences is less than the parameter 8, the period of the delayed ACK timer is too short.
Step 3) according to the period judgment result, correspondingly processing the value of the timer period: if the period of the timer is judged to be longer, the value of the period of the timer is divided by 2, if the period of the timer is judged to be shorter, if the period is not more than 20ms, the value of the period is added with 1, and if the period is more than 20ms, the value of the period is added with 10 percent of the period. As shown in fig. 3, ToldIndicating the old period, TnewIndicates a new circumfluence.
Step 41) obtaining a new timing period T when entering the delayed ACK timer processing function n +1 timesn+1Then T isn+1Will be added to the length-4 periodic save sequence, with all previous parameters shifted overall towards the exit, Tn-4Removed from the outlet end;
step 42) the average value of the stored sequence in the current period is obtained, all the parameter types in the sequence are shaped, the average value of the sequence is rounded, and the period of the delayed ACK timer is set as the current average value.
The embedded system A collects the analog signals generated by the signal generator once every 1ms, and after the collection is finished, the digital quantity is transmitted to the embedded system B through the Ethernet. The embedded system B converts the data into analog signals immediately after receiving the data.
The communication effect without the present invention is shown in fig. 6, fig. 6(a) shows the communication effect when the signal generator generates a sine wave signal, in which it can be seen that the communication period is only 250ms, and fig. 6(b) shows the communication effect when the signal generator generates a square wave signal, in which it can be seen that the delay is as high as 224 ms.
The actual communication effect after the invention is used is shown in fig. 7, fig. 7(a) is a graph showing the communication effect when the signal generator generates a sine wave signal, the communication period and reaching 1ms can be seen in the graph, fig. 7(b) is a graph showing the communication effect when the signal generator generates a square wave signal, the delay can be seen in the graph as 1.4ms, and the total time spent by the AD conversion and the DA conversion of the system is measured by experiments to be 960 mus, so the communication delay is reduced to 440 mus, and the invention greatly improves the real-time performance of communication. Different communication cycles are respectively set, the value of the timing cycle of the delayed ACK timer in the LwIP protocol stack at the moment is obtained through a JTAG port, the test is carried out for 4 times, the obtained data is shown in a table 1, and the table 1 shows that the method can ensure that the self-adaptive delayed ACK timer cycle is between 80 percent of the communication cycle and 100 percent of the communication cycle, so that the use efficiency of ARM can be improved on the basis of ensuring the real-time performance of communication.
Figure BDA0001550608060000071
The above description is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, several modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.

Claims (4)

1. A self-adaptive method for delaying the period of an ACK timer based on data statistics is characterized by comprising the following steps:
step 1) a delayed ACK timer is independent from a fast timer of LwIP;
step 2) judging whether the timer period is appropriate or not by a period judging method based on data statistics, and the method specifically comprises the following steps:
21) inquiring the working state of the Ethernet communication block when a delayed ACK timer processing function is entered, if the Ethernet communication block is in the delayed ACK state, setting Flag to 1, otherwise, setting Flag to 0;
22) get a new Flag when entering the delayed ACK timer handling function n +1 timesn+1Then Flagn+1The mark with the length of m is added into a mark storage sequence, the whole former mark is translated to the outlet end, and Flagn-mRemoving from the outlet end, wherein when n is 0, 1, 2, …, and n is less than or equal to m, the removing from the outlet end does not occur;
23) the sum of the current mark storage sequences is obtained, if the sum of the sequences is equal to m, the period of the delayed ACK timer is too long, and if the sum of the sequences is less than a parameter l, the period of the delayed ACK timer is too short;
step 3) correspondingly processing the value of the timer period according to the period judgment result, wherein the specific content is as follows:
if the timer period is judged to be too long, dividing the value of the timer period by 2;
if the period of the timer is judged to be too short, if the period is not more than 20ms, adding 1 to the value of the period, and if the period is more than 20ms, adding 10 percent of the period;
step 4) the period resetting of the delayed ACK timer based on the inertia principle comprises the following specific contents:
41) obtaining a new timing period T when entering the delayed ACK timer processing function n +1 timesn+1Then T isn+1Will be added to the periodic save sequence of length k, with all previous parameters shifted overall towards the exit, Tn-kRemoving from the outlet end, wherein when n is 0, 1, 2, …, and n is less than or equal to k, the removing from the outlet end does not occur;
42) and calculating the average value of the stored sequence in the current period, wherein all parameter types in the sequence are shaped, rounding the sequence average value, and setting the period of the delayed ACK timer as the current average value.
2. The LwIP delay ACK timer period adaptive method based on data statistics as claimed in claim 1, wherein the specific steps of step 1) are as follows:
11) setting the period of a delayed ACK timer as a variable;
12) the function of sending delayed ACK packets is transferred to the delayed ACK timer handling function.
3. The LwIP delay ACK timer period adaptive method based on data statistics as claimed in claim 2, wherein the length m of the flag storage sequence ranges from 10 to 15, and the parameter l takes the value of
Figure FDA0002763842510000021
And l is an integer.
4. The LwIP delay ACK timer period adaptive method based on data statistics as claimed in claim 3, wherein the length k of the period preservation sequence ranges from 4 to 5.
CN201810044900.4A 2018-01-17 2018-01-17 LwIP delay ACK timer period self-adaption method based on data statistics Active CN108418656B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810044900.4A CN108418656B (en) 2018-01-17 2018-01-17 LwIP delay ACK timer period self-adaption method based on data statistics

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810044900.4A CN108418656B (en) 2018-01-17 2018-01-17 LwIP delay ACK timer period self-adaption method based on data statistics

Publications (2)

Publication Number Publication Date
CN108418656A CN108418656A (en) 2018-08-17
CN108418656B true CN108418656B (en) 2021-01-08

Family

ID=63125878

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810044900.4A Active CN108418656B (en) 2018-01-17 2018-01-17 LwIP delay ACK timer period self-adaption method based on data statistics

Country Status (1)

Country Link
CN (1) CN108418656B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111262659B (en) * 2020-03-04 2021-02-19 华南理工大学 Semi-TCP grouping batch acknowledgement reply method based on fountain codes

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2006062328A1 (en) * 2004-12-08 2006-06-15 Electronics And Telecommunications Research Institute Retransmission and delayed ack timer management logic for tcp protocol
CN102413503A (en) * 2011-12-27 2012-04-11 上海海事大学 Method for adaptively determining packet delayed sending for Semi-TCP (transmission control protocol)

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7937470B2 (en) * 2000-12-21 2011-05-03 Oracle International Corp. Methods of determining communications protocol latency
US6961309B2 (en) * 2001-04-25 2005-11-01 International Business Machines Corporation Adaptive TCP delayed acknowledgment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2006062328A1 (en) * 2004-12-08 2006-06-15 Electronics And Telecommunications Research Institute Retransmission and delayed ack timer management logic for tcp protocol
CN102413503A (en) * 2011-12-27 2012-04-11 上海海事大学 Method for adaptively determining packet delayed sending for Semi-TCP (transmission control protocol)

Also Published As

Publication number Publication date
CN108418656A (en) 2018-08-17

Similar Documents

Publication Publication Date Title
CN109327288B (en) Data transmission acceleration method, device and system
CN107171969B (en) Data transmission method, device and system
CN109120544B (en) Transmission control method based on host end flow scheduling in data center network
CN109039936B (en) Transmission rate control method, device, sending equipment and receiving equipment
WO2017124985A1 (en) Data transmission method and related device
EP1701506B1 (en) Method and system for transmission control protocol (TCP) traffic smoothing
CN112104562B (en) Congestion control method and device, communication network and computer storage medium
WO2012126424A2 (en) Method and device for forwarding data packet
JP2004523992A (en) Data flow control method
WO2012089110A1 (en) Systems and methods to improve performance of tcp over large bandwidth-delay-product networks
WO2020134755A1 (en) Data transmission method and device
CN101599965A (en) Based on the self-adaption high-speed information transmission protocol of measuring
CN108418656B (en) LwIP delay ACK timer period self-adaption method based on data statistics
Huang et al. Packet slicing for highly concurrent TCPs in data center networks with COTS switches
CN101969432B (en) Random backoff based control method of TCP (Transmission Control Protocol) congestion window
KR100922472B1 (en) Communication terminal, communication control method, and communication control program
CN101562567B (en) Method and server for processing messages
WO2013185480A1 (en) Method and device for obtaining throughput rate
Han et al. A QoS-based fairness-aware BBR congestion control algorithm using QUIC
EP2383647A1 (en) Networking system call data division for zero copy operations
CN111314961A (en) TCP transmission method, device and system
CN104580171B (en) The transmission method of Transmission Control Protocol, device and system
EP3108631B1 (en) Buffer bloat control
Al-Saadi et al. Characterising LEDBAT performance through bottlenecks using PIE, FQ-CoDel and FQ-PIE active queue management
Dayma et al. Improved TCP Hybla: A TCP enhancement for link with high RTT and error rate

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant