可靠的组播库 C++

Reliable Multicast Library C++

我知道 this and this Whosebug 问题,这些问题回答了已知的实现方法 "Reliable Multicast" 但是最近我遇到了一些网站,其中提到甚至路由器也应该被编程为处理自定义协议是基于 UDP 设计的,是真的吗?

基本上我想为我的应用程序使用多播并且我不想对更改路由器施加任何限制以配置自定义协议以可靠的方式处理 UDP,例如我正在考虑 implementing/using通过 UDP 的 PGM 协议来处理多播,但有人说路由器也应该支持 PGM,这限制了我提供解决方案,因为客户应该为我的解决方案更改基础设施,这是没有根据的。

请让我知道是否有任何我可以实施的解决方案来以可靠的方式处理 UDP 数据包,而无需对网络基础设施进行任何更改。

提前致谢。

编辑:

我并不是说我不想在路由器中启用多播,我肯定会在路由器中启用多播路由。当我读到有关 PGM 实现的内容时,有人说甚至路由器也应该具有 PGM 功能,我认为这与商店中的商用路由器不同。我的理解错了吗?

如果您使用多播,您需要向网络基础设施添加多播支持要求。除非在网络设备(多播路由器)上启用多播路由,否则多播将仅在一个 LAN 内可用。

通过 Internet 基础设施的唯一可靠方法是单播。

更新:多播路由是在网络层执行的,多播路由器不需要知道transport/application层的任何信息。在某些情况下,网络层需要有关应用层的知识,但几乎所有情况都与 NAT ALG(应用层网关)有关。

顺便说一下,通过 Internet 传递多播的一种可能解决方案是隧道协议(GRE、IP over IP 等)。

如果您不能或不想将路由器配置为转发多播流量或以其他方式处理第三方协议,则需要通过单播隧道传送多播流量 link。 UFTP 能够通过使用 UFTP 代理服务器进行多播隧道传输。

来自手册页:

The proxy can run in one of three modes: a server proxy, a client proxy, or response proxy.

A server proxy is typically local to a server and acts as the upstream end of a multicast tunnel. It listens on the public multicast address (and private multicast address when specified) and forwards downstream packets to a specific address downstream. Upstream packets are forwarded back where the announcement originated from.

A client proxy is typically local to one or more clients and forms the downstream end of a multicast tunnel. It receives unicast data from one or more server proxies and forwards downstream traffic to the multicast address specified in the packet header. Upstream traffic from clients is gathered and forwarded back where the announcement came from as an aggregated response.

下图是一个典型的配置图,其中服务器将多播消息发送到本地网络,一个或多个服务器代理将消息单播到相应的客户端代理,而客户端代理又将消息多播到其本地网络。

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x                                              Network A   x
x   ----------                                             x
x   | Server |                                             x
x   ----------                                             x
x        |                                                 x
x        |  multicast                                      x
x        |                                                 x
x        |-----------------------------------------        x
x        |                   |                    |        x
x        v                   v                    v        x
x   ----------------    ----------------      ----------   x
x   | Server Proxy |    | Server Proxy |      | Client |   x
x   ----------------    ----------------      ----------   x
x        |                   |                             x
x        |  unicast          |  unicast                    x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
         |                   |
         |                   ------------
         |                              |
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx   xxxxxxxxxxxxxxxxxxxxxxxxxxxx
x        |       Network B  x   x       |       Network C  x
x        v                  x   x       v                  x
x  ----------------         x   x  ----------------        x
x  | Client Proxy |         x   x  | Client Proxy |        x
x  ----------------         x   x  ----------------        x
x       |                   x   x       |                  x
x       |  multicast        x   x       |  multicast       x
x       |                   x   x       |                  x
x       |-------------      x   x       |------------      x
x       |            |      x   x       |           |      x
x       v            v      x   x       v           v      x
x  ----------   ----------  x   x  ----------  ----------  x
x  | Client |   | Client |  x   x  | Client |  | Client |  x
x  ----------   ----------  x   x  ----------  ----------  x
x                           x   x                          x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx   xxxxxxxxxxxxxxxxxxxxxxxxxxxx

这些代理也能够在 NATed 环境中工作:

If a client proxy is behind a firewall, the proxy can send a heartbeat message to the upstream proxy to make a pinhole in the firewall that the upstream server proxy can connect to. If the client proxy is also NATed, the upstream server proxy may not know the IP/port of the client proxy, so the server proxy can be configured to wait for a heartbeat message, and use the IP/port the heartbeat came from as its downstream address. If the server proxy is also behind a firewall or NAT, a second server proxy on a machine with a publicly accessible IP can be inserted between the first server proxy and the client proxy. In this case, the first server proxy is set up to use the second as its downstream address, and the second server proxy is set up to use the first heartbeat it receives from a client proxy as its downstream address.

我是这个软件的作者,所以如果你需要关于如何设置它的指导,请通过 UFTP 页面底部的 link 给我发一封电子邮件,我们会看到什么我们可以做到。

更新:

对于 PGM,它可以在应用层(即在 UDP 之上)或在传输层(即直接在 IP 之上)配置为 运行。如果 PGM 在传输层 运行,您可能需要担心路由器对它有特殊支持。相反,UFTP运行严格在应用层。