当前位置:网站首页>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 .
边栏推荐
- C main function
- 使用CSDN-markdown编辑器
- Loadbalancer load balancer
- [untitled]
- IMU learning records
- Qiming Zhixian shares the application scheme of 2.8-inch handheld central control screen
- Prompt that the program cannot access key files / directories when installing PS software. Error code: 41
- Open Chinese path file in C language
- Simple crawler framework: parsing 51job page position information
- How to add WWW to the domain name
猜你喜欢
随机推荐
Two ways of array simulating queue
Module yaml error: Unexpected key in data: static_ context [line 9 col 3]
Conversion between sparse array and array and file reading and writing
Solve log4j2 vulnerability and be attacked by mining and zombie process viruses
Rust tip - running the tensorrt model through FFI programming
[jvm learning] types of GC and allocation process of objects on JVM heap
Summary of advantages and disadvantages of various architectures
广播和多播(TCP/IP详解卷1/2)
Raccourci vers le nouvel environnement du carnet de notes Jupiter
Self induction of exception handling
Deepin20.6 rtx3080 installing graphics card drivers 510.60.02, cuda11.6, pytorch1.11
Kinect2.0+ORBSLAM2_ with_ pointcloud_ map
远程操控其它电脑--详细教程
Acwing summer daily question (sexy prime number on June 10)
Introduction to microservices
How to add WWW to the domain name
Pta: self test -3 array element cyclic right shift problem (20 points)
Use of boost:: bind() in ROS
Servlet连接数据库实现用户登录功能
CUDA out of memory 或 BrokenPipeError: [Errno 32] Broken pipe 或 OSError: [WinError 1455] 页面文件太小的解决办法

![[jvm learning] local method stack and heap](/img/5d/2e0b758ae52cfdc0d060431df19eea.jpg)






