当前位置:网站首页>Differences between TCP and UDP
Differences between TCP and UDP
2022-06-26 04:40:00 【Half crazy and half bumpy】
Common seven story application diagram :

1. TCP Connection process ( Three handshakes )
As shown in the figure below , You can see to create a TCP The process of connection is ( Three handshakes ):

The first handshake
The client sends the connection request message segment to the server . The message segment contains its own initial data communication serial number . After the request is sent , The client enters SYN-SENT state .
The second handshake
After the server receives the connection request message segment , If you agree to connect , A response will be sent , The response will also contain its own initial data communication serial number , After sending, enter SYN-RECEIVED state .
The third handshake
When the client receives the reply of the connection consent , Also send a confirmation message to the server . After the client sends this message segment, it will enter ESTABLISHED state , After receiving this response, the server will enter ESTABLISHED state , At this time, the connection is established successfully .
There may be a doubt here : Why? TCP Establishing a connection requires three handshakes , Not twice ? This is to prevent the invalid connection request message segment from being received by the server , So there's a mistake .
2.TCP break link ( Four waves )

TCP It's full duplex , Both ends need to send... When disconnected FIN and ACK.
The first handshake
If the client A Think data transmission is complete , Then it needs to go to the server B Send connection release request .
The second handshake
B After receiving the connection release request , Will tell the application layer to release TCP link . Then it will send ACK package , And enter CLOSE_WAIT state , At this point, it means A To B The connection of has been released , No longer receive A Data sent . But because TCP The connection is two-way , therefore B You can still send data to A.
The third handshake
B If there is still unfinished data at this time, it will continue to send , When it's done, I'll go to A Send connection release request , then B Then enter LAST-ACK state .
The fourth handshake
A After receiving the release request , towards B Send a confirmation response , here A Get into TIME-WAIT state . This state will last 2MSL( The maximum survival period , It refers to the time of message segment in the network , Overtime will be abandoned ) Time , If there is no B If you want to resend the request , To get into CLOSED state . When B After receiving the confirmation reply , And then I went into CLOSED state .
TCP and UDP The difference between
Refer to the below

summary :
- TCP Provide reliable connection oriented services to the upper layer ,UDP Provide connectionless and unreliable services to the upper layer .
- although UDP did not TCP The transmission is accurate , But it can also make a difference in many places with high real-time requirements
- High requirements for data accuracy , The speed can be relatively slow , May choose TCP
边栏推荐
- What is the best way to store chat messages in a database? [Close] - best way to store chat messages in a database? [closed]
- Nightmare
- Notes on enterprise wechat development [original]
- Database design (I)
- SSH password free login, my server password free login to the other server, the other server password free login to your server
- Problem follow up - PIP source change
- Laravel framework Alipay payment fails to receive asynchronous callback request [original]
- 1.19 learning summary
- Oracle 数据泵导表
- Mobile terminal pull-down loading pull-down loading data
猜你喜欢

6、 Project practice --- identifying cats and dogs

2021-01-31

Gateway can not connect to tcp://127.0.0.1: Connection refused

Performance test comparison between PHP framework jsnpp and thinkphp6

#微信小程序# 在小程序里面退出退出小程序(navigator以及API--wx.exitMiniProgram)

How to carry out word-of-mouth marketing for enterprises' products and services? Can word of mouth marketing be done on behalf of others?

1.19 learning summary

2.9 learning summary
![Notes on enterprise wechat development [original]](/img/66/cd83f4f86b7c42921db45f07957c15.jpg)
Notes on enterprise wechat development [original]

A new paradigm for large model application: unified feature representation optimization (UFO)
随机推荐
Numpy data input / output
Numpy general function
What is the best way to store chat messages in a database? [Close] - best way to store chat messages in a database? [closed]
TP5 distinct method paging problem
Tp6 multi table Association (table a is associated with table B, table B is associated with table C, and table d)
Realize video call and interactive live broadcast in the applet
Gateway can not connect to tcp://127.0.0.1: Connection refused
PHP syntax summary
Anti withdrawal test record
pip 批量完全卸载包
条件查询
Be a hard worker from today on
Redis cache message queue
小程序中实现视频通话及互动直播功能
2022.2.13
There is no response to redirection and jump in the laravel constructor [original]
1.19 learning summary
[H5 development] 03- take you hand in hand to improve H5 development - single submission vs batch submission with a common interface
Rdkit chemical formula molecular formula search
Multipass中文文档-使用实例命令别名