UDP最大包大小 [英] UDP maximum packet size

查看:201
本文介绍了UDP最大包大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查了最大UDP数据包大小并看到它是65507字节的数据。

这是65535-8(udp标头) - 20(ip标头)。

UDP长度标头是2个字节长,这是65535限制。

我明白我们从它减去8因为它的UDP标头大小
但是如果它总是8,为什么我们需要减去它。

20个ip标题长度的相同问题。

I checked the maximum UDP packet size and saw it is 65507 bytes of data.
Which is 65535-8 (udp headers) - 20 (ip headers).
The UDP length header is 2 bytes long which is 65535 limit.
I understand that we substract 8 from it because its the size of the UDP header but if it is always 8 why do we need to substract it.
Same question for the 20 of the ip headers length.

谢谢

推荐答案

UDP数据报封装在IP数据包中。如果您使用20作为IP数据包标头大小,则表示IPv4,最小 IPv4标头大小为20. IPv4的理论最大数据包大小为65,535(总长度为16位的字段) IPv4标头),但真正的IPv4最大数据包大小将是链路上的MTU。此大小包括IPv4标头和IPv4有效负载,它将是UDP数据报,包括UDP标头和UDP有效负载。

UDP datagrams are encapsulated inside IP packets. If you are using 20 as the IP packet header size then you mean IPv4, and the minimum IPv4 header size is 20. IPv4 has a theoretical maximum packet size of 65,535 (a 16-bit total length field in the IPv4 header), but the real IPv4 maximum packet size will be the MTU on the link. This size includes the IPv4 header and the IPv4 payload, which will be the UDP datagram, including the UDP header and UDP payload.

由于UDP数据报是数据报IPv4数据报和IPv4数据报的整个长度(包括IPv4报头)是IPv4报头的16位总长度字段,整个IPv4报文(包括IPv4报头)最多为65,535个八位字节。这在IPv4的定义中有详细说明, RFC 971 Internet协议,第3.1节Internet标题格式

Since the UDP datagram is the data of the IPv4 datagram, and the entire length of the IPv4 datagram, including the IPv4 header, is a 16-bit Total Length field of the IPv4 header, the entire IPv4 packet, including the IPv4 header is a maximum of 65,535 octets. This is detailed in the definition of IPv4, RFC 971 Internet protocol, Section 3.1 Internet Header Format:


3.1。互联网标头格式

3.1. Internet Header Format

互联网标题内容摘要如下:

A summary of the contents of the internet header follows:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  IHL  |Type of Service|          Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |Flags|      Fragment Offset    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Live |    Protocol   |         Header Checksum       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source Address                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Destination Address                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


总长度字段的定义是:


总长度:16位

Total Length: 16 bits

总长度是数据报的长度,以八位字节为单位,
包括互联网标题和数据。该字段允许
数据报的长度达到65,535个八位字节。对于大多数主机和网络来说,这样的长数据报对于b $ b来说是不切实际的。所有主机必须准备好
以接受最多576个八位字节的数据报(无论它们是全部到达还是
的片段)。建议主机只发送大于576个八位字节的数据报
如果它们确保目的地是
准备接受更大的数据报。

Total Length is the length of the datagram, measured in octets, including internet header and data. This field allows the length of a datagram to be up to 65,535 octets. Such long datagrams are impractical for most hosts and networks. All hosts must be prepared to accept datagrams of up to 576 octets (whether they arrive whole or in fragments). It is recommended that hosts only send datagrams larger than 576 octets if they have assurance that the destination is prepared to accept the larger datagrams.

选择数字576以允许除了所需的标题信息之外还传送合理大小的数据块到
。对于
示例,此大小允许512个八位字节的数据块加上64个头
个八位字节以适合数据报。最大互联网标题是60
八位字节,典型的互联网标题是20个八位字节,允许更高级协议标题的保证金

The number 576 is selected to allow a reasonable sized data block to be transmitted in addition to the required header information. For example, this size allows a data block of 512 octets plus 64 header octets to fit in a datagram. The maximal internet header is 60 octets, and a typical internet header is 20 octets, allowing a margin for headers of higher level protocols.

这意味着您必须从最大值65,535中减去IPv4标头长度,以达到最大UDP数据报长度,其中包括8个八位位组UDP标头。

That means you must subtract the IPv4 header length from the maximum of 65,535 to arrive at the maximum UDP datagram length, which includes the 8 octet UDP header.

这篇关于UDP最大包大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆