当前位置:网站首页>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 .
边栏推荐
- Finance online homework
- 力扣(LeetCode)186. 翻转字符串里的单词 II(2022.07.05)
- Can CDC pull the Oracle table in full
- 几种RS485隔离通讯的方案介绍
- RT thread analysis log system RT_ Kprintf analysis
- 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
- Class inheritance in yyds dry inventory C
- 集合详解之 Map + 面试题
- RT thread analysis - object container implementation and function
- Postman manage test cases
猜你喜欢
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
Postman assertion
How to estimate the population with samples? (mean, variance, standard deviation)
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
Visio draw fan
11. Intranet penetration and automatic refresh
ETCD数据库源码分析——etcdserver bootstrap初始化存储
Idea one key guide package
Fuzzy -- basic application method of AFL
ue5 小知识点 开启lumen的设置
随机推荐
[detailed steps of FreeRTOS shift value for the first time]
Ue5 small knowledge points to enable the setting of lumen
Visio draws Tai Chi
Crazy God said redis notes
Idea one key guide package
ETCD数据库源码分析——etcdserver bootstrap初始化存储
Platformio create libopencm3 + FreeRTOS project
Microblogging hot search stock selection strategy
Bubble sort
Quick sort
SQL注入漏洞(MSSQL注入)
RT thread analysis - object container implementation and function
[buuctf.reverse] 159_ [watevrCTF 2019]Watshell
【Try to Hack】john哈希破解工具
Programmers' position in the Internet industry | daily anecdotes
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
Dynamic programming (tree DP)
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
Biscuits (examination version)
行业专网对比公网,优势在哪儿?能满足什么特定要求?