BitTorrent磁铁链接如何工作? [英] How do BitTorrent magnet links work?

查看:224
本文介绍了BitTorrent磁铁链接如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用磁铁链接.好奇它是如何工作的,我查看了规格并没有找到任何答案.维基说xt的意思是确切的主题",后跟带有SHA1哈希的格式(在这种情况下为btih).我看到提到了base32,知道它是每个字符5位和32个字符,我发现它正好可以容纳160位,这正好是SHA1的大小.

For the first time I used a magnet link. Curious about how it works, I looked up the specs and didn't find any answers. The wiki says xt means "exact topic" and is followed by the format (btih in this case) with a SHA1 hash. I saw base32 mentioned, knowing it's 5 bits per character and 32 characters, I found it holds exactly 160bits, which is exactly the size of the SHA1.

没有空间容纳IP地址或其他任何东西,而只是SHA1.那么,BitTorrent客户端如何找到实际文件?我打开了URL Snooper,以查看它是否访问了页面(使用TCP)或进行了查找等操作,但是没有任何反应.我不知道客户如何找到同龄人.如何运作?

There's no room for an IP address or anything, it's just a SHA1. So how does the BitTorrent client find the actual file? I turned on URL Snooper to see if it visits a page (using TCP) or does a lookup or the like, but nothing happened. I have no idea how the client finds peers. How does this work?

此外,哈希是什么?它是所有文件散列在一起的数组的哈希吗?也许是所需的实际torrent文件的哈希值(去除了某些信息)?

Also, what is the hash of? Is it a hash of an array of all the file hashes together? Maybe it's a hash of the actual torrent file required (stripping certain information)?

在虚拟机中,我尝试了与uTorrent(已全新安装)的磁力链接,它设法找到了对等节点.第一个同龄人来自哪里?它是新鲜的,没有其他种子.

In a VM, I tried a magnet link with uTorrent (which was freshly installed) and it managed to find peers. Where did the first peer come from? It was fresh and there were no other torrents.

推荐答案

BitTorrent磁力链接使用 1 SHA-1或被截断的SHA-256哈希值(称为"infohash")来标识torrent. .与跟踪器或其他对等方进行通信时,对等方(客户端)用于标识洪流的值与该值相同.传统的.torrent文件包含具有两个顶级密钥的数据结构:announce,用于标识要用于下载的跟踪器,以及info,用于包含torrent的文件名和哈希. "infohash"是编码的info数据的哈希.

A BitTorrent magnet link identifies a torrent using1 a SHA-1 or truncated SHA-256 hash value known as the "infohash". This is the same value that peers (clients) use to identify torrents when communicating with trackers or other peers. A traditional .torrent file contains a data structure with two top-level keys: announce, identifying the tracker(s) to use for the download, and info, containing the filenames and hashes for the torrent. The "infohash" is the hash of the encoded info data.

一些磁铁链接包括跟踪器或Web种子,但通常不包含这些链接.您的客户可能只对torrent一无所知.它需要做的第一件事就是找到其他正在下载种子的对等设备.它使用运行分布式哈希表"(DHT)的独立对等网络 2 进行此操作. DHT是一个大型的分布式索引,它将torrent(由信息哈希标识)映射到参与该洪流群(上传/下载数据或元数据)的对等方列表(由IP地址和端口标识).

Some magnet links include trackers or web seeds, but they often don't. Your client may know nothing about the torrent except for its infohash. The first thing it needs to is find other peers who are downloading the torrent. It does this using a separate peer-to-peer network2 operating a "distributed hash table" (DHT). A DHT is a big distributed index which maps torrents (identified by infohashes) to lists of peers (identified by IP address and ports) who are participating in a swarm for that torrent (uploading/downloading data or metadata).

客户端第一次加入DHT网络时,会从与信息哈希相同的空间生成一个随机的160位ID.然后,它使用由客户端开发人员控制的客户端的硬编码地址或先前在洪流群中遇到的支持DHT的客户端来引导其与DHT网络的连接.当它想加入一个给定的种子文件时,它会在DHT网络中搜索其他几个ID尽可能接近infohash的客户端.它会通知这些客户端其想要加入该群,并要求他们提供他们已经知道谁正在加入群的任何对等方的连接信息.

The first time a client joins the DHT network it generates a random 160-bit ID from the same space as infohashes. It then bootstraps its connection to the DHT network using either hard-coded addresses of clients controlled by the client developer, or DHT-supporting clients previously encountered in a torrent swarm. When it wants to participate in a swarm for a given torrent, it searches the DHT network for several other clients whose IDs are as close3 as possible to the infohash. It notifies these clients that it would like to participate in the swarm, and asks them for the connection information of any peers they already know of who are participating in the swarm.

当对等方上载/下载特定的洪流时,他们会尝试将彼此知道的所有其他对等方都参与同一洪流群.这使同伴可以快速相互了解,而无需使跟踪器或DHT受到不断的请求.一旦您从DHT获悉了一些对等节点,您的客户端就可以向这些对等节点请求torrent群中更多对等节点的连接信息,直到您拥有所需的所有对等节点为止.

When peers are uploading/downloading a particular torrent, they try to tell each other about all of the other peers they know of that are participating in the same torrent swarm. This lets peers know of each other quickly, without subjecting a tracker or DHT to constant requests. Once you've learned of a few peers from the DHT, your client will be able to ask those peers for the connection information of yet more peers in the torrent swarm, until you have all of the peers you need.

最后,我们可以向这些对等节点索要torrent的info元数据,其中包含文件名和哈希列表.一旦下载了此信息并使用已知的infohash验证了它的正确性,我们就与以常规.torrent文件开头并从随附的跟踪器获得对等项列表的客户端处于实际上的位置.

Finally, we can ask these peers for the torrent's info metadata, containing the filenames and hash list. Once we've downloaded this information and verified that it's correct using the known infohash, we're in practically the same position as a client that started with a regular .torrent file and got a list of peers from the included tracker.

下载可能会开始.

1 信息散列通常是十六进制编码的,但是某些旧客户端改为使用基数32. v1(urn:btih:)直接使用SHA-1摘要,而v2(urn:bimh:)添加 multihash 前缀以标识哈希算法和摘要长度.
2 有两个主要的DHT网络:更简单的主线" DHT和Azureus使用的更复杂的协议.
3 距离是通过XOR测量的.

1 The infohash is typically hex-encoded, but some old clients used base 32 instead. v1 (urn:btih:) uses the SHA-1 digest directly, while v2 (urn:bimh:) adds a multihash prefix to identify the hash algorithm and digest length.
2 There are two primary DHT networks: the simpler "mainline" DHT, and a more complicated protocol used by Azureus.
3 The distance is measured by XOR.

  • BEP-3: The BitTorrent Protocol Specification
  • BEP-52: The BitTorrent Protocol Specification v2
  • BEP-5: DHT Protocol
  • BEP-9: Extension for Peers to Send Metadata Files
  • BEP-10: Extension Protocol
  • BEP-11: Peer Exchange (PEX)
  • Azureus DHT Description

这篇关于BitTorrent磁铁链接如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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