编程知识 cdmana.com

ACK definition and delay confirmation mechanism in Linux

One 、ACK Definition

TCP Agreement , After the receiver successfully receives the data , Will reply one ACK Data packets , It means that you have confirmed the receipt of ACK All the data in front of the confirmation number .
ACK The length of the field is 32 position , Can express 0~2^32-1 Between the value of the .

Two 、ACK effect

The sender did not receive the server's ACK After confirming the package , It will resend TCP Data packets . The sender received it ACK, Indicates that the receiver has received the data , Ensure the reliability of the data .

3、 ... and 、ACK Mechanism

After receiving the data , Not immediately to the sender ACK Of . This can be caused by :
1、 Before the serial number of the received data packet, there are packets to be received . Because when the sender sends data , You don't have to wait until the data was sent last time Ack You can continue sending TCP package , And these TCP The order in which packets arrive is not guaranteed , In this way, the receiver may receive and then send TCP package ( Note that the submission to the application layer is sequential ).
2、 In order to reduce network traffic ,ACK There is a delay confirmation mechanism .
3、ACK After reaching the maximum value of , And from 0 Start .


Four 、ACK Delay confirmation mechanism

After receiving the data , Not immediately ACK, It's a delay . commonly ACK The delay time is 200ms, But this 200ms It's not the amount of time you need to delay after you receive the data . The system has a fixed timer every 200ms Will check if you need to send ACK package .
There are two purposes to do this :
1、 Doing so The purpose is ACK It can be combined , That is, if you receive two in a row TCP package , It doesn't have to be ACK two , Just reply to the final ACK That's all right. , Can reduce network traffic .
2、 If The receiver has data to send , Then the data will be sent TCP In the packet , close ACK Information . To do so , Can avoid a lot of ACK With a single TCP Packet sending , Reduced network traffic .


Delay confirmation (Delayed Ack)
 setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){
   
   1}, sizeof(int))

Generally speaking, it is related to nagle Use... In specific situations

版权声明
本文为[osc_ 7ac8o6u9]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224084836738q.html

Scroll to Top