When we explain the TCP protocol, we should note that the TCP protocol is a protocol set. One of the Protocols is UDP. This is the user data packet protocol we will introduce to you today. So what is it for? What is its structure? Here we will go one by one.
UDP protocol
User Data Protocol (UDP) is also a communication Protocol on the OSI transport layer. However, UDP is a non-connection-oriented protocol. TCP is a surface connection protocol ). The establishment of a UDP connection does not require the server to listen like the TCP protocol, nor requires a client to request a connection to the server to establish a connection before both parties can communicate.
Overview of UDP protocol
User Datagram Protocol (UDP) is a simple datagram-oriented transport layer protocol. ietf rfc 768 is the formal specification of UDP. In the TCP/IP model, UDP provides a simple interface under the network layer and the application layer.
UDP only provides unreliable data delivery. Once an application sends data to the network layer, data backup is not retained. Therefore, UDP is sometimes considered an unreliable datagram protocol ). UDP only adds multiplexing and data validation fields to the IP datagram header ).
The UDP header field consists of four parts, two of which are optional. Each 16-bit source port and destination port are used to mark the application process sent and received. Because UDP does not need to respond, the source port is optional. If the source port is not used, set it to zero. The destination port is followed by a fixed length field in bytes, which is used to specify the length of the UDP datagram including the data part.
Due to lack of reliability, UDP applications generally have to allow a certain amount of packet loss, errors, and replication. Due to the lack of congestion avoidance and control mechanisms of UDP, the network-based mechanism is required to reduce the congestion collapse effect caused by runaway traffic and high-speed UDP traffic load.
UDP only adds a few functions to the IP datagram service. This means that the port function can be reused and reused at the transport layer with the port function. In addition, UDP applications can be clients or server programs, without having to create client programs and server programs separately as TCP applications do. In remote control software, if the screen information is transmitted within the LAN, it is easier to use UDP protocol. However, UDP does not provide reliability. Its reliability is handled by other network devices. At the same time, the data transmitted through UDP is generally small. It requires the IP protocol to segment the data. Theoretically, the maximum IP protocol datagram length is 65535 bytes.
UDP datagram format
In this datagram format, the source port is an optional domain. when it makes sense, it refers to the UDP port for sending the application. If you do not use it, enter 0 in this field. The destination port is meaningful when a specific destination network address exists. It refers to the UDP port of the target application. The length refers to the 8 bytes of the User Datagram length, which indicates that the minimum datagram length is 8 ). Checksum is also a simple mathematical operation used to check bit-level errors in UDP messages. Returns the opposite and opposite numbers of IP headers, UDP headers, and data headers. The UDP protocol package does not have the complex reliability and Control Mechanism of the TCP protocol package. There are no "sequence" or "validation" fields.
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, higher image frame refresh rate, certain reliability such as meeting quality can be sacrificed ). This is the trade-off between UDP and TCP. Based on different environments and features, the two transmission protocols will play a more important role in the future online world.