如何像种子(torrents)那样通过全球互联网发送数据?

huangapple go评论85阅读模式
英文:

How to send data over global internet like torrents do?

问题

我正在开发一个移动应用程序,希望在全球互联网上无需服务器将数据发送到其他设备。

假设有两台移动设备,其IP地址分别为 XY,它们位于全球互联网上。它们彼此知道对方的地址,并且希望在没有远程服务器的情况下相互通信。他们决定使用端口 A1 进行通信。如果 XY 发送数据到端口 A1,这些数据是否会被传送,而不会被网络服务提供商(ISPs)阻止?

我对网络不太熟悉,只了解一些基础知识。从理论上讲,只要IP的端口是开放的,并且它们通过一些网络相连,数据应该能够传递,没有问题。我之所以问这个问题,是因为我对于如何在全球互联网上,没有服务器和静态IP的情况下,种子文件是如何相互传递数据的很感兴趣。另外,我不确定是否存在任何标准的阻止措施,比如每个网络服务提供商只允许使用从 A1 到 A100 的端口。我知道大多数规则可能取决于网络服务提供商,但在这个例子中,让我们考虑一些典型的正常情况下的网络服务提供商。对于任何解释,我都表示感谢。

英文:

I am developing a mobile app where I want to send data to other devices without servers over the global internet.

Suppose that there are 2 mobile devices with IP addresses X and Y that are on the global internet. They both know each other's addresses and want to communicate with each other without a remote server. They decided to use port A1 for that. If X will send data to Y on the port A1 will it be delivered without ISPs blocking it?

I am not that familiar with networking, only know some basics. In theory, it should deliver it without problems as long as IP's port is open and they are connected through some networks. The reason I am asking this is that I am interested in how do torrents send data to each other on the global internet without servers and static IPs, also I am not sure if there are any standard blocks that ISPs could put, for example, every ISP only allows ports from A1-A100. I know most of the rules might depend on ISP but for this example let's consider some typical normal ISP. Any explanation would be appreciated.

答案1

得分: 4

这被称为Hole Punching,可用于TCPUDP。实际上,这个概念非常简单:

  1. 客户端在中间服务器之间提供它们的套接字信息。
  2. 服务器更新套接字信息(如果在客户端和服务器之间存在NAT或代理)。
  3. 服务器将套接字信息共享给目标客户端。
  4. 客户端通过对等连接通过其他套接字信息连接到彼此。

其中许多已经在Github上。请查看。

英文:

It's called Hole Punching, can be used for TCP or UDP. The concept is pretty simple actually:

  1. clients are giving their sockets information between intermediary server
  2. the server update the socket information (if there is a NAT or Proxy between client and server)
  3. server share the socket information to target client
  4. client connect on each through other socket information via peer-to-peer connection

Many of those are already in Github. Check it.

答案2

得分: 0

我在网络方面也不是很擅长,Torrents 使用浏览器IP。以下是一篇文章:如何检查您的Torrent IP地址
以下是一些源代码链接。
WebTorrent
BitTorrent
希望这能给您一些关于它们如何工作的想法。

英文:

I am also not very good at networking, torrents works with your browser IP. Here is an article: How to check your torrent IP address
Below some links to the source codes.
WebTorrent and
BitTorrent
I hope this gives you some ideas on how they work.

答案3

得分: 0

short answer : 是的。

long answer :
有多种选项可以实现这一点:

  1. WebRTC(Web实时通信)是一种技术,使Web应用程序和站点能够捕获和选择性地传输音频和/或视频媒体,并在浏览器之间交换任意数据,而无需中介。

现在在初始过程中需要一个服务器,两个对等体将在其中交换数据以相互连接。

  1. IPFS(星际文件系统):一个点对点的超媒体协议,
    旨在使Web变得更快、更安全、更开放。它是一个类似于种子的点对点文件传输协议。

您可以选择使用第一个选项WebRTC,因为它在现代基于Web的应用程序中易于使用,大多数浏览器现在都支持WebRTC。

英文:

your question : is it possible to send data between 2 non-static IPs like 2 mobile phones on the global internet, preferably with some sources.

short answer : yes .

long answer :
There are multiple options to achieve this

  1. WebRTC (Web Real-Time Communication) is a technology which enables Web applications and sites to capture and optionally stream audio and/or video media, as well as to exchange arbitrary data between browsers without requiring an intermediary.

now there is a need of server in the initial process where both peers will exchange data to connect to each other

2.IPFS - InterPlanetary File System : A peer-to-peer hypermedia protocol
designed to make the web faster, safer, and more open.its a peer to peer file transfer protocol like torrent.

you can use the first option WebRTC, as it is easy to use in modern web-based applications and most browsers support WebRTC now a days

huangapple
  • 本文由 发表于 2020年7月23日 14:58:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/63048587.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定