设置GCDAsyncUdpSocket的最大数据包大小 [英] set max packet size for GCDAsyncUdpSocket

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

问题描述

我正在使用GCDAsyncUdpSocket将数据发送/接收到多播组.在GCDAsyncUdpSocket.m文件中,我找到了下面的设置,并将其更改为例如32768.但是我仍然无法接收到大于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;

还有其他设置吗?

我发现GCDAsyncUdpSocket类确实提供了一种设置此值的方法,称为setMaxReceiveIPv4BufferSize.尝试过,但仍然只接收到约9216字节.

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.

推荐答案

随着设置的变化,这将有助于准确了解您所使用的操作系统.在OS X 10.6上,请查看:

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

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

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.

通常,不安全地假定将允许通过大于576字节(包括所有协议标头)的任何IP数据报,因为576将支持IPv4保证的最大IP数据包大小.对于IPv6,保证的大小为1280.大多数设备将支持更大的数据包,但并非必需.

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.

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

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