UDP 广播还是 IP 组播?
如果您必须实现网络广播,您会在新应用程序中使用 UDP 广播还是 IP 多播? 为什么?
您使用这两种方法时遇到的优点和缺点是什么? (特别是有关 VPN、不同子网、各种路由器等的问题)
If you had to implement a network broadcast, would you use UDP broadcast or IP multicast in a new application? Why?
What are the benefits and drawbacks you encountered with either method? (Especially concerning problems with VPNs, different subnets, various routers etc.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
组播的缺点是路由器和 NAT 不能很好地支持它。 如果所有客户端都位于仅具有简单网桥的同一网络上,则多播效果很好,并且可以避免不属于该组的计算机的广播寻址开销。 如果路由器支持 IGMP 并正确传播 TTL,则它可以在本地网络上工作。 人们曾尝试通过 Internet 进行多播,例如 Mbone,并取得了不同程度的成功。 他们中的大多数使用某种隧道来绕过网桥和不合规的路由器。
然而,对于多播数据包的一个警告是,如果存在任何 WiFi 连接接入点将对多播数据包使用尽可能低的比特率,并且需要来自所有客户端的确认,即使是那些不属于多播组的客户端。 对于不参与的客户和电池寿命也有缺点。
Multicast has the drawback that it is not well supported by routers and NAT. If all of your clients are on the same network with only simple bridges, multicast works great and avoids the overhead of broadcast addressing for machines that are not part of the group. If the routers support IGMP and properly propagate the TTL it can work on local networks. There have been attempts to do multicast across the Internet, such as Mbone, with various levels of success. Most of them use some sort of tunnel to get around bridges and non-compliant routers.
One caveat for multicast packets, however, is if there are any WiFi connections the access point will use the slowest possible bit rate for the multicast packets and requires acks from all clients, even those who are not part of the multicast group. There are also drawbacks for non-participating clients and battery life.
选择最合适的方法取决于应用程序的性质以及运行该应用程序的网络的配置 - 没有硬性或快速的规则。
因此我不会强制执行 - 我会允许配置广播地址。
如果用户在 224.0.0.0/4 范围内配置某些内容,则它是多播的,否则它是广播的。
The choice of which is most appropriate depends on the nature of the application and the configuration of the networks over which it's to be run - there's no hard or fast rules.
I therefore wouldn't enforce either - I'd allow configuration of the broadcast address.
If the user configures something in the 224.0.0.0/4 range then it's multicast, otherwise it's broadcast.
多播的行为方式几乎(但不完全)不同于所有其他类型的网络流量。 您的系统和网络管理员不会感谢您将其强加于他们。 这通常是巫术,在我看来,如果可以的话最好避免。
The way multicast behaves is almost, but not entirely, unlike every other type of network traffic. Your systems and network administrators won't thank you for forcing it on them. It's often voodoo, and IMO best avoided if you can.