当前位置:网站首页>Key network protocols in tcp/ip four layer model
Key network protocols in tcp/ip four layer model
2022-07-25 20:23:00 【Pinellia and cool】
Catalog
Application layer key protocol
reliable ( Security ) Mechanism
UDP Deal with the TCP Protocol comparison
Application layer key protocol
DNS
DNS Is a set of mapping from domain name to IP The system of .
TCP/IP Use in IP Address to determine a host on the network , however IP The address is not easy to remember , And cannot express address organization information , So people invented domain names , And through the domain name system to map domain names and IP Address .
A domain name is a string , Such as www.baidu.com
NAT
NAT Be able to put private IP When communicating with the outside world, it turns to the overall situation IP( That's LAN ip Public transfer network ip)
NAPT
So here comes the question , If the LAN , Multiple hosts access the same Internet server , So for the data returned by the server , Purpose IP It's all the same .NAPT The function of LAN is to IP+port Converted to public network IP+port
HTTP/HTTPS
HTTP And HTTPS It is the key agreement of application layer , I will write a separate article .
Transport layer key protocol
TCP agreement
TCP, namely Transmission Control Protocol, Transmission control protocol . It is to control the transmission of data in detail .
TCP Protocol segment format

Port number : The fields used in the network transmission process encapsulation
Other fields :TCP Fields that the principle will use
6 Bit flag bit :Boolean value ,0/1 data
URG: Is the emergency pointer valid
ACK: Apply for connection , The reply
PSH: Prompt the receiving end to read from the cache immediately
RST: The other side asked to reestablish the connection , Reset message segment
SYN: Request to establish a connection , Synchronization segment
FIN: Request to disconnect , End segment
TCP principle
TCP Control mechanism for data transmission , It is mainly reflected in two aspects : Safety and efficiency .
principle : On the premise of ensuring the safety of data transmission , Improve the transmission efficiency as much as possible .
reliable ( Security ) Mechanism
(1) Confirmation response mechanism
The sender sends data , The receiving end needs to return the response of the received datagram .

The data will be numbered , And use 32 Bit serial number saving , The next datagram is the maximum continuous sequence number of the received datagram +1, It means that all previous datagrams have been received .
(2) Timeout retransmission mechanism
The sender has exceeded a certain time , Have not received ack Answer pack , Will be retransmitted .
There are two situations , The first is the loss of sending packets , There's another one ack The reply packet is lost . When retransmission reaches a certain number , It means that the other party is abnormal , Close the connection .
(3) Connection management mechanism
Under normal circumstances ,TCP It takes three handshakes to establish a connection , Four waves to disconnect .
Three handshakes to establish a connection
- The client sends syn---- Apply for establishing a client-server connection
- Server return syn+ack----syn Is to apply for establishing a connection from the server to the client ,ack Is the response to the first datagram , You can merge and send them together , It can also be developed separately .
- The client returns ack---- For the second datagram syn Response to
Four waves to disconnect
- The client sends fin To the server ---- Apply to close the connection from client to server
- Server return ack---- The server status is set to close_wait
- Server send fin To client ---- Apply to close the connection from the server to the client ( Client received , The state is set to time_wait)
- The client returns ack---- The receiving status of the server is set to closed( The client waits for a period of time , The state is set to closed)
notes : The client receives the third datagram , It cannot be set to immediately close, Also send a reply to the server , Otherwise, packet loss may occur ( The server cannot disconnect ), The server will retransmit according to the timeout mechanism , Resend the third datagram , At this time, the client is closed 了
(4) Flow control mechanism
The speed of data processing at the receiving end is limited . If the sender sends too fast , This causes the buffer at the receiving end to be full , At this time, if the sender continues to send , It will cause packet loss , Then it causes a series of chain reactions such as packet loss and retransmission . therefore TCP Support according to the processing capacity of the receiving end , To determine the sending speed of the sender .
The receiving end actively tells the sending end its own window size (TCP The first one 16 Bit window field )
(5) congestion control mechanism
Without knowing the current network state , Sending a lot of data rashly , It's likely to make things worse .TCP introduce Slow start mechanism , Start with a small amount of data , Explore the way , Find out the current state of network congestion , And then decide how fast to transmit data . That is, when the sender starts sending data, it should use the congestion window to explore the way . A small amount of packet loss , We just trigger a timeout retransmission ; Massive packet loss , We think of network congestion .
Efficiency mechanism
(1) Sliding window mechanism
Send datagrams in parallel , Reduce waiting time , Increase of efficiency .
Window size : It refers to the maximum value of data that can be sent without waiting for an acknowledgement , The greater the window , The higher the throughput of the network .
The operating system kernel maintains this sliding window , You need to open a send buffer to record what data is not responding , Only confirmed data , Can be deleted from the cache .
But how to retransmit if there is a packet loss ? There are two situations to discuss here
The first one is : Datagram has arrived ,ack lost
No influence , Follow up ack It can also indicate that everything before the serial number has been received
The second kind : Packet loss of sent datagram
The maximum value of consecutive serial number received by the receiving end +1( If the middle part is not received , The serial number is not continuous )
The next is received for three consecutive times XXX, It means the from XXX Start losing datagrams , Need to retransmit , Also called fast retransmission .
(2) Delay response mechanism
The traffic window returned by the receiving end , Not immediately , But waiting for a certain time , In this way, the returned traffic window may be larger ( The greater the window , The greater the throughput , The more efficient )
(3) Piggyback response mechanism
Whether it's the client or the server , Both can be the sender and the receiver , No matter the client or the server , When data is received , Back to ack Answer pack , It can be combined with the sent datagram and sent to the other party .
Stick package problem
“ package ” It refers to the data packet of the application layer
Avoid sticking bags : Define the boundaries between packages
- Fix the size of the package : Read and write are sent in a fixed size / receive
- Variable length package : Include length information when sending , Read data of corresponding size according to this information after receiving
UDP There is no sticking problem with the protocol : because UDP The protocol is datagram oriented , Sending data is a block by block method , There is no sticking problem .
UDP agreement
UDP Deal with the TCP Protocol comparison
| UDP | TCP |
| There is no connection | There is a connection |
| unreliable | reliable |
| For datagram | Byte stream oriented |
| Only receive buffer ( Just send , No matter whether the packet is lost , So there is no send buffer ) | There are both receive and send buffers |
| Limited size | There is no limit to size |
| Applicable scenario : High real-time requirement , Allow a small amount of packet loss | Applicable scenario : Where the reliability is relatively high |
Network layer key protocols
IP agreement
Protocol header format

Key data link layer protocols
Get to know Ethernet
Ethernet : A technical standard for local area networks
Ethernet frame : Form of agreement ( Encapsulate the format of datagram in the data link layer )
know MTU
Maximum transmission unit of Ethernet , The maximum limit specified by Ethernet is exceeded , Will subcontract / Fragmentation
Yes ip The impact of the agreement :
beyond mtu Limit , It will be partitioned at the network layer , There may be a problem of parts package loss ( Multiple packets received by the receiving end , If part is lost , The whole bag is useless )
Yes udp Influence :
Packet loss , The receiving end cannot restore it , Whole udp Datagrams are useless
Yes tcp Influence :
Packet loss , The receiving end still cannot restore , but tcp There is a reliable mechanism to ensure data retransmission
ARP agreement
ARP It is not a simple data link layer protocol , But a protocol between data link layer and network layer .
ARP The protocol establishes the host IP Address and MAC Address The mapping relation of .
边栏推荐
- Redis source code -ziplist
- Recommended books | essentials of industrial digital transformation: methods and Practice
- securecrt乱码解决方法[通俗易懂]
- CarSim仿真快速入门(十四)—CarSim-Simulink联合仿真
- Share 25 useful JS single line codes
- 4everland storage node portal network design
- [advanced mathematics] [8] differential equation
- PreScan快速入门到精通第十八讲之PreScan轨迹编辑的特殊功能
- 笔记——记录一个CannotFindDataSourceException: dynamic-datasource can not find primary datasource问题解决
- Vivo official website app full model UI adaptation scheme
猜你喜欢

Export and call of onnx file of pytorch model

笔记——记录一个CannotFindDataSourceException: dynamic-datasource can not find primary datasource问题解决

Do you still have certificates to participate in the open source community?

Recommended books | essentials of industrial digital transformation: methods and Practice

Google pixel 6A off screen fingerprint scanner has major security vulnerabilities

导电滑环在机械设备方面的应用

Share 25 useful JS single line codes

网络协议:TCP Part2

Socket error Event: 32 Error: 10053. Connection closing...Socket close
![[onnx] export pytorch model to onnx format: support multi parameter and dynamic input](/img/bd/e9a1d3a2c9343b75dbae5c7e18a87b.png)
[onnx] export pytorch model to onnx format: support multi parameter and dynamic input
随机推荐
During the interview, I was asked how to remove the weight of MySQL, and who else wouldn't?
Pytorch's transforms (numpy data type is converted to tensor, normalized and resized)
[today in history] July 5: the mother of Google was born; Two Turing Award pioneers born on the same day
笔记——记录一个CannotFindDataSourceException: dynamic-datasource can not find primary datasource问题解决
Google pixel 6A off screen fingerprint scanner has major security vulnerabilities
CarSim仿真快速入门(十六)—CarSim传感器仿真之ADAS Sensor Objects (2)
How much memory does bitmap occupy in the development of IM instant messaging?
SecureCRT garbled code solution [easy to understand]
RF, gbdt, xgboost feature selection methods "recommended collection"
谷歌Pixel 6a屏下指纹扫描仪存在重大安全漏洞
Apache MINA框架「建议收藏」
Introduction and construction of consul Registration Center
[noi simulation] string matching (suffix automata Sam, Mo team, block)
Web crawler principle analysis "suggestions collection"
Go language go language built-in container
Volcanic engine Xiang Liang: machine learning and intelligent recommendation platform multi cloud deployment solution officially released
redis源码 -ziplist
DIY personal server (DIY storage server)
9.< tag-动态规划和子序列, 子数组>lt.718. 最长重复子数组 + lt.1143. 最长公共子序列
Cloud native guide: what is cloud native infrastructure


