问题描述
我正在编码一个我想使其分散化的p2p实现,但是在掌握像bittorrent这样的协议中DHT的工作方式时遇到了一些麻烦.如果没有跟踪器,客户端如何知道对等方在哪里?同行是否存储在实际的torrent文件中?
对于无跟踪器/DHT种子,对等IP地址使用BitTorrent infohash作为密钥存储在DHT中.因为基本上所有的跟踪器都响应放置/获取请求,所以此功能与DHT(分布式哈希表)提供的接口完全对应:它允许您通过infohash查找并在DHT中存储IP地址. /p>
因此,获取"请求将查找BT infohash并返回一组IP地址. 放置"存储给定信息哈希的IP地址.这对应于您本应向跟踪器发出的通告"请求,以接收对等IP地址的字典.
在DHT中,对等点被随机分配以存储属于键空间的一小部分的值;散列可确保密钥在参与对等方之间随机分布. DHT协议(用于BitTorrent的 Kademlia )可确保将放置/获取请求有效地路由到负责的同行用于维护给定密钥的IP地址列表.
I'm coding a p2p implementation that I would like to make decentralized however I'm having some trouble grasping how DHT in protocols like bittorrent work. How does the client know where the peers are if there is no tracker? Are peers stored in the actual torrent file?
With trackerless/DHT torrents, peer IP addresses are stored in the DHT using the BitTorrent infohash as the key. Since all a tracker does, basically, is respond to put/get requests, this functionality corresponds exactly to the interface that a DHT (distributed hash table) provides: it allows you to look up and store IP addresses in the DHT by infohash.
So a "get" request would look up a BT infohash and return a set of IP addresses. A "put" stores an IP address for a given infohash. This corresponds to the "announce" request you would otherwise make to the tracker to receive a dictionary of peer IP addresses.
In a DHT, peers are randomly assigned to store values belonging to a small fraction of the key space; the hashing ensures that keys are distributed randomly across participating peers. The DHT protocol (Kademlia for BitTorrent) ensures that put/get requests are routed efficiently to the peers responsible for maintaining a given key's IP address lists.
这篇关于种子中的DHT如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!