90
Kademlia Utah Distributed Systems Meetup and Reading Group - Kademlia JT Olds Space Monkey Vivint R&D January 20, 2015

Utah Distributed Systems Meetup and Reading Group - Kademlia

  • Upload
    jt-olds

  • View
    222

  • Download
    2

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Utah Distributed Systems Meetup andReading Group - Kademlia

JT Olds

Space MonkeyVivint R&D

January 20, 2015

Page 2: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Outline

1 Introduction

2 Kademlia Basics

3 Routing Table

4 Protocol

5 Field notes

Page 3: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Introduction

Outline

1 Introduction

2 Kademlia Basics

3 Routing Table

4 Protocol

5 Field notes

Page 4: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Introduction

Introduction

1 Introduction

Page 5: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Introduction

Distributed Hash TablesWhy?What options are out there?

Page 6: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Introduction

Distributed Hash TablesWhy?What options are out there?

Page 7: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Introduction

Distributed Hash TablesWhy?What options are out there?

Page 8: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Outline

1 Introduction

2 Kademlia Basics

3 Routing Table

4 Protocol

5 Field notes

Page 9: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Kademlia Basics

2 Kademlia BasicsIdsDistance

Page 10: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Ids

Kademlia Basics

2 Kademlia BasicsIdsDistance

Page 11: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Ids

Ids

Every node in the network gets a unique, random id of thesame length (160 bits).

00111010001...1100100101111

Values also get ids of the same length.

Page 12: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Kademlia Basics

2 Kademlia BasicsIdsDistance

Page 13: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Distance

Every node id has a defined distance from every othernode and value id.We store values on the nearest k nodes.

Page 14: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Distance

Every node id has a defined distance from every othernode and value id.We store values on the nearest k nodes.

Page 15: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Distance

Every node id has a defined distance from every othernode and value id.We store values on the nearest k nodes.

Page 16: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude about metrics

1 d(x , y) ≥ 02 d(x , y) = 0 ⇐⇒ x = y3 d(x , y) = d(y , x)4 d(x , z) ≤ d(x , y) + d(y , z)

Page 17: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude about metrics

1 d(x , y) ≥ 02 d(x , y) = 0 ⇐⇒ x = y3 d(x , y) = d(y , x)4 d(x , z) ≤ d(x , y) + d(y , z)

Page 18: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude about metrics

1 d(x , y) ≥ 02 d(x , y) = 0 ⇐⇒ x = y3 d(x , y) = d(y , x)4 d(x , z) ≤ d(x , y) + d(y , z)

Page 19: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude about metrics

1 d(x , y) ≥ 02 d(x , y) = 0 ⇐⇒ x = y3 d(x , y) = d(y , x)4 d(x , z) ≤ d(x , y) + d(y , z)

Page 20: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude about metrics

1 d(x , y) ≥ 02 d(x , y) = 0 ⇐⇒ x = y3 d(x , y) = d(y , x)4 d(x , z) ≤ d(x , y) + d(y , z)

Page 21: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: Standard distance metric

1 |x − y | ≥ 02 |x − y | = 0 ⇐⇒ x = y3 |x − y | = |y − x |4 |x − z| ≤ |x − y |+ |y − z|

Page 22: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: Standard distance metric

1 |x − y | ≥ 02 |x − y | = 0 ⇐⇒ x = y3 |x − y | = |y − x |4 |x − z| ≤ |x − y |+ |y − z|

Page 23: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: Standard distance metric

1 |x − y | ≥ 02 |x − y | = 0 ⇐⇒ x = y3 |x − y | = |y − x |4 |x − z| ≤ |x − y |+ |y − z|

Page 24: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: Standard distance metric

1 |x − y | ≥ 02 |x − y | = 0 ⇐⇒ x = y3 |x − y | = |y − x |4 |x − z| ≤ |x − y |+ |y − z|

Page 25: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: Standard distance metric

1 |x − y | ≥ 02 |x − y | = 0 ⇐⇒ x = y3 |x − y | = |y − x |4 |x − z| ≤ |x − y |+ |y − z|

Page 26: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: XOR metric

1 x ⊕ y ≥ 02 x ⊕ y = 0 ⇐⇒ x = y3 x ⊕ y = y ⊕ x4 x ⊕ z ≤ x ⊕ y + y ⊕ z

Page 27: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: XOR metric

1 x ⊕ y ≥ 02 x ⊕ y = 0 ⇐⇒ x = y3 x ⊕ y = y ⊕ x4 x ⊕ z ≤ x ⊕ y + y ⊕ z

Page 28: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: XOR metric

1 x ⊕ y ≥ 02 x ⊕ y = 0 ⇐⇒ x = y3 x ⊕ y = y ⊕ x4 x ⊕ z ≤ x ⊕ y + y ⊕ z

Page 29: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: XOR metric

1 x ⊕ y ≥ 02 x ⊕ y = 0 ⇐⇒ x = y3 x ⊕ y = y ⊕ x4 x ⊕ z ≤ x ⊕ y + y ⊕ z

Page 30: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: XOR metric

1 x ⊕ y ≥ 02 x ⊕ y = 0 ⇐⇒ x = y3 x ⊕ y = y ⊕ x4 x ⊕ z ≤ x ⊕ y + y ⊕ z

Why?

Page 31: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Interlude: XOR metric

1 x ⊕ y ≥ 02 x ⊕ y = 0 ⇐⇒ x = y3 x ⊕ y = y ⊕ x4 x ⊕ z ≤ x ⊕ y + y ⊕ z

Why? Because:a⊕ b ≤ a + bx ⊕ z = (x ⊕ y)⊕ (y ⊕ z)so (x ⊕ y)⊕ (y ⊕ z) ≤ x ⊕ y + y ⊕ z

Page 32: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

id euclidian xor101 0 0000 5 5001 4 4010 3 7011 2 6100 1 1101 0 0110 1 3111 2 2

Page 33: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

id euclidian xor101 0 0000 5 5001 4 4010 3 7011 2 6100 1 1101 0 0110 1 3111 2 2

Page 34: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

id euclidian xor101 0 0000 5 5001 4 4010 3 7011 2 6100 1 1101 0 0110 1 3111 2 2

Page 35: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

id euclidian xor101 0 0000 5 5001 4 4010 3 7011 2 6100 1 1101 0 0110 1 3111 2 2

Page 36: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

id euclidian xor101 0 0000 5 5001 4 4010 3 7011 2 6100 1 1101 0 0110 1 3111 2 2

Page 37: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

id euclidian xor101 0 0000 5 5001 4 4010 3 7011 2 6100 1 1101 0 0110 1 3111 2 2

Page 38: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

id euclidian xor101 0 0000 5 5001 4 4010 3 7011 2 6100 1 1101 0 0110 1 3111 2 2

Page 39: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

id euclidian xor101 0 0000 5 5001 4 4010 3 7011 2 6100 1 1101 0 0110 1 3111 2 2

Page 40: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

id euclidian xor101 0 0000 5 5001 4 4010 3 7011 2 6100 1 1101 0 0110 1 3111 2 2

Page 41: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

id euclidian xor101 0 0000 5 5001 4 4010 3 7011 2 6100 1 1101 0 0110 1 3111 2 2

Page 42: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

000 001 010 011 100 101 110 111

Page 43: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

000 001 010 011 100 101 110 111

Page 44: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

000 001 010 011 100 101 110 111

Page 45: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

000 001 010 011 100 101 110 111

Page 46: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

000 001 010 011 100 101 110 111

Page 47: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

......

......

......

......

bn−1 = 1

...

b2 = 1

b1 = 0

b0 = 1

· · ·

0 2n − 1

Page 48: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Space of 160−bit numbers

0

0

0

0

0

00

00

0

0

0

00

0

1

1

1

1 1

1

1

1 1

1

1

1 1

1

111

00...0011...11

0

0

����� ¤����7¢�� ����� � ¢ � ��� ¢w¡��  G¡����m¤��� �ï���âP£���� �w ���� �! ��L �� �"�#�½£�¢w  � � � ��$ � �%� ���� � '&�&(&���  ��)�� G¡��!�m¤�*'¡ ¢!�+�!,V¢-�`�R��� �! ��.½�ã G¡����V� ��� /� � £0� � �)�)� �� � 1&(&2& �3.ã�G �½¢!,4�,¢]£5� �  G¢w£f f¤

1

2

3

4

0

0

0

0

0

0

0

00

00

0

0

0

00

0

1

1

1

1 1

1

1

1 1

1

1

1 1

1

111

00...0011...11 Space of 160−bit numbers

����� ¤06%�87'�[£f¢V  ��� � ¢ � �%� ���%� �  ¯�:92;1¤8<=�&¡��� �� � � �%� �> �  (�@?ã¡���ACB ��� A � �ã�� �� �� �)�)�D �  ��E?ã¡���A�B � � �%�Ú��.ã£N£5�&�¯� � ,4�!���+���I¢w¡ �C��� � ��$�¢ � �GF). �I¡�� ��� � £H�#�m�(�I¡á¢ � �£5���m�(�I¡ � �)�)�V�f¤'��� �3� ��� �]�(� � �I� �  J� �  2��?�¡��!?�¡��&�(� �  ¯�� �� �1�(?ã¢w£5�3��$K�!L�M�N�� �  O9P;,�5Q¢ � �1��� �� ��R� �!  (� �/���S�4�%. ?��K£5� � ,4�I¡ � �* 2�, �� �* G¢w¡ � �I  � �)�)��¤4TK�!���! U �� � ����.ã�G G¡ ¢V (�V:W�X �I�&�¯�G¢ � �&��1¢�� �R�%� � � ¤8�K� �OA�¡i�G  V:W�XY� �^ (� � �%� � � Qã¢��á��I¢�� �D� � �! � 2� � � ¤[Z).½���(�!F). � �   V:W�X ��¢V¡��1 2� � �%� �&��¡��& (.�¡ � �!���)�L ��)�\?ã¡��!, � �4.�� VOW�X ¤

Page 49: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Kademlia Basics

Distance

Distance

Every node id has a defined distance from every othernode and value id.We store values on the nearest k nodes.

Page 50: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Outline

1 Introduction

2 Kademlia Basics

3 Routing Table

4 Protocol

5 Field notes

Page 51: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Routing Table

3 Routing TableBucketsReplacement Cache

Page 52: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Buckets

Routing Table

3 Routing TableBucketsReplacement Cache

Page 53: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Buckets

1 0 1 1 · · · 0

entry 1: id, ip, portentry 2: id, ip, port...entry k : id, ip, port

Page 54: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Buckets

1 0 1 1 · · · 0

entry 1: id, ip, portentry 2: id, ip, port...entry k : id, ip, port

Page 55: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Buckets

1 0 1 1 · · · 0

entry 1: id, ip, portentry 2: id, ip, port...entry k : id, ip, port

Page 56: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Buckets

Space of 160−bit numbers

0

0

0

0

0

00

00

0

0

0

00

0

1

1

1

1 1

1

1

1 1

1

1

1 1

1

111

00...0011...11

0

0

����� ¤����7¢�� ����� � ¢ � ��� ¢w¡��  G¡����m¤��� �ï���âP£���� �w ���� �! ��L �� �"�#�½£�¢w  � � � ��$ � �%� ���� � '&�&(&���  ��)�� G¡��!�m¤�*'¡ ¢!�+�!,V¢-�`�R��� �! ��.½�ã G¡����V� ��� /� � £0� � �)�)� �� � 1&(&2& �3.ã�G �½¢!,4�,¢]£5� �  G¢w£f f¤

1

2

3

4

0

0

0

0

0

0

0

00

00

0

0

0

00

0

1

1

1

1 1

1

1

1 1

1

1

1 1

1

111

00...0011...11 Space of 160−bit numbers

����� ¤06%�87'�[£f¢V  ��� � ¢ � �%� ���%� �  ¯�:92;1¤8<=�&¡��� �� � � �%� �> �  (�@?ã¡���ACB ��� A � �ã�� �� �� �)�)�D �  ��E?ã¡���A�B � � �%�Ú��.ã£N£5�&�¯� � ,4�!���+���I¢w¡ �C��� � ��$�¢ � �GF). �I¡�� ��� � £H�#�m�(�I¡á¢ � �£5���m�(�I¡ � �)�)�V�f¤'��� �3� ��� �]�(� � �I� �  J� �  2��?�¡��!?�¡��&�(� �  ¯�� �� �1�(?ã¢w£5�3��$K�!L�M�N�� �  O9P;,�5Q¢ � �1��� �� ��R� �!  (� �/���S�4�%. ?��K£5� � ,4�I¡ � �* 2�, �� �* G¢w¡ � �I  � �)�)��¤4TK�!���! U �� � ����.ã�G G¡ ¢V (�V:W�X �I�&�¯�G¢ � �&��1¢�� �R�%� � � ¤8�K� �OA�¡i�G  V:W�XY� �^ (� � �%� � � Qã¢��á��I¢�� �D� � �! � 2� � � ¤[Z).½���(�!F). � �   V:W�X ��¢V¡��1 2� � �%� �&��¡��& (.�¡ � �!���)�L ��)�\?ã¡��!, � �4.�� VOW�X ¤

Page 57: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Buckets

V ��.�  ��� �  �¢w�����3$ �P¡�¢ � �%� �3 /�)�m�(�392; � �/M�M½¤¶¤ M-M

00...0011...11 Space of 160−bit ID numbers

01

00

1

1

1

1

0

0

0

1

����� ¤�� ��� ,4����.�  � � � �-$}¢á¡���.�  ��� �  G¢V�����>��,4�I¡�  � �I�m¤89 �C�   � ¢����#��Q3¢ � �%� �>��¢P��¢]� ��� � �����N���.�£0���I 5Qw¢P�����)�� �>���  �� �� (��?á¡��4.�  ���)�  G¢w�C���m¤��7�p �� ����N���.�£0���I ¯��A ��� Qm (� ����.ã£����I  � �m�(�Y¡ ¢ � � �á£0��,4�I¡i�* �� � � �)�)�����/9P; ¡���? �I¢w (�!�C��� �(?�� �  ¯� ���  2�% P �������.ã£����I ¯�f¤

e~Mme~EdDiO FI×ÃH�D�F&Z�M1Ñ[FVe�ORQ&H�D�EdѽFIT #]T�QmZmDfe�éK_ÕEdÑíÒ�HdDiå�ë�õ&õ�óVÞ��(WVDiH�M1T�QmZmD'éK_�E�ÑLÒ�H�D å�ëõ&õ�ó+é�Q&S[×ÃZ�Ñ[FNWVDpFIT�D�ORÒmE�M #PÙ�Ô�S½ÓGU&D E�_ÕTwEdQ�éKÑ�_ÃÓGÑ � edÑ�Q&S�×`Z�Ô�Dp_ÃT[e~D�H~E�D�Z�Ø�M&DiE � ñ e#Ô[S[ÓGU&DiEHdDißàHdDfe~ÑRé�Q&S�×`Z,Q&T�×ÃM7T[QIEd_ÕßàM�#,QIß�EdÑ�D^T�QmZmD�e�Þ&Ð�Q'FNW&QV_ÃZ'EdÑ�_`e(Ò[HdQVÔ�×ÕD�O%Ø&Ö�F&ZmD�OR×Õ_`F�T�QmZmD�eU&DiD�Ò]F&×Õ×2WNF&×Õ_`Z%Ó QVTVEGF&Ó E�eA_ÃT%FYedS�ÔmE�HdD�D�QIß+e~_ÃaiD�FIEA×ÃD�FVe�E #áT�QmZmDfeiØmD�W&D�T]_Õß3EdÑ�_`eKH�D�ìwS�_ÃHdDfee~Ò�×Ã_ÕE~Ed_ÃT�æ�Ô[S[ÓGU&DiE�e+_ÃTYéKÑ�_`ÓGÑ7E�Ñ�D�T�QmZmDVñ e(QXéKT,ä�\ ZmQPD�e+T[QIEpH�D�ed_ÃZ�D&Þ&ò3_Ãæ&S�H�D��*_Õ×Ã×ÃS[e�E�H�FIEdDfeEdÑ�Dfe~D�F&Z[Zm_�E�_ÕQVT[FI×ãedÒ�×Õ_ÕE�e�Þ��ÄÑ�D�T � H�D ßàH�D�edÑ�D�epEdÑ�D�edÒ�×Ã_�EKÔ�S[ÓGUVD EGeiØmFI×Ã×ãT�QmZmD�e�éK_ÕEdÑ]Ò�H�D å�ëõ&õ�ó*éK_Ã×Õ×#×ÃD�F&HdT%FIÔ�Q&S�EA_ÕE�Þ

��� � � � ��� 4��� ���l������ �� "�(�(e��d� �Ð2QáDiT[edS�H�D�EdÑ[D'Ò�DiHGe~_`e�E�DiT[ÓiD'Q&ßpU&D�MVÙzWXFI×ÃS�D�Ò[F&_ÕHGe�Ø[T�QmZmDfe�O7S[e�E�Ò�DiH�_ÕQmZm_`ÓiF&×Õ×ÃMáH�DiÒ[S�Ô�×Ã_ÃedÑU&DiMme�Þ[þ�EdÑ�D�HdéK_`e~DVØ&E�é�Q,Ò�Ñ�DiT[Q&ORDiT[F7OYFNMYÓiFIS½e~D*×ÕQPQVUwS[Ò[e}ßàQ&H�WNF&×Õ_`ZáU&DiMmepEdQ,ß­FI_Ã×�ÞPò3_ÃH�e~E�Øe~QVO,D*QIß�EdÑ�D #1T�QmZmDfepE�Ñ[FXE�_ÃT�_ÕEd_`FI×Ã×ÕM1æ&D EKF,U&D�MVÙzWXFI×ÃS�D*Ò[FI_ÃHAéKÑ�DiT]_�EK_`eAÒ�S�Ô�×Ã_`e~Ñ�DfZ]ORFNM×ÕDfFNW&D�E�Ñ�D7T[D E�é�Q&H�U�ÞãöPD�ÓiQ&T[Z#ؽT�D�é T�QmZmD�e^OYFNM#��Q&_ÃT�EdÑ�D,T�DiE�é}QVHdU]éK_�E�Ñíä�\*e^Ói×ÕQwe~D�H�E�Qe~QVO,D,Ò�S�Ô[×Õ_`e~Ñ[D�Z U&DiM%E�Ñ[FIT EdÑ[DYT�QmZmD�e*Q&T�éKÑ�_`ÓGÑLE�Ñ�DRU&DiMwÙzWXFI×ÃS�D7Ò½FI_ÃH*éAF&e*QVHd_Ãæ&_ÃT[FI×Ã×ÃMÒ�S�Ô�×Ã_ÃedÑ�DfZ�ÞVä�T1Ô½Q&EdÑ1Ó�F&edD�e�ØIEdÑ[D�T�QmZmDfe(éK_ÕEdÑ1F�UVDiMwÙzWNF&×ÕS[D�Ò[FI_ÃHpO7S[e~EpHdD�Ò�S�Ô�×Ã_`e~Ñ�_ÕE�edQ'FVeQ&T[ÓiD�F&æVF&_ÕTáEdQRDiT½e~S�H�D�_�E�_`eKFNWXFI_Ã×ÃF&Ô�×ÃD*QVT1E�Ñ�D #áT�QmZmD�eKÓi×ÕQwe~Dfe�EAE�Q7E�Ñ�D�U&D�M&Þ

Ð2Q³ÓiQ&ORÒ½D�T[e�FXEdD%ßàQVH�T�QmZmDfeY×ÕDfFNWP_ÕT�æ�E�Ñ�DLT�DiE�é}QVHdUãØ(Ö�F&Z�DiOR×Õ_`F�H�DiÒ�S�Ô[×Õ_`e~Ñ[D�eYDfF&ÓGÑU&DiMwÙzWXFI×ÃS�DLÒ[F&_ÕHáQ&T[ÓiDíFITÄÑ�QVS�HfÞ}÷ T[F�� �ÃW&D%_ÃORÒ�×ÕD�ORDiTwE�FIEd_ÃQ&T Q&ß�EdÑ�_`eáe~EdHGFXE�DiæVMÚé�Q&S�×`ZHdDfìVS[_ÕH�DRORF&TPMLORD�e�edF&æ&D�e sÄD�F&ÓGÑíQIßAS�Ò�EdQ # T�QmZmD�e'e�E�Q&H�_ÕT�æ%F%U&D�MwÙ�WXFI×ÃS�D,Ò[FI_ÃH�é�Q&S�×`ZÒ½D�H~ßàQVHdO F,T�QmZmD�×ÃQPQ&UPS�ÒáßàQ&×Ã×ÕQXé�D�Z1ÔwM #��ïó ) +.-5/10áÿ�C�ç�eADiWVDiH�MYÑ�Q&S[H�Þmò�QVH~E�S�T[FIEdDi×ÃM&ØEdÑ�D^HdD�Ò�S�Ô�×Ã_ÃedÑ�_ÃT�æ�Ò�H�QmÓ Dfede}ÓiFITYÔ�D�Ñ[D�FNWP_Õ×ÃM,Q&ÒmE�_ÕOR_ÃaiD�Z#Þwò3_ÃH�e~E�ØVéKÑ�DiT1F'T�QmZmD�H�D�ÓiDi_ÃW&D�epF) +.-5/10�ÿ�CAç ßàQ&H+F�æV_ÕWVDiT7U&DiMwÙzWXFI×ÃS�D(Ò[F&_ÕHfØN_�E+F&e�e~S[O,Dfe�EdÑ�DAÿ�C�ç�é�FVe�F&×ÃedQ�_`ededS�DfZ�EdQ^EdÑ[D

Page 58: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Replacement Cache

Routing Table

3 Routing TableBucketsReplacement Cache

Page 59: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Replacement Cache

1 0 1 1 · · · 0

entry 1: id, ip, portentry 2: id, ip, port...entry k : id, ip, port

replacement 1: id, ip, portreplacement 2: id, ip, port

Page 60: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Routing Table

Replacement Cache

��� �

��� �

��� �

��� �

r

� ����� r ���� r ��� ���� ������

����� ¤��%� W ¡��P��¢w� � � �  P�>��$ã¡����ᢠ���C��� � � � � ��� ��¢ � �P �� �I¡ � ��.�¡K¢P�(¢/$ . � £f  � � � ��$ . ?�  � �I�m¤��� �� �¢-B � ��¡���?ã¡��&�(� �  G�=� ��� .½ (�&�f¤1��� ���á¢�B � �7��� �! ��� �� �á �� �I$c¡ ¢P£�  � � � ��$ � �%� �&� (��¢w ��G G¢��4�!� � � � ��� �1¢w ���I¢P�G � � ��� .½ (�&�� ���¢w �¢-�`�(���G G¢��4�!� � � � ��� �1¢w :�#�&¢w�G � �� ���� ��� .½ (�&�f¤

�ÄÑ�DiTYF�Ö�F&Z�DiOR×Õ_`F*T�QmZmD�H�D�ÓiDi_ÃW&D�e�F&TwM7ORD�e�edF&æ&D�ÛàH�D�ìwS�Dfe�E(QVH+HdD�Ò�×ÕM�Ý�ßàH�Q&O FIT�Q&EdÑ�D�HT�QmZmD&Øf_�E�S�ÒãZ�FXE�D�e�EdÑ[D}FIÒ[Ò�HdQVÒ�H�_ÃFIEdD #wÙzÔ�S[ÓGUVD E�ßàQ&H#E�Ñ�DAe~D�T[ZmDiHfñ e2T�QmZmD}ä�\'ÞNäzß�E�Ñ�D}edDiT½Zm_ÕT[æT�QmZmD�FI×ÃHdDfF&ZmMRD ëm_`e�EGe�_ÕT1EdÑ�D�H�D�Ó _ÃÒ�_ÃDiTwE�ñ e�#wÙzÔ�S[ÓGU&DiE�ØwEdÑ[D*H�D�Ói_ÕÒ[_ÕD�TVEAORQXW&Dfep_ÕEAEdQ7EdÑ�D*E�F&_Õ×QIß�EdÑ[D^×Ã_Ãe~E�Þwäzß#E�Ñ�D�T�QmZmD^_Ãe}T�Q&EAF&×ÕH�D�FVZmM'_ÃT�E�Ñ�D^F&Ò�Ò�H�Q&Ò�H�_ÃFIEdD #PÙ�Ô�S½ÓGU&D E�FIT[ZRE�Ñ�D�Ô[S[ÓGU&DiEÑ[F&e*ßàD�é}D�H�EdÑ[F&T�# D�TVE�Hd_ÃD�e�ØãEdÑ[DiT�EdÑ�DYH�D�Ói_ÕÒ[_ÕD�TVE���S½e�E�_ÃT[edDiHdE�e*EdÑ[DYT�Dié e~D�T[ZmD�H�FXE�EdÑ[DE�FI_Ã×pQ&ßAEdÑ�Dá×Õ_`e�EfÞ2äzßKE�Ñ�D1FIÒ[Ò�HdQVÒ�H�_ÃFIEdD #wÙzÔ�S[ÓGUVD E�_`e�ßàS�×Ã×cØ3Ñ�QXé�DiWVDiHfØãEdÑ�D�T�EdÑ�D1HdDfÓ _ÃÒ�_ÕD�TwEÒ�_ÕT[æVeAE�Ñ�D #wÙzÔ�S[ÓGUVD Efñ eA×ÃD�FVe�EdÙ�H�D�ÓiDiTwEd×ÃMáedDiD�T]T[QPZ�D�EdQ1Z�D�Ó _`ZmD�éKÑ[FIE�EdQáZmQ[Þ�äzß+E�Ñ�D�×ÃD�FVe�EdÙHdDfÓ DiTwE�×ÕM1edDiD�TáT[QPZ�D�ß­FI_Ã×ÃeAE�QRHdDfe~Ò�Q&T[Z#Ø�_�E�_`eADiWP_`Ó¯E�D�ZáßàHdQVO EdÑ[D #wÙ�Ô[S[ÓGU&DiEKF&T[ZáEdÑ�D�T[Diée~D�T[ZmDiH*_ÃT[e~D�H~E�D�ZLFIE�E�Ñ�D�EGFI_Ã×cÞ2þ�EdÑ[DiH�éK_ÃedD&ؽ_�ß(E�Ñ�D,×ÕDfF&e~E~ÙzHdDfÓ DiTwE�×ÕM]e~D�DiTLT�QmZmD,H�D�edÒ½QVT[Z�e�Ø_�E�_`eKORQXW&DfZYEdQRE�Ñ�D�E�F&_Õ×�Q&ß�E�Ñ�D�×Ã_Ãe~E�Ø[F&T[Z1EdÑ�D�T�D�é�edDiT½ZmDiHfñ eAÓiQ&TwE�FVÓ¯EK_Ãe�Zm_Ãe�ÓiF&H�Z�D�Z�Þ

#wÙ�Ô[S[ÓGU&DiE�e^D âãD�Ó¯E�_ÕWVDi×ÃM%_ÕORÒ�×ÃDiORDiTwE�Fá×ÕDfF&e~E~ÙzHdDfÓ DiTwE�×ÕM%e~D�DiT DiWP_ÃÓ Ed_ÃQ&T Ò½QV×Õ_`Ó MVØ�Dië�Ó DiÒ�EEdÑ[FIE�×Ã_ÕWVD^T[QPZ�D�e�FIH�D�T�D�W&DiH�H�DiORQXW&DfZ,ßàHdQVO EdÑ�D*×Õ_`e~E�ÞmÐAÑ�_`e}Ò[HdDißàDiH�DiT[ÓiD�ßàQ&H�Q&×`Z1ÓiQ&TwE�FVÓ¯EGe_Ãe�Z�Hd_ÃW&D�T ÔPMíQVS�H'F&T[FI×ÃMme~_`e*QIß\�*TwS�EdDi×Ã×`F]EdHGF&Ó D�Z[FXE�F%ÓiQ&×Ã×ÕDfÓ¯EdDfZ�ÔwM�ömFIH�Q&_ÃS�D E�Þ�FI×�Þ � � ��Þò�_Ãæ&S[HdD��^edÑ�QXé�e2EdÑ�D�Ò½D�H�ÓiDiTwE�F&æ&D}QIß1�*TPSmE�Di×Ã×ÃF^T�QmZmD�e2EdѽFXE(e�EGFNM�Q&T�×Ã_ÕT[D}FIT[QIEdÑ[DiH3Ñ�Q&S�H+FVeF�ßàS[T[Ó¯E�_ÕQVT,Q&ß�ÓiS�HdH�DiTwE�S�ÒmE�_ÕORD&ÞVÐAÑ�DK×ÕQVT�æ&D�H+F�T�QmZmDKѽF&e3Ô½D�DiTRS�Ò#ØIEdÑ�DAORQ&H�DA×Õ_ÃU&D�×ÕM�_ÕE(_ÃeEdQ*HdD�ORF&_ÕT7S�Ò7F&T�QIE�Ñ�DiH3Ñ�QVS�H�Þ���M�U&D�DiÒ�_ÃT�æ^EdÑ�D�Q&×`ZmD�e~E�×Õ_ÃW&DAÓ QVTVEGF&Ó E�e3FIH�Q&S�T[Z#Ø�#wÙzÔ�S[ÓGUVD EGeORFIëm_ÕOR_ÃaiD*EdÑ�D�Ò[HdQVÔ[FIÔ�_Ã×Ã_�E�MYE�Ñ[FXEKE�Ñ�D�T�QmZmDfe�EdÑ�D�MáÓ QVTwE�FI_ÃT]éK_Õ×Ã×#H�DiOYFI_ÃTáQVT�×Ã_ÕT�DVÞ

÷ e~DfÓ Q&T½Z1Ô�DiT�Diå�E�Q&ß #wÙzÔ�S[ÓGUVD EGeA_ÃeAE�Ñ[FXEKE�Ñ�DiMáÒ�H�QXWw_`ZmD�H�D�ed_Ãe~E�F&T[Ó D*EdQ�ÓiDiHdE�F&_ÕT%\�QPöFXE~EGF&ÓGUme�Þ�þ^T[D*Ó�FIT�T�Q&EAê[S[edÑáT�QmZmDfeiñmH�Q&S�Ed_ÃT�æ,e~E�FIEdD*ÔPMYê[QPQmZm_ÕT[æ7E�Ñ�D�e~Mme~EdD�O5éK_�E�ÑáT[DiéT�QmZmD�e�ÞwÖ�FVZmDiOR×Ã_ÃF�T[QPZ�D�e}éK_Õ×Ã×½QVT�×ÃM7_ÃT[edDiHdE(EdÑ�D^T�DiéÄT[QPZ�D�e}_ÕTYE�Ñ�D #PÙ�Ô�S½ÓGU&D EGe+éKÑ�D�T�Q&×`ZT�QmZmD�eA×ÃD�FNWVD^E�Ñ�D�edMPe~EdD�O%Þ

����� �bg cd�F��(��g��@��a �ia'� a �ÐAÑ�DáÖ�FVZmDiOR×Ã_ÃF�Ò[HdQ&EdQmÓ QV×}Ó QVT[ed_Ãe~E�e'QIßAßàQ&S�HRÿ�CAç�e�2"!$#&%('(Ø*),+.-(/10�Ø"23#&%.4 %(-54(0�Ø3F&T[Z26#&%(4 73859;:.0�ÞVÐAÑ�D�!<#&%('Lÿ�C�çÚÒ�H�Q&Ô�D�e(F�T[QPZ�DKEdQ'edDiD�_�ß#_ÕE}_`e(QVT�×Õ_ÃT�DVÞ3),+1-5/10,_ÃT[e�E�HdS½Ó¯E�eF7T[QPZ�D�EdQYe�E�Q&H�D�F]ø­U&D�M !dWXFI×ÃS�D�ù�Ò[F&_ÕHAßàQVHK×ÃFIEdDiHKH�D E�Hd_ÃDiWXF&×cÞ

26#&%(4 %(-(450]E�F&U&Dfe�FLófô&õIÙ�Ô�_ÕE�ä�\ F&e^FITíF&HdæVS�ORDiTwE�Þ�ÐAÑ�D'H�D�Ói_ÕÒ�_ÃDiTwE*QIßpFYE�Ñ�D7ÿ�C�çHdDiEdS�H�T[e�øàä�C FVZ�ZmH�D�e�e! �^\^C Ò�Q&HdE�!�è�QmZmD�ä�\�ù}EdH�_ÕÒ�×ÃD�e�ßàQVHAEdÑ�D #1T�QmZmDfeA_�E�UPT�QXé�eAFIÔ�Q&S�E

Page 61: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Outline

1 Introduction

2 Kademlia Basics

3 Routing Table

4 Protocol

5 Field notes

Page 62: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Protocol

4 ProtocolEndpointsLookupsMaintenance

Page 63: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Endpoints

Protocol

4 ProtocolEndpointsLookupsMaintenance

Page 64: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Endpoints

Node endpoints

Ping

Store

FindNode

FindValue

Page 65: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Endpoints

Node endpoints

Ping

Store

FindNode

FindValue

Page 66: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Endpoints

Node endpoints

Ping

Store

FindNode

FindValue

Page 67: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Endpoints

Node endpoints

Ping

Store

FindNode

FindValue

Page 68: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Endpoints

Node endpoints

Ping

Store

FindNode

FindValue

Page 69: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Lookups

Protocol

4 ProtocolEndpointsLookupsMaintenance

Page 70: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Lookups

Lookups

Kick off α workersAs long as a k -close node is uncontacted, contact, andadd results.

Page 71: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Lookups

Lookups

Kick off α workersAs long as a k -close node is uncontacted, contact, andadd results.

Page 72: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Lookups

Lookups

Kick off α workersAs long as a k -close node is uncontacted, contact, andadd results.

Page 73: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Lookups

Space of 160−bit numbers

0

0

0

0

0

00

00

0

0

0

00

0

1

1

1

1 1

1

1

1 1

1

1

1 1

1

111

00...0011...11

0

0

����� ¤����7¢�� ����� � ¢ � ��� ¢w¡��  G¡����m¤��� �ï���âP£���� �w ���� �! ��L �� �"�#�½£�¢w  � � � ��$ � �%� ���� � '&�&(&���  ��)�� G¡��!�m¤�*'¡ ¢!�+�!,V¢-�`�R��� �! ��.½�ã G¡����V� ��� /� � £0� � �)�)� �� � 1&(&2& �3.ã�G �½¢!,4�,¢]£5� �  G¢w£f f¤

1

2

3

4

0

0

0

0

0

0

0

00

00

0

0

0

00

0

1

1

1

1 1

1

1

1 1

1

1

1 1

1

111

00...0011...11 Space of 160−bit numbers

����� ¤06%�87'�[£f¢V  ��� � ¢ � �%� ���%� �  ¯�:92;1¤8<=�&¡��� �� � � �%� �> �  (�@?ã¡���ACB ��� A � �ã�� �� �� �)�)�D �  ��E?ã¡���A�B � � �%�Ú��.ã£N£5�&�¯� � ,4�!���+���I¢w¡ �C��� � ��$�¢ � �GF). �I¡�� ��� � £H�#�m�(�I¡á¢ � �£5���m�(�I¡ � �)�)�V�f¤'��� �3� ��� �]�(� � �I� �  J� �  2��?�¡��!?�¡��&�(� �  ¯�� �� �1�(?ã¢w£5�3��$K�!L�M�N�� �  O9P;,�5Q¢ � �1��� �� ��R� �!  (� �/���S�4�%. ?��K£5� � ,4�I¡ � �* 2�, �� �* G¢w¡ � �I  � �)�)��¤4TK�!���! U �� � ����.ã�G G¡ ¢V (�V:W�X �I�&�¯�G¢ � �&��1¢�� �R�%� � � ¤8�K� �OA�¡i�G  V:W�XY� �^ (� � �%� � � Qã¢��á��I¢�� �D� � �! � 2� � � ¤[Z).½���(�!F). � �   V:W�X ��¢V¡��1 2� � �%� �&��¡��& (.�¡ � �!���)�L ��)�\?ã¡��!, � �4.�� VOW�X ¤

Page 74: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Maintenance

Protocol

4 ProtocolEndpointsLookupsMaintenance

Page 75: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Maintenance

Maintenance

Bucket refreshesNeighbor republishingOwner republishing

Page 76: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Maintenance

Maintenance

Bucket refreshesNeighbor republishingOwner republishing

Page 77: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Maintenance

Maintenance

Bucket refreshesNeighbor republishingOwner republishing

Page 78: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Protocol

Maintenance

Maintenance

Bucket refreshesNeighbor republishingOwner republishing

Page 79: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Field notes

Outline

1 Introduction

2 Kademlia Basics

3 Routing Table

4 Protocol

5 Field notes

Page 80: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Field notes

Field notes

5 Field notesSpace Monkey Differences

Page 81: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Field notes

Space Monkey Differences

Field notes

5 Field notesSpace Monkey Differences

Page 82: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Field notes

Space Monkey Differences

Address updates are not bidirectional.Data is mutable.No hot caching.No neighbor republishing.SSL identification proofs.Namespaces.

Page 83: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Field notes

Space Monkey Differences

Address updates are not bidirectional.Data is mutable.No hot caching.No neighbor republishing.SSL identification proofs.Namespaces.

Page 84: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Field notes

Space Monkey Differences

Address updates are not bidirectional.Data is mutable.No hot caching.No neighbor republishing.SSL identification proofs.Namespaces.

Page 85: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Field notes

Space Monkey Differences

Address updates are not bidirectional.Data is mutable.No hot caching.No neighbor republishing.SSL identification proofs.Namespaces.

Page 86: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Field notes

Space Monkey Differences

Address updates are not bidirectional.Data is mutable.No hot caching.No neighbor republishing.SSL identification proofs.Namespaces.

Page 87: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Field notes

Space Monkey Differences

Address updates are not bidirectional.Data is mutable.No hot caching.No neighbor republishing.SSL identification proofs.Namespaces.

Page 88: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Conclusion

Shameless plug

Page 89: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Conclusion

Shameless plug

Space Monkey!

Distributed Hash TablesConsensus algorithmsReed SolomonMonitoring and sooo much dataSecurity and cryptography engineering

Page 90: Utah Distributed Systems Meetup and Reading Group - Kademlia

Kademlia

Conclusion

Shameless plug

Space Monkey!

Come work with us!