First, the User Datagram Protocol (UDP) Introduction
UDP is a simple data packets for a boundary transport protocol reservation message
UDP characteristics
It does not provide error correction, queue management, deduplication, flow control and congestion control
It does not provide error correction: It passed to the application layer of the IP data sent, but does not guarantee that they can reach their destination
It does not provide flow control: no protocol mechanism to prevent the negative impact of high-speed UDP traffic to other network users
It provides error detection, comprising a first true we encountered in the transport layer end (end-to-end) Checksum
This protocol itself provides minimal functionality, so use it to do a lot of applications that work on how to control packets sent and processed. Want to ensure that data is delivered reliably or correct sequencing, the application must implement these self-protection
Generally, each UDP output operation requested application produced only a UDP datagram, so as to send an IP datagram. This is different from the data stream-oriented protocol , such as TCP, applications written with the real people of all data transferred in a single IP datagram inside or the receiving party content may not contact
advantage:
Because it is connectionless characteristics, other than its transport protocol using less overhead
Further, the broadcast and multicast operation more directly connectionless transmission such as UDP
Finally, the application can choose their own retransmission unit capacity is an important consideration
Two, UDP datagram encapsulation
The following figure shows a UDP datagram as a single IPv4 datagram encapsulation. IPv6 encapsulation are similar, but some details are slightly different (we will discuss later in the IPv6 UDP and articles)
IPv4 Protocol field 17 with a value to identify the UDP. IPv6 at the same value of the next header field
We will discuss later in the article when the UDP datagram what will happen when the size exceeds MTU , the datagram must be fragmented into more than one IP packet layer
Three, UDP head
The following figure shows a UDP packet includes a load and UDP header (usually 8 bytes)
Source port number
Source port number is optional; datagram if the sender does not respond to other requirements, then it may be set to 0
Destination port number
Transport protocols such as TCP, UDP and the SCTP, the use of the destination port to help separate the data from the IP layer into the
Since IP layer header field according to the value in the IPv4 header protocol field or IPv6 next header into the isolated human IP datagrams to a specific transport protocol, which means that the port number of transmission protocols between different It is independent . In other words, TCP port number can only be used by TCP, UDP UDP port number can only be used and so on. A direct result of such a separation is due to two different servers may use the same IP address and port number , as long as they use different transport protocols
length
UDP length field is the total length of the UDP header and UDP data , in bytes
This field minimum value is 8 , unless the long UDP datagram with IPv6. 0 byte of data transmitted with a UDP datagram is allowed , although this is rare