-
Leave Group : Whenever User laeves the group , the files shared by user will also be deleted from the group,but when the user re-joins the group , the files will be restored to the group(user can wish to delete the files permenatntly by invoking stop_share command)
-
Stop_Share : Whenever a user enters stop_share command , the files shared by the user will be deleted from the group permanently ,but if a another user has already downloaded/is sharing the file then the file will be listed in list_files command as the file can be shared by that other user.
As soon as any user downloads the file ,he/she becomes seeder of the file and to stop sharing the file ,the user has to invoke stop_share command.
- Create User Account:
create_user <user_id> <passwd>
- Login:
login <user_id> <passwd>
- Create Group:
create_group <group_id>
- Join Group:
join_group <group_id>
- Leave Group:
leave_group <group_id>
- List pending join:
list_requests <group_id>
- Accept Group Joining Request:
accept_request <group_id> <user_id>
- List All Group In Network:
list_groups
- List All sharable Files In Group:
list_files <group_id>
- Upload File:
upload_file <file_path> <group_id>
- Download File:
download_file <group_id> <file_name> <destination_path>
- Logout:
logout
- Show_downloads:
show_downloads
- Output format:
- [D] [grp_id] filename
- [C] [grp_id] filename
- D(Downloading), C(Complete)
- Output format:
- Stop sharing:
stop_share <group_id> <file_name>
cd tracker
g++ tracker.cpp -lcrypto -Wall -pthread -o tracker
./tracker tracker_info.txt tracker_no
eg : ./tracker tracker_info.txt 1
cd client
g++ client.cpp -lcrypto -Wall -pthread -o client
./client ./client <IP>:<PORT> tracker_info.txt
eg : ./client 127.0.0.1:7600 tracker_info.txt
- Clarity of Distributed - Architecture Program Building
- BIT Mapping / File Integration - Division
- Intense Socket Programming
- To acquire Knowledge of system calls and core libraries like fntcl , unistd .sys/stat
- At Least one tracker will always be online.
- Client needs to create an account (userid and password) in order to be part of the network.
- Client can create any number of groups(groupid should be different) and hence will be owner of those groups
- Client needs to be part of the group from which it wants to download the file
- Client will send join request to join a group
- Owner Client Will Accept/Reject the request
- After joining group ,client can see list of all the shareable files in the group
- Client can share file in any group (note: file will not get uploaded to tracker but only the : of the client for that file)
- Client can send the download command to tracker with the group name and filename and tracker will send the details of the group members which are currently sharing that particular file
- After fetching the peer info from the tracker, client will communicate with peers about the portions of the file they contain and hence accordingly decide which part of data to take from which peer (You need to design your own Piece Selection Algorithm)
- As soon as a piece of file gets downloaded it should be available for sharing
- After logout, the client should temporarily stop sharing the currently shared files till the next login
- All trackers need to be in sync with each other
cd tracker
g++ tracker.cpp -lcrypto -Wall -pthread -o tracker
./tracker tracker_info.txt tracker_no
eg : ./tracker tracker_info.txt 1
cd client
g++ client.cpp -lcrypto -Wall -pthread -o client
./client ./client <IP>:<PORT> tracker_info.txt
eg : ./client 127.0.0.1:7600 tracker_info.txt
- Create User Account:
create_user <user_id> <passwd>
- Login:
login <user_id> <passwd>
- Create Group:
create_group <group_id>
- Join Group:
join_group <group_id>
- Leave Group:
leave_group <group_id>
- List pending join:
list_requests <group_id>
- Accept Group Joining Request:
accept_request <group_id> <user_id>
- List All Group In Network:
list_groups
- List All sharable Files In Group:
list_files <group_id>
- Upload File:
upload_file <file_path> <group_id>
- Download File:
download_file <group_id> <file_name> <destination_path>
- Logout:
logout
- Show_downloads:
show_downloads
- Output format:
- [D] [grp_id] filename
- [C] [grp_id] filename
- D(Downloading), C(Complete)
- Output format:
- Stop sharing:
stop_share <group_id> <file_name>
- connect :
connection_status = connect(client_socket, (struct sockaddr * ) &server _ address , sizeof(server_address));
- htons :
**server_address.sin_port = htons((PORT));**
- socket :
**client_socket = socket(AF_INET, SOCK_STREAM, 0);**
- close :
**close(client_socket);**
- bind :
**bind(server_sd, (struct sockaddr *)&server_addr, sizeof(server_addr));**
- listen :
**listen(server_sd, 5);**
- accept :
**accept(server_sd, (sockaddr *)&client_addr, &client_addr_size);**
- Unistd.h : Mainly to get size of file while uploading ,
**i.e information about no. of chunks ,pread , pwrite,getcwd
** - fnctl.h : To use macros for S_IRUSR , S_IRWXO ,etc.
- *openssl/sha.h *****: To calculate SHA-1
- pthread : To create and execute c threads (
**pthread_create
** ) - pread : To read parallelly from threads
- pwrite : To write parallelly from threads
- pthread_join: To join threads
- stat st ⇒ To obtain file size
**(using st.size( ) )**
while uploading the file , this information is sent to tracker so that it can maintain a bit-map of chunks a particular peer has.
From Socket.h library following were used to implement functionality of sending and receive
- send() : function shall initiate transmission of a message from the specified socket to its peer. The send() function shall send a message only when the socket is connected (including when the peer of a connection-less socket has been set via *connect*()).
- The recv() : The recv() function receives data on a socket with descriptor socket and stores it in a buffer. The recv() call applies only to connected sockets.
To obtain SHA1 (hash) of a file so that intgerity of each and individual chunks can be verified. following system calls are used
- SHA1 : from sha.h library
- sprintf : To Write formatted output to S