问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/9123098/set-max-packet-size-for-gcdasyncudpsocket