Skip to content

rishavmehra/bitTorrent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BitTorrent

BitTorrent is a peer-to-peer file sharing protocol


Usage:

git clone [email protected]:rishavmehra/bitTorrent.git
cd bitTorrent
go build .
./bitTorrent  <.torrent file> <path to save the file>

example:
  ./bitTorrent ubuntu-24.10-desktop-amd64.iso.torrent ubutnu-24.10-desktop-amd64.iso


Docs:

alt text

alt text

BitTorrent Flow

  • Find Peers
    • Open .torrent file (Parsing file)
    • Peers from the Tracker (Tracker received in .torrent file)
    • Parse Response of the Tracker
  • Download from the Peers
    • TCP Connection
    • Complete the Handshake
    • Send and receive messages
      • Interpreting messages
      • Bitfields
    • Join all together
      • Managing concurrency: channels as queues
        • peer-to-peer connection
      • Managing state
  • Final touch for main.go
  • Multifile Torrents
  • Better Error handling for buffers

announce - holds the URL of the tracker

created by - name and version of the program who created it

creation date - time at which the torrent was created

encoding - encoding of the strings in info dictionary

comment - some additional comments

info - a dictionary that describes files in the torrent

The info dictionary holds the information about the file that is being shared through the torrent. If the torrent is about the Ubuntu image, it will hold info like name, length, and md5sum of the actual file.

Given that the file is split into equal-length pieces, the info dictionary also holds

pieces - SHA1 of every piece of the file concatenated

piece length - number of bytes in each piece

The .torrent file holds all critical meta yet static information about the content, like

 d
  8:announce
    41:http://bttracker.debian.org:6969/announce
  7:comment
    35:"Ubuntu CD from cdimage.ubuntu.com" 35:"
  13:creation date
    i1573903810e
  4:info
    d
      6:length
        i351272960e
      4:name
        31:ubuntu-24.10-desktop-amd64.iso
      12:piece length
        i262144e
      6:pieces
        26800:�������PS�^�� (binary blob of the hashes of each piece)
    e
e
---

About

Blazingly fast Golang powered BitTorrent client

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages