设置 GCDAsyncUdpSocket 的最大数据包大小

发布于 2025-01-01 13:35:55 字数 312 浏览 1 评论 0原文

我正在使用 GCDAsyncUdpSocket 向多播组发送/接收数据。在 GCDAsyncUdpSocket.m 文件中,我找到了以下设置并将值更改为 32768 例如。但我仍然无法接收任何大于 9216 字节的数据包。

max4ReceiveSize = 9216;
max6ReceiveSize = 9216;

还有其他设置吗?

编辑: 我发现 GCDAsyncUdpSocket 类确实提供了一个方法来设置此值,称为 setMaxReceiveIPv4BufferSize。尝试过,但仍然只收到 9216 字节左右。

I am using the GCDAsyncUdpSocket to send/receive data to a multicast group. In the GCDAsyncUdpSocket.m file, I found the setting bellow and changed the value to 32768 for example. But I can't still receive any packet that is larger than 9216 bytes.

max4ReceiveSize = 9216;
max6ReceiveSize = 9216;

Is there another setting?

Edit:
I discovered that the GCDAsyncUdpSocket class did provide a method to set this value called setMaxReceiveIPv4BufferSize. Tried that but it still only received at around 9216 bytes.

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

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

发布评论

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

评论(1

秋千易 2025-01-08 13:35:55

由于设置各不相同,这将有助于准确了解您使用的操作系统。在 OS X 10.6 上,请查看:

# sysctl net.inet.udp.maxdgram
net.inet.udp.maxdgram: 9216

但是,您必须记住,任何数据路径的最大传输单元 (MTU) 将由路径中任何设备支持的最小值决定。换句话说,如果只有一个设备或软件规则拒绝处理大于特定大小的数据报,那么这将是该路径的限制。因此,许多设备上可能有许多设置会影响这一点。另请注意,IPv4 和 IPv6 的 MTU 规则完全不同,并且某些路由器对于多播和单播具有不同的规则。

一般来说,假设任何总长度超过 576 字节(包括所有协议头)的 IP 数据报将被允许通过是不安全的,因为 576 是 IPv4 保证支持的最大 IP 数据包大小。对于 IPv6,保证的大小为 1280。大多数设备将支持更大的数据包,但这不是必需的。

It would help to know exactly which operating system you are on, as the settings vary. On OS X 10.6, look at:

# sysctl net.inet.udp.maxdgram
net.inet.udp.maxdgram: 9216

However, you must keep in mind that the maximum transmit unit (MTU) of any data path will be determined by the smallest value supported by any device in the path. In other words, if just one device or software rule refuses to handle datagrams larger than a particular size, then that will be the limit for that path. Thus there could be many settings on many devices which affect this. Also note that the MTU rules for IPv4 and IPv6 are radically different, and some routers have different rules for multicast versus unicast.

In general, it is not safe to assume that any IP datagram larger than a total of 576 bytes (including all protocol headers) will be allowed through, as 576 the maximum IP packet size which IPv4 guarantees will be supported. For IPv6, the guaranteed size is 1280. Most devices will support larger packets, but they are not required to.

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