<s>
Kademlia	B-Operating_System
is	O
a	O
distributed	B-Operating_System
hash	I-Operating_System
table	I-Operating_System
for	O
decentralized	O
peer-to-peer	O
computer	B-Architecture
networks	I-Architecture
designed	O
by	O
Petar	O
Maymounkov	O
and	O
David	O
Mazières	O
in	O
2002	O
.	O
</s>
<s>
It	O
specifies	O
the	O
structure	O
of	O
the	O
network	B-Architecture
and	O
the	O
exchange	O
of	O
information	O
through	O
node	B-Protocol
lookups	O
.	O
</s>
<s>
Kademlia	B-Operating_System
nodes	O
communicate	O
among	O
themselves	O
using	O
UDP	B-Protocol
.	O
</s>
<s>
A	O
virtual	O
or	O
overlay	B-Architecture
network	I-Architecture
is	O
formed	O
by	O
the	O
participant	O
nodes	O
.	O
</s>
<s>
Each	O
node	B-Protocol
is	O
identified	O
by	O
a	O
number	O
or	O
node	B-Protocol
ID	O
.	O
</s>
<s>
The	O
node	B-Protocol
ID	O
serves	O
not	O
only	O
as	O
identification	O
,	O
but	O
the	O
Kademlia	B-Operating_System
algorithm	O
uses	O
the	O
node	B-Protocol
ID	O
to	O
locate	O
values	O
(	O
usually	O
file	O
hashes	B-Error_Name
or	O
keywords	O
)	O
.	O
</s>
<s>
In	O
order	O
to	O
look	O
up	O
the	O
value	O
associated	O
with	O
a	O
given	O
key	O
,	O
the	O
algorithm	O
explores	O
the	O
network	B-Architecture
in	O
several	O
steps	O
.	O
</s>
<s>
Each	O
step	O
will	O
find	O
nodes	O
that	O
are	O
closer	O
to	O
the	O
key	O
until	O
the	O
contacted	O
node	B-Protocol
returns	O
the	O
value	O
or	O
no	O
more	O
closer	O
nodes	O
are	O
found	O
.	O
</s>
<s>
This	O
is	O
very	O
efficient	O
:	O
like	O
many	O
other	O
s	O
,	O
Kademlia	B-Operating_System
contacts	O
only	O
nodes	O
during	O
the	O
search	O
out	O
of	O
a	O
total	O
of	O
nodes	O
in	O
the	O
system	O
.	O
</s>
<s>
Even	O
if	O
a	O
whole	O
set	O
of	O
nodes	O
is	O
flooded	O
,	O
this	O
will	O
have	O
limited	O
effect	O
on	O
network	B-Architecture
availability	O
,	O
since	O
the	O
network	B-Architecture
will	O
recover	O
itself	O
by	O
knitting	O
the	O
network	B-Architecture
around	O
these	O
"	O
holes	O
"	O
.	O
</s>
<s>
I2P	B-Protocol
's	O
implementation	O
of	O
Kademlia	B-Operating_System
is	O
modified	O
to	O
mitigate	O
Kademlia	B-Operating_System
's	O
vulnerabilities	O
,	O
such	O
as	O
Sybil	O
attacks	O
.	O
</s>
<s>
The	O
first	O
generation	O
peer-to-peer	O
file	O
sharing	O
networks	O
,	O
such	O
as	O
Napster	B-Application
,	O
relied	O
on	O
a	O
central	O
database	O
to	O
co-ordinate	O
lookups	O
on	O
the	O
network	B-Architecture
.	O
</s>
<s>
Second	O
generation	O
peer-to-peer	O
networks	O
,	O
such	O
as	O
Gnutella	B-Protocol
,	O
used	O
flooding	O
to	O
locate	O
files	O
,	O
searching	O
every	O
node	B-Protocol
on	O
the	O
network	B-Architecture
.	O
</s>
<s>
Third	O
generation	O
peer-to-peer	O
networks	O
,	O
such	O
as	O
Bittorrent	B-Protocol
,	O
use	O
distributed	B-Operating_System
hash	I-Operating_System
tables	I-Operating_System
to	O
look	O
up	O
files	O
in	O
the	O
network	B-Architecture
.	O
</s>
<s>
Distributed	B-Operating_System
hash	I-Operating_System
tables	I-Operating_System
store	O
resource	O
locations	O
throughout	O
the	O
network	B-Architecture
.	O
</s>
<s>
Kademlia	B-Operating_System
uses	O
a	O
"	O
distance	O
"	O
calculation	O
between	O
two	O
nodes	O
.	O
</s>
<s>
This	O
distance	O
is	O
computed	O
as	O
the	O
exclusive	O
or	O
(	O
XOR	O
)	O
of	O
the	O
two	O
node	B-Protocol
IDs	O
,	O
taking	O
the	O
result	O
as	O
an	O
unsigned	O
integer	O
number	O
.	O
</s>
<s>
Keys	O
and	O
node	B-Protocol
IDs	O
have	O
the	O
same	O
format	O
and	O
length	O
,	O
so	O
distance	O
can	O
be	O
calculated	O
among	O
them	O
in	O
exactly	O
the	O
same	O
way	O
.	O
</s>
<s>
The	O
node	B-Protocol
ID	O
is	O
typically	O
a	O
large	O
random	O
number	O
that	O
is	O
chosen	O
with	O
the	O
goal	O
of	O
being	O
unique	O
for	O
a	O
particular	O
node	B-Protocol
(	O
see	O
UUID	O
)	O
.	O
</s>
<s>
It	O
can	O
and	O
does	O
happen	O
that	O
geographically	O
far	O
nodes	O
–	O
from	O
Germany	O
and	O
Australia	O
,	O
for	O
instance	O
–	O
can	O
be	O
"	O
neighbors	O
"	O
if	O
they	O
have	O
chosen	O
similar	O
random	O
node	B-Protocol
IDs	O
.	O
</s>
<s>
XOR	O
was	O
chosen	O
because	O
it	O
acts	O
as	O
a	O
distance	O
function	O
between	O
all	O
the	O
node	B-Protocol
IDs	O
.	O
</s>
<s>
Each	O
Kademlia	B-Operating_System
search	O
iteration	O
comes	O
one	O
bit	O
closer	O
to	O
the	O
target	O
.	O
</s>
<s>
A	O
basic	O
Kademlia	B-Operating_System
search	O
algorithm	O
has	O
complexity	O
of	O
,	O
that	O
means	O
for	O
network	B-Architecture
with	O
nodes	O
it	O
will	O
take	O
at	O
most	O
steps	O
to	O
find	O
that	O
node	B-Protocol
.	O
</s>
<s>
An	O
actual	O
Kademlia	B-Operating_System
implementation	O
does	O
not	O
have	O
a	O
fixed-size	O
routing	O
table	O
,	O
but	O
a	O
dynamically	O
sized	O
one	O
.	O
</s>
<s>
Kademlia	B-Operating_System
routing	O
tables	O
consist	O
of	O
a	O
list	O
for	O
each	O
bit	O
of	O
the	O
node	B-Protocol
ID	O
(	O
e.g.	O
</s>
<s>
if	O
a	O
node	B-Protocol
ID	O
consists	O
of	O
128	O
bits	O
,	O
a	O
node	B-Protocol
will	O
keep	O
128	O
such	O
lists	O
.	O
)	O
</s>
<s>
Every	O
entry	O
in	O
a	O
list	O
holds	O
the	O
necessary	O
data	O
to	O
locate	O
another	O
node	B-Protocol
.	O
</s>
<s>
The	O
data	O
in	O
each	O
list	O
entry	O
is	O
typically	O
the	O
IP	B-Protocol
address	I-Protocol
,	O
port	O
,	O
and	O
node	B-Protocol
ID	O
of	O
another	O
node	B-Protocol
.	O
</s>
<s>
Every	O
list	O
corresponds	O
to	O
a	O
specific	O
distance	O
from	O
the	O
node	B-Protocol
.	O
</s>
<s>
Nodes	O
that	O
can	O
go	O
in	O
the	O
nth	O
list	O
must	O
have	O
a	O
differing	O
nth	O
bit	O
from	O
the	O
node	B-Protocol
's	O
ID	O
;	O
the	O
first	O
n-1	O
bits	O
of	O
the	O
candidate	O
ID	O
must	O
match	O
those	O
of	O
the	O
node	B-Protocol
's	O
ID	O
.	O
</s>
<s>
This	O
means	O
that	O
it	O
is	O
very	O
easy	O
to	O
populate	O
the	O
first	O
list	O
as	O
1/2	O
of	O
the	O
nodes	O
in	O
the	O
network	B-Architecture
are	O
far	O
away	O
candidates	O
.	O
</s>
<s>
The	O
next	O
list	O
can	O
use	O
only	O
1/4	O
of	O
the	O
nodes	O
in	O
the	O
network	B-Architecture
(	O
one	O
bit	O
closer	O
than	O
the	O
first	O
)	O
,	O
etc	O
.	O
</s>
<s>
With	O
an	O
ID	O
of	O
128	O
bits	O
,	O
every	O
node	B-Protocol
in	O
the	O
network	B-Architecture
will	O
classify	O
other	O
nodes	O
in	O
one	O
of	O
128	O
different	O
distances	O
,	O
one	O
specific	O
distance	O
per	O
bit	O
.	O
</s>
<s>
As	O
nodes	O
are	O
encountered	O
on	O
the	O
network	B-Architecture
,	O
they	O
are	O
added	O
to	O
the	O
lists	O
.	O
</s>
<s>
Every	O
node	B-Protocol
encountered	O
will	O
be	O
considered	O
for	O
inclusion	O
in	O
the	O
lists	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
knowledge	O
that	O
a	O
node	B-Protocol
has	O
of	O
the	O
network	B-Architecture
is	O
very	O
dynamic	O
.	O
</s>
<s>
This	O
keeps	O
the	O
network	B-Architecture
constantly	O
updated	O
and	O
adds	O
resilience	O
to	O
failures	O
or	O
attacks	O
.	O
</s>
<s>
In	O
the	O
Kademlia	B-Operating_System
literature	O
,	O
the	O
lists	O
are	O
referred	O
to	O
as	O
k-buckets	O
.	O
</s>
<s>
for	O
a	O
network	B-Architecture
with	O
k	O
=	O
20	O
,	O
each	O
node	B-Protocol
will	O
have	O
lists	O
containing	O
up	O
to	O
20	O
nodes	O
for	O
a	O
particular	O
bit	O
(	O
a	O
particular	O
distance	O
from	O
itself	O
)	O
.	O
</s>
<s>
Since	O
the	O
possible	O
nodes	O
for	O
each	O
k-bucket	O
decreases	O
quickly	O
(	O
because	O
there	O
will	O
be	O
very	O
few	O
nodes	O
that	O
are	O
that	O
close	O
)	O
,	O
the	O
lower	O
bit	O
k-buckets	O
will	O
fully	O
map	O
all	O
nodes	O
in	O
that	O
section	O
of	O
the	O
network	B-Architecture
.	O
</s>
<s>
Since	O
the	O
quantity	O
of	O
possible	O
IDs	O
is	O
much	O
larger	O
than	O
any	O
node	B-Protocol
population	O
can	O
ever	O
be	O
,	O
some	O
of	O
the	O
k-buckets	O
corresponding	O
to	O
very	O
short	O
distances	O
will	O
remain	O
empty	O
.	O
</s>
<s>
Consider	O
the	O
simple	O
network	B-Architecture
to	O
the	O
right	O
.	O
</s>
<s>
The	O
network	B-Architecture
size	O
is	O
2^3	O
or	O
eight	O
maximum	O
keys	O
and	O
nodes	O
.	O
</s>
<s>
The	O
node	B-Protocol
under	O
consideration	O
is	O
node	B-Protocol
six	O
(	O
binary	O
110	O
)	O
in	O
black	O
.	O
</s>
<s>
There	O
are	O
three	O
k-buckets	O
for	O
each	O
node	B-Protocol
in	O
this	O
network	B-Architecture
.	O
</s>
<s>
Node	B-Protocol
three	O
(	O
binary	O
011	O
,	O
not	O
shown	O
)	O
is	O
not	O
participating	O
in	O
the	O
network	B-Architecture
.	O
</s>
<s>
Finally	O
,	O
the	O
third	O
k-bucket	O
can	O
only	O
contain	O
node	B-Protocol
seven	O
(	O
binary	O
111	O
)	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
node	B-Protocol
six	O
has	O
node	B-Protocol
one	O
and	O
two	O
in	O
the	O
farthest	O
2-bucket	O
,	O
it	O
would	O
have	O
to	O
request	O
a	O
node	B-Protocol
ID	O
lookup	O
to	O
these	O
nodes	O
to	O
find	O
the	O
location	O
(	O
ip	B-Protocol
address	I-Protocol
)	O
of	O
node	B-Protocol
zero	O
.	O
</s>
<s>
Each	O
node	B-Protocol
knows	O
its	O
neighbourhood	O
well	O
and	O
has	O
contact	O
with	O
a	O
few	O
nodes	O
far	O
away	O
which	O
can	O
help	O
locate	O
other	O
nodes	O
far	O
away	O
.	O
</s>
<s>
It	O
is	O
known	O
that	O
nodes	O
that	O
have	O
been	O
connected	O
for	O
a	O
long	O
time	O
in	O
a	O
network	B-Architecture
will	O
probably	O
remain	O
connected	O
for	O
a	O
long	O
time	O
in	O
the	O
future	O
.	O
</s>
<s>
Because	O
of	O
this	O
statistical	O
distribution	O
,	O
Kademlia	B-Operating_System
selects	O
long	O
connected	O
nodes	O
to	O
remain	O
stored	O
in	O
the	O
k-buckets	O
.	O
</s>
<s>
This	O
increases	O
the	O
number	O
of	O
known	O
valid	O
nodes	O
at	O
some	O
time	O
in	O
the	O
future	O
and	O
provides	O
for	O
a	O
more	O
stable	O
network	B-Architecture
.	O
</s>
<s>
When	O
a	O
k-bucket	O
is	O
full	O
and	O
a	O
new	O
node	B-Protocol
is	O
discovered	O
for	O
that	O
k-bucket	O
,	O
the	O
least	O
recently	O
seen	O
node	B-Protocol
in	O
the	O
k-bucket	O
is	O
PINGed	O
.	O
</s>
<s>
If	O
the	O
node	B-Protocol
is	O
found	O
to	O
be	O
still	O
alive	O
,	O
the	O
new	O
node	B-Protocol
is	O
placed	O
in	O
a	O
secondary	O
list	O
,	O
a	O
replacement	O
cache	O
.	O
</s>
<s>
The	O
replacement	O
cache	O
is	O
used	O
only	O
if	O
a	O
node	B-Protocol
in	O
the	O
k-bucket	O
stops	O
responding	O
.	O
</s>
<s>
Kademlia	B-Operating_System
has	O
four	O
messages	O
.	O
</s>
<s>
PING	O
—	O
Used	O
to	O
verify	O
that	O
a	O
node	B-Protocol
is	O
still	O
alive	O
.	O
</s>
<s>
STORE	O
—	O
Stores	O
a	O
(	O
key	O
,	O
value	O
)	O
pair	O
in	O
one	O
node	B-Protocol
.	O
</s>
<s>
Each	O
RPC	B-Operating_System
message	O
includes	O
a	O
random	O
value	O
from	O
the	O
initiator	O
.	O
</s>
<s>
Node	B-Protocol
lookups	O
can	O
proceed	O
asynchronously	O
.	O
</s>
<s>
A	O
node	B-Protocol
initiates	O
a	O
FIND_NODE	O
request	O
by	O
querying	O
to	O
the	O
α	O
nodes	O
in	O
its	O
own	O
k-buckets	O
that	O
are	O
the	O
closest	O
ones	O
to	O
the	O
desired	O
key	O
.	O
</s>
<s>
The	O
requester	O
will	O
update	O
a	O
results	O
list	O
with	O
the	O
results	O
(	O
node	B-Protocol
IDs	O
)	O
it	O
receives	O
,	O
keeping	O
the	O
k	O
best	O
ones	O
(	O
the	O
k	O
nodes	O
that	O
are	O
closer	O
to	O
the	O
searched	O
key	O
)	O
that	O
respond	O
to	O
queries	O
.	O
</s>
<s>
Because	O
every	O
node	B-Protocol
has	O
a	O
better	O
knowledge	O
of	O
its	O
own	O
surroundings	O
than	O
any	O
other	O
node	B-Protocol
has	O
,	O
the	O
received	O
results	O
will	O
be	O
other	O
nodes	O
that	O
are	O
every	O
time	O
closer	O
and	O
closer	O
to	O
the	O
searched	O
key	O
.	O
</s>
<s>
When	O
the	O
iterations	O
stop	O
,	O
the	O
best	O
k	O
nodes	O
in	O
the	O
results	O
list	O
are	O
the	O
ones	O
in	O
the	O
whole	O
network	B-Architecture
that	O
are	O
the	O
closest	O
to	O
the	O
desired	O
key	O
.	O
</s>
<s>
The	O
node	B-Protocol
information	O
can	O
be	O
augmented	O
with	O
round	O
trip	O
times	O
,	O
or	O
RTT	O
.	O
</s>
<s>
This	O
information	O
will	O
be	O
used	O
to	O
choose	O
a	O
time-out	O
specific	O
for	O
every	O
consulted	O
node	B-Protocol
.	O
</s>
<s>
A	O
hash	B-Error_Name
is	O
typically	O
used	O
for	O
the	O
map	O
.	O
</s>
<s>
Locating	O
a	O
value	O
follows	O
the	O
same	O
procedure	O
as	O
locating	O
the	O
closest	O
nodes	O
to	O
a	O
key	O
,	O
except	O
the	O
search	O
terminates	O
when	O
a	O
node	B-Protocol
has	O
the	O
requested	O
value	O
in	O
its	O
store	O
and	O
returns	O
this	O
value	O
.	O
</s>
<s>
The	O
values	O
are	O
stored	O
at	O
several	O
nodes	O
(	O
k	O
of	O
them	O
)	O
to	O
allow	O
for	O
nodes	O
to	O
come	O
and	O
go	O
and	O
still	O
have	O
the	O
value	O
available	O
in	O
some	O
node	B-Protocol
.	O
</s>
<s>
Periodically	O
,	O
a	O
node	B-Protocol
that	O
stores	O
a	O
value	O
will	O
explore	O
the	O
network	B-Architecture
to	O
find	O
the	O
k	O
nodes	O
that	O
are	O
close	O
to	O
the	O
key	O
value	O
and	O
replicate	O
the	O
value	O
onto	O
them	O
.	O
</s>
<s>
Also	O
,	O
for	O
popular	O
values	O
that	O
might	O
have	O
many	O
requests	O
,	O
the	O
load	O
in	O
the	O
storer	O
nodes	O
is	O
diminished	O
by	O
having	O
a	O
retriever	O
store	O
this	O
value	O
in	O
some	O
node	B-Protocol
near	O
,	O
but	O
outside	O
of	O
,	O
the	O
k	O
closest	O
ones	O
.	O
</s>
<s>
The	O
node	B-Protocol
that	O
is	O
providing	O
the	O
file	O
will	O
periodically	O
refresh	O
the	O
information	O
onto	O
the	O
network	B-Architecture
(	O
perform	O
FIND_NODE	O
and	O
STORE	O
messages	O
)	O
.	O
</s>
<s>
When	O
all	O
of	O
the	O
nodes	O
having	O
the	O
file	O
go	O
offline	O
,	O
nobody	O
will	O
be	O
refreshing	O
its	O
values	O
(	O
sources	O
and	O
keywords	O
)	O
and	O
the	O
information	O
will	O
eventually	O
disappear	O
from	O
the	O
network	B-Architecture
.	O
</s>
<s>
A	O
node	B-Protocol
that	O
would	O
like	O
to	O
join	O
the	O
net	O
must	O
first	O
go	O
through	O
a	O
bootstrap	O
process	O
.	O
</s>
<s>
In	O
this	O
phase	O
,	O
the	O
joining	O
node	B-Protocol
needs	O
to	O
know	O
the	O
IP	B-Protocol
address	I-Protocol
and	O
port	O
of	O
another	O
node	B-Protocol
—	O
a	O
bootstrap	O
node	B-Protocol
(	O
obtained	O
from	O
the	O
user	O
,	O
or	O
from	O
a	O
stored	O
list	O
)	O
—	O
that	O
is	O
already	O
participating	O
in	O
the	O
Kademlia	B-Operating_System
network	B-Architecture
.	O
</s>
<s>
If	O
the	O
joining	O
node	B-Protocol
has	O
not	O
yet	O
participated	O
in	O
the	O
network	B-Architecture
it	O
computes	O
a	O
random	O
ID	O
number	O
,	O
which	O
by	O
virtue	O
of	O
being	O
a	O
very	O
large	O
random	O
number	O
is	O
extremely	O
likely	O
not	O
to	O
be	O
already	O
assigned	O
to	O
any	O
other	O
node	B-Protocol
.	O
</s>
<s>
It	O
uses	O
this	O
ID	O
until	O
leaving	O
the	O
network	B-Architecture
.	O
</s>
<s>
The	O
joining	O
node	B-Protocol
inserts	O
the	O
bootstrap	O
node	B-Protocol
into	O
one	O
of	O
its	O
k-buckets	O
.	O
</s>
<s>
The	O
joining	O
node	B-Protocol
then	O
performs	O
a	O
node	B-Protocol
lookup	O
of	O
its	O
own	O
ID	O
against	O
the	O
bootstrap	O
node	B-Protocol
(	O
the	O
only	O
other	O
node	B-Protocol
it	O
knows	O
)	O
.	O
</s>
<s>
The	O
"	O
self-lookup	O
"	O
will	O
populate	O
other	O
nodes	O
 '	O
k-buckets	O
with	O
the	O
new	O
node	B-Protocol
ID	O
,	O
and	O
will	O
populate	O
the	O
joining	O
node	B-Protocol
's	O
k-buckets	O
with	O
the	O
nodes	O
in	O
the	O
path	O
between	O
it	O
and	O
the	O
bootstrap	O
node	B-Protocol
.	O
</s>
<s>
After	O
this	O
,	O
the	O
joining	O
node	B-Protocol
refreshes	O
all	O
k-buckets	O
further	O
away	O
than	O
the	O
k-bucket	O
the	O
bootstrap	O
node	B-Protocol
falls	O
in	O
.	O
</s>
<s>
The	O
split	O
occurs	O
if	O
the	O
range	O
of	O
nodes	O
in	O
the	O
k-bucket	O
spans	O
the	O
node	B-Protocol
's	O
own	O
id	O
(	O
values	O
to	O
the	O
left	O
and	O
right	O
in	O
a	O
binary	O
tree	O
)	O
.	O
</s>
<s>
Kademlia	B-Operating_System
relaxes	O
even	O
this	O
rule	O
for	O
the	O
one	O
"	O
closest	O
nodes	O
"	O
k-bucket	O
,	O
because	O
typically	O
one	O
single	O
bucket	O
will	O
correspond	O
to	O
the	O
distance	O
where	O
all	O
the	O
nodes	O
that	O
are	O
the	O
closest	O
to	O
this	O
node	B-Protocol
are	O
,	O
they	O
may	O
be	O
more	O
than	O
k	O
,	O
and	O
we	O
want	O
it	O
to	O
know	O
them	O
all	O
.	O
</s>
<s>
It	O
may	O
turn	O
out	O
that	O
a	O
highly	O
unbalanced	O
binary	O
sub-tree	O
exists	O
near	O
the	O
node	B-Protocol
.	O
</s>
<s>
If	O
k	O
is	O
20	O
,	O
and	O
there	O
are	O
21+	O
nodes	O
with	O
a	O
prefix	O
"	O
xxx0011	O
.....	O
"	O
and	O
the	O
new	O
node	B-Protocol
is	O
"	O
xxx000011001	O
"	O
,	O
the	O
new	O
node	B-Protocol
can	O
contain	O
multiple	O
k-buckets	O
for	O
the	O
other	O
21+	O
nodes	O
.	O
</s>
<s>
This	O
is	O
to	O
guarantee	O
that	O
the	O
network	B-Architecture
knows	O
about	O
all	O
nodes	O
in	O
the	O
closest	O
region	O
.	O
</s>
<s>
Kademlia	B-Operating_System
uses	O
an	O
XOR	O
metric	O
to	O
define	O
distance	O
.	O
</s>
<s>
Two	O
node	B-Protocol
IDs	O
or	O
a	O
node	B-Protocol
ID	O
and	O
a	O
key	O
are	O
XORed	O
and	O
the	O
result	O
is	O
the	O
distance	O
between	O
them	O
.	O
</s>
<s>
The	O
XOR	O
metric	O
allows	O
Kademlia	B-Operating_System
to	O
extend	O
routing	O
tables	O
beyond	O
single	O
bits	O
.	O
</s>
<s>
The	O
missing	O
k-bucket	O
is	O
a	O
further	O
extension	O
of	O
the	O
routing	O
tree	O
that	O
contains	O
the	O
node	B-Protocol
ID	O
.	O
</s>
<s>
An	O
m-bit	O
prefix	O
reduces	O
the	O
maximum	O
number	O
of	O
lookups	O
from	O
log2	O
n	O
to	O
log2m	O
n	O
.	O
These	O
are	O
maximum	O
values	O
and	O
the	O
average	O
value	O
will	O
be	O
far	O
less	O
,	O
increasing	O
the	O
chance	O
of	O
finding	O
a	O
node	B-Protocol
in	O
a	O
k-bucket	O
that	O
shares	O
more	O
bits	O
than	O
just	O
the	O
prefix	O
with	O
the	O
target	O
key	O
.	O
</s>
<s>
Nodes	O
can	O
use	O
mixtures	O
of	O
prefixes	O
in	O
their	O
routing	O
table	O
,	O
such	O
as	O
the	O
Kad	O
Network	B-Architecture
used	O
by	O
eMule	B-Protocol
.	O
</s>
<s>
The	O
Kademlia	B-Operating_System
network	B-Architecture
could	O
even	O
be	O
heterogeneous	O
in	O
routing	O
table	O
implementations	O
,	O
at	O
the	O
expense	O
of	O
complicating	O
the	O
analysis	O
of	O
lookups	O
.	O
</s>
<s>
While	O
the	O
XOR	O
metric	O
is	O
not	O
needed	O
to	O
understand	O
Kademlia	B-Operating_System
,	O
it	O
is	O
critical	O
in	O
the	O
analysis	O
of	O
the	O
protocol	O
.	O
</s>
<s>
Other	O
DHT	O
protocols	O
and	O
algorithms	O
require	O
simulation	B-Application
or	O
complicated	O
formal	O
analysis	O
in	O
order	O
to	O
predict	O
network	B-Architecture
behavior	O
and	O
correctness	O
.	O
</s>
<s>
To	O
analyze	O
the	O
algorithm	O
,	O
consider	O
a	O
Kademlia	B-Operating_System
network	B-Architecture
of	O
nodes	O
with	O
IDs	O
,	O
each	O
of	O
which	O
is	O
a	O
string	O
of	O
length	O
that	O
consists	O
of	O
only	O
ones	O
and	O
zeros	O
.	O
</s>
<s>
It	O
can	O
be	O
modeled	O
as	O
a	O
trie	B-General_Concept
,	O
in	O
which	O
each	O
leaf	O
represents	O
a	O
node	B-Protocol
,	O
and	O
the	O
labeled	O
path	O
from	O
the	O
root	O
to	O
a	O
leaf	O
represents	O
its	O
ID	O
.	O
</s>
<s>
For	O
a	O
node	B-Protocol
,	O
let	O
be	O
the	O
set	O
of	O
nodes	O
(	O
IDs	O
)	O
that	O
share	O
a	O
prefix	O
with	O
of	O
length	O
.	O
</s>
<s>
This	O
justifies	O
the	O
intuition	O
that	O
in	O
Kademlia	B-Operating_System
only	O
nodes	O
are	O
contacted	O
in	O
searching	O
for	O
a	O
target	O
node	B-Protocol
.	O
</s>
<s>
To	O
make	O
the	O
model	O
closer	O
to	O
real	O
Kademlia	B-Operating_System
networks	O
,	O
can	O
also	O
be	O
assumed	O
to	O
be	O
chosen	O
uniformly	O
at	O
random	O
without	O
replacement	O
from	O
.	O
</s>
<s>
This	O
implies	O
that	O
the	O
number	O
of	O
nodes	O
need	O
to	O
be	O
contact	O
in	O
searching	O
for	O
a	O
target	O
node	B-Protocol
is	O
actually	O
on	O
average	O
.	O
</s>
<s>
Kademlia	B-Operating_System
is	O
used	O
in	O
file	O
sharing	O
networks	O
.	O
</s>
<s>
By	O
making	O
Kademlia	B-Operating_System
keyword	O
searches	O
,	O
one	O
can	O
find	O
information	O
in	O
the	O
file-sharing	O
network	B-Architecture
so	O
it	O
can	O
be	O
downloaded	O
.	O
</s>
<s>
Since	O
there	O
is	O
no	O
central	O
instance	O
to	O
store	O
an	O
index	O
of	O
existing	O
files	O
,	O
this	O
task	O
is	O
divided	O
evenly	O
among	O
all	O
clients	O
:	O
If	O
a	O
node	B-Protocol
wants	O
to	O
share	O
a	O
file	O
,	O
it	O
processes	O
the	O
contents	O
of	O
the	O
file	O
,	O
calculating	O
from	O
it	O
a	O
number	O
(	O
hash	B-Error_Name
)	O
that	O
will	O
identify	O
this	O
file	O
within	O
the	O
file-sharing	O
network	B-Architecture
.	O
</s>
<s>
Since	O
file	O
hashes	B-Error_Name
and	O
node	B-Protocol
IDs	O
have	O
the	O
same	O
length	O
,	O
the	O
client	O
can	O
use	O
the	O
XOR	O
distance	O
function	O
to	O
search	O
for	O
several	O
nodes	O
whose	O
ID	O
is	O
close	O
to	O
the	O
hash	B-Error_Name
,	O
and	O
instructs	O
those	O
nodes	O
to	O
store	O
the	O
publisher	O
's	O
IP	B-Protocol
address	I-Protocol
in	O
an	O
implementation-defined	O
manner	O
.	O
</s>
<s>
Nodes	O
with	O
IDs	O
closest	O
to	O
the	O
file	O
hash	B-Error_Name
will	O
therefore	O
have	O
a	O
list	O
of	O
IP	B-Protocol
addresses	I-Protocol
of	O
peers/publishers	O
of	O
this	O
file	O
,	O
from	O
which	O
a	O
client	O
may	O
in	O
an	O
implementation-defined	O
manner	O
download	O
the	O
file	O
.	O
</s>
<s>
Clients	O
that	O
wish	O
to	O
download	O
the	O
file	O
from	O
this	O
publisher	O
do	O
not	O
have	O
to	O
know	O
the	O
publisher	O
's	O
IP	B-Protocol
address	I-Protocol
(	O
there	O
can	O
be	O
many	O
publishers	O
)	O
,	O
but	O
only	O
the	O
hash	B-Error_Name
of	O
the	O
file	O
.	O
</s>
<s>
A	O
searching	O
client	O
will	O
use	O
Kademlia	B-Operating_System
to	O
search	O
the	O
network	B-Architecture
for	O
the	O
node	B-Protocol
whose	O
ID	O
has	O
the	O
smallest	O
distance	O
to	O
the	O
file	O
hash	B-Error_Name
,	O
then	O
will	O
retrieve	O
the	O
sources	O
list	O
that	O
is	O
stored	O
in	O
that	O
node	B-Protocol
.	O
</s>
<s>
many	O
sources	O
of	O
the	O
same	O
file	O
,	O
every	O
storing	O
node	B-Protocol
may	O
have	O
different	O
information	O
.	O
</s>
<s>
The	O
file	O
hash	B-Error_Name
is	O
usually	O
obtained	O
from	O
a	O
specially	O
formed	O
Internet	O
magnet	B-Protocol
link	I-Protocol
found	O
elsewhere	O
,	O
or	O
included	O
within	O
an	O
indexing	O
file	O
obtained	O
from	O
other	O
sources	O
.	O
</s>
<s>
Each	O
of	O
these	O
keywords	O
is	O
hashed	O
and	O
stored	O
in	O
the	O
network	B-Architecture
,	O
together	O
with	O
the	O
corresponding	O
filename	O
and	O
file	O
hash	B-Error_Name
.	O
</s>
<s>
A	O
search	O
involves	O
choosing	O
one	O
of	O
the	O
keywords	O
,	O
contacting	O
the	O
node	B-Protocol
with	O
an	O
ID	O
closest	O
to	O
that	O
keyword	O
hash	B-Error_Name
,	O
and	O
retrieving	O
the	O
list	O
of	O
filenames	O
that	O
contain	O
the	O
keyword	O
.	O
</s>
<s>
Since	O
every	O
filename	O
in	O
the	O
list	O
has	O
its	O
hash	B-Error_Name
attached	O
,	O
the	O
chosen	O
file	O
can	O
then	O
be	O
obtained	O
in	O
the	O
normal	O
way	O
.	O
</s>
<s>
Public	O
networks	O
using	O
the	O
Kademlia	B-Operating_System
algorithm	O
(	O
these	O
networks	O
are	O
incompatible	O
with	O
one	O
another	O
)	O
:	O
</s>
<s>
I2P	B-Protocol
:	O
an	O
anonymous	O
overlay	B-Architecture
network	I-Architecture
layer	O
.	O
</s>
<s>
Kad	O
network	B-Architecture
:	O
developed	O
originally	O
by	O
the	O
eMule	B-Protocol
community	O
to	O
replace	O
the	O
server-based	O
architecture	O
of	O
the	O
eDonkey	O
network	B-Architecture
.	O
</s>
<s>
Ethereum	B-Application
:	O
the	O
node	B-Protocol
discovery	O
protocol	O
in	O
the	O
Ethereum	B-Application
blockchain	O
network	B-Architecture
stack	O
is	O
based	O
on	O
a	O
slightly	O
modified	O
implementation	O
of	O
Kademlia	B-Operating_System
.	O
</s>
<s>
Overnet	B-Protocol
:	O
With	O
KadC	O
a	O
C	O
library	O
for	O
handling	O
its	O
Kademlia	B-Operating_System
is	O
available	O
.	O
</s>
<s>
Mainline	B-Protocol
DHT	I-Protocol
:	O
a	O
DHT	O
for	O
BitTorrent	B-Protocol
based	O
on	O
an	O
implementation	O
of	O
the	O
Kademlia	B-Operating_System
algorithm	O
,	O
for	O
trackerless	O
torrents	B-Protocol
.	O
</s>
<s>
Osiris	B-Language
(	O
all	O
version	O
)	O
:	O
used	O
to	O
manage	O
distributed	O
and	O
anonymous	O
web	O
portal	O
.	O
</s>
<s>
Retroshare	B-Application
:	O
F2F	O
decentralised	O
communication	O
platform	O
with	O
secure	O
VOIP	O
,	O
instant	O
messaging	O
,	O
file	O
transfer	O
etc	O
.	O
</s>
<s>
Gnutella	B-Protocol
DHT	O
:	O
originally	O
by	O
LimeWire	B-Application
to	O
augment	O
the	O
Gnutella	B-Protocol
protocol	O
for	O
finding	O
alternate	O
file	O
locations	O
,	O
now	O
in	O
use	O
by	O
other	O
gnutella	B-Protocol
clients	O
.	O
</s>
<s>
IPFS	B-Protocol
:	O
a	O
peer-to-peer	O
distributed	O
filesystem	O
based	O
on	O
libp2p	O
.	O
</s>
<s>
TeleHash	B-Protocol
:	O
a	O
mesh	O
networking	O
protocol	O
that	O
uses	O
Kademlia	B-Operating_System
to	O
resolve	O
direct	O
connections	O
between	O
parties	O
.	O
</s>
<s>
iMule	O
:	O
file	O
sharing	O
utility	B-Application
software	I-Application
for	O
I2P	B-Protocol
.	O
</s>
<s>
OpenDHT	O
:	O
library	O
providing	O
an	O
implementation	O
of	O
Kademlia	B-Operating_System
,	O
used	O
by	O
Jami	B-Protocol
and	O
others	O
.	O
</s>
<s>
GNUnet	B-Language
:	O
alternative	O
network	B-Architecture
stack	O
for	O
building	O
secure	O
,	O
decentralized	O
and	O
privacy-preserving	O
distributed	O
applications	O
.	O
</s>
<s>
Uses	O
randomized	O
version	O
of	O
Kademlia	B-Operating_System
called	O
R5N	O
.	O
</s>
