当前位置:网站首页>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 .
边栏推荐
- DMA use of stm32
- Biscuits (examination version)
- 项目经理,你会画原型嘛?项目经理需要做产品设计了?
- The web project imported the MySQL driver jar package but failed to load it into the driver
- Ue5 small knowledge freezerendering view rendered objects in the cone
- [NOIP2008 提高组] 笨小猴
- Postman pre script - global variables and environment variables
- Orm-f & Q object
- RT thread analysis log system RT_ Kprintf analysis
- Postman Association
猜你喜欢
How to estimate the population with samples? (mean, variance, standard deviation)
Extension of graph theory
DMA use of stm32
SQL injection vulnerability (MSSQL injection)
IPv6 comprehensive experiment
比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
Postman assertion
Codeforces Round #804 (Div. 2)
Use sentinel to interface locally
Postman pre script - global variables and environment variables
随机推荐
Weng Kai C language third week 3.1 punch in
2021 RoboCom 世界机器人开发者大赛-本科组(复赛)
Etcd database source code analysis -- etcdserver bootstrap initialization storage
canal同步mysql数据变化到kafka(centos部署)
内核判断i2c地址上是否挂载外设
[NOIP2009 普及组] 分数线划定
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
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
Programmers' position in the Internet industry | daily anecdotes
Microblogging hot search stock selection strategy
Crazy God said redis notes
[Yu Yue education] reference materials of complex variable function and integral transformation of Northwestern Polytechnic University
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
Fuzzy -- basic application method of AFL
Digital children < daily question> (Digital DP)
MySQL reported an error datetime (0) null
word封面下划线
[FreeRTOS interrupt experiment]
关于imx8mp的es8316的芯片调试
Scala function advanced