A bit torrent like file sharing system with fallback multi-tracker system with synchronization and parallel downloading. Implemented own RPC mechanism, message encoding and methods for message serialization and de-serialization. Used openssl library for computing hash values of files(SHA1)
- Create a 2-D map of chunk index - list of peers having that chunk of the file
- For each chunk index i:
- Generate a random number x of range (0, len(peer_list_of_chunk))
- Download chunk i from the peer present at index x
- Magic start: Indicates the start of a new message
- Msg Type size: Size(in bytes) of the message type, ie, number of bytes to read to get the message type
- Msg type: Actual message type(ex: share, etc)
- Payload size: Size(in bytes) of the entire payload, ie, number of bytes to read to get entire payload
- Payload: Payload in bytes
- Magic end: Indicates the end of the message
- Payload can constitute of a number of arguments, each appened by the arg size(in bytes) to indicate the number of bytes to read to retrive the argument
Inspired from Protocol buffers, created a generic Message class and used inheritance to create class for each message type. Implemented class methods for message serialization and de-serialization
- Share: Share file request to the tracker
- AddSeeder: Add seeder to the tracker list for a given file
- RemoveSeeder: Remove seeder from the tracker list for a given file
- SeederInfoRequest: Get the seeder list for a given file
- SeederInfoResponse: Response for the Seeder list request
- ChunkInfoRequest: Get the chunk availability information from peer
- ChunkInfoResponse: Response for the chunk info request
- SendChunkRequest: Request to send chunk data based on chunk index
- SendChunkResponse: Get the chunk data from the peer(download chunk)
- Response: Response for one directional communications
- SyncShare: Relay of share message to the other tracker
- SyncAddSeeder: Relay of add seeder request to the other tracker
- SyncRemoveSeeder: Relay of remove seeder request to the other tracker
- SyncSeederListRequest: seeder list request to the other tracker during startup of the tracker
- SyncSeederListResponse: seeder list response for the above request
- ChunkDownloader - Handles download of all the chunks of a file
- ChunkSaver - Handles download of single chunk and saves to the file
- clientDatabase - Singleton class to store all data required by the client
- commandHandler - Handler to handle all the different user commands
- download - Creates a download object to store all download related data
- downloadManager - Singleton class to manage all ongoing and completed downloads
- fileHandler - Handler to handle all file related operations
- mtorrent - Creates an mtorrent object to store all data related to mtorrent file
- peerHandler - Handler to handle all the different peer related requests
- peerListener - Listens for incoming connections from peers
- peerMessageHandler - Message specific Handler to handle different requests
- fileAttr - Creates an object to store all data related to a single file(ex: hash, seeder list, etc)
- rpcHandler - Handler to handle all the different client requests
- trackerMessageHandler - Message specific Handler to handle different requests
- trackerDatabase - Singleton class to store all data required by the tracker
- Decoder - Class to handle decoding of different messages from raw bytes
- Encoder - Class to handle encoding of different messages into raw bytes
- logHandler - Singleton class to handle logging
- message - Contains classes for each message type(Core part for communication)
- NetworkInterfacer - Handles interfacing with network(Read/write from network sockets)
- TrackerServiceServer - Handles communication to single/multiple trackers
- share .mtorrent : Shares file availability to the network
- get <path to .mtorrent> : Downloads the file to the destination path
- show downloads: shows the ongoing/completed file downloads
- remove <filename.mtorrent>: remove sharing of the file by the current user
- quit: exits application