当前位置:网站首页>TCP three handshakes you need to know
TCP three handshakes you need to know
2022-07-06 04:51:00 【Front end watermelon brother】
TCP, Full name Transmission Control Protocal. From the name, we can know that it is used for Control transmission The protocol at the transport layer .
TCP be located TCP/IP and OSI The transport layer of the model . What we use most HTTP agreement , The bottom layer usually uses TCP agreement .
If you want to create TCP Connect , We need to send three requests at the beginning to confirm that the communication ability of both sides is normal , These three connections are called TCP Three handshakes of .
TCP Three handshakes of
The following figure for TCP The structure of the head , our TCP The three handshakes mainly use the yellow part .

Now let's talk about these three handshakes .
The first handshake
The client sends a... To the server TCP message . stay TCP In the head :
take SYN The flag bit is set to 1;
And then to seq Assign a random number ( Suppose the random number is x)
The so-called flag bit , It's actually one bit of data , Set to 1 , In fact, it is similar to programming to set a Boolean value to true.
SYN On behalf of the synchronization (sync) It means ,seq It's the serial number (Sequence number) It means , Is a place where values can be loaded , We set it as a random number , It is used as a voucher (token) Of , The server will use it later .
The second handshake
Server received SYN, Know that the client wants to establish TCP Connect , And got one seq random number .
The server then sends TCP message ,TCP In the head :
take ACK The flag bit is set to 1, Means known (acknowledge) Client's connection request ;
ack The value of is set to that passed by the client seq value + 1( namely x+1);
take SYN The flag bit is set to 1, It means that the server should also be connected ;
seq Set a random number with the value of ( Suppose the random number is y)
Server through ACK and ack To inform the client that the connection request is known , And send your own SYN and seq To request a connection with the client .
The third handshake
Client received TCP request , Verify first SYC Is it 1, seq Is it x+1.
If it is , It indicates that the sending of the server is the return of the first handshake . The client will send another TCP request :
ACK Set to 1;
ack Set as the server ack Value + 1( namely y + 1)
After three handshakes ,TCP The connection is established .
summary
Three handshakes , Simply speaking , That's it :
client -> Server side :SYN=1, seq=x (x Is a random number )
Server side -> client :ACK=1, ack=x+1, SYN=1, seq=y (y Is a random number )
client -> Server side :ACK=1, ack=y+1

I'm brother watermelon , Welcome to follow me , Master more front-end interview questions .
边栏推荐
- Chip debugging of es8316 of imx8mp
- RTP gb28181 document testing tool
- Some common skills on unity inspector are generally used for editor extension or others
- 关于Unity Inspector上的一些常用技巧,一般用于编辑器扩展或者其他
- Fuzzy -- basic application method of AFL
- canal同步mysql数据变化到kafka(centos部署)
- Sqlserver query results are not displayed in tabular form. How to modify them
- Application of Flody
- The video in win10 computer system does not display thumbnails
- Postman assertion
猜你喜欢

Postman关联

Acwing week 58

yolov5 tensorrt加速

麦斯克电子IPO被终止:曾拟募资8亿 河南资产是股东

比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元

Use sentinel to interface locally

Why does MySQL need two-phase commit

Basic explanation of turtle module - draw curve

RTP GB28181 文件测试工具

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
随机推荐
2021RoboCom机器人开发者大赛(初赛)
Orm-f & Q object
Canal synchronizes MySQL data changes to Kafka (CentOS deployment)
Lepton 无损压缩原理及性能分析
Basic explanation of turtle module - draw curve
yolov5 tensorrt加速
Finance online homework
Luogu deep foundation part 1 Introduction to language Chapter 2 sequential structure programming
A little knowledge of CPU, disk and memory
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
麦斯克电子IPO被终止:曾拟募资8亿 河南资产是股东
SQL injection vulnerability (MSSQL injection)
Embedded development program framework
Scala function advanced
集合详解之 Collection + 面试题
The kernel determines whether peripherals are attached to the I2C address
集合详解之 Map + 面试题
Sqlserver query results are not displayed in tabular form. How to modify them
Redis 排查大 key 的4種方法,優化必備
ISP learning (2)