向Kademlia添加新节点,构建Kademlia路由表 [英] Adding new nodes to Kademlia, building Kademlia routing tables

查看:111
本文介绍了向Kademlia添加新节点,构建Kademlia路由表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不太了解Kademlia DHT的加入过程.我在线上看过一些教程和演示文稿,但是它们似乎都以相同的方式说些事情,并且所有psedo代码等在大多数情况下都是相同的(实际复制/粘贴).

I can't quite wrap my brain around the joining process of Kademlia DHTs. I've seen a few tutorials and presentations online, but they all seem to say things the same way and all psedo code etc is the same in most (actual copy/paste).

有人可以对此进行高层介绍吗?

Can somebody give a high level walk through on this?

推荐答案

我假设您已阅读 Kademlia纸.以下摘录自我的文章《 Kademlia DHT简介》和《工作原理

I'm assuming you've read the Kademlia paper. Here's an excerpt from my article An Introduction to Kademlia DHT & How It Works

一些背景信息:

  1. 当您运行一个Kademlia网络时,应该总是有一个每个其他节点都知道的节点,以便他们加入网络.我们将此称为Bootstrap节点BN.

K是一个Kademlia常数,它确定节点路由表中存储桶的大小以及应存储数据的节点数量.

K is a Kademlia constant that determines the size of the Buckets in a node's routing table as well as the amount of nodes a piece of Data should be stored on.

加入过程:

  1. 使用节点ID(通过某种方法分配)和IP地址(托管它的计算机的IP)创建新的节点NN.

NNLookupRequest(A.NodeId)发送到BN.查找请求基本上是向接收节点询问对给定NodeId知道的K最近节点.在这种情况下,BN会将已知的K-Closest节点返回给NN.

NN sends a LookupRequest(A.NodeId) to BN. A Lookup Request basically asks the receiving node for the K-Closest nodes it knows to a given NodeId. In this case, BN will return the K-Closest nodes it knows to NN.

BN现在会将NN添加到其路由表中,因此NN现在已在网络中.

BN will now add NN to it's routing table, so NN is now in the network.

NNBN接收其自身的K最近节点列表. NNBN添加到其路由表中.

NN receives the list of K-Closest nodes to itself from BN. NN adds BN to it's routing table.

NN现在可以对从BN接收到的K个节点执行ping操作,然后根据距离将回复的节点添加到必要的存储桶中的路由表"中.通过对这些节点执行ping操作,他们还可以了解NN的存在并将NN添加到其路由表中.

NN now pings these K nodes received from BN, and the ones that reply are added to it's Routing Table in the necessary buckets based on distance. By pinging these nodes, they also learn of NN existence and add NN to their Routing tables.

NN现在已连接到网络,并且被网络上的节点所知道.

NN is now connected to the network and is known by nodes on the network.

NN现在循环遍历每个K-Buckets

NN now loops through each of it's K-Buckets

foreach(K-Buckets as KB)         
    1. NN generates a random NodeId `RNID` // A NodeId that will be in KB 
    2. NN sends LookupRequest(RNID) to the K-Closest nodes it knows to RNID. 
    3. The response will be K nodes closest to RNID.
    4. NN now fills KB. 

NN对其每个存储桶执行此操作以填充这些存储桶. 完成此操作后,NN可以更好地了解网络上与自身不同距离的节点.

NN does this for each of it's buckets to fill these buckets. After this operation, NN has a better idea of the nodes on the network at different distances away from itself.

注意:此步骤不是强制性的,但是我在我的实现Kademlia ,以便每个节点加入网络后都能更好地了解网络.

Note: This step is not mandatory, however I did it in My Implementation of Kademlia so that each node will have better knowledge of the network when they join.

我在 Kademlia DHT简介中对Kademlia进行了完整介绍. &工作原理

这篇关于向Kademlia添加新节点,构建Kademlia路由表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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