IPv6多播寻址:所有“组ID”都是IPv6组播寻址吗?被认为有效/用户可分配?

发布于 2024-08-05 00:56:15 字数 646 浏览 9 评论 0原文

我在程序的链路本地 IPv6 多播例程中看到了一些“有趣”的行为。看来如果我设置了 112 位组 ID 字段的任何高 16 位,那么 MacOS/X 将不再接受那些多播数据包。我的问题是,这是 MacOS/X 网络堆栈中的错误,还是有某种原因设置组 ID 字段的高 16 位会影响路由行为?

更具体的信息如下:

  • 从一台 Mac 到另一台 Mac 的多播始终有效(在 10.5 和 10.6 上测试)

  • 从 Linux 进行多播到 Windows 始终有效

  • 从 Mac 到 Windows、或 Windows 到 Mac、或 Linux 到 Mac 的多播,仅当多播地址中组 ID 的高 16 位为设置为零。例如:

  • ff02::666 有效
  • ff02:0:ffff::666 有效
  • ff02:1::666 不起作用
  • ff02:8000::666 不起作用

    • 在“不起作用”的情况下,Mac 上运行的 WireShark 显示 Mac 已收到多播数据包,但这些数据包永远不会传递到 Mac 上的接收应用程序。这是否意味着 Mac 网络堆栈存在错误,或者多播寻址是否存在一些我不知道的更深层次的魔力?
  • I'm seeing some "interesting" behavior in my program's link-local IPv6 multicast routines. It seems that if I set any of the upper 16 bits of the 112-bit Group ID field, then MacOS/X will no longer accept those multicast packets. My question is, is this a bug in the MacOS/X network stack, or is there some reason why setting the upper 16 bits of the Group ID field would affect routing behavior?

    More specific info follows:

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

    • Multicasting from Linux to Windows always works

    • Multicasting 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 the "doesn't work" cases, WireShark running on the Mac shows that the Mac has received the multicast packets, but those packets are never passed on to the receiving application(s) on the Mac. Does this mean that the Mac networking stack has a bug, or is there some deeper magic to multicast addressing that I'm not aware of?
  • 如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

    评论(1

    七月上 2024-08-12 00:56:15

    您是否先加入多播组?您必须明确告诉操作系统您想要加入的组,然后操作系统才会向您发送组的消息。您可以使用 setsockopt() 访问一个命令来加入多播组。来自 Darwin ip6 联机帮助页

    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.
    

    我找到了一些示例代码这里

    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));
    

    但也许你已经在这样做了吗?

    Are you joining the multicast group first? You have to explicitly tell the OS the group that you want to join before it will deliver you a group's messages. There's a command you can access with setsockopt() to join a multicast group. From the 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 some 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're doing this already?

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文