UDP of network protocol

Source: Internet
Author: User

Objective

The TCP protocol provides a reliable communication channel in an unreliable network environment, hiding a lot of underlying details and making the application more concise. However, some applications do not require this high level of reliability, do not require sequential delivery, and TCP increases latency for increased reliability, which is not applicable in some scenarios where latency or jitter requirements are high. For this reason, UDP (user Datagram Protocol, Subscriber Datagram Protocol) is presented. UDP, although widely used, such as DNS query, but has not been an important role. Since the WEBRTC was introduced, it can enable the browser on the basis of UDP to achieve native voice and video real-time communication and other forms of peer communication, UDP in this situation is more important. This paper introduces the principle and application of UDP in order to deepen its understanding.

Udp

TCP is connection-oriented, requires three handshake to establish a connection and then transfer data, but UDP is non-connected, it does not guarantee the delivery of information, and does not guarantee the order of interaction, or tracking the connection state, and do not need congestion control.

to understand UDP and why it is commonly referred to as the "null protocol," we first need to understand the Internet Protocol (IP), which is located under the TCP and UDP protocol layers. The primary task of the IP layer is to send datagrams from the source host to the destination host based on the address. To do this, messages are encapsulated in an IP packet , identifying the source and destination address, as well as some other routing parameters.

We emphasize again the meaning of the term "datagram" mentioned above: the IP layer provides unreliable data transmission, neither message acknowledgement nor loss notification, the IP layer directly exposes this layer of unreliability to the upper level. If a datagram is in transit because a routing node is congested, heavy, or otherwise lost, then the protocol from the upper layer of the IP detects, recovers, and retransmits the data--of course, this is the demand on the upper level! The IPV4 header structure is as follows:

The UDP protocol encapsulates user information in its own packet structure, with the following data formats:

As shown, we have added the source and destination ports in the UDP datagram, so that when the IP packet is sent to the receiver, the receiver can open the UDP packet, locate the corresponding application according to the target port, and then pass the data to the application.

From the IP and UDP data formats can be seen, their header with checksum, can be used to verify the data, then the application even ignore the UDP checksum does not affect the data integrity, checksum field is optional. This means that all of the UDP layer's error detection and correction can be delegated to the above application layer checksum. Ultimately,UDP provides an "application multiplexing" mechanism simply by embedding the application's source and destination ports on the IP layer. the characteristics of UDP can be obtained as follows:

    • No guaranteed message Delivery: No acknowledgement, no retransmission, no timeout;
    • Do not guarantee the order of delivery: Do not set the package sequence number, do not rearrange, does not occur the team first block;
    • Do not track connection status: Do not need to establish a connection or restart the state machine;
    • No congestion control required: No built-in client or network feedback machine.

TCP is a byte-stream-oriented protocol that can send the application's message data in multiple groupings, without any explicit message boundaries within the package itself. In order to achieve this goal, the connection ends are assigned a connection state, and the packets are sorted, the packet is sent again, and the packets are dispatched sequentially. Instead, the UDP datagram has a clear boundary: Every datagram is packaged into an IP packet, and every UDP packet read by the application layer is the complete message-the datagram cannot be split .

A detailed definition of the datagram (Datagram) is as follows:

Datagram: A self-contained, stand-alone data entity that hosts enough information to reach a destination route from a source route without relying on any data exchange and transport network that is not dependent on the network node.

Data message (Datagram) and Packet (Packet) two terms are used interchangeably, but in fact there are some slight differences between the two. Data packets (packet) are generally used to describe blocks of data in any format, whereas datagrams (Datagram) are often reserved to describe packets transmitted through an unreliable service (packet)-no transmission guarantees, no failure notifications. So UDP packets are generally or more accurately referred to as datagrams (Datagram).

UDP is a simple, stateless protocol that is suitable for booting the upper layer of other application layer protocols-almost all protocol decisions are left to the application layer above it. However, when you want to implement your own protocol to replace TCP, you should carefully consider the complexities involved, such as UDP interaction with other tiers (such as NAT traversal), and some best practices for network protocols. Without careful planning and design, designing a new protocol is not a good idea, and may eventually be implemented as a rudimentary TCP version. Various algorithms and TCP state machines have been honed and promoted for decades, and have taken dozens of mechanisms to ensure his performance.

UDP and NAT

UDP for network protocol

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.