简体   繁体   English

Kademlia / DHT如何获取节点ID并更新同伴离开群组?

[英]How does Kademlia/DHT get the node ID and update the peer leaving the swarm?

I've read the paper-Kademlia: A Peer-to-peer Information System Based on the XOR Metric. 我读过Kademlia:基于XOR度量的点对点信息系统。 but i still have 2 questions. 但我还有两个问题。

Q1:How does a node get its node id? Q1:节点如何获得其节点ID?

BEP5 says: Each node has a globally unique identifier known as the "node ID." BEP5说:每个节点都有一个全称唯一的标识符,称为“节点ID”。 Node IDs are chosen at random from the same 160-bit space as BitTorrent infohashes . 节点ID是从与BitTorrent信息相同的160位空间中随机选择的。

Then if you choose at random,how do you choose and how to make sure the id you choose is globally unique? 然后,如果您随机选择,您如何选择以及如何确保您选择的ID是全球唯一的? I mean somebody may choose the same id as yours. 我的意思是有人可能选择与你相同的身份。

Q2: How does the node storing the key-value know if some peer leave the swarm? Q2:存储键值的节点如何知道某个对等体是否离开了群组?

The paper I mentioned in the first line says:To compensate for nodes leaving the network, Kademlia republishes each key-value pair once an hour. 我在第一行中提到的论文说:为了补偿离开网络的节点,Kademlia每小时重新发布一次键值对。

But if I were the node, i want to update who is still downloading one certain file, i still have no idea who have left the swarm. 但如果我是节点,我想更新谁还在下载某个文件,我仍然不知道谁离开了这个群。

Then if you choose at random,how do you choose 那么如果你随意选择,你如何选择

With a random number generator. 随机数发生器。

how to make sure the id you choose is globally unique? 如何确保您选择的ID是全球唯一的?

It is exceedingly unlikely that someone will choose the same node ID at random. 人们极不可能随机选择相同的节点ID。 The keyspace is 160bits in size. 密钥空间大小为160位。 That's 2^160 possibilities. 这是2 ^ 160种可能性。 That's slightly fewer than Earth has atoms. 这比地球有原子的要少一些。

Q2: How does the node storing the key-value know if some peer leave the swarm? Q2:存储键值的节点如何知道某个对等体是否离开了群组?

It doesn't. 它没有。 It simply times out values that are not refreshed. 它只会超出未刷新的值。

But if I were the node, i want to update who is still downloading one certain file 但如果我是节点,我想更新谁还在下载某个文件

The goal of the DHT is not to have an accurate reflection of who's downloading a torrent, it's only there to provide initial contacts to join a swarm. DHT的目标不是要准确反映谁在下载洪流,而只是提供初始联系人加入群。 Slight inaccuracies do not matter. 轻微的不准确无关紧要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM