UDP报文

http://en.wikipedia.org/wiki/User_Datagram_Protocol

Packet structure [edit]

UDP is a minimal message-oriented Transport Layer protocol that is documented in IETF RFC 768.

UDP provides no guarantees to the upper layer protocol for message delivery and the UDP protocol layer retains no state of UDP messages once sent. For this reason, UDP is sometimes referred to as Unreliable Datagram Protocol.[4]

UDP provides application multiplexing (via port numbers) and integrity verification (via checksum) of the header and payload.[5] If transmission reliability is desired, it must be implemented in the user's application.

UDP Header
Offsets Octet 0 1 2 3
Octet Bit  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0 0 Source port Destination port
4 32 Length Checksum

The UDP header consists of 4 fields, each of which is 2 bytes (16 bits).[2] The use of the fields "Checksum" and "Source port" is optional in IPv4 (pink background in table). In IPv6 only the source port is optional (see below).

Source port number
This field identifies the sender's port when meaningful and should be assumed to be the port to reply to if needed. If not used, then it should be zero. If the source host is the client, the port number is likely to be an ephemeral port number. If the source host is the server, the port number is likely to be a well-known port number. [3]
Destination port number
This field identifies the receiver's port and is required. Similar to source port number, if the client is the destination host then the port number will likely be an ephemeral port number and if the destination host is the server then the port number will likely be a well-known port number. [3]
Length
A field that specifies the length in bytes of the entire datagram: header and data. The minimum length is 8 bytes since that's the length of the header. The field size sets a theoretical limit of 65,535 bytes (8 byte header + 65,527 bytes of data) for a UDP datagram. The practical limit for the data length which is imposed by the underlying  IPv4 protocol is 65,507 bytes (65,535 − 8 byte UDP header − 20 byte IP header). [3]
In IPv6  Jumbograms it is possible to have UDP packets of size greater than 65,535 bytes. [6] This allows for a maximum length value of 4,294,967,295 bytes (2^32 - 1) with 8 bytes representing the header and 4,294,967,287 bytes for data.
Checksum
The  checksum field is used for error-checking of the header  and data. If no checksum is generated by the transmitter, the field uses the value all-zeros. [7]This field is not optional for IPv6. [8]

用Wireshark抓包:

UDP报文_第1张图片


UDP报文_第2张图片

UDP报文_第3张图片

你可能感兴趣的:(UDP报文)