The UDP protocol is the abbreviation of English UserDataGramProtocol, that is, the user's datagram protocol, mainly used to support network applications that need to transmit data between computers. Network applications including network video conferencing systems include UDP protocols. The UDP protocol has been used since the introduction has been used in many years. Although its original brilliance has been concealed by some similar protocols, even in today, UDP is still a very practical and viable network transport layer protocol.
Like the TCP (Transport Control Protocol) protocol we are well known, the UDP protocol is directly on the top floor of the IP (Internet Protocol) protocol. Based on the OSI (Open System Interconnection) Reference Model, UDP and TCP belong to the transport layer protocol.
The main role of the UDP protocol is to compress network traffic into the form of a datagram. A typical datagram is a transmission unit of binary data. The first 8 bytes of each datagram are used to include header information, and the remaining bytes are used to include specific transport data.
UDP header
The UDP header consists of 4 domains, with each domain to occupy 2 bytes, as follows:
Source port number
Target port number
Data report length
Verify value
The UDP protocol uses port numbers to retain their respective data transmission channels. The UDP and TCP protocols are supported by this mechanism to achieve support for multiple applications in the same time to simultaneously send and receive data. Data Send One (which can be a client or server side) transmits the UDP datagram via the source port, and the data receives the data through the target port. Some network applications can only use static ports that are preserved or registered in advance; while others can use unregistered dynamic ports. Because the UDP header stores the port number using two bytes, the valid range of the port number is from 0 to 65535. In general, the port numbers greater than 49151 represent dynamic ports.
The length of the datagram refers to the total number of bytes including the header and the data part. Since the length of the header is fixed, the domain is mainly used to calculate the data portion of the variable length (also known as a data load). The maximum length of the datagram varies depending on the operating environment. Theoretically, the maximum length of the datagram containing the header is 65535 bytes. However, some practical applications tend to limit the size of the datagram, sometimes reduced to 8192 bytes.
The UDP protocol uses the verification value in the header to ensure the security of the data. The verification value first calculates the data sender through a special algorithm. After passing to the receiver, it needs to be recalculated. If a data report is damaged by a third-party tamper or due to line noise or the like, the verification calculation value of the transmission and the receiver will not match, whereby the UDP protocol can detect whether it is wrong. This is different from the TCP protocol, and the latter requires a check value.
UDP vs. TCP
The main difference between the UDP and TCP protocols is that both are different in how the information is reliably transmitted. The TCP protocol includes a special delivery guarantee mechanism. When the data receiver receives the information sent by the sender, the sender will automatically issue a confirmation message to the sender; the sender only continues other information after receiving the confirmation message, Otherwise, you will always wait until you receive confirmation information.
Unlike TCP, the UDP protocol does not provide a guarantee mechanism for data transfer. If the data report is lost during the transfer of the sender to the recipient, the protocol itself cannot make any testing or prompt. Therefore, people typically call UDP protocols as unreliable transmission protocols.
Another difference between the UDP protocol is how to receive multiple datagrams of the progestericity relative to the TCP protocol. Unlike TCP, UDP does not ensure data transmission and reception order. For example, an application in the client issues the following four datagrams to the server.
D1
D22
D333
D4444
However, UDP is possible to submit the received data to the server according to the following order:
D333
D1
D4444
D22
In fact, this kind of discontinuation in the UDP protocol has basically appeared, usually only possible in the case of very crowded networks. Application of UDP protocol
Since UDP is an unreliable network protocol, then what is the use value or necessary? In fact, in some cases, the UDP protocol may become very useful. Because the UDP has a speed advantage that TCP is Mono. Although various security functions are implanted in the TCP protocol, it will occupy a large amount of system overhead during the actual implementation, which is undoubtedly affected by the speed. Confused UDP is completed due to the exclusion of information reliable transmission mechanism, and the function of safety and sorting is handed over to the upper application, which greatly reduces the execution time, so that the speed is guaranteed.
The earliest specification on the UDP protocol is RFC768, 1980. Although time is already long, the UDP protocol continues to play in mainstream applications. Many applications including video conference systems have proven the value of the UDP protocol. Because of the reliability, these applications are more focused on actual performance, so in order to achieve better use effects (eg, higher screen frame refresh rates) can often sacrifice certain reliability (eg, aspect quality). This is the trade-off of the UDP and TCP protocols. Based on different environmental and characteristics, both transport protocols will play a more important role in future online worlds.