SlideShare a Scribd company logo
TECH TALKS
                                    BitTorrent DHT | Arvid Norberg




BitTorrent, Inc / 2013 Tech Talks                                                 01
INTRODUCTION




                                    DHT = DISTRIBUTED HASH TABLE
                                     (It’s like a hash table, where the payload is divided up across many nodes.)




BitTorrent, Inc / 2013 Tech Talks                                                                                   02
INTRODUCTION
   The DHT is primarily used to introduce peers to each other.




                                           Who e
                                                lse is
                                    PEER                 on sw
                                                               arm X
                                                                       ?

                                              172.4
                                             119.7 .12.7
                                            217.1    3.53.
                                                  3.98.
                                                   ...
                                                          83
                                                        220                DHT

BitTorrent, Inc / 2013 Tech Talks                                                03
INTRODUCTION



   protocol <what do nodes say to each other?>

   topology <how are nodes organized?>

   routing <how are target nodes found?>

   routing table <representation of routing info>

   traversal algorithm <search implementation?>




BitTorrent, Inc / 2013 Tech Talks                   04
PROTOCOL




BitTorrent, Inc / 2013 Tech Talks   05
PROTOCOL
   ping <are you still around?>

   announce_peer <hey, i’m on this swarm!>

   get_peers <who else is on this swarm?, or who can I ask?>

   find_node <who is close to this ID?, or who can I ask?>




                                    PEER
                                                               DHT

BitTorrent, Inc / 2013 Tech Talks                                    06
PROTOCOL
   ping <are you still around?>
                                                                ONE-OFF MESSAGES
   announce_peer <hey, i’m on this swarm!>

   get_peers <who else is on this swarm?, or who can I ask?>

   find_node <who is close to this ID?, or who can I ask?>




                                    PEER
                                                               DHT

BitTorrent, Inc / 2013 Tech Talks                                                  07
PROTOCOL
   ping <are you still around?>
                                                                ONE-OFF MESSAGES
   announce_peer <hey, i’m on this swarm!>

   get_peers <who else is on this swarm?, or who can I ask?>
                                                                RECURSIVE
   find_node <who is close to this ID?, or who can I ask?>




                                    PEER
                                                               DHT

BitTorrent, Inc / 2013 Tech Talks                                                  08
PROTOCOL
   ping <are you still around?>

   announce_peer <hey, i’m on this swarm!>

   get_peers <who else is on this swarm?, or who can I ask?>

   find_node <who is close to this ID?, or who can I ask?>




                                                 get_peers (x)
                                    PEER         nodes: <...>
                                                                 DHT

BitTorrent, Inc / 2013 Tech Talks                                      09
PROTOCOL
   ping <are you still around?>

   announce_peer <hey, i’m on this swarm!>

   get_peers <who else is on this swarm?, or who can I ask?>

   find_node <who is close to this ID?, or who can I ask?>


                                                                  get_ peers (x)

                                                                    nod es: <...>
                                                 get_peers (x)
                                    PEER         nodes: <...>
                                                                get_pee
                                                                          rs (x)
                                                                                    DHT
                                                                 nodes:
     REPEATS                                                              <...>




BitTorrent, Inc / 2013 Tech Talks                                                         10
PROTOCOL
   ping <are you still around?>

   announce_peer <hey, i’m on this swarm!>

   get_peers <who else is on this swarm?, or who can I ask?>

   find_node <who is close to this ID?, or who can I ask?>




                                                 get_peers (x)
                                    PEER         nodes: <...>
                                                                get_pee
                                                                          rs (x)
                                                                                   DHT
                                                                 nodes:
    TERMINATES WHEN WE                                                    <...>
    RECEIVE VALUES (I.E. PEERS)
    AND NO BETTER NODES

BitTorrent, Inc / 2013 Tech Talks                                                        11
PROTOCOL
    ping <are you still around?>

    announce_peer <hey, i’m on this swarm!>

    get_peers <who else is on this swarm?, or who can I ask?>

    find_node <who are close to this ID?, or who can I ask?>




 EACH MESSAGE INCLUDES ONES OWN NODE ID.
 THIS ENABLES NODES TO LEARN ABOUT NEW
 NODES AS PART OF THE PROTOCOL CHATTER.

BitTorrent, Inc / 2013 Tech Talks                               12
PROTOCOL




   bootstrap <find_nodes(self)>

   refresh buckets <find_nodes (target-bucket)>

   announce <get_peer(ih) + announce_peer(ih)>




BitTorrent, Inc / 2013 Tech Talks                 13
PROTOCOL



   Spoof protection

   get_peers responds with a write-token

   Write-token is typically a MAC of:
   - source (IP, port)
   - target info-hash
   - local secret (which may expire in tens of minutes)

   announce_peer requires a valid write token to insert the node in the peer list




BitTorrent, Inc / 2013 Tech Talks                                                   14
TOPOLOGY
   This section describes how nodes can
   respond to recursive lookup queries like this,
   with nodes closer and closer to the target.*




 *Spoiler alert: it has to do with the topology
BitTorrent, Inc / 2013 Tech Talks                   15
TOPOLOGY
    The DHT is made up by all BitTorrent peers, across all swarms.



                                                    PEER            PEER

                                            PEER           PEER          PEER

                                    PEER           PEER           PEER           PEER

                                           PEER           PEER      PEER           PEER

                                            PEER           PEER           PEER

                                                                  PEER


BitTorrent, Inc / 2013 Tech Talks                                                         16
TOPOLOGY
    Each node has a self-assigned address, or node ID.



                                                                            PEER                                        PEER
                                                                            71690...29736                               24e52...a22a6



                                                        PEER                                PEER                              PEER
                                                                                            138b8...cea6f
                                                        caa39...9087a                                                         09b9b...6216b




                                    PEER                                PEER                                 PEER                                PEER
                                                                                                              f091c...7fc09
                                    9a2ac...1993e                       03afa...f0200                                                            09b9b...6216b



                                                    PEER
                                                    6c6cf...10f46
                                                                                        PEER
                                                                                        f8466...b21cf
                                                                                                                      PEER                              PEER
                                                                                                                                                        5f08d...e2537
                                                                                                                       22942...48a07




                                                       PEER                                 PEER                                 PEER
                                                        255d5...b923d                        0f35f...386ab                       79280...f8bf3




                                                                                                             PEER
                                                                                                             2f1d5...04177




BitTorrent, Inc / 2013 Tech Talks                                                                                                                                       17
TOPOLOGY
    Consider all nodes lined up in the node ID space....




     0                                                     2   160




BitTorrent, Inc / 2013 Tech Talks                                    18
TOPOLOGY
    Consider all nodes lined up in the node ID space....




     0                                                   node-ID space   2   160




....all nodes appear evenly distributed in this space.




BitTorrent, Inc / 2013 Tech Talks                                                  19
TOPOLOGY
    IDs are 160 bits (20 bytes) long...
    Keys in the hash table (info-hashes) are also 160 bits.




     0                                                node-ID space   2   160




BitTorrent, Inc / 2013 Tech Talks                                               20
TOPOLOGY
    IDs are 160 bits (20 bytes) long...
    Keys in the hash table (info-hashes) are also 160 bits


                                    info-hash




     0                                                node-ID space   2   160




Nodes whose ID is close to an info-hash are responsible for
storing information about it.




BitTorrent, Inc / 2013 Tech Talks                                               21
TOPOLOGY
    IDs are 160 bits (20 bytes) long...
    Keys in the hash table (info-hashes) are also 160 bits


                                    info-hash




     0                                                node-ID space   2   160




Nodes whose ID is close to an info-hash are responsible for
storing information about it.




BitTorrent, Inc / 2013 Tech Talks                                               22
ROUTING




BitTorrent, Inc / 2013 Tech Talks   23
ROUTING



   It is impractical for every node to know about every other node.

   There are millions of nodes.

   Nodes come and go constantly.

   Every node specializes in knowing about all nodes close to itself.

   The farther from itself, the more sparse its knowledge of nodes become.




BitTorrent, Inc / 2013 Tech Talks                                            24
ROUTING
    The routing table orders nodes based on their distance from oneself.




                                                                           distance          distance



     0                                              node-ID space                     self              2   160




BitTorrent, Inc / 2013 Tech Talks                                                                                 25
ROUTING
    The routing table orders nodes based on their distance from oneself.




                                                                           distance          distance



     0                                                  node-ID space                 self
                                                                                                        2   160




                 self                            distance from self

This is simplified. The euclidian distance is not actually used.
BitTorrent, Inc / 2013 Tech Talks                                                                                 26
ROUTING
   The euclidian distance has a problem that it “folds” the space,
   and nodes are no longer uniformly distributed (in the distance-space).




                                                                        distance          distance



     0                                                  node-ID space
                                                                                                     2   160

                                                                                   self




BitTorrent, Inc / 2013 Tech Talks                                                                              27
ROUTING
    The XOR distance metric is: d(a,b) = a ⊕ b




     0              self                                  distance from self
                                                                               2   160




                   The XOR distance metric makes it so that the
                   distances are still uniformly distributed. It doesn't
                   “fold” the space the way euclidian distance does.




BitTorrent, Inc / 2013 Tech Talks                                                        28
ROUTING
    The distance space is divided up into buckets. Each bucket holds no more than 8 nodes.




     0              self                      distance from self
                                                                                             2   160




BitTorrent, Inc / 2013 Tech Talks                                                                      29
ROUTING
    The distance space is divided up into buckets. Each bucket holds no more than 8 nodes.

    The space covered by a bucket is half as big as the previous one.

    You know about more nodes close to you.




     0              self                                                                     2   160

                                                      distance from self

       ...                          bucket 2   bucket 1                           bucket 0




BitTorrent, Inc / 2013 Tech Talks                                                                      3-
ROUTING
   For every hop in a recursive lookup, the nodes distance is cut in half.

   Lookup complexity:
   O(log n)




     0                                                                                                          2   160

                                                     node ID space


                                     target
                                                   This illustration is also simplified, the XOR Distance metric will
                                                   make you jump back and forth a bit.
                                                   Cutting your distance in half every hop still holds.



BitTorrent, Inc / 2013 Tech Talks                                                                                         31
ROUTING TABLE




BitTorrent, Inc / 2013 Tech Talks   32
ROUTING TABLE
   The XOR distance metric applied to the routing table just counts the length of the common bit-prefix.




                                      OUR NODE ID: 10101110100010101001110...
                                    OTHER NODE ID: 10101011010010110100101...




BitTorrent, Inc / 2013 Tech Talks                                                                          33
ROUTING TABLE
   The XOR distance metric applied to the routing table just counts the length of the common bit-prefix.




                                      OUR NODE ID: 10101110100010101001110...
                                    OTHER NODE ID: 10101011010010110100101...

                                                 shared bit prefix: 5 bits
                                                      node belongs in bucket 5




BitTorrent, Inc / 2013 Tech Talks                                                                          34
ROUTING TABLE
   A 160 bit space can be cut in half 160 times. There is a max of 160 buckets.




       ...                          prefix = 00   prefix = 0                      no prefix




     0                                                                                        2   160




       ...                           bucket 2     bucket 1                        bucket 0




BitTorrent, Inc / 2013 Tech Talks                                                                       35
ROUTING TABLE
   View of the routing table in node ID space (instead of distance space).




                                    bucket 0                3       4        bucket 2   bucket 1




     0                                                              self
                                                                                                   2   160




                                                            bit 0
                                                            bit 1
                                                            bit 2
                                                            bit 3



BitTorrent, Inc / 2013 Tech Talks                                                                            36
ROUTING TABLE
   A naïve routing table implementation would be an array of 160 buckets....




                                                     bucket 4


                                                                bucket 3


                                                                           bucket 2


                                                                                      bucket 1


                                                                                                 bucket 0
                                    ...   bucket 5




BitTorrent, Inc / 2013 Tech Talks                                                                           37
ROUTING TABLE
   A naïve routing table implementation would be an array of 160 buckets...

   Not very efficient, since the majority of buckets will be empty.




                                                     bucket 4


                                                                bucket 3


                                                                           bucket 2


                                                                                      bucket 1


                                                                                                 bucket 0
                                    ...   bucket 5




BitTorrent, Inc / 2013 Tech Talks                                                                           38
ROUTING TABLE




    A typical routing table starts with only bucket 0.

    When the 9th node is added, the bucket is split into bucket 0 and
    bucket 1, with the nodes moved to their respective bucket.

    Only the highest numbered bucket is ever split.




BitTorrent, Inc / 2013 Tech Talks                                       39
ROUTING TABLE




                                    bucket 0




BitTorrent, Inc / 2013 Tech Talks              40
ROUTING TABLE




                                    bucket 0




BitTorrent, Inc / 2013 Tech Talks              41
ROUTING TABLE




                                    bucket 0




BitTorrent, Inc / 2013 Tech Talks              42
ROUTING TABLE


                                        arrange nodes into the correct bucket




                                    bucket 1                             bucket 0




BitTorrent, Inc / 2013 Tech Talks                                                   43
ROUTING TABLE




                                    bucket 1   bucket 0




BitTorrent, Inc / 2013 Tech Talks                         44
ROUTING TABLE




                                    bucket 1   bucket 0




BitTorrent, Inc / 2013 Tech Talks                         45
ROUTING TABLE




                                    bucket 1   bucket 0




BitTorrent, Inc / 2013 Tech Talks                         46
ROUTING TABLE




                                    bucket 1   bucket 0




BitTorrent, Inc / 2013 Tech Talks                         47
TRAVERSAL ALGORITHM
   A deeper look at the get_peers and announce_peer query.




BitTorrent, Inc / 2013 Tech Talks                            48
TRAVERSAL ALGORITHM
    Pick known nodes out of routing table, close to the target we're looking up.

    Sort by distance to target.


                                                       (IP, Node ID)

                                    closer to target   (IP, Node ID)
                                                       (IP, Node ID)
                                                       (IP, Node ID)




BitTorrent, Inc / 2013 Tech Talks                                                  49
TRAVERSAL ALGORITHM
   Send requests to 3 (or so) at a time.

                                                                                        s( ih)
                                                                                   pe er
                                                                           g et_
                                                       (IP, Node ID)   x
                                                                            get_peers (ih)
                                    closer to target   (IP, Node ID)   x
                                                       (IP, Node ID)   x   get
                                                                               _pe
                                                       (IP, Node ID)                  ers
                                                                                            (ih)




BitTorrent, Inc / 2013 Tech Talks                                                                  50
TRAVERSAL ALGORITHM
   Send requests to 3 (or so) at a time.


                                                                                  s( ....)
                                                                           n ode
                                                       (IP, Node ID)   x
                                                                            nodes (....)
                                    closer to target   (IP, Node ID)   x
                                                       (IP, Node ID)   x
                                                                           nod
                                                                                 es (
                                                       (IP, Node ID)                  ....)




BitTorrent, Inc / 2013 Tech Talks                                                             51
TRAVERSAL ALGORITHM
   Nodes are inserted in sorted order.
   Nodes we already have are ignored. Nodes that don't respond, are marked as stale



                                                       (IP, Node ID)

                                    closer to target   (IP, Node ID)
                                                       (IP, Node ID)
                                                       (IP, Node ID)
                                                       (IP, Node ID)    x
                                                       (IP, Node ID)
                                                       (IP, Node ID)    x
                                                       (IP, Node ID)    x
                                                       (IP, Node ID)
                                                       (IP, Node ID)
BitTorrent, Inc / 2013 Tech Talks                                                     52
TRAVERSAL ALGORITHM
   Keep requests 3 outstanding at all times.

                                                                                        s( ih)
                                                                                   pe er
                                                                           g et_
                                                       (IP, Node ID)   x
                                                                            get_peers (ih)
                                    closer to target   (IP, Node ID)   x
                                                       (IP, Node ID)   x   get
                                                                               _pe
                                                       (IP, Node ID)                  ers
                                                                                            (ih)
                                                       (IP, Node ID)   x
                                                       (IP, Node ID)
                                                       (IP, Node ID)   x
                                                       (IP, Node ID)   x
                                                       (IP, Node ID)



BitTorrent, Inc / 2013 Tech Talks                                                                  53
TRAVERSAL ALGORITHM
   Terminating condition: the top 8 nodes have all been queried (and responded).




                                                       (IP, Node ID)     x

                                    closer to target   (IP, Node ID)     x
                                                       (IP, Node ID)     x
                                                       (IP, Node ID)     x
                                                       (IP, Node ID)     x
                                                       (IP, Node ID)     x
                                                       (IP, Node ID)     x
                                                       (IP, Node ID)     x
                                                       (IP, Node ID)



BitTorrent, Inc / 2013 Tech Talks                                                  54
PROTOCOL
   Send announce_peer to the top 8 nodes.

                                                                                              r( ih)
                                                                                          pee
                                                                                    n ce_        ih)
                                                                             nn ou         ee r(
                                                       (IP, Node ID)   x
                                                                           a
                                                                                    nc e_p       ih)
                                                                             nn ou         ee r(
                                                                           a           e_p
                                    closer to target   (IP, Node ID)   x          u nc           ih)
                                                                           an no            er (
                                                                                        _pe
                                                       (IP, Node ID)   x        ou  nce       r( ih)
                                                                           ann         e_ pee
                                                       (IP, Node ID)   x        ou  nc        r( ih)
                                                                           a nn        e_ pee
                                                       (IP, Node ID)   x        o unc            ih)
                                                                           a nn             er (
                                                                                        _pe
                                                       (IP, Node ID)   x        ou  nce       r( ih)
                                                                           ann         e_ pee
                                                       (IP, Node ID)   x      no  unc
                                                                           an
                                                       (IP, Node ID)   x
                                                       (IP, Node ID)



BitTorrent, Inc / 2013 Tech Talks                                                                      55

More Related Content

Viewers also liked

Bit Torrent Protocol
Bit Torrent ProtocolBit Torrent Protocol
Bit Torrent ProtocolAli Habeeb
 
P2P in 2020 - The Push for Supplier Self-Service
P2P in 2020 - The Push for Supplier Self-ServiceP2P in 2020 - The Push for Supplier Self-Service
P2P in 2020 - The Push for Supplier Self-Service
Tradeshift
 
The eMule application of the eDonkey protocol
The eMule application of the eDonkey protocolThe eMule application of the eDonkey protocol
The eMule application of the eDonkey protocol
zankyw
 
Bittorrent
BittorrentBittorrent
Bittorrent
Anush Shenoy
 
BitTorrent - sharing files has never been easier
BitTorrent - sharing files has never been easierBitTorrent - sharing files has never been easier
BitTorrent - sharing files has never been easierMohd253
 
Bit Torrent
Bit Torrent Bit Torrent
Bit Torrent
Ashish Kumar
 
BitTorrent
BitTorrentBitTorrent
BitTorrent
maheshmohanmu
 
Bittorrent Seminar by dhananjay pardeshi
Bittorrent Seminar by dhananjay pardeshiBittorrent Seminar by dhananjay pardeshi
Bittorrent Seminar by dhananjay pardeshi
dhananjaypardeshi13
 
Torrent
TorrentTorrent
Bit torrent Technology ppt
Bit torrent Technology pptBit torrent Technology ppt
Bit torrent Technology ppt
Akshay K Sajan
 
Bit Torrent presentation
Bit Torrent presentationBit Torrent presentation
Bit Torrent presentationAvula Jagadeesh
 
Deploy your own P2P network
Deploy your own P2P networkDeploy your own P2P network
Deploy your own P2P network
Dobrica Pavlinušić
 
Introduction to Peer-to-Peer Networks
Introduction to Peer-to-Peer Networks Introduction to Peer-to-Peer Networks
Introduction to Peer-to-Peer Networks Venkatesh Iyer
 
BitTorrent Protocol
BitTorrent ProtocolBitTorrent Protocol
BitTorrent Protocol
SridharBR
 

Viewers also liked (15)

Bit Torrent Protocol
Bit Torrent ProtocolBit Torrent Protocol
Bit Torrent Protocol
 
P2P in 2020 - The Push for Supplier Self-Service
P2P in 2020 - The Push for Supplier Self-ServiceP2P in 2020 - The Push for Supplier Self-Service
P2P in 2020 - The Push for Supplier Self-Service
 
The eMule application of the eDonkey protocol
The eMule application of the eDonkey protocolThe eMule application of the eDonkey protocol
The eMule application of the eDonkey protocol
 
Bittorrent
BittorrentBittorrent
Bittorrent
 
BitTorrent - sharing files has never been easier
BitTorrent - sharing files has never been easierBitTorrent - sharing files has never been easier
BitTorrent - sharing files has never been easier
 
Bit Torrent
Bit Torrent Bit Torrent
Bit Torrent
 
BitTorrent
BitTorrentBitTorrent
BitTorrent
 
Bittorrent Seminar by dhananjay pardeshi
Bittorrent Seminar by dhananjay pardeshiBittorrent Seminar by dhananjay pardeshi
Bittorrent Seminar by dhananjay pardeshi
 
Torrent
TorrentTorrent
Torrent
 
Bit torrent Technology ppt
Bit torrent Technology pptBit torrent Technology ppt
Bit torrent Technology ppt
 
Bit Torrent presentation
Bit Torrent presentationBit Torrent presentation
Bit Torrent presentation
 
Deploy your own P2P network
Deploy your own P2P networkDeploy your own P2P network
Deploy your own P2P network
 
Introduction to Peer-to-Peer Networks
Introduction to Peer-to-Peer Networks Introduction to Peer-to-Peer Networks
Introduction to Peer-to-Peer Networks
 
BitTorrent Protocol
BitTorrent ProtocolBitTorrent Protocol
BitTorrent Protocol
 
P2PFile
P2PFileP2PFile
P2PFile
 

Recently uploaded

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 

Recently uploaded (20)

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 

Bit torrent techtalks_dht

  • 1. TECH TALKS BitTorrent DHT | Arvid Norberg BitTorrent, Inc / 2013 Tech Talks 01
  • 2. INTRODUCTION DHT = DISTRIBUTED HASH TABLE (It’s like a hash table, where the payload is divided up across many nodes.) BitTorrent, Inc / 2013 Tech Talks 02
  • 3. INTRODUCTION The DHT is primarily used to introduce peers to each other. Who e lse is PEER on sw arm X ? 172.4 119.7 .12.7 217.1 3.53. 3.98. ... 83 220 DHT BitTorrent, Inc / 2013 Tech Talks 03
  • 4. INTRODUCTION protocol <what do nodes say to each other?> topology <how are nodes organized?> routing <how are target nodes found?> routing table <representation of routing info> traversal algorithm <search implementation?> BitTorrent, Inc / 2013 Tech Talks 04
  • 5. PROTOCOL BitTorrent, Inc / 2013 Tech Talks 05
  • 6. PROTOCOL ping <are you still around?> announce_peer <hey, i’m on this swarm!> get_peers <who else is on this swarm?, or who can I ask?> find_node <who is close to this ID?, or who can I ask?> PEER DHT BitTorrent, Inc / 2013 Tech Talks 06
  • 7. PROTOCOL ping <are you still around?> ONE-OFF MESSAGES announce_peer <hey, i’m on this swarm!> get_peers <who else is on this swarm?, or who can I ask?> find_node <who is close to this ID?, or who can I ask?> PEER DHT BitTorrent, Inc / 2013 Tech Talks 07
  • 8. PROTOCOL ping <are you still around?> ONE-OFF MESSAGES announce_peer <hey, i’m on this swarm!> get_peers <who else is on this swarm?, or who can I ask?> RECURSIVE find_node <who is close to this ID?, or who can I ask?> PEER DHT BitTorrent, Inc / 2013 Tech Talks 08
  • 9. PROTOCOL ping <are you still around?> announce_peer <hey, i’m on this swarm!> get_peers <who else is on this swarm?, or who can I ask?> find_node <who is close to this ID?, or who can I ask?> get_peers (x) PEER nodes: <...> DHT BitTorrent, Inc / 2013 Tech Talks 09
  • 10. PROTOCOL ping <are you still around?> announce_peer <hey, i’m on this swarm!> get_peers <who else is on this swarm?, or who can I ask?> find_node <who is close to this ID?, or who can I ask?> get_ peers (x) nod es: <...> get_peers (x) PEER nodes: <...> get_pee rs (x) DHT nodes: REPEATS <...> BitTorrent, Inc / 2013 Tech Talks 10
  • 11. PROTOCOL ping <are you still around?> announce_peer <hey, i’m on this swarm!> get_peers <who else is on this swarm?, or who can I ask?> find_node <who is close to this ID?, or who can I ask?> get_peers (x) PEER nodes: <...> get_pee rs (x) DHT nodes: TERMINATES WHEN WE <...> RECEIVE VALUES (I.E. PEERS) AND NO BETTER NODES BitTorrent, Inc / 2013 Tech Talks 11
  • 12. PROTOCOL ping <are you still around?> announce_peer <hey, i’m on this swarm!> get_peers <who else is on this swarm?, or who can I ask?> find_node <who are close to this ID?, or who can I ask?> EACH MESSAGE INCLUDES ONES OWN NODE ID. THIS ENABLES NODES TO LEARN ABOUT NEW NODES AS PART OF THE PROTOCOL CHATTER. BitTorrent, Inc / 2013 Tech Talks 12
  • 13. PROTOCOL bootstrap <find_nodes(self)> refresh buckets <find_nodes (target-bucket)> announce <get_peer(ih) + announce_peer(ih)> BitTorrent, Inc / 2013 Tech Talks 13
  • 14. PROTOCOL Spoof protection get_peers responds with a write-token Write-token is typically a MAC of: - source (IP, port) - target info-hash - local secret (which may expire in tens of minutes) announce_peer requires a valid write token to insert the node in the peer list BitTorrent, Inc / 2013 Tech Talks 14
  • 15. TOPOLOGY This section describes how nodes can respond to recursive lookup queries like this, with nodes closer and closer to the target.* *Spoiler alert: it has to do with the topology BitTorrent, Inc / 2013 Tech Talks 15
  • 16. TOPOLOGY The DHT is made up by all BitTorrent peers, across all swarms. PEER PEER PEER PEER PEER PEER PEER PEER PEER PEER PEER PEER PEER PEER PEER PEER PEER BitTorrent, Inc / 2013 Tech Talks 16
  • 17. TOPOLOGY Each node has a self-assigned address, or node ID. PEER PEER 71690...29736 24e52...a22a6 PEER PEER PEER 138b8...cea6f caa39...9087a 09b9b...6216b PEER PEER PEER PEER f091c...7fc09 9a2ac...1993e 03afa...f0200 09b9b...6216b PEER 6c6cf...10f46 PEER f8466...b21cf PEER PEER 5f08d...e2537 22942...48a07 PEER PEER PEER 255d5...b923d 0f35f...386ab 79280...f8bf3 PEER 2f1d5...04177 BitTorrent, Inc / 2013 Tech Talks 17
  • 18. TOPOLOGY Consider all nodes lined up in the node ID space.... 0 2 160 BitTorrent, Inc / 2013 Tech Talks 18
  • 19. TOPOLOGY Consider all nodes lined up in the node ID space.... 0 node-ID space 2 160 ....all nodes appear evenly distributed in this space. BitTorrent, Inc / 2013 Tech Talks 19
  • 20. TOPOLOGY IDs are 160 bits (20 bytes) long... Keys in the hash table (info-hashes) are also 160 bits. 0 node-ID space 2 160 BitTorrent, Inc / 2013 Tech Talks 20
  • 21. TOPOLOGY IDs are 160 bits (20 bytes) long... Keys in the hash table (info-hashes) are also 160 bits info-hash 0 node-ID space 2 160 Nodes whose ID is close to an info-hash are responsible for storing information about it. BitTorrent, Inc / 2013 Tech Talks 21
  • 22. TOPOLOGY IDs are 160 bits (20 bytes) long... Keys in the hash table (info-hashes) are also 160 bits info-hash 0 node-ID space 2 160 Nodes whose ID is close to an info-hash are responsible for storing information about it. BitTorrent, Inc / 2013 Tech Talks 22
  • 23. ROUTING BitTorrent, Inc / 2013 Tech Talks 23
  • 24. ROUTING It is impractical for every node to know about every other node. There are millions of nodes. Nodes come and go constantly. Every node specializes in knowing about all nodes close to itself. The farther from itself, the more sparse its knowledge of nodes become. BitTorrent, Inc / 2013 Tech Talks 24
  • 25. ROUTING The routing table orders nodes based on their distance from oneself. distance distance 0 node-ID space self 2 160 BitTorrent, Inc / 2013 Tech Talks 25
  • 26. ROUTING The routing table orders nodes based on their distance from oneself. distance distance 0 node-ID space self 2 160 self distance from self This is simplified. The euclidian distance is not actually used. BitTorrent, Inc / 2013 Tech Talks 26
  • 27. ROUTING The euclidian distance has a problem that it “folds” the space, and nodes are no longer uniformly distributed (in the distance-space). distance distance 0 node-ID space 2 160 self BitTorrent, Inc / 2013 Tech Talks 27
  • 28. ROUTING The XOR distance metric is: d(a,b) = a ⊕ b 0 self distance from self 2 160 The XOR distance metric makes it so that the distances are still uniformly distributed. It doesn't “fold” the space the way euclidian distance does. BitTorrent, Inc / 2013 Tech Talks 28
  • 29. ROUTING The distance space is divided up into buckets. Each bucket holds no more than 8 nodes. 0 self distance from self 2 160 BitTorrent, Inc / 2013 Tech Talks 29
  • 30. ROUTING The distance space is divided up into buckets. Each bucket holds no more than 8 nodes. The space covered by a bucket is half as big as the previous one. You know about more nodes close to you. 0 self 2 160 distance from self ... bucket 2 bucket 1 bucket 0 BitTorrent, Inc / 2013 Tech Talks 3-
  • 31. ROUTING For every hop in a recursive lookup, the nodes distance is cut in half. Lookup complexity: O(log n) 0 2 160 node ID space target This illustration is also simplified, the XOR Distance metric will make you jump back and forth a bit. Cutting your distance in half every hop still holds. BitTorrent, Inc / 2013 Tech Talks 31
  • 32. ROUTING TABLE BitTorrent, Inc / 2013 Tech Talks 32
  • 33. ROUTING TABLE The XOR distance metric applied to the routing table just counts the length of the common bit-prefix. OUR NODE ID: 10101110100010101001110... OTHER NODE ID: 10101011010010110100101... BitTorrent, Inc / 2013 Tech Talks 33
  • 34. ROUTING TABLE The XOR distance metric applied to the routing table just counts the length of the common bit-prefix. OUR NODE ID: 10101110100010101001110... OTHER NODE ID: 10101011010010110100101... shared bit prefix: 5 bits node belongs in bucket 5 BitTorrent, Inc / 2013 Tech Talks 34
  • 35. ROUTING TABLE A 160 bit space can be cut in half 160 times. There is a max of 160 buckets. ... prefix = 00 prefix = 0 no prefix 0 2 160 ... bucket 2 bucket 1 bucket 0 BitTorrent, Inc / 2013 Tech Talks 35
  • 36. ROUTING TABLE View of the routing table in node ID space (instead of distance space). bucket 0 3 4 bucket 2 bucket 1 0 self 2 160 bit 0 bit 1 bit 2 bit 3 BitTorrent, Inc / 2013 Tech Talks 36
  • 37. ROUTING TABLE A naïve routing table implementation would be an array of 160 buckets.... bucket 4 bucket 3 bucket 2 bucket 1 bucket 0 ... bucket 5 BitTorrent, Inc / 2013 Tech Talks 37
  • 38. ROUTING TABLE A naïve routing table implementation would be an array of 160 buckets... Not very efficient, since the majority of buckets will be empty. bucket 4 bucket 3 bucket 2 bucket 1 bucket 0 ... bucket 5 BitTorrent, Inc / 2013 Tech Talks 38
  • 39. ROUTING TABLE A typical routing table starts with only bucket 0. When the 9th node is added, the bucket is split into bucket 0 and bucket 1, with the nodes moved to their respective bucket. Only the highest numbered bucket is ever split. BitTorrent, Inc / 2013 Tech Talks 39
  • 40. ROUTING TABLE bucket 0 BitTorrent, Inc / 2013 Tech Talks 40
  • 41. ROUTING TABLE bucket 0 BitTorrent, Inc / 2013 Tech Talks 41
  • 42. ROUTING TABLE bucket 0 BitTorrent, Inc / 2013 Tech Talks 42
  • 43. ROUTING TABLE arrange nodes into the correct bucket bucket 1 bucket 0 BitTorrent, Inc / 2013 Tech Talks 43
  • 44. ROUTING TABLE bucket 1 bucket 0 BitTorrent, Inc / 2013 Tech Talks 44
  • 45. ROUTING TABLE bucket 1 bucket 0 BitTorrent, Inc / 2013 Tech Talks 45
  • 46. ROUTING TABLE bucket 1 bucket 0 BitTorrent, Inc / 2013 Tech Talks 46
  • 47. ROUTING TABLE bucket 1 bucket 0 BitTorrent, Inc / 2013 Tech Talks 47
  • 48. TRAVERSAL ALGORITHM A deeper look at the get_peers and announce_peer query. BitTorrent, Inc / 2013 Tech Talks 48
  • 49. TRAVERSAL ALGORITHM Pick known nodes out of routing table, close to the target we're looking up. Sort by distance to target. (IP, Node ID) closer to target (IP, Node ID) (IP, Node ID) (IP, Node ID) BitTorrent, Inc / 2013 Tech Talks 49
  • 50. TRAVERSAL ALGORITHM Send requests to 3 (or so) at a time. s( ih) pe er g et_ (IP, Node ID) x get_peers (ih) closer to target (IP, Node ID) x (IP, Node ID) x get _pe (IP, Node ID) ers (ih) BitTorrent, Inc / 2013 Tech Talks 50
  • 51. TRAVERSAL ALGORITHM Send requests to 3 (or so) at a time. s( ....) n ode (IP, Node ID) x nodes (....) closer to target (IP, Node ID) x (IP, Node ID) x nod es ( (IP, Node ID) ....) BitTorrent, Inc / 2013 Tech Talks 51
  • 52. TRAVERSAL ALGORITHM Nodes are inserted in sorted order. Nodes we already have are ignored. Nodes that don't respond, are marked as stale (IP, Node ID) closer to target (IP, Node ID) (IP, Node ID) (IP, Node ID) (IP, Node ID) x (IP, Node ID) (IP, Node ID) x (IP, Node ID) x (IP, Node ID) (IP, Node ID) BitTorrent, Inc / 2013 Tech Talks 52
  • 53. TRAVERSAL ALGORITHM Keep requests 3 outstanding at all times. s( ih) pe er g et_ (IP, Node ID) x get_peers (ih) closer to target (IP, Node ID) x (IP, Node ID) x get _pe (IP, Node ID) ers (ih) (IP, Node ID) x (IP, Node ID) (IP, Node ID) x (IP, Node ID) x (IP, Node ID) BitTorrent, Inc / 2013 Tech Talks 53
  • 54. TRAVERSAL ALGORITHM Terminating condition: the top 8 nodes have all been queried (and responded). (IP, Node ID) x closer to target (IP, Node ID) x (IP, Node ID) x (IP, Node ID) x (IP, Node ID) x (IP, Node ID) x (IP, Node ID) x (IP, Node ID) x (IP, Node ID) BitTorrent, Inc / 2013 Tech Talks 54
  • 55. PROTOCOL Send announce_peer to the top 8 nodes. r( ih) pee n ce_ ih) nn ou ee r( (IP, Node ID) x a nc e_p ih) nn ou ee r( a e_p closer to target (IP, Node ID) x u nc ih) an no er ( _pe (IP, Node ID) x ou nce r( ih) ann e_ pee (IP, Node ID) x ou nc r( ih) a nn e_ pee (IP, Node ID) x o unc ih) a nn er ( _pe (IP, Node ID) x ou nce r( ih) ann e_ pee (IP, Node ID) x no unc an (IP, Node ID) x (IP, Node ID) BitTorrent, Inc / 2013 Tech Talks 55