关于 UDP 数据报大小的说明
IPv4/v6 数据报的最大大小取决于 MTU
(最大传输单元)和 Payload Length
字段大小。
-
Payload Length
字段是 16 位宽,这意味着正常的有效载荷不能超过 64K 八位字节,包括互联网标头和数据(65,507 字节 = 65,535 − 8 字节 UDP 标头 − 20 字节 IP 标头);这对于环回接口通常是正确的,但是如此长的数据报消息对于大多数主机和网络来说是不切实际的。 -
MTU
是给定链路层技术可以支持数据报消息的最大尺寸。 对于任何链接,IPv4 要求至少MTU
为 68 个八位字节,而建议 IPv4 的MTU
为 576(通常建议为拨号类型应用程序的MTU
),无论它们是完整的还是分段的。对于 IPv6,最小
MTU
是 1280 个八位字节。 但是,强制的最小片段重组缓冲区大小是 1500 个八位字节。 68 个八位字节的值非常小,因为大多数当前的链路层技术,如以太网,最小MTU
为 1500。
不可能事先知道数据包可能通过的每个链路的 MTU。
发送大于接收方 MTU
的数据报将不起作用,因为数据包将被悄悄丢弃,而不会通知源数据未到达其预期接收方。
The maximum size of an IPv4/v6 datagram depends on the MTU
(Maximum Transmission Unit) and on the Payload Length
field size.
-
The
Payload Length
field is 16 bits wide, which means that a normal payload cannot exceed 64K octets including the internet header and data (65,507 bytes = 65,535 − 8 bytes UDP header − 20 bytes IP header); this is generally true for loopback interfaces, but such long datagram messages are impractical for most hosts and networks. -
The
MTU
is the largest size a given link layer technology can support for datagram messages. For any link, IPv4 mandates a minimumMTU
of 68 octets, while the recommendedMTU
for IPv4 is 576 (typically recommended as theMTU
for dial-up type applications), whether they arrive whole or in fragments.For IPv6, the minimum
MTU
is 1280 octets. However, the mandatory minimum fragment reassembly buffer size is 1500 octets. The value of 68 octets is very small, since most current link layer technologies, like Ethernet, have a minimumMTU
of 1500.
It is impossible to know in advance the MTU of each link through which
a packet might travel. Sending a datagram greater than the receiver MTU
will
not work because the packet will get silently dropped without informing the
source that the data did not reach its intended recipient.