当前位置:网站首页>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 .
边栏推荐
- Google pixel 6A off screen fingerprint scanner has major security vulnerabilities
- Vivo official website app full model UI adaptation scheme
- Stock software development
- String of sword finger offer question bank summary (II) (C language version)
- [today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console
- 各厂商网络虚拟化的优势
- securecrt乱码解决方法[通俗易懂]
- 移动web布局方法
- 股票软件开发
- RF, gbdt, xgboost feature selection methods "recommended collection"
猜你喜欢

wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac

Go language go language built-in container

分享 25 个有用的 JS 单行代码

【云原生 | 从零开始学Kubernetes】八、命名空间资源配额以及标签

【高等数学】【4】不定积分
![[advanced mathematics] [3] Application of differential mean value theorem and derivative](/img/a9/3b024dbbb201bee4eed6c9f6ce3001.png)
[advanced mathematics] [3] Application of differential mean value theorem and derivative

When AI encounters life and health, Huawei cloud builds three bridges for them

谷歌Pixel 6a屏下指纹扫描仪存在重大安全漏洞

4、Nacos 配置中心源码解析之 服务端启动

网络协议:TCP Part2
随机推荐
JVM(二十三) -- JVM运行时参数
Is QQ 32-bit or 64 bit software (where to see whether the computer is 32-bit or 64 bit)
10. < tag dynamic programming and subsequence, subarray> lt.53. maximum subarray and + lt.392. Judge subsequence DBC
Advantages of network virtualization of various manufacturers
【ONNX】pytorch模型导出成ONNX格式:支持多参数与动态输入
[today in history] July 3: ergonomic standards act; The birth of pioneers in the field of consumer electronics; Ubisoft releases uplay
【高等数学】【5】定积分及应用
Sentinel simple current limiting and degradation demo problem record
How to set tiktok mobile network environment? How can tiktok break the playback volume?
如何保证定制滑环质量
股票软件开发
Rainbow plug-in extension: monitor MySQL based on MySQL exporter
各厂商网络虚拟化的优势
FanoutExchange交换机代码教程
分享 25 个有用的 JS 单行代码
【高等数学】【1】函数、极限、连续
网络协议:TCP Part2
Go language go language built-in container
CarSim simulation quick start (XIV) - CarSim Simulink joint simulation
Socket error Event: 32 Error: 10053. Connection closing...Socket close


