通过Internet发送UDP数据包 [英] Sending UDP packets over the Internet

查看:115
本文介绍了通过Internet发送UDP数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解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.

谢谢!

推荐答案

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

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

检测本地Intranet上的客户端的一种好方法可能是使用多播,但是它在ISP(至少在英国是这里)上没有广泛的支持,因此不能依靠.许多设备发现平台都使用多播,例如mDNS(在Apple的Bonjour中使用)

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)

我认为在Internet上发现新客户端的最佳方法是让一台服务器与新客户端联系,以使其知道它们的存在,然后集中式服务器将向所有其他客户端告知您.例如在现代战争2等P2P游戏中使用的,这就是BitTorrent协议中跟踪器"的作用.

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.

这篇关于通过Internet发送UDP数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆