Current location - Quotes Website - Collection of slogans - What is UDP protocol
What is UDP protocol
UDP protocol is the abbreviation of English UserDatagramProtocol, which is mainly used to support network applications that need to transmit data between computers. Many client/server network applications, including network video conference system, need to use UDP protocol. UDP protocol has been used for many years since it came out. Although its initial glory has been covered by some similar protocols, UDP is still a very practical and feasible network transport layer protocol even today.

Like the well-known TCP (Transmission Control Protocol) protocol, UDP protocol is directly on the top layer of IP (Internet Protocol) protocol. According to OSI (Open Systems Interconnection) reference model, both UDP and TCP belong to transport layer protocols.

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

UDP header

The UDP header consists of four fields, each occupying 2 bytes, as shown below:

Source port number

Target port number

Datagram length

Check value

UDP protocol uses port numbers to reserve its own data transmission channels for different applications. UDP and TCP protocols use this mechanism to support multiple applications to send and receive data simultaneously. The data sender (client or server) sends UDP datagrams 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 in advance; While other network applications can use unregistered dynamic ports. Because UDP headers use two bytes to store port numbers, the valid range of port numbers is from 0 to 65535. Generally speaking, port numbers greater than 49 15 1 represent dynamic ports.

The length of datagram refers to the total number of bytes including header and data part. Because the length of the header is fixed, this field is mainly used to calculate the variable length data part (also called data load). The maximum length of datagram varies according to the operating environment. Theoretically, the maximum length of datagram including header is 65535 bytes. However, some practical applications often limit the size of datagram, sometimes reducing it to 8 192 bytes.

UDP protocol uses the check value in the header to ensure the security of data. The check value is first calculated by the special algorithm of the data sender, and needs to be recalculated after being transmitted to the receiver. If a datagram is tampered with by a third party or damaged due to line noise during transmission, the check calculation values of the sender and the receiver will not match, so UDP protocol can detect whether there is an error. This is different from the TCP protocol, which requires a check value.