Why is my application unable to add a multicast address?

Note: Applies to NDDS 3.x, RTI Connext 4.x and above.

Many operating systems, including Linux, limit the number of multicast group memberships that a machine can belong to simultaneously. (A "multicast group membership" indicates that a machine is listening to messages for a specific multicast IP address. In other words, there is a limit on how many multicast IP addresses you can listen to.)

On Linux, in particular, the default limit is relatively small (only 20 on many standard kernels). However, this limit can be configured dynamically.

In addition to the operating system, there might be a physical or practical limit of the NIC that is being used. For example, for the Intel's Pro 10/100 cards the practical limit is 14 (according to docs http://www.intel.com/support/network/sb/cs-009951.htm).

If your application tries to use too many multicast addresses at once, you may run into error messages from RTI Connext, telling you that a multicast address could not be added. For example, the error messages will look like this with NDDS 3.1c: 

NDDS: unable to add multicast address 227.1.2.3 on interface 192.168.0.1: socket error 105 
NDDS Subscription: MulticastAddrSet: Registering multicast address 227.1.2.3 
NDDS Subscription: Unable to allocate subscription variable

(Your own IP addresses will vary, of course.) 

The "socket error 105" in this message indicates that the errno value returned by the Linux network stack is 105, or ENOBUFS. This return value while adding a multicast address indicates that your machine is trying to be a member of too many multicast groups at the same time. 

Here are a few tips if you see this message:

  • Evaluate whether you really need as to use as many multicast addresses for your RTI Connext topics as you are currently using. It is possible (and usually desirable) to share the same multicast IP address for multiple topics in the same application.
  • Keep in mind that the multicast group limit applies to the whole machine, not just a single application. If the limit is 20, and the OS uses one internally, and your other code listens to 15 different addresses, that will leave only 4 addresses for use from RTI Connext.
  • You can check the multicast groups your machine currently belongs to by running "netstat -gn". You can ignore the IPv6 entries (unless you are using IPv6 multicast, in which case you can ignore IPv4). The entry for 224.0.0.1 will be set up internally by the network stack. You can verify that the other addresses match the multicast addresses you believe should be in use.
  • You can check the current maximum number of multicast group memberships that your Linux machine can belong to simultaneously by running "cat /proc/sys/net/ipv4/igmp_max_memberships". The default value is usually 20.
  • If you need to increase the limit, you can do so dynamically by using the /proc file system. For example, running "echo 40 > /proc/sys/net/ipv4/igmp_max_memberships" (as root) would set the limit to 40. To make the change permanent, modify net.ipv4.igmp_max_memberships in /etc/sysctl.conf.

You can reload the configuration file by using sysctl -p or by rebooting your system.

Platform:
Keywords: