1

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.

user523234
  • 14,323
  • 10
  • 62
  • 102

1 Answers1

2

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.

Seth Noble
  • 3,233
  • 19
  • 31
  • GCDAsyncUdpSocket is a library for Mac and iOS from this: https://github.com/robbiehanson/CocoaAsyncSocket – user523234 Feb 03 '12 at 17:37
  • Correct, but it matters which version of OSX or iOS we are talking about because names and default values of various system settings change in different versions. If you know that you will be working with a particular environment, you can tailor you code to that or adjust the environment. But if you need to handle the general case, you must be prepared to cope with small datagrams. – Seth Noble Feb 03 '12 at 18:57
  • According to the author of the above library, I ran into the SO_RCVBUF issue. Do you know how to read the max value that is allowed for iOS and Mac? BTW: I am aware some of technical implication that your original answer above. For what I am doing right just some experiment. – user523234 Feb 03 '12 at 20:13
  • In that case, assuming 10.5 or later, you probably want `i=1048576; socket(s,SOL_SOCKET,SO_RCVBUF,&i,sizeof(i));` and do the same for `SO_SNDBUF`. iOS 3 or later is probably the same. – Seth Noble Feb 03 '12 at 22:04
  • It looked like the 9k is the setting for Windows as well. Thank you for your info. – user523234 Feb 05 '12 at 01:57