User Datagram Protocol
Collection
zero Useful+1
zero
This entry is made by China Science and Technology Information Magazine Participate in editing and review Science Popularization China · Science Encyclopedia authentication.
UDP is a transport layer protocol working in the OSI (Open Systems Interconnection) model. It uses IP as the underlying protocol to application program A protocol that provides a minimal protocol mechanism for sending messages to other programs. Its main characteristics are connectionless, reliable transmission and message oriented. RFC 768 is the UDP standard provided by IETF (Internet Engineering Task Force).
Chinese name
User Datagram Protocol
Foreign name
User Datagram Protocol
Features
No connection, no guarantee of reliable delivery, message oriented
Foundation
Add a little function to the IP packet service
Purpose
Send IP packets
Work level
Transport layer

Introduction to the Agreement

Announce
edit
Header and pseudo header of UDP user datagram
UDP (User Datagram Protocol) is a datagram mode that provides packet switched computer communication in a group of interconnected computer network environments. This protocol assumes that IP is used as the underlying protocol and works at the transport layer according to the OSI model. UDP provides a process for applications to send messages to other programs with the least protocol mechanism [1] The protocol is transaction oriented and does not guarantee delivery and duplicate protection. Applications that need to transmit data streams in an orderly and reliable manner should use Transmission Control Protocol (TCP).

Message format

Announce
edit

Header format

User datagram header format
User datagram UDP has two fields, data field and header field. The first field has 8 bytes and is composed of four fields. Each field is 2 bytes long [1] The meaning of each field is as follows:
<1> Source Port The source port number is selected when the other party is required to reply. If not required, all zeros can be used.
<2> Destination Port Destination port number. This must be used when delivering messages at the destination.
<3> Length The length of UDP user datagram, including header and data, with a minimum value of 8 (only header).
<4> Checksum If the checksum is used to detect whether the UDP user data packet has errors in transmission, the message will be discarded if there are errors. When calculating the checksum, first put all zeros into the checksum field, and then regard the pseudo header and UDP user datagram as connected by many 16 bit strings. If the data part of the UDP user data packet is not an even number of bytes, jump into an all zero byte (this byte is not sent), and then calculate the sum of these 16 bit words according to the binary inverse code [2]

Pseudo Header

Announce
edit
When calculating the checksum, a pseudo header of 12 words should be added before the UDP user datagram. The so-called pseudo header is because this pseudo header is not the real header, but is temporarily added in front of the UDP user datagram to obtain a temporary UDP user datagram when calculating the checksum [2] The checksum is calculated according to this temporary UDP user datagram. The pseudo header is neither transmitted downward nor submitted upward, but is only used to calculate the checksum.
Pseudo header format
The fake header contains the following parts [1]
<1> Source address
<2> Destination address
<3> Zero field
<4> Protocol field
<5> UDP length

main features

Announce
edit
(1) No connection. UDP does not connect before sending data, and no connection can be released at the end of sending, which reduces the overhead and delay before sending data.
(2) Try your best to deliver. UDP does not guarantee reliable delivery, so the host does not maintain a complex connection state.
(3) Message oriented. The sender's UDP will add headers to the messages handed over by the application program and then deliver them down to the IP layer. UDP neither merges nor splits the messages handed over by the application layer, but retains the boundaries of these messages. The UDP of the receiver delivers the UDP user datagram delivered by the IP layer to the upper application process intact after the header is removed [2] UDP delivers a complete message at one time, so the application must select a message of appropriate size.
(4) No congestion control. Many real-time applications (such as IP phone, real-time video conference, etc.) require the source host to send data at a constant rate, and allow some data to be lost when the network is congested, but do not allow data to have too much delay. UDP is just suitable for this requirement [2]
(5) Support one-to-one, one-to-many, many to one and many to many interactive communication.
(6) The overhead is small. UDP has only an 8 byte header.

Protocol Comparison

Announce
edit
UDP is a connectionless protocol and does not guarantee reliable delivery. It only adds a few functions to the top of IP datagram service, mainly including multiplexing, distribution and error detection. This is applicable to real-time applications that require the source host to send data at a constant rate, allowing data loss when the network is congested, but not allowing data to have too much delay.
TCP is a connection oriented transport layer protocol that provides reliable delivery services. TCP regards connection as the most basic abstraction, and the connection endpoint is called socket. Each TCP connection is uniquely determined by the two endpoints at both ends of the communication (that is, socket pair), that is, each TCP connection can only be point-to-point [2] The application must establish a TCP connection before using the TCP protocol, and release the established TCP connection after data transmission. TCP provides full duplex communication, allowing application processes of both sides of the communication to send data at any time. Both ends of the TCP connection are equipped with send cache and receive cache, which are used to temporarily store two-way communication data. Unlike UDP for packets, TCP is byte stream oriented. The "stream" here refers to the byte sequence flowing into or out of the process [2] Although the interaction between the application and TCP is a data block of different sizes at a time, TCP regards the data handed over by the application as a series of unstructured byte streams, and does not know the meaning of the transmitted byte streams. TCP is suitable for applications that need to transmit data streams in an orderly and reliable manner.

Interface and application

Announce
edit
The user interface shall allow the creation of a new receive port and the execution of operations on the receive port to return data and the indication of the source port and source address. At the same time, datagrams can be sent, specifying the data to be sent, the source port, the target port, and the address.
The UDP module must be able to determine the source address, target address and protocol field from the header. A possible UDP/IP interface will return the entire datagram, including all headers, in response to receive operations. Such an interface also allows UDP to deliver the complete Internet datagram with header to the IP to be sent. IP verifies the consistency of specific fields and calculates the header checksum [1]
UDP is mainly used for Internet Name Server and simple file transfer. Its protocol number is 17.