Since the IP protocol can also perform connectionless and unreliable transmission of data, why do you need the UDP protocol?
Protocol reuse
The IP Header protocol field has only one byte, which provides identification of up to 255 protocols, and is basically dominated by big-name protocols, such as: 1 ICMP, 2 IGMP, 6 TCP, 17 UDP, 47 GRE, 50 ESP, 51 AH , 88 EIGRP, 89OSPF, 115 L2TPv3 and so on. The space left for end users is very small, so UDP needs to provide more port space to meet the needs of user applications. The UDP port number occupies two bytes. In theory, 65535 port numbers can be provided. 1-1023 is reserved for the system, and users can use more than 64,000 port numbers.
Optional checksum
UDP provides optional checksum verification function, covering the range: Pseudo IP Header + UDP Header + UDPPayload
Pseudo IP Header: Source IP (4 Byte) + Destination IP (4 Byte) + Total Length (2 Byte) + Reserved (1 Byte) + Protocol (1 Byte)
The Reserved is to make the IP pseudo header be an integer multiple of 4 bytes, and the data is 0.
The IP pseudo header has a total of 12 bytes. The consideration of using a part of the IP header is to prevent the system from sending other quintuple data to another quintuple by mistake. Therefore, the UDP / IP layer does not achieve complete layer independence in the true sense, that is, independent implementation of the network layer and the transport layer.
NAT
IP packets do not have UDP / TCP port numbers and cannot complete 1: N NAT. With UDP-based encapsulation, a UDP port number can traverse any NAT device without any obstacle. Some IP-based protocols, such as standard GRE and ESP, cannot traverse NAT and cause communication obstacles. So now more and more tunnels based on UDP protocol, that's because the current network NAT is everywhere.
When designing UDP, I did not expect that the future network will rely heavily on the translation of port numbers. Due to the exhaustion of IPv4 resources, now I have to rely on this technology. Write socket mini programs, generally call stream or datagram two types, can implement TCP-Based or UDP-Based programs, that is, users can only encapsulate their own application data, but cannot control the IP layer and Ethernet layer and protocol fields You can use the raw mode to customize these underlying protocol fields, including Ethernet frame headers and IP headers. You need to be responsible for the entire package to ensure that the protocol fields are correct. Although it adds complexity, it is more flexible.
If you haven't understood the above text, you can use the following text to assist in understanding.
UDP is the equivalent of a postbox on the street. The IP driver will come to transport these letters and reach the destination based on the recipient's address. If the IP driver rolls over and falls into the ditch, the letter will be destroyed together. How does the sender know that his letter reached the recipient? Very easy to handle, as long as the recipient returns a letter "The letter has been received"!
And TCP is equivalent to a courier company, and the courier will throw it away for you immediately? No matter how long it takes to take it completely depends on their scheduling (control), which is why TCP is called a control protocol, and TCP has to complete scheduling control.
Some of these lazy, high-latency scheduling methods are not familiar with TCP, so they use UDP to complete the underlying encapsulation, so that applications can completely avoid TCP control. Because UDP has no control, "UDP is a walk-and-go transmission", all control rhythms are in the application itself!
"Life is precious and love is more expensive. If it is freedom, both can be thrown away." Freedom is a double-edged sword that can reduce communication delays, but it also requires self-made TCP-like reliability. This ca n’t help communication experts. The “QUIC” protocol developed by Google directly uses UDP for transmission. QUIC achieves reliable transmission and secure encryption:
o Low latency
o Reliability
o Security
There are all three. Isn't this the ultimate goal pursued by the Internet?
The above is the news sharing from the PASSHOT. I hope it can be inspired you. If you think today' s content is not too bad, you are welcome to share it with other friends. There are more latest Linux dumps, CCNA 200-301 dumps and CCNP Written dumps waiting for you.
Comments