![bittorrent](https://i-blog.csdnimg.cn/blog_migrate/7ea2eae3fce8e719b40d19649bd51e6c.png)
bittorrent
![](https://i-blog.csdnimg.cn/blog_migrate/7c97a6452824a00ddda2851ed56c1391.png)
When your torrent client joins the swarm to share and gather file pieces, how exactly does it know where all its peers are? Read on as we poke around inside the mechanisms that undergird the BitTorrent protocol.
当您的洪流客户端加入群以共享和收集文件片段时,它如何确切地知道所有对等节点在哪里? 在我们深入了解构成BitTorrent协议的机制时,请继续阅读。
Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.
今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。
问题 (The Question)
SuperUser reader Steve V. had a very specific question about the Distributed Hash Table (DHT) system within the BitTorrent protocol:
超级用户读者Steve V.对BitTorrent协议中的分布式哈希表(DHT)系统有一个非常具体的问题:
I’ve already read this SuperUser answer and this Wikipedia article but both are too technical for me to really wrap my head around.
我已经阅读了SuperUser的答案和Wikipedia上的文章,但是对我来说,这两者都是太技术性的问题,无法真正解决。
I understand the idea of a tracker: clients connect to a central server which maintains a list of peers in a swarm.
我了解跟踪器的概念:客户端连接到中央服务器,该服务器维护群集中的对等方列表。
I also understand the idea of peer exchange: clients already in a swarm send the complete list of their peers to each other. If new peers are discovered, they are added to the list.
我也理解了对等交换的思想:已经成群的客户端将彼此的完整列表相互发送。 如果发现新的对等方,则将它们添加到列表中。
My question is, how does DHT work? That is, how can a new client join a swarm without either a tracker or the knowledge of at least one member of the swarm to exchange peers with?
我的问题是,DHT如何工作? 也就是说,没有跟踪者或不知道该群集中至少一个成员与之交换对等方的情况下,新客户端如何加入群集?
(Note: simple explanations are best.)
(注意:最好是简单的解释。)
His question in turn prompted a really detailed reply about the different functions of the BitTorrent system; let’s take a look at it now.
他的问题反过来又引发了有关BitTorrent系统不同功能的非常详细的答复。 让我们现在来看一下。
答案 (The Answer)
SuperUser contributor Allquixotic offers an in depth explanation:
超级用户贡献者Allquixotic提供了深入的解释:
How can a new client join a swarm without either a tracker or the knowledge of at least one member of the swarm to exchange peers with?
在没有跟踪者或不知道群集中至少一个成员与之交换对等对象的情况下,新客户端如何加入群集?
You can’t. It is impossible.*
你不能是不可能的。*
* (Unless a node on your local area network happens to already be a node in the DHT. In this case, you could use a broadcasting mechanism, such as Avahi, to “discover” this peer, and bootstrap from them. But how did they bootstrap themselves? Eventually, you’ll hit a situation where you need to connect to the public Internet. And the public Internet is unicast-only, not multicast, so you’re stuck with using pre-determined lists of peers.)
* (除非您局域网上的一个节点恰好已经是DHT中的一个节点。在这种情况下,您可以使用广播机制(例如Avahi)“发现”该对等节点,并从中进行引导。但是如何做到的他们会自行引导?最终,您将遇到需要连接到公共Internet的情况。公共Internet仅是单播的,而不是多播的,因此您必须使用预定的对等方列表。)
参考文献 (References)
Bittorrent DHT is implemented via a protocol known as Kademlia, which is a special case of theoretical concept of a Distributed hash table.
Bittorrent DHT通过称为Kademlia的协议实现,这是Distributed hash表的理论概念的特例。
展览会 (Exposition)
With the Kademlia protocol, when you join the network, you go through a bootstrapping procedure, which absolutely requires that you know, in advance, the IP address and port of at least one node already participating in the DHT network. The tracker that you connect to, for instance, may be itself a DHT node. Once you are connected to one DHT node, you then proceed to download information from the DHT, which provides you connectivity information for more nodes, and you then navigate that “graph” structure to obtain connections to more and more nodes, who can provide both connectivity to other nodes, and payload data (chunks of the download).
使用Kademlia协议,当您加入网络时,您需要执行自举程序,这绝对需要您事先知道至少一个已经参与DHT网络的节点的IP地址和端口。 例如,您连接到的跟踪器本身可能是DHT节点。 连接到一个DHT节点后,您便可以继续从DHT下载信息,该信息为您提供了更多节点的连接信息,然后您可以浏览该“图形”结构以获得与越来越多节点的连接,这些节点可以提供与其他节点的连接性以及有效载荷数据(下载块)。
I think your actual question in bold — that of how to join a Kademlia DHT network without knowing anyother members — is based on a false assumption.
我认为您的粗体实际问题(即如何在不认识任何其他成员的情况下加入Kademlia DHT网络的问题)基于错误的假设。
The simple answer to your question in bold is, you don’t. If you do not know ANY information at all about even one host which might contain DHT metadata, you are stuck — you can’t even get started. I mean, sure, you could brute force attempt to discover an IP on the public internet with an open port that happens to broadcast DHT information. But more likely, your BT client is hard-coded to some specific static IP or DNS which resolves to a stable DHT node, which just provides the DHT metadata.
以粗体显示您的问题的简单答案是,您不需要。 如果您甚至根本不了解可能包含DHT元数据的一台主机的任何信息,那么您就会陷入困境-您甚至无法上手。 我的意思是,可以肯定,您可以蛮力尝试在公共互联网上使用恰好广播DHT信息的开放端口来发现IP。 但是更可能的是,您的BT客户端被硬编码为某些特定的静态IP或DNS,该IP或DNS解析为一个稳定的DHT节点,该节点仅提供DHT元数据。
Basically, the DHT is only as decentralized as the joining mechanism, and because the joining mechanism is fairly brittle (there’s no way to “broadcast” over the entire Internet! so you have to unicastto an individual pre-assigned host to get the DHT data), Kademlia DHT isn’t really decentralized. Not in the strictest sense of the word.
基本上,DHT仅与连接机制一样分散,并且由于连接机制非常脆弱(无法在整个Internet上“广播”!因此,您必须单播到单个预先分配的主机上才能获得DHT数据),但Kademlia DHT并未真正分散。 严格意义上讲不是这样。
Imagine this scenario: Someone who wants P2P to stop goes out and prepares an attack on all commonly used stable DHT nodes which are used for bootstrapping. Once they’ve staged their attack, they spring it on all nodes all at once. Wham; every single bootstrapping DHT node is down all in one fell swoop. Now what? You’re stuck with connecting to centralized trackers to download traditional lists of peers from those. Well, if they attack the trackers too, then you’re really, really up a creek. In other words, Kademlia and the entire BT network is constrained by the limitations of the Internet itself, in that, there is a finite (and relatively small) number of computers that you would have to successfully attack or take offline to prevent >90% of users from connecting to the network.
想象一下这种情况:某个希望P2P停止的人出去了,并准备对所有用于引导的稳定DHT节点进行攻击。 一旦发动了攻击,他们就会立即在所有节点上发动攻击。 ham ; 每一个自举DHT节点都一口气掉下来。 怎么办? 您必须连接到集中式跟踪器,才能从中下载传统的对等方列表。 好吧,如果它们也攻击跟踪器,那么您真的非常小溪。 换句话说,Kademlia和整个BT网络都受到Internet自身的局限性的限制,因为有一定数量(且相对较小)的计算机必须成功攻击或脱机才能阻止> 90%用户连接到网络。
Once the “pseudo-centralized” bootstrapping nodes are all gone, the interior nodes of the DHT, which are not bootstrapping because nobody on the outside of the DHT knows about the interior nodes, are useless; they can’t bring new nodes into the DHT. So, as each interior node disconnects from the DHT over time, either due to people shutting down their computers, rebooting for updates, etc., the network would collapse.
一旦“伪集中”自举节点全部消失,DHT的内部节点(因为DHT外部的人都不了解内部节点)就无法自举,这些内部节点是无用的。 他们无法将新节点引入DHT。 因此,随着时间的推移,由于每个内部节点都与DHT断开连接,或者由于人们关闭计算机,重新启动以进行更新等原因,网络将崩溃。
Of course, to get around this, someone could deploy a patched BitTorrent client with a new list of pre-determined stable DHT nodes or DNS addresses, and loudly advertise to the P2P community to use this new list instead. But this would become a “whack-a-mole” situation where the aggressor (the node-eater) would progressively download these lists themselves, and target the brave new bootstrapping nodes, then take them offline, too.
当然,要解决此问题,有人可以部署具有新的预定稳定DHT节点或DNS地址列表的修补BitTorrent客户端,然后大声地向P2P社区做广告以使用此新列表。 但是,这将变成一种“恶作剧”的情况,其中攻击者(食节点者)将自己逐步下载这些列表,并以勇敢的新引导节点为目标,然后使它们也脱机。
Not only did we learn the answer to the original question but we also learned quite a bit about the nature of the BitTorrent system and its vulnerabilities.
我们不仅了解了原始问题的答案,而且还了解了有关BitTorrent系统及其漏洞的很多知识。
Have something to add to the explanation? Sound off in the the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.
有什么补充说明吗? 在评论中听起来不对。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程。
翻译自: https://www.howtogeek.com/163751/how-does-a-bittorrent-client-initially-discover-its-peers/
bittorrent