UDP IP 分段和 MTU

发布于 2024-09-19 04:49:42 字数 627 浏览 4 评论 0 原文

我试图了解我在发送 UDP 数据包的上下文中看到的一些行为。

我有两个小 Java 程序:一个传输 UDP 数据包,另一个接收它们。我在通过单个交换机连接的两台计算机之间的网络上本地运行它们。

两个网络适配器上的 MTU 设置(由 /sbin/ifconfig 报告)均为 1500。

  • 如果我发送的数据包大小 < 1500,我收到了。预期的。
  • 如果我发送 1500 < 的数据包尺寸< 24258 我收到了。预期的。我已经通过wireshark确认IP层正在对它们进行碎片化。
  • 如果我发送大小>的数据包24258,他们迷路了。 不符合预期。当我在接收端运行wireshark时,我没有看到任何这些数据包。

我可以通过 ping -s 看到类似的行为。

ping -s 24258 hostA 有效,但

ping -s 24259 hostA 失败。

有谁了解可能发生的情况,或者知道我应该寻找什么?

两台计算机都运行 CentOS 5 64 位。我使用的是 1.6 JDK,但我并不认为这是一个编程问题,而是一个网络问题或者操作系统问题。

I'm trying to understand some behavior I'm seeing in the context of sending UDP packets.

I have two little Java programs: one that transmits UDP packets, and the other that receives them. I'm running them locally on my network between two computers that are connected via a single switch.

The MTU setting (reported by /sbin/ifconfig) is 1500 on both network adapters.

  • If I send packets with a size < 1500, I receive them. Expected.
  • If I send packets with 1500 < size < 24258 I receive them. Expected. I have confirmed via wireshark that the IP layer is fragmenting them.
  • If I send packets with size > 24258, they are lost. Not Expected. When I run wireshark on the receiving side, I don't see any of these packets.

I was able to see similar behavior with ping -s.

ping -s 24258 hostA works but

ping -s 24259 hostA fails.

Does anyone understand what may be happening, or have ideas of what I should be looking for?

Both computers are running CentOS 5 64-bit. I'm using a 1.6 JDK, but I don't really think it's a programming problem, it's a networking or maybe OS problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仅冇旳回忆 2024-09-26 04:49:42

IP 协议的实现不需要能够处理任意大的数据包。理论上,最大可能的 IP 数据包大小为 65,535 个八位位组,但标准仅要求实现支持至少 576 个八位位组。

您的主机的实现似乎支持远大于 576 的最大大小,但仍然明显小于最大理论大小 65,535。 (我不认为交换机应该是一个问题,因为它不需要进行任何碎片整理——它甚至不在IP层运行)。

IP 标准进一步建议主机不要发送大于 576 字节的数据包,除非它们确定接收主机可以处理更大的数据包大小。您也许应该考虑您的程序是否发送较小的数据包会更好。 24,529 对我来说似乎非常大。我认为很多主机可能无法处理那么大的数据包。

请注意,这些数据包大小限制完全独立于 MTU(数据链路层协议支持的最大帧大小)。

Implementations of the IP protocol are not required to be capable of handling arbitrarily large packets. In theory, the maximum possible IP packet size is 65,535 octets, but the standard only requires that implementations support at least 576 octets.

It would appear that your host's implementation supports a maximum size much greater than 576, but still significantly smaller than the maximum theoretical size of 65,535. (I don't think the switch should be a problem, because it shouldn't need to do any defragmentation -- it's not even operating at the IP layer).

The IP standard further recommends that hosts not send packets larger than 576 bytes, unless they are certain that the receiving host can handle the larger packet size. You should maybe consider whether or not it would be better for your program to send a smaller packet size. 24,529 seems awfully large to me. I think there may be a possibility that a lot of hosts won't handle packets that large.

Note that these packet size limits are entirely separate from MTU (the maximum frame size supported by the data link layer protocol).

惯饮孤独 2024-09-26 04:49:42

我发现以下可能感兴趣:

Dan 的答案很有用,但请注意,在标头之后,您实际上被限制为 65507 字节。

I found the following which may be of interest:

Dan's answer is useful but note that after headers you're really limited to 65507 bytes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文