如何找到我可以在不分段的情况下发送的最大 UDP 数据包? [英] How to find the largest UDP packet I can send without fragmenting?

查看:23
本文介绍了如何找到我可以在不分段的情况下发送的最大 UDP 数据包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道我可以发送到另一台计算机而没有碎片的最大 UDP 数据包是多少.

I need to know what the largest UDP packet I can send to another computer is without fragmentation.

此大小通常称为 MTU(最大传输单元).据说,在两台计算机之间,将有许多路由器和调制解调器,它们可能具有不同的 MTU.

This size is commonly known as the MTU (Maximum Transmission Unit). Supposedly, between 2 computers, will be many routers and modems that may have different MTUs.

我读到 Windows 中的 TCP 实现会自动找到路径中的最大 MTU.

I read that the TCP implementation in windows automatically finds the maximum MTU in a path.

我也在试验,我发现从我的电脑到服务器的最大 MTU 是 57712 字节 + 标头.上面的任何东西都被丢弃了.我的电脑在局域网上,MTU 不是应该在 1500 字节左右吗?

I was also experimenting, and I found out that the maximum MTU from my computer to a server was 57712 bytes+header. Anything above that was discarded. My computer is on a LAN, isn't the MTU supposed to be around 1500 bytes?

推荐答案

以下内容没有直接回答您的问题,但您可能会觉得它很有趣;它说 IP 数据包可以分解/重新组装,因此大于底层媒体(例如 1500 字节以太网)的限制:解决 GRE 和 IPSEC 的 IP 碎片、MTU、MSS 和 PMTUD 问题

The following doesn't answer your question directly but you might find it interesting; it says that IP packets can be disassembled/reassembled, and therefore bigger than limit on the underling media (e.g. 1500-byte Ethernet): Resolve IP Fragmentation, MTU, MSS, and PMTUD Issues with GRE and IPSEC

有关此主题的更多信息:

More on this topic:

  • Re: UDP fragmentation says you should use ICMP instead of UDP to discover MTU
  • Path MTU Discovery says that a TCP connection might include implicit MTU negotiation via ICMP

我不知道如何通过 Windows 上的 API 生成 ICMP:曾经提出过这样的 API,并且引起了争议,因为人们认为这将使编写实现拒绝服务功能的软件变得容易大量 ICMP 消息.

I don't know about generating ICMP via an API on Windows: at one time such an API was proposed, and was controversial because people argued that would make it easy to write software that implements denial-of-service functionality by generating a flood of ICMP messages.

不,看起来它实现了:参见例如Winsock程序员常见问题解答示例:Ping:原始套接字方法.

No, it looks like it is implemented: see for example Winsock Programmer's FAQ Examples: Ping: Raw Sockets Method.

因此,要发现 MTU,请生成带有不分段"标志的 ping 数据包.

So, to discover MTU, generate ping packets with the 'do not fragment' flag.

也许还有比这更简单的 API,我不知道;但我希望我已经让你了解底层协议[s].

Maybe there's an easier API than this, I don't know; but I hope I've given you to understand the underlying protocol[s].

这篇关于如何找到我可以在不分段的情况下发送的最大 UDP 数据包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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