当前位置:网站首页>The difference between TCP and UDP, the three handshakes of TCP and the four waves of TCP
The difference between TCP and UDP, the three handshakes of TCP and the four waves of TCP
2022-06-12 15:22:00 【Stars_ min】
One 、 TCP And UDP The difference between
1. The same thing
All belong to the transport layer protocol
2. Difference
| TCP | UDP | |
|---|---|---|
| 1 | Based on connections , High reliability | Based on connectionless , Low reliability |
| 2 | It takes three handshakes 、 Reconfirmation and other processes , Poor real-time , At the same time, the process is complex , Vulnerable to attack | There is no connection , Therefore, the real-time performance is very strong , A little safer |
| 3 | When transmitting data of the same size , Headlines 20 byte , and tcp No packet loss , Costly | When transmitting data of the same size ,udp The first cost is only 8 Bytes , and udp Frequent packet loss , It's a small expense |
| 4 | Every one of them tcp Connections can only be point-to-point | udp Support one-to-one 、 One to many 、 For one more 、 Many to many interactive communication |
| 5 | It's called transmission control protocol , Low transmission efficiency , High reliability | Called user datagram protocol , It is suitable for low reliability transmission , A small amount of data |
Two 、 TCP Three handshakes of
TCP Some nouns need to be explained , To understand
1. A term is used to explain
SYN: Sync serial number , Used to initiate a connection ,SYN=1 Can't carry data , But it consumes a sequence
ACK: Confirm logo , When ACK=1 The confirmation field is valid only when
seq: Serial number , That is, the serial number of the packet itself , Use... For data transmission after connection
ack: Acknowledgement of receipt of a packet , The value is the sequence number of the packet waiting to be accepted ( Is the serial number of the packet that the other party is expected to continue sending )
2. Handshake process


for the first time : client C To the server S Send connection request message , In the header of the message SYN = 1,ACK = 0, Pick a serial number at random seq = i As the initial serial number ,
At this time, the client enters SYN_SEDN Sync sent status .
The second time : The server receives the connection request message from the client , If you agree to establish a connection , Then send a confirmation message , Confirm... In the header of the message SYN = 1 , ACK = 1 ,
ack = i + 1 ,seq = j ( The initial serial number of the server ), here , Server entry SYN_RCVD Sync receive status .
third time : After the client receives the confirmation message from the server , A confirmation message will be sent to the server , Tell the server that it has received its acknowledgement message and is ready to establish a connection , In the header of the confirmation message SYN = 0、
ACK = 1、ack = j + 1、 seq = i + 1. The server receives the client confirmation message , here , Server access ESTABLISHED Connection state established .
3. TCP Why use three handshakes , Instead of shaking hands twice or four times
TCP The purpose of the third handshake is to synchronously connect the serial number and confirmation number of both parties , And exchange TCP Window size information
Why use three handshakes : To prevent invalid request message segments from being accepted by the server , So there's a mistake .
source :TCP Why use three handshakes , Not two or four handshakes
3、 ... and 、 TCP Four waves ( Release )


Active shutdown by one party , The other side closes passively
for the first time : client C Send a FIN, Used to close the client C To the server S Data transfer of , client C Get into FIN-WAIT-1 state
The second time : Server side S received FIN after , Send a ACK To the client C, Confirm that the serial number is the received serial number +1, Server side S Get into CLOSE-WAIT
third time : Server side S Send a FIN, Used to close the server S To client C Data transfer of , Server side S Get into LAST-ACK
The fourth time : client C received FIN after , client C Get into TIME-WAIT state , And then send a ACK To the server S,
Confirm that the serial number is the received serial number +1, Server side S Get into CLOSE state , Complete the fourth wave .
边栏推荐
- Solution to the new database prompt on the pagoda panel that the database name cannot be greater than 16 bits
- Function related matters
- How to add WWW to the domain name
- Use of thread communication
- Self induction of exception handling
- 安装rhel 7/8 (红帽)虚拟机(转载)
- Wild pointer understanding
- Idea pull branch code
- 2021-06-20
- What is reflection-- The soul of frame design
猜你喜欢

IMU的学习记录

Understanding of Odom coordinate system

ROS beginners write the server that the little turtle rotates a certain angle at a certain speed

虚拟机中用户和root忘记密码解决办法

Array related content

Xshell 7 official website free download

简单的爬虫框架:解析51job页面岗位信息
![[LDA] LDA theme model notes - mainly Dirichlet](/img/e0/bc96b141aa577106379fab63d9df40.png)
[LDA] LDA theme model notes - mainly Dirichlet

Two ways of array simulating queue

PTA:自测-3 数组元素循环右移问题 (20分)
随机推荐
IMU learning records
C escape character
如何写年终总结
FIRSTVT and LASTVT vernacular
Kinect2.0+ORBSLAM2_with_pointcloud_map
USART (rs232422485), I2C, SPI, can, USB bus
简单的爬虫框架:解析51job页面岗位信息
Raccourci vers le nouvel environnement du carnet de notes Jupiter
频繁项集产生强关联规则的过程
Microservice fault tolerance
Acwing summer daily question (sexy prime number on June 10)
学习是一件逆人性的事情(成为高手的内功心法)
Function recursion example
[spark][core] what is an external shuffle service?
Xshell 7 official website free download
[jvm learning] parental delegation mechanism and PC register (program counter)
Two ways of array simulating queue
Qiming Zhixian shares the application scheme of 2.8-inch handheld central control screen
Learning is an inhumane thing (becoming an expert's internal mind skill)
學習是一件逆人性的事情(成為高手的內功心法)