IPv6 Multicast: Are All "Group IDs" considered valid / user assignable?

I see "interesting" behavior in my link-local IPv6 multicast routines. It looks like if I set any of the top 16 bits of the 112-bit group ID field, then MacOS / X will no longer accept these multicast packets. My question is, is this a bug in the MacOS / X networking stack, or is there a reason why setting the upper 16 bits of the group ID field affects routing behavior?

The following information follows:

  • Multicast from one Mac to another Mac always works (tested on 10.5 and 10.6)

  • Multicast from Linux to Windows always works

  • Multicast from Mac to Windows or Windows to Mac or Linux to Mac only works if the upper 16 bits of the group ID in the multicast address are set to zero. For example:

ff02 :: 666 works ff02: 0: ffff :: 666 works ff02: 1 :: 666 doesn't work ff02: 8000 :: 666 doesn't work
  • In "not working" cases, WireShark running on the Mac indicates that the Mac received multicast packets, but those packets are never sent to the receiving applications on the Mac. Does this mean that there is a bug in the Mac networking stack, or is there some deeper magic for multicast that I am not aware of?
+2


source to share


1 answer


This is your first time joining a multicast group? You must explicitly tell the OS you want to join before it presents you with group messages. There you can access using setsockopt()

to join a multicast group. From Darwin ip6 manpage :

IPV6_JOIN_GROUP struct ipv6_mreq *
    Join a multicast group.  A host must become a member of a multicast group before it can receive
    datagrams sent to the group.

    struct ipv6_mreq {
            struct in6_addr ipv6mr_multiaddr;
            unsigned int    ipv6mr_interface;
    };

    ipv6mr_interface may be set to zeroes to choose the default multicast interface or to the index
    of a particular multicast-capable interface if the host is multihomed.  Membership is associ-
    ated with a single interface; programs running on multihomed hosts may need to join the same
    group on more than one interface.

    If the multicast address is unspecified (i.e., all zeroes), messages from all multicast
    addresses will be accepted by this group.  Note that setting to this value requires superuser
    privileges.

      

I found the example code here :



struct ipv6_mreq mreq6;
memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr),
       sizeof(struct in6_addr));
mreq6.ipv6mr_interface= 0;

err = setsockopt(sockfd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq6, sizeof(mreq6));
if (err) fprintf(stderr, "setsockopt IPV6_JOIN_GROUP: %s\n", strerror (errno));

      

But maybe you are already doing this?

+1


source







All Articles