当前位置:网站首页>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 .
边栏推荐
- web工程导入了mysql驱动jar包却无法加载到驱动的问题
- 2021 robocom world robot developer competition - undergraduate group (semi-finals)
- ISP学习(2)
- Microservice resource address
- 集合详解之 Map + 面试题
- canal同步mysql数据变化到kafka(centos部署)
- 也算是學習中的小總結
- [NOIP2009 普及组] 分数线划定
- acwing周赛58
- Vulnerability discovery - vulnerability probe type utilization and repair of web applications
猜你喜欢
Introduction of several RS485 isolated communication schemes
Embedded development program framework
Postman断言
Lepton 无损压缩原理及性能分析
Extension of graph theory
几种RS485隔离通讯的方案介绍
Uva1592 Database
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
RT thread analysis log system RT_ Kprintf analysis
[FreeRTOS interrupt experiment]
随机推荐
Platformio create libopencm3 + FreeRTOS project
ETCD数据库源码分析——etcdserver bootstrap初始化存储
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
Selection of slow motion function
The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
Etcd database source code analysis -- etcdserver bootstrap initialization storage
Extension of graph theory
最高法院,离婚案件判决标准
Basic explanation of turtle module - draw curve
Postman断言
[classic example] binary tree recursive structure classic topic collection @ binary tree
优秀PM必须经历这3层蜕变!
Excellent PM must experience these three levels of transformation!
The underlying structure of five data types in redis
Postman pre script - global variables and environment variables
[05-1, 05-02, 05-03] network protocol
驱动开发——HelloWDM驱动
MySQL reported an error datetime (0) null
组播和广播的知识点梳理
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry