p2p开源库tcp/udp多播支持

发布于 2024-11-19 17:11:36 字数 252 浏览 4 评论 0原文

我的计算机上运行着某个应用程序。相同的应用程序可以在局域网或世界不同地方的许多计算机上运行。我想在他们之间进行交流。所以我基本上想要一个p2p系统。但我总是知道哪些计算机(特定的IP地址)将是对等的。我只希望同行具有加入和离开功能。最重要的目标是通信速度和所需的时间。我认为对等点之间的简单 UDP 多播(如果存在类似的情况)将是最快的解决方案。即使丢失我也不想重传消息。我应该使用现有的 p2p 库,例如 libjingle 等吗?或者只是从头开始创建一些基本框架,因为我的需求非常基本?

I have a certain application running on my computer. The same application can run on many computers on a LAN or different places in the world. I want to communicate between them. So I basically want a p2p system. But I will always know which computers(specific IP address) will be peers. I just want peers to have join and leave functionality. The single most important aim will be communication speed and time required. I assume simple UDP multicast (if anything like that exists) between peers will be fastest possible solution. I dont want to retransmit messages even if lost. Should I use an existing p2p library e.g. libjingle,etc. or just create some basic framework from scratch as my needs are pretty basic?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

虚拟世界 2024-11-26 17:11:36

我认为你没有抓住 UDP 的要点。从某种意义上说,消息更快到达目的地并不能节省任何时间,只是您发布消息而不关心它是否安全到达另一端。在 WAN 上 - 它可能不会到达另一端。跨网络的 UDP 是有问题的,因为它可能被带宽紧张的路径上的任何路由器丢弃 - 无法保证它的传送。

我不建议在您控制的拓扑之外使用 UDP。

至于 P2P 与定向套接字 - 问题是您需要移动什么。您是否需要所有对等点之间的双向/多向通信,或者您正在从所有节点与单个服务器进行通信?

您提到了多播 - 这意味着您有一些集中的数据源来传输信息,而其余的都在监听 - 在这种情况下,P2P 没有任何好处,并且多播作为 UDP 协议,可能无法在多个网络上正常工作。但是您可以使用 TCP 连接到每个节点,并自行“多播”,而不是通过 IGMP。如果您担心发送会阻塞您,您可以(并且应该)使用线程和非阻塞套接字,当然您可以使用 QoS 设置来“要求”路由器快速通过您的套接字。

I think you're missing the point of UDP. It's not saving any time in a sense that a message gets faster to the destination, it's just you're posting the message and don't care if it arrives safely to the other side. On WAN - it will probably not arrive on the other side. UDP accross networks is problematic, as it can be thrown out by any router on the way which is tight on bandwidth - there's no guarantee of delivery for it.

I wouldn't suggest using UDP out of the topology under your control.

As to P2P vs directed sockets - the question is what it is that you need to move around. Do you need bi/multidirectional communication between all the peers, or you're talking to a single server from all the nodes?

You mentioned multicast - that would mean that you have some centralized source of data that transmits information and all the rest listen - in this case there's no benefit for P2P, and multicast, as a UDP protocol, may not work well accross multiple networks. But you can use TCP connections to each of the nodes, and "multicast" on your own, and not through IGMP. You can (and should) use threading and non-blocking sockets if you're concerned about sending blocking you, and of course you can use the QoS settings to "ask" routers to rush your sockets through.

情绪操控生活 2024-11-26 17:11:36

您可以使用 Zeromq 来支持所有网络通信:
Zeromq 是一个封装 TCP 和 UDP 的简单库,用于高级通信。

对于 P2P,您可以使用 0mq 的不同模式:

  • 模式 PGM/EPGM 用于发现 LAN 上的 P2P 成员(它使用多播)
  • 模式 REQ/REP 用于向一位成员提问
  • 模式 PULL/PUSH 用于重复网络上的一个资源
  • 模式发布/订阅以将文件传输给所有请求者

警告,zeromq 很难在 Windows 上安装...

对于 HMI,请使用绿鞋?

You can use zeromq for support all network communication:
zeromq is a simple library encapsulate TCP and UDP for high level communication.

For P2P you can use the different mode of 0mq :

  • mode PGM/EPGM for discover member of P2P on your LAN (it use multicast)
  • mode REQ/REP for ask a question to one member
  • mode PULL/PUSH for duplicate one resource on the net
  • mode Publish/subscribe for transmission a file to all requester

Warning, zeromq is hard to install on windows...

And for HMI, use green-shoes ?

錯遇了你 2024-11-26 17:11:36

我认为你应该成功使用多播,
不幸的是我不知道任何库,

但如果你必须从头开始,

请看一下:
http://www.tldp.org/HOWTO/Multicast-HOWTO.html

祝你好运 :-)

i think you should succeed using multicast,
unfortunately i do not know any library,

but still in case you have to do it from scratch

take a look at this:
http://www.tldp.org/HOWTO/Multicast-HOWTO.html

good luck :-)

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