当前位置:网站首页>TCP (sliding window, flow control)
TCP (sliding window, flow control)
2022-06-10 04:26:00 【little-peter】
We discussed the acknowledge response strategy earlier , For each data segment sent , Give one ACK Confirm response , received ACK Then send the next data segment .
There is a big disadvantage in doing so , It's just poor performance , Especially when the data round-trip time is long .

The sliding window
Since the performance of this one send one receive method is low , So we send multiple pieces of data at a time , It can greatly improve the performance ( In fact, it overlaps the waiting time of multiple segments )

- Window size refers to the maximum value that can continue to send data without waiting for an acknowledgement . The window size in the above figure is 4000 Bytes ( Four sections ).
- When sending the first four segments , There's no need to wait for any ACK, Direct transmission ;
- Got the first one ACK after , Slide the window back , Continue to send the data of the fifth segment ; By analogy ;
- The operating system kernel maintains this sliding window , It needs to be opened up Send buffer To record what data is not answered ; Only confirm the data that has been answered , To delete from the buffer ;
- The greater the window , The higher the throughput of the network
So if there is packet loss , How to retransmit ? There are two situations to discuss here .
Situation 1 : The packet has arrived ,ACK Lost

In this case , part ACK It doesn't matter if you lose it , Because it can be through subsequent ACK Confirm ;
ACK=6001 The meaning of , Not telling the host A I have received 5001-6000 Data between , It tells the host A I have received 0-6000 Between the .
Situation two : Packet loss

- When a message segment is lost , The sender will always receive 1001 In this way ACK, It's like reminding the sender " What I want is 1001" equally
- If the sending host receives the same message three times in a row "1001" Such a response , The corresponding data will be 1001 -2000 To resend ;
- At this time, the receiver receives 1001 after , Return again ACK Namely 7001 了 ( because 2001 - 7000) In fact, the receiving end has already received , It is placed in the receive buffer of the receiving operating system kernel
This mechanism is called " High speed retransmission control "( Also called " Fast retransmission ")
flow control
The speed of data processing at the receiving end is limited . If the sender sends too fast , This causes the buffer at the receiving end to be full , At this time, if the sender continues to send , It will cause packet loss , Then it causes a series of chain reactions such as packet loss and retransmission
therefore TCP Support according to the processing capacity of the receiving end , To determine the sending speed of the sender . This mechanism is called flow control (Flow Control)
- The receiver puts the size of the buffer it can receive into TCP In the first part " Window size " Field , adopt ACK The sending end is informed by the sending end ;
- The larger the window size field , The higher the throughput of the network ;
- Once the receiver finds that its buffer is almost full , It will set the window size to a smaller value and inform the sender ;
- After the sender receives this window , It will slow down your sending speed ;
- If the receiving buffer is full , Will set the window to 0; At this time, the sender no longer sends data , However, a window probe data segment needs to be sent periodically , Make the receiving end tell the sending end the window size .
There is no need to pass it around
( See the courseware for details )
Used to review :https://blog.csdn.net/dangzhangjing97/article/details/81008836?
Delay response
If the host receiving the data immediately returns ACK The reply , At this time, the return window may be smaller
- Assume that the receiver buffer is 1M. Once received 500K The data of ; If you answer immediately , The returned window is 500K;
- But in fact, the processing speed of the processing end may be very fast , 10ms Put... In 500K Data is consumed from the buffer ;
- under these circumstances , The receiving end processing is far from reaching its limit , Even if the window is a little bigger , Can handle it ;
- If the receiver waits a little while before answering , Such as waiting for 200ms Answer again , Then the window size returned at this time is 1M
Remember that , The greater the window , The greater the network throughput , The higher the transmission efficiency . Our goal is to improve the transmission efficiency as much as possible without congestion
Can all packets delay the response ? Certainly not
- Quantitative restriction : every other N Just one response per packet ;
- The time limit : Answer once when the maximum delay time is exceeded
Specific number and timeout , Depending on the operating system ; commonly N take 2, The timeout time is taken as 200ms

Take a reply
Performance optimization for delay response
On the basis of delayed response , We found that , In many cases , The client server is also in the application layer " Send and receive " Of . It means that the client says to the server "How are you", The server will also give a reply to the client "Fine, thank you";
So at this point ACK You can take a ride , And server response "Fine, thank you" Back to the client together
边栏推荐
- Why use layer 3 switches
- [机缘参悟-16]:金字塔层次结构符合天道自然
- 91. fence
- Good news 𞓜 wangchain technology signed the Miluo cultural, tourism and sports industry project to create a digital village on the "chain"
- 497. random points in non overlapping rectangles
- idea中怎樣編寫Scala代碼
- [in depth study of 4g/5g/6g topic -25]: 5g NR startup process 4.3 - first scheduling of RRC connection request message msg3/rrcsetuprequest and Pusch uplink channel
- Pampy | 超强的模式匹配工具
- 5- common tool management
- [机缘参悟-20]:鬼谷子-反应篇-动静之术、说听结合、沉默是金
猜你喜欢

tensorflow 中的 cross_entropy

分布式数据对象:超级终端的'全局变量'

Jenkinsclient | easy to use Jenkins client

Pytoch cpu/gpu installation method.
![[激光器原理与应用-1]:什么是激光器以及激光器的常见应用](/img/90/d463b762e546154a6427404fa0de8d.jpg)
[激光器原理与应用-1]:什么是激光器以及激光器的常见应用

Fastapi-15-file upload-3

Today, 19:30 | graphics special session - Gao Lin's team from Institute of computing technology, Chinese Academy of Sciences

3- programming language -- golang website learning
![[understanding of opportunity -16]: Pyramid hierarchy conforms to nature](/img/d3/799e67b6dc825758927191d2ef8c4f.jpg)
[understanding of opportunity -16]: Pyramid hierarchy conforms to nature

Use 80% of the charts to meet daily work, and use the remaining 20% of the charts to build core competitiveness!
随机推荐
Golang learning 4: closures and defers
图解固件、驱动、软件的区别
[深入研究4G/5G/6G专题-31]: 5G NR开机流程5.2 - UE Attach流程(Registeration Request/Accept/Complete)
[in depth study of 4g/5g/6g topic-23]: 5g NR startup process 4.1 - scheduling of the first uplink channel between MSG1 and PRACH and detection of time advance ta
Common database field type mapping relationships
[深入研究4G/5G/6G专题-23]: 5G NR开机流程4.1 - 随机接入请求消息MSG1与PRACH首个上行信道的调度、时间提前量TA的检测
QT cannot connect to local MySQL
Two modes of epoll and epoll reactor
Webcodecs parsing GIF graph
[in depth study of 4g/5g/6g topic -28]: 5g NR startup process 4.6 - msg5 (rrcsetupcomplete) message scheduling
Puzzling color deviation of unity illumination black
Pytoch cpu/gpu installation method.
Ammonium tech, a well-known network security hardware platform manufacturer, joined dragon lizard community
[科技特长-1]:科技特长生概述与优势
Celery | task queue artifact
Metersphere | a super easy-to-use open source testing platform
Use 80% of the charts to meet daily work, and use the remaining 20% of the charts to build core competitiveness!
常见的数据库-字段类型映射关系
[in depth study of 4g/5g/6g topic -27]: 5g NR startup process 4.5 - RRC connection response message msg4, first scheduling of PUCCH uplink control channel, UCI and HARQ response
[enlightenment -18]: Confucianism, Buddhism and Taoism, different life stages, different choices