当前位置:网站首页>How TCP protocol ensures reliable transmission
How TCP protocol ensures reliable transmission
2020-11-08 09:45:17 【Total cost】
About “tcp How protocols ensure reliable transmission ” This problem , The information on the Internet is uneven . Recently, I began to read some textbooks in the library , Read the following bibliography with questions about TCP Chapter of , The summary is recorded .
- University of Potsdam, Germany 《internetworking Technische Grundlagen und Anwendungen》/《 Network technology foundation and Application 》(christoph meinel,harald sack)
- 《 In depth understanding of computer networks 》( Wang Da )
- 《 Computer network tutorial top-down method 》(Behrouz A.Forouzan Firouz Mosharraf)
- 《 computer network 》( Zhang Zengke 、 Yang Xianhui )
- 《 computer network 》 The first 7 edition ( Xie Xiren )
Why? TCP We need reliable transmission
- The network layer is unreliable . The task of the network layer is only to select the appropriate inter network routing and switching nodes , Make sure the data is transmitted in time .
- Due to the nature of the transport layer , The upper level needs reliability . Therefore, the main task of transport layer is to make the best use of network resources according to the characteristics of communication subnet , And Reliability and economy The way , Between the conversation layers , Provide to build 、 Function of maintaining and canceling transmission connection , Responsible for reliable transmission of data .
- UDP By sacrificing reliability , In exchange for best effort delivery 、 High communication efficiency 、 Ensure the real-time characteristics of the data . Natural needs TCP Appearance , Come on Use needs complement each other .
So the above 3 spot , The burden of reliable transmission has been placed on TCP above .
TCP How to achieve reliable transmission
For the purpose of reliable transmission ,TCP Use 4 Solutions : Connection oriented transport mechanism 、 Timeout retransmission control 、 Variable sliding window flow control 、 Congestion control .
Connection oriented transport mechanism
Used Three handshakes 、 Four waves , This is more common , Everybody is familiar with , There is no redundancy .
The checksum , Confirm response (ACK), Serial number .
And it doesn't work for repetition ACK To deal with , Take it and discard it , Realize automatic retransmission request .
Timeout retransmission control
When the message is sent, the receiver's confirmation is not received within a certain period of time , The sender will retransmit . Every time a packet is sent , Just set up a Timeout retransmission timer , When the other party returns ack, To undo the set timeout timer . To achieve this , There are three points to note :
- Keep after sending copy , For retransmission , Received the return of the other party ack after , To clear the copy .
- Number .
- The time setting of the timeout retransmission timer takes the delay into account 、 Congestion and other uncertain factors , thus Retransmission time The setting will be longer than the average round-trip time of data packets .
Variable slide window flow control
The window is divided into sending window and receiving window . Briefly , The receiver puts the acceptable data size ( Accept window size ), adopt ACK Feedback to the sender , To set the coordinated sending content size . The details are as follows :
- When the sending data exceeds the size of the receiver window , Retransmit the excess ;
- When the sending data is smaller than the size of the receiver window , The sender continues to send the content ;
- Not for every segment ACK Reply to , When possible, one or more segments , Send a ACK;
- When the number of received message segments is missing , The received segment is stored in the cache , Wait for the sender to retransmit the missing segment ; Merge complete , Back again ACK; If the missing segment is not received for a long time , Then the message segments in the cache will be emptied .
Congestion control
There are four kinds of control algorithms : Slow start 、 Congestion avoidance 、 Fast retransmission and fast recovery .
- Slow start : Gradually increase the value of congestion window from small to large .
Initial value of congestion window = 1 The value of the maximum segment to two senders ;
Congestion window increases each time = min( The number of bytes of the newly received acknowledgement message , The value of the maximum message segment of the sender ).
- Congestion avoidance : Let the congestion window slow down and increase .
Every time I pass by RTT Just slide the window size and just add 1;
- Fast retransmission : The data received by the receiver shall be confirmed immediately , A packet returns a confirmation ACK, In order to know the loss of individual messages as soon as possible .
for example , When sending M3 Packet loss , The receiver only received M2 And M4 Packet time , The receiver returns in succession 3 individual M2 Of ACK To the sender ( The sender is missing M3 Little brother );
The sender received 3 A continuous M2 Of ACK after , immediately Retransmission M3 Data packets .
- Fast recovery : After encountering network congestion , Reduce congestion window immediately .
Set up a ssthresh As a starting point for using congestion avoidance algorithms , Through this ssthresh value It is half of the maximum threshold of sliding window .
Understand the above four algorithms , It's easy to look at the picture below :
summary :TCP Because it's in the transport layer , The essential , Solve the unreliable problem of the lower network layer , Provides a reliable connection to the session layer ; And realize the right to UDP The use of complementary .
TCP Reliability is mainly through connection oriented transport mechanism 、 Timeout retransmission control 、 Variable sliding window flow control 、 Congestion control implementation .
版权声明
本文为[Total cost]所创,转载请带上原文链接,感谢
边栏推荐
- C++ 数字、string和char*的转换
- C++学习——centos7上部署C++开发环境
- C++学习——一步步学会写Makefile
- C++学习——临时对象的产生与优化
- C++学习——对象的引用的用法
- C++编程经验(6):使用C++风格的类型转换
- Won the CKA + CKS certificate with the highest gold content in kubernetes in 31 days!
- C + + number, string and char * conversion
- C + + Learning -- capacity() and resize() in C + +
- C + + Learning -- about code performance optimization
猜你喜欢
-
C + + programming experience (6): using C + + style type conversion
-
Latest party and government work report ppt - Park ppt
-
在线身份证号码提取生日工具
-
Online ID number extraction birthday tool
-
️野指针?悬空指针?️ 一文带你搞懂!
-
Field pointer? Dangling pointer? This article will help you understand!
-
HCNA Routing&Switching之GVRP
-
GVRP of hcna Routing & Switching
-
Seq2Seq实现闲聊机器人
-
【闲聊机器人】seq2seq模型的原理
随机推荐
- LeetCode 91. 解码方法
- Seq2seq implements chat robot
- [chat robot] principle of seq2seq model
- Leetcode 91. Decoding method
- HCNA Routing&Switching之GVRP
- GVRP of hcna Routing & Switching
- HDU7016 Random Walk 2
- [Code+#1]Yazid 的新生舞会
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- HDU7016 Random Walk 2
- [code + 1] Yazid's freshman ball
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- Qt Creator 自动补齐变慢的解决
- HALCON 20.11:如何处理标定助手品质问题
- HALCON 20.11:标定助手使用注意事项
- Solution of QT creator's automatic replenishment slowing down
- Halcon 20.11: how to deal with the quality problem of calibration assistant
- Halcon 20.11: precautions for use of calibration assistant
- “十大科学技术问题”揭晓!|青年科学家50²论坛
- "Top ten scientific and technological issues" announced| Young scientists 50 ² forum
- 求反转链表
- Reverse linked list
- js的数据类型
- JS data type
- 记一次文件读写遇到的bug
- Remember the bug encountered in reading and writing a file
- 单例模式
- Singleton mode
- 在这个 N 多编程语言争霸的世界,C++ 究竟还有没有未来?
- In this world of N programming languages, is there a future for C + +?
- es6模板字符
- js Promise
- js 数组方法 回顾
- ES6 template characters
- js Promise
- JS array method review
- 【Golang】️走进 Go 语言️ 第一课 Hello World
- [golang] go into go language lesson 1 Hello World