两台计算机通过Internet互相查找

时间:2022-02-02 08:59:17

Given two computers attached to the Internet that know nothing about each other before hand, is it possible for one computer to be able to broadcast a message so that the second computer could receive it and respond?

鉴于连接到互联网的两台计算机之前对彼此一无所知,一台计算机是否可以广播一条消息,以便第二台计算机可以接收并响应?

I know UDP broadcast exsits, but I believe that those are generally filtered by the ISP before it reaches the true Internet. Is this true?

我知道UDP广播存在,但我相信这些通常在它到达真正的互联网之前被ISP过滤掉。这是真的?

9 个解决方案

#1


12  

The current best way to achieve a multinode network without centralized coordination is through the use of Distributed Hash Tables. That link explains a bit and links to various implementations you can leverage.

在没有集中协调的情况下实现多节点网络的当前最佳方法是使用分布式哈希表。该链接解释了一些可以利用的各种实现的链接。

That said, you still need each machine to coordinate with at least some peers. It's just that you don't need it to coordinate with a central server. A solution using a central server that know both (all) participating machines will also work, but imposes further restrictions on anonymity and scalability, just remember what happened to Napster.

也就是说,你仍然需要每台机器至少与一些同行协调。只是你不需要它与*服务器协调。使用知道两个(所有)参与机器的*服务器的解决方案也将起作用,但对匿名性和可扩展性施加进一步限制,只记得Napster发生了什么。

#2


7  

You need an intermediate third party that they both know, that could distribute messages directed towards it in a broadcast-like fashion.

您需要一个他们都知道的中间第三方,它可以以类似广播的方式分发针对它的消息。

#3


4  

A solution for this problem (where none of your peers know the final address of the other) could be relying on IM protocols.

针对此问题的解决方案(其中没有一个对等方知道另一方的最终地址)可能依赖于IM协议。

In particular, the XMPP protocol is extensible, open and used by many providers such as Google Talk. Libraries exist for most languages and it has the plus of being able to work (slowly and going through a 3rd party server) even if both hosts are behind a NAT-box.

特别是,XMPP协议是可扩展的,开放的,并被许多提供商使用,例如Google Talk。大多数语言都存在库,即使两个主机都在NAT框之后,它也能够工作(慢慢地通过第三方服务器)。

If communication must use another channel, you can use XMPP to exchange IP address and then proceed with the standard socket route (but if you encrypt your messages, there should be no problem even going through a 3rd party server - to be true all packets go through untrusted 3rd party routers so you should encrypt anyway if you have sensitive data..).

如果通信必须使用另一个通道,您可以使用XMPP交换IP地址,然后继续使用标准套接字路由(但如果您加密消息,即使通过第三方服务器也应该没有问题 - 所有数据包都是真的通过不受信任的第三方路由器,所以如果你有敏感数据,你应该加密..)。

Hope this helps.

希望这可以帮助。

#4


2  

No, you can't broadcast like that over the internet. You need to know which address you want your packets to go to.

不,你不能通过互联网这样播放。您需要知道您希望数据包到达哪个地址。

#5


2  

A possible solution for you is to use a dynamic DNS service.

您可能的解决方案是使用动态DNS服务。

Your application would need to know in advance which hostname the other host will be using, but this service would at least get around the fact that you don't know exactly which IP address the other computer is on.

您的应用程序需要事先知道其他主机将使用哪个主机名,但此服务至少可以解决您不确切知道另一台计算机所在的IP地址的问题。

Note that this won't solve the potential issue of firewalls between the two hosts blocking your packets. The only practical way around that is for both hosts to open an outbound connection to a central host which can then relay data between them.

请注意,这不能解决阻止数据包的两台主机之间防火墙的潜在问题。唯一可行的方法是两台主机打开到*主机的出站连接,然后*主机可以在它们之间中继数据。

#6


2  

Look at the chord or pastry algorithm. It is an overlay network (DHT based) which has a discovery mechanism involved. It's a P2P (Peer 2 Peer) routing algorithm.

看看和弦或糕点算法。它是一个覆盖网络(基于DHT),它涉及一个发现机制。它是P2P(Peer 2 Peer)路由算法。

#7


1  

UDP is a dead end - its just a protocol where the order the packets are received is less important and there are issues routing over WANS. You said that you want to connect two computer on the "internet" presumably with the end points moving around etc. The only way is to use a central server as a register/directory. If each end point allso a web service or something and registeres its current IP address and name periodically then the other end point can look up the IP address of the other using this service. (could host your own DNS server and code your end point to register on this DNS?)

UDP是一个死胡同 - 它只是一个协议,接收数据包的顺序不太重要,并且在WANS上存在路由问题。你说你想在“互联网”上连接两台计算机,大概是端点移动等等。唯一的方法是使用*服务器作为注册/目录。如果每个端点都是Web服务或其他东西,并定期注册其当前的IP地址和名称,则另一端点可以使用此服务查找另一端点的IP地址。 (可以托管您自己的DNS服务器并编写您的终点以在此DNS上注册?)

One of the problems is that even if you have the IP address what is one or more nodes are behind a firewall or NAT router ? You will need to host a server to proxy traffic. The best example is SKYPE - look into how it works it is documented, very interesting.

其中一个问题是,即使您拥有IP地址,防火墙或NAT路由器后面的一个或多个节点是什么?您需要托管服务器以代理流量。最好的例子是SKYPE - 看看它是如何工作的,它是有记录的,非常有趣。

The simplist answer might be to jump on the back on an existing service such as messanger, skype, bit torrent, etc.

简单的回答可能是跳过现有的服务,如messanger,skype,bit torrent等。

Simon

#8


1  

If the computers are running Windows, I'd look at using PNRP.

如果计算机运行的是Windows,我会考虑使用PNRP。

#9


-2  

Multicasting is also a possible solution. It's certainly feasible in a corporate network

多播也是一种可能的解决方案。它在企业网络中肯定是可行的

#1


12  

The current best way to achieve a multinode network without centralized coordination is through the use of Distributed Hash Tables. That link explains a bit and links to various implementations you can leverage.

在没有集中协调的情况下实现多节点网络的当前最佳方法是使用分布式哈希表。该链接解释了一些可以利用的各种实现的链接。

That said, you still need each machine to coordinate with at least some peers. It's just that you don't need it to coordinate with a central server. A solution using a central server that know both (all) participating machines will also work, but imposes further restrictions on anonymity and scalability, just remember what happened to Napster.

也就是说,你仍然需要每台机器至少与一些同行协调。只是你不需要它与*服务器协调。使用知道两个(所有)参与机器的*服务器的解决方案也将起作用,但对匿名性和可扩展性施加进一步限制,只记得Napster发生了什么。

#2


7  

You need an intermediate third party that they both know, that could distribute messages directed towards it in a broadcast-like fashion.

您需要一个他们都知道的中间第三方,它可以以类似广播的方式分发针对它的消息。

#3


4  

A solution for this problem (where none of your peers know the final address of the other) could be relying on IM protocols.

针对此问题的解决方案(其中没有一个对等方知道另一方的最终地址)可能依赖于IM协议。

In particular, the XMPP protocol is extensible, open and used by many providers such as Google Talk. Libraries exist for most languages and it has the plus of being able to work (slowly and going through a 3rd party server) even if both hosts are behind a NAT-box.

特别是,XMPP协议是可扩展的,开放的,并被许多提供商使用,例如Google Talk。大多数语言都存在库,即使两个主机都在NAT框之后,它也能够工作(慢慢地通过第三方服务器)。

If communication must use another channel, you can use XMPP to exchange IP address and then proceed with the standard socket route (but if you encrypt your messages, there should be no problem even going through a 3rd party server - to be true all packets go through untrusted 3rd party routers so you should encrypt anyway if you have sensitive data..).

如果通信必须使用另一个通道,您可以使用XMPP交换IP地址,然后继续使用标准套接字路由(但如果您加密消息,即使通过第三方服务器也应该没有问题 - 所有数据包都是真的通过不受信任的第三方路由器,所以如果你有敏感数据,你应该加密..)。

Hope this helps.

希望这可以帮助。

#4


2  

No, you can't broadcast like that over the internet. You need to know which address you want your packets to go to.

不,你不能通过互联网这样播放。您需要知道您希望数据包到达哪个地址。

#5


2  

A possible solution for you is to use a dynamic DNS service.

您可能的解决方案是使用动态DNS服务。

Your application would need to know in advance which hostname the other host will be using, but this service would at least get around the fact that you don't know exactly which IP address the other computer is on.

您的应用程序需要事先知道其他主机将使用哪个主机名,但此服务至少可以解决您不确切知道另一台计算机所在的IP地址的问题。

Note that this won't solve the potential issue of firewalls between the two hosts blocking your packets. The only practical way around that is for both hosts to open an outbound connection to a central host which can then relay data between them.

请注意,这不能解决阻止数据包的两台主机之间防火墙的潜在问题。唯一可行的方法是两台主机打开到*主机的出站连接,然后*主机可以在它们之间中继数据。

#6


2  

Look at the chord or pastry algorithm. It is an overlay network (DHT based) which has a discovery mechanism involved. It's a P2P (Peer 2 Peer) routing algorithm.

看看和弦或糕点算法。它是一个覆盖网络(基于DHT),它涉及一个发现机制。它是P2P(Peer 2 Peer)路由算法。

#7


1  

UDP is a dead end - its just a protocol where the order the packets are received is less important and there are issues routing over WANS. You said that you want to connect two computer on the "internet" presumably with the end points moving around etc. The only way is to use a central server as a register/directory. If each end point allso a web service or something and registeres its current IP address and name periodically then the other end point can look up the IP address of the other using this service. (could host your own DNS server and code your end point to register on this DNS?)

UDP是一个死胡同 - 它只是一个协议,接收数据包的顺序不太重要,并且在WANS上存在路由问题。你说你想在“互联网”上连接两台计算机,大概是端点移动等等。唯一的方法是使用*服务器作为注册/目录。如果每个端点都是Web服务或其他东西,并定期注册其当前的IP地址和名称,则另一端点可以使用此服务查找另一端点的IP地址。 (可以托管您自己的DNS服务器并编写您的终点以在此DNS上注册?)

One of the problems is that even if you have the IP address what is one or more nodes are behind a firewall or NAT router ? You will need to host a server to proxy traffic. The best example is SKYPE - look into how it works it is documented, very interesting.

其中一个问题是,即使您拥有IP地址,防火墙或NAT路由器后面的一个或多个节点是什么?您需要托管服务器以代理流量。最好的例子是SKYPE - 看看它是如何工作的,它是有记录的,非常有趣。

The simplist answer might be to jump on the back on an existing service such as messanger, skype, bit torrent, etc.

简单的回答可能是跳过现有的服务,如messanger,skype,bit torrent等。

Simon

#8


1  

If the computers are running Windows, I'd look at using PNRP.

如果计算机运行的是Windows,我会考虑使用PNRP。

#9


-2  

Multicasting is also a possible solution. It's certainly feasible in a corporate network

多播也是一种可能的解决方案。它在企业网络中肯定是可行的