Introduction to KolibriOS
KolibriOS is tiny yet powerful operating system that can run with few megabytes of disk and 8MB of RAM. It boots in less than 10 seconds. It is completely written in FASM assembly language which is the reason for such small memory footprint and tremendous speed.
One can read more about KolibriOS here. KolibriOS has an active community support. Developers are available on IRC channel #KolibriOS on freenode server.
Introduction to Bittorrent Client
Bittorrent client is an application that helps to perform peer to peer file sharing using Bittorrent Protocol
Bittorrent client runs on every machine which is involved in downloading/uploading files among peers.
Bittorrent Client project has been carried out as part of Google Summer of Code 2016 program under KolibriOS organization. Click here for more details.
For developement purpose, look at unoffical specification of Bittorrent Protocol here
For understanding overall developement process, visit Kristen Widman's awesome blog.
For more information and queries, visit KolibriOS's forum
You can find my GSoC Proposal Here
List of commits
This project is carried out under category 'New Feature'. So it has its independent repository.
Here is list of commits I made , over period of 3 months of my GSoC Project.
Overall Directory Structure
All the code files have been kept directly under the main repository
It Contains important notes for developement in simple english
It contains all files which needs to be included to run complete code. These files are developed by KolibriOS community.
It contains various torrent files , I have used for testing.
It contains tiny pieces of code, I have developed or taken reference of, during developement process. It is not part of torrent client code.
Torrent Code Files and their significance
These files are heart of bit-torrent project.
This file contains methods for generating front-end part of bit-torrent client.
Front-end of bittorrent client is command line interface through which user can handle all torrents.
This file is still in developement phase.
This file keeps running in background and keeps updating torrent data structure.
This file is still in developement phase.
This is helper file to bittorrent_backend.asm. This file contains mainly methods for handling different torrent actions invoked by front-end
This file contains all structures and constants.
This is primary file for torrent operations. It handles over-all flow of torrent. It involves methods for adding new torrent, starting and resuming existing torrents.
This file is written as library and includes all files , followed in this list. It creates torrent.obj file , once it is compiled.
The tracker is an HTTP(S) service that holds information about the torrent and peers. The tracker itself does not have the file you want to download, but it does have a list of all peers that are connected for this torrent who have the file or are downloading the file.
Tracker.asm contains method that prepares get request for tracker and helps to decode response from tracker.
Bencoding is a way to specify and organize data in a terse format. It supports only four types: byte strings, integers, lists, and dictionaries.
Bencoding is the official way to represent any BitTorrent Specific data. Complete .torrent file is written in bencoded format.
Bencode.asm decodes bencoded data. Bencode.asm is helpful in decoding .torrent file and tracker response.
Percent-encoding, also known as URL encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI)
In bittorrent communication, while connecting with tracker server, URL must be encoded using percent-encoding.
Percent.asm helps to perform percent encoding.
A piece is chunk of data that can be verified against hash provided in torrent file.
Size of piece range from 256kB to 4096kB , depending on the total torrent size.
Piece.asm contains methods that helps in filling the piece structure (mentioned in torrent.inc), getter and setter methods for member variables of piece structure and writing/reading piece to/from file.
Peer is any BitTorrent client participating in a download.
According to bittorrent protocol, Bittorrent client performs handshake message exchange before starting any data exchange. Once handshake messages, from both the sides, are verified, bittorrent client starts communicating with other bittorrent client using 11 different messages.
Peer.asm contains methods to communicate with peers.
All of the remaining messages in the protocol take the form of <length prefix><message ID><payload>. The length prefix is a four byte big-endian value. The message ID is a single decimal byte. The payload is message dependent.
Message.asm prepares and verifies these messages.
SHA1 hash in bittorrent protocol provides protection against malicious data transfer.
Torrent file contains SHA1 hash of each piece [under 'pieces' field of info dictionary]
Also, Bittorrent protocol requires to compute SHA1 hash of bencoded info dictionary while connecting with tracker.
Hash.asm contains methods for generating and verifying SHA1 hash of data.
Bitfields, in bittorrent protocol, is compact way of specifying available pieces using 0s and 1s.
Bitfields requires x number of bytes. x = number of pieces/8. As each bit of byte represents one piece.
Bitfields are maintained for each peer as well as bittorent client.
Bitfield.asm involves finding available piece, setting and getting bit (i.e. availibility status of piece) in bitfields.
Memops.asm is helper file which helps managing pieces which are kept in memory.
Methods of this file mainly involves finding suitable memory location for piece download/upload and
Fileops.asm is helper file which helps creating directory structure and empty files for torrent downloading.
Genops.asm is helper file which contains general methods which is helpful in overall torrent process.