当前位置:网站首页>Network protocol details: TCP part1
Network protocol details: TCP part1
2022-07-24 02:12:00 【Gold content of Xiaobai】
Catalog
2. Confirmed data number (ASN)
4.SN Sending TCP Segment Of Header How to embody
Switch in header Embodiment in
1. No data received , So I didn't answer
2. Receive the data , Also answered , But it hasn't come back yet
3. When to choose to resend data
syn Flag bit and carry data problems
State transition during three handshakes
TCP The reliability of the
TCP The reliability of is achieved through the following points :
1.TCP Will try to send data to each other , But there's no guarantee 100%
2.TCP If the data is not sent successfully , It will notify the sender of the application layer error , At this time, the application layer knows that the data is lost
3.TCP It can ensure that the application layer of the receiver receives the data strictly in the order of sending
4.TCP Ensure that the data will not be inadvertently damaged (UDP It's fine too )
5.TCP Maintain network quality as much as possible
TCP The mechanism of
ack
ack The representative confirms the information , When the other party receives the message , Will be ack Send back to the sender , At this time, until the data is successfully transmitted .
Numbering mechanism
When we send data , It must be some data , At this time, you only need to pass the beginning of the serial number of the data to be transferred .
1. Number of data sent (SN)
SN That is, the beginning of the sent data number
2. Confirmed data number (ASN)
ASN Confirmed data number , This information is usually sent back by the receiver twice , It represents the next starting number of the sender , It is convenient for the next sending end to send data .
3. Numbering rules
Generally not from 0 Start , Because it's too easy to be hijacked by bad guys , Good guess
In general, our payload All are byte[] Array , So we basically use a number for each byte
4.SN Sending TCP Segment Of Header How to embody
TCP The complete data content sent and received is generally called Segment( paragraph ), That is to say header and payload The sum of
We send multiple data at a time , Again because byte[] Continuity of arrays , So we SN Directly fill in the data number of the first byte of the data sent this time .
stay Header in , We will save payload Data of the first byte in (SN Number ), So the number becomes available , When we send , Just send this byte of data ,segent Will undertake payload The length of

5.ASN Filling rules
1. stay header in , Namely 32 Confirm the column of serial number
2.ASN Represents the next byte of data to be received , Send it back to the sender , The sender knows what to send

6.ISN
ISN Refers to the first byte number of data , Generally not from 0 Start , This is from a safety point of view , In case malicious users speculate on Legal SN Value to use .
TCP segment Play a role
segement That is, the complete content of the above figure is merged , It can not only serve send Role , When our flag switch is turned on , Also has the acknowledge segment The function of .

Switch in header Embodiment in
header There are flag bits in , Each flag bit is imagined as a switch , Switch on , It has the response function

Retransmission mechanism
Retransmission can be divided into the following two cases
1. No data received , So I didn't answer
1. It is possible that the data is still on the way
2. It is possible that the data has been lost
2. Receive the data , Also answered , But it hasn't come back yet
1. It may still be on the way
2. The loss of
We can set a reasonable timeout , Solve the problems on the way , We can wait a little longer , No more , It can only be lost .
3. When to choose to resend data
Whether the data has been lost , Or is the data halfway , As long as the timeout is not received ack, We can all choose to resend data without brain
4. Resend failure processing
After trying to resend several times, I still can't receive ack, We will stop sending . here TCP I have tried my best
Next , You can do this :
1. Notification application layer , fail in send ( Generally in write() Exception will be thrown in )
2. Try your best to contact again (reset segment) : The last attempt , If you don't receive it, you won't receive it
TCP buffer
Send buffer
TCP There is a send buffer , Because I don't know if I can send it successfully , So you need to keep the data temporarily , In case of a one thousand
Once the data is put into the local TCP Send buffer , It proves that the transmission is successful
Receive buffer
TCP There is also a receive buffer , Usage and UDP One meaning
TCP Connect
Connection is an abstract concept , To put it bluntly, it is the interconnection of two hosts , It can exchange information
Connection management
When we connect , There are several stages :
handshake ( Connection is established ) -> Use -> wave ( Connection is broken )

Understanding of handshake
Sync information
Handshake is a process of information synchronization between both sides

Handshake process
Generally, the sender sends the synchronization request first , After being received by the receiver , Then put it back to send synchronization requests and ack, such , The two sides are connected and can exchange data

syn Flag bit and carry data problems
Also in header In the flag bit , Turn on the switch , Sync now
When we first set up synchronization , You can't carry data , Because I don't know if I can connect

Although it doesn't carry data , but syn It will also consume serial numbers

Three handshakes
We can see from the above description , There are three interworking processes between the two ends , After that, it can be used normally , This is called three handshakes

State transition during three handshakes
I think the teacher's summary is in place
It's when I send syn From the time of , The receiver will be opened , Then we shake hands three times and it's over

边栏推荐
- 暑假第三周
- 20220723 record an unexplained shutdown of SAP Oracle monitoring service
- Jenkins multitask concurrent construction
- Redis 6.0 source code learning simple dynamic string
- Ardunio - ULN2003 drive board and DC motor fan - control fan speed
- Preliminary use of 145 keep alive
- [machine learning basics] common operations of Feature Engineering
- Hospital network security architecture
- Phantom core is about to close? Is there a future for digital collections?
- Hospital generic cabling
猜你喜欢

Tdengine helps Siemens' lightweight digital solution simicas simplify data processing process

ACM SIGIR 2022 | interpretation of selected papers of meituan technical team

Non boost ASIO notes: UDP UART socketcan multicast UDS

原生组件、小程序与客户端通信原理、video、map、canvas、picker等运行原理

Async await details & Promise

Decrypt redis to help the e-commerce seckill system behind the double 11

Hospital network security architecture

Running around, market and quantitative page function optimization! Stock quantitative analysis tool qtyx-v2.4.5

CANopen communication - PDO and SDO

ASP. Net core write a cache attribute tool
随机推荐
[MySQL] character set utf8mb4 cannot store the record of expression stepping on the pit
利用canvas画图片
Build a CPU Simulator
Jenkins multitask concurrent construction
Number of combinations....
Jar package used by jsonarray in main function provided by leetcode
[pumpkin Book ml] (task3) decision tree (updating)
Summary of the first change to open source middleware keycloak
jenkins多任務並發構建
文心大模型扬起新“帆”,产业应用大潮已至
快速排序注意点
Phantom core is about to close? Is there a future for digital collections?
xxl-job使用注意事项
Notes - record a dynamic datasource please check the setting of primary problem solving
Today's code farmer girl learned about the express framework under node
Detailed explanation of php7 garbage collection mechanism
Thread pool interview
Non boost ASIO notes: UDP UART socketcan multicast UDS
Chapter 9.2 program control of MATLAB
1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮