通过 Internet 发送 UDP 数据包

发布于 2024-10-28 11:47:40 字数 221 浏览 1 评论 0原文

我正在尝试了解 P2P/去中心化网络的一些细节。我的问题如下。假设我有两台名为 comp1 和 comp2 的机器。现在,comp1 设置在我的家庭网络中的路由器后面,comp2 位于我的办公室中,也位于路由器后面。我是否可以像这样在 Internet 上来回发送 UDP 数据包,当然假设端口已正确转发?为了更深入地了解我正在调查的内容,我试图弄清楚新节点如何在不使用中央服务器的情况下发现现有节点。

谢谢你!

I'm trying to learn some of the ins and outs of P2P/decentralized networks. My question is the following. Say I have two machines named comp1 and comp2. Now comp1 is setup on my home network behind a router, and comp2 is located in my office at also behind a router. Is it possible for me to send UDP packets back and forth across the Internet like this assuming of course that ports are forwarded properly? To offer more insight on what I'm investigating, I'm trying to figure out how a new node would discover existing nodes without the use of a central server.

Thank you!

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

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

发布评论

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

评论(2

浮生面具三千个 2024-11-04 11:47:40

假设,正如您所说,端口转发正确,您可以将 UDP 数据包发送到路由器后面的 2 个客户端。

检测本地 Intranet 上的客户端的一个好方法可能是使用多播,但是这并没有得到 ISP 的广泛支持(至少在英国),因此不能依赖。许多设备发现平台都使用组播,例如 mDNS(用于 Apple 的 Bonjour)

http://en.wikipedia。 org/wiki/Multicast

(它基本上是通过客户端订阅组,然后向该组发送消息来工作的)

我认为通过互联网发现新客户端的最佳方法是拥有一台新客户端联系的服务器它知道它们存在,然后集中式服务器将告诉所有其他客户端有关您的信息。例如,这在现代战争 2 等 P2P 游戏中使用,这就是“追踪者”在 BitTorrent 协议中所做的事情。

这并不是完全去中心化的,但它可能是最容易实现、也是最可靠的。

Assuming, as you said the ports are forwarded correctly you can send UDP packets to 2 clients behind router's.

A good way of detecting clients on a local intranet may be using Multicast, however this does not have widespread support on ISP's (At least here in the UK) so cannot be relied upon. Multicast is used by many device discovery platforms, such as mDNS (used inApple's Bonjour)

http://en.wikipedia.org/wiki/Multicast

(It basically works by clients subscribing to groups, and then sending messages to that group)

I think the best way of discovering new clients over the internet is to have one server which new clients contact to let it know they exist, then the centralised server will tell all the other clients about you. This is used for example in P2P games such as Modern Warfare 2 and this is what the "Trackers" do in the BitTorrent protocol.

This isn't entirely decentralised but it's probably the easiest to implement, and the most reliable.

蓝眼泪 2024-11-04 11:47:40

要添加 Dotmister 的响应,如果端口未正确转发(例如,路由器未静态配置为转发端口),您将必须查看类似 UDP 打洞。无论哪种方式,为了在没有某种中央服务器的情况下发现新节点,您都必须依赖某种多播。

To add to Dotmister's response, if the ports are not forwarded correctly (e.g. the router isn't statically configured to forward the ports), you will have to look into something like UDP hole punching. Either way, in order to discover a new node without some sort of central server you'll have to rely on some sort of Multicast.

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