当前位置:网站首页>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 .
边栏推荐
- 2022.7.24-----leetcode.1184
- 10. < tag dynamic programming and subsequence, subarray> lt.53. maximum subarray and + lt.392. Judge subsequence DBC
- [today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console
- 9.< tag-动态规划和子序列, 子数组>lt.718. 最长重复子数组 + lt.1143. 最长公共子序列
- 接口请求合并的3种技巧,性能直接爆表!
- wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
- JS scope and scope chain
- 第六章 修改规范(SPEC)类
- 4everland storage node portal network design
- 【高等数学】【6】多元函数微分学
猜你喜欢

【高等数学】【5】定积分及应用
![[today in history] July 8: PostgreSQL release; SUSE acquires the largest service provider of k8s; Activision Blizzard merger](/img/14/f2b68dbe4e6a9b8d89ed9ff38f5e11.png)
[today in history] July 8: PostgreSQL release; SUSE acquires the largest service provider of k8s; Activision Blizzard merger

Technology cloud report: what is the difference between zero trust and SASE? The answer is not really important
![[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world](/img/41/76687ea13e1722654b235f2cfa66ce.png)
[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world

Share 25 useful JS single line codes

4everland storage node portal network design
![[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console](/img/7d/7a01c8c6923077d6c201bf1ae02c8c.png)
[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console
![[today in history] July 7: release of C; Chrome OS came out;](/img/a6/3170080268a836f2e0973916d737dc.png)
[today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued

Prescan quick start to master Lesson 19: prescan actuator configuration, track synchronization and non configuration of multiple tracks

【TensorRT】动态batch进行推理
随机推荐
Redis source code -ziplist
JVM (XXIII) -- JVM runtime parameters
智能电子界桩自然保护区远程监控解决方案
Rainbow plug-in extension: monitor MySQL based on MySQL exporter
PMP adopts the latest exam outline, here is [agile project management]
SecureCRT garbled code solution [easy to understand]
[today in history] June 29: SGI and MIPS merged; Microsoft acquires PowerPoint developer; News corporation sells MySpace
Technology cloud report: more than zero trust, the wild hope of Parra's "Digital Security Cloud strategy"
分享 25 个有用的 JS 单行代码
JS作用域与作用域链
When AI encounters life and health, Huawei cloud builds three bridges for them
What is cluster analysis? Categories of cluster analysis methods [easy to understand]
Recommended system topic | Minet: cross domain CTR prediction
JS scope and scope chain
统信UOS下配置安装cocos2dx开发环境
Distributed link logging minbox logging usage document
How to ensure the quality of customized slip rings
CarSim仿真快速入门(十六)—CarSim传感器仿真之ADAS Sensor Objects (2)
谷歌Pixel 6a屏下指纹扫描仪存在重大安全漏洞
Log in to Baidu online disk with cookies (websites use cookies)


