当前位置:网站首页>TCP protocol
TCP protocol
2022-07-21 19:00:00 【1 2 3 pursue dreams together】
1、TCP brief introduction
- TCP(Transmission Control Protocol) Transmission control protocol , seeing the name of a thing one thinks of its function , Is to control the transmission of data .
Source port :
We can see from the source port that it refers to the port number sent by the sender's computer
Destination port :
The same goes for the destination port , It refers to the port number of the data received by the receiving computer
Serial number (seq):
seq Number , We know that a data may consist of multiple packets , The function of serial number is to identify the sequence of each packet , Serial number occupation 32bit, Then the serial number is at most 2 Of 32 Power -1 individual , What if it exceeds this number ? From 0 Start renumbering .
Confirmation no. (ack):
ack Number , Be careful ack Number and below ACK The logo is different ,ack=seq+1 It means that the sender and receiver are paired successfully . This confirmation number is an attribute that the data receiver feeds back to the sender , If the confirmation number is N, Then it means that the receiver has received N-1 And previous data
Data migration :
This data offset is for TCP Message segment , Means from TCP Message segment to TCP Distance between data parts , That is to say TCP The size of the head , Generally speaking, it is 20 Bytes , But we can find that the sixth row has a variable length , So sometimes it's not 20 Bytes .
Retain :
Reserved means that it is not used now , This length can be used .
URG:
URG=1 Indicates that this message is an emergency message , So this message has the highest priority , It will be put at the beginning of transmission by the sender , It should be used together with the emergency pointer we will talk about next
ACK:
ACK Is a property used to indicate whether a connection is established , When ACK=1 It indicates that the connection has been established , All messages after the connection is established ACK All must be 1, And only when ACK=1 The confirmation number will only be valid
PSH:
This attribute is used when the application process at one end wants to receive a response from the other immediately after typing a command ,TCP Push operation is available
RST:
This field is actually reset, When our TCP When a serious error occurs in the connection , We need to reset the connection , You need to release the connection at this time , Re establish a new connection
SYN:
This attribute is more important , When it's equal to 1 It is used to indicate that this message is a connection request or connection acceptance message , When SYN=1 And ACK=0 when , That means it is a connection request message . When SYN=1 And ACK=1 when , It indicates that this is the connection acceptance message , And when the SYN=1 It is not allowed to carry data , And will consume a serial number .
FIN:
This property is used to release the connection , yes finnish Abbreviation , When the sender will FIN Set up 1 when , It indicates that the data has been completely sent , Request release connection
window :
Window is an attribute used to control the transmission rate , It indicates the amount of data the receiver allows the other party to send , To solve the problem of inconsistent bandwidth
The checksum :
It is used to verify the header and data
Pointer to an emergency :
When URG=1 when , It indicates that this message is an emergency message , The emergency pointer indicates the number of bytes of emergency data in this report , Emergency data processing is completed TCP Will tell the application to resume normal operation , also , The window is 0 You can also send emergency data
2、 Three handshakes and four waves
2.1 Three handshakes
The first handshake : When establishing a connection , The client sends SYN package (SYN=1,seq=x) To the server , And enter SYN_SEND state , Wait for server to confirm ;
The second handshake : Server received SYN package , Must confirm the client's SYN(ACK=1,ack=x+1), At the same time, I also send a SYN package (SYN=1,seq=y), namely SYN+ACK package , At this time, the server enters SYN_RECV state ;
The third handshake : Client receives server's SYN+ACK package , Send confirmation package to server ACK(ACK=1,ack=y+1,seq=x+1), This package has been sent , Client and server access established state , Complete three handshakes .
2.2 Four waves
1. First wave : The client sends one FIN, Used to close client to server data transfer , Client access fin_wait_1 state
2. Second wave : Server received FIN after , Send a ACK To the client , Confirmation No. is receipt No +1, Server access Close_wait state . here TCP The connection is half closed , That is, the client has no data to send , But if the server sends data , Then the client still needs to accept
3. Third wave : The server sends a FIN, It is used to close the data transmission from the server to the client , Server access Last_ack state
4. Fourth wave : Client received FIN after , Client access Time_wait state , And then send a ACK To the server , After the confirmation , Server access Closed state , Finish four waves
边栏推荐
- Redis+Caffeine两级缓存,让访问速度纵享丝滑
- Hongmeng harmonios deveco studio reported an error unistall_ FAILED_ INTERNAL_ ERROR
- Digital twin technology offshore wind farm solution
- Which programming language is recommended for beginners?
- The longest valid bracket of question 32 in C language. Implement with stack
- 循环结构--while循环和do-while循环
- 有趣的 Kotlin 0x0D:IntArray vs Array<Int>
- emuelec开发笔记
- ESP 特权隔离机制介绍
- [QNX Hypervisor 2.2用户手册]8.6 中断
猜你喜欢
ORACLE导出表数据-dmp文件
Description du développement de l'ESB en combinaison avec la plateforme UMC Cloud
Manual implementation of solving single source shortest path
这还是我最熟悉的package.json吗?
乐鑫ESP-RTC 实时音视频通信方案
Okaleido tiger NFT即将登录Binance NFT平台,NFT权益时代即将开启
Apple released watchos 8.7 with bug fixes and security updates
Machine learning univariate linear regression
Digital twin technology offshore wind farm solution
ESB結合UMC雲平臺開發說明
随机推荐
Okaleido tiger NFT即将登录Binance NFT平台,NFT权益时代即将开启
Mysql -bash: mysqldump: command not found 错误解决方法
Golang collection: custom types and method sets
ClickHouse表引擎
Embedded learning: introduction to Cortex-M series chips
Which programming language is recommended for beginners?
高质量WordPress下载站模板5play主题源码
Manual implementation of solving single source shortest path
电子招标采购商城系统:优化传统采购业务,提速企业数字化升级
powermock实战
API Test
The risk control data (model) is not bothered because of the processing skills in this flow process
第一部分—C语言基础篇_7. 指针
How to solve the problem of cascading offline after the server is restarted on the video fusion cloud platform easycvr?
The longest valid bracket of question 32 in C language. Implement with stack
oracle 启动命令
Natural fit between NFT and luxury culture: NFT meets the human nature of seeking uniqueness and status
Interesting kotlin 0x0D: intarray vs array < int>
接口幂等性
Hongmeng harmonios deveco studio reported an error unistall_ FAILED_ INTERNAL_ ERROR