About UDP protocol

Source: Internet
Author: User

UDP is short for user‑ramprotocol, which is a User Datagram Protocol. It is mainly used to support network applications that need to transmit data between computers. Network applications in customer/Server mode, including network video conferencing systems, must use UDP protocol. UDP has been used for many years since its publication. Although its initial Glory has been concealed by some similar protocols, even today, UDP is still a very practical and feasible network transport layer protocol.

Like the well-known TCP (Transport Control Protocol) protocol, UDP is directly located at the top layer of the IP (Internet Protocol) protocol. According to the OSI (Open System Interconnection) reference model, both UDP and TCP are transport layer protocols.

The main function of UDP protocol is to compress network data traffic into a datagram. A typical datagram is the unit of transmission of binary data. The first eight bytes of each datagram are used to contain header information, and the remaining bytes are used to contain specific transmitted data.

0udp Header

The UDP header consists of four fields, each of which occupies two bytes, as follows:

Source Port Number

Destination Port Number

Datagram Length

Check Value

The UDP protocol uses the port number to reserve its own data transmission channels for different applications. The UDP and TCP Protocols use this mechanism to support sending and receiving data simultaneously for multiple applications at the same time. The data sender (either a client or a server) sends UDP data through the source port, while the data receiver receives data through the target port. Some network applications can only use static ports reserved or registered for them in advance, while other network applications can use unregistered dynamic ports. Because the UDP header uses two bytes to store the port number, the valid range of the port number is from 0 to 65535. Generally, a port number larger than 49151 represents a dynamic port.

The length of a datagram refers to the total number of bytes, including the header and data. Because the header length is fixed, this field is mainly used to calculate the variable-length data section (also known as data load ). The maximum length of a datagram varies depending on the operating environment. Theoretically, the maximum length of a datagram containing a header is 65535 bytes. However, in some practical applications, the size of data packets is often limited, and sometimes reduced to 8192 bytes.

UDP uses the checksum value in the header to ensure data security. The check value is first passed by the Data sender through a specialAlgorithmAfter being passed to the receiver, the computation is performed again. If a data packet is tampered with by a third party during transmission or damaged due to line noise or other reasons, the sent data does not match the verification calculation value of the receiver. Therefore, the UDP protocol can detect whether an error occurs. This is different from the TCP protocol, which requires a verification value.

Udpvs. TCP

The main difference between UDP and TCP is that they differ in how to implement reliable information transmission. The TCP protocol includes a special transmission guarantee mechanism. When the data receiver receives the message from the sender, it will automatically send a confirmation message to the sender; the sender continues to transmit other information only after receiving the confirmation message. Otherwise, the sender waits until the confirmation message is received.

Unlike TCP, UDP does not provide a data transmission guarantee mechanism. If a data packet is lost during transmission from the sender to the receiver, the Protocol itself cannot detect or prompt. Therefore, UDP is often called an unreliable transmission protocol.

Compared with the TCP protocol, another difference between the UDP protocol is how to receive multiple burst data packets. Unlike TCP, UDP does not guarantee the order in which data is sent and received. For example, an application on the clientProgramThe following four datagram messages are sent to the server:

D1

D22

D333

D4444

However, UDP may submit the received data to the application on the server in the following order:

D333

D1

D4444

D22

In fact, this out-of-order nature of UDP is rarely seen. Generally, it can only happen when the network is very crowded.

Application of UDP protocol

Some readers may ask, since UDP is an unreliable network protocol, what is the value or necessity? In fact, in some cases, UDP may become very useful. Because UDP has a speed advantage beyond the reach of TCP. Although various security protection functions are embedded in the TCP protocol, a large amount of system overhead will be occupied during actual execution, and the speed will undoubtedly be seriously affected. In contrast, UDP eliminates the information reliable transfer mechanism and transfers security and sorting functions to upper-layer applications, greatly reducing the execution time and ensuring the speed.

The earliest specification for UDP protocol was rfc768, which was released in 1980. Although it has been a long time, UDP continues to play a role in mainstream applications. Many applications, including video teleconference systems, prove the value of UDP. Compared with reliability, these applications focus more on actual performance. Therefore, in order to achieve better performance (for example, a higher frame refresh rate), certain reliability (for example, meeting quality ). This is the trade-off between UDP and TCP. Based on different environments and features, both transmission protocols will play a more important role in the future online world.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.