-
Notifications
You must be signed in to change notification settings - Fork 8
aavegmit/p2p
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Team:- Aaveg Mittal - [email protected] (1523097378) Manu Bhadoria - [email protected] (7151287551) Peer to Peer File sharing System - Final Project Part(2) CSCI 551, Computer Compunication Spring 2011 FILES: Below are the files in this prject, Part 2:- -main.cc This file includes the main body of the peer to peer file system. This is the main thread, and it creates multiple child thread which goes on to accept connection and other goes on to connect to the hostname and port number supplied. This file consist of Init() and cleanup() code which is used in Soft restart. -main.h Consist of declaration of multiple data structres used throughout the program and these data structres have been extern. Declaration of functions, variables. This header file is included in multiple files -incoming_connection.cc This file consist of accept thread, which accpets the connection and then creates the read and write threads for every incomming connections. This file includes read Thread which reads on the connected socket for the data and passes the data to function, which processes the header and the buffer part of the message, so as to respond or put the response in the message queue of the write thread accordingly. This file consist of message dispatcher, which puts the message into the queue of the write thread -outgoing_connection.cc consist of function which attempts to connect to the given hostname and port no. consist of write thread which process the message in the queue and then writes on the sockets accordingly. This file consist of join network function which is called whenever the init_neighbor_list is not given. GETUOID function is also present in this file, alongwith the function which write to the status file whenevr the user enters the "status neighbors" command on the command prompt -connectBeacon.cc This file is for Beacon Node, and consist of the part which attempts to send connect request to the other beacon node, so that fully connected mesh could be formed. Whenever the beacon node goes down, this thread retries conecting after the given retry period. -iniParser.cc This file consist of the complete iniParser, which parses the ".ini" file given at the command promopt, function has been self written. Not used the "Nicolas Devillard's iniparser". Consist of the function which removes the white spaces, and new line charcaters from the line read from the file. This file consist of function which sets the parameters of the node equal to the values read from the .ini file -iniParser.h declarartion of parameters for the node, data structre and iniParser function declaration -keepAliveTimer.cc consist of a thread which sends keepalive messages to the neighbors on the interval of keepAliveTimeOut/3. -keepAliveTimer.h declaration of the keepAliveTimer function -keyboard.cc thread which takes the user input by simulating the command prompt, either "shutdown" or "status neighbor" command -logEntry.cc This function is called to enter the formatted text into the log file, named "servant.log" present in the HOME DIRECTORY -signalHandler.cc handles the varios signals generated during the program flow, such as SIGINT or SIGTERM, for shutdown -signalHandler.h declaration of signal handler function -timer.cc timer thread which decrements the counter every 1 sec for multiple timers, such as autoShutDown, KeepAliveTimeOut, joinTimeOut, CheckResponseTimeout, statusTimeOut, messageLifeTimeTimer. and performs action when value reaches to 0, indicating timeout. - indexSearch.cc this file contains numerous functions related to mainting the data in name_index, sha1_index, kwrd_index. functions related to externalizng index, searching in the index, creating bit vector for the keywords, populating the index from external files, removing file entry from Index, writing data to files directory in the homedir, creating metadata and data files. -indexSearch.h declaration of functios defined in indexSearch.cc, functions related to index, i.e. sha1_index, name_index, kwrd_index - metaData.cc This file consist of functions creating metadata, which is to be written to meta files in files dir in homedir. parses the messages to give out metadata structures, populating with , file size, file name, sha1, nonce, bit vector, keywords. Functions, which produces metadata sturctes from the '.meta' files on filesystem, functions related to LRU, externalizing LRU, updating the lru, removing from lru, storing in the lru. - '.fileNumber' this is a hidden file stored in the HOME DIR, which containes a number which signifies the number system in the filesystem. To store a file in filesystem, a node will read the value from this file, increment the number, and rewrite the number to the file, and uses the number as a file name in it's filesystem. e.g. 5.meta, 5.data, 5.pass. If this file does not exist in the filesystem, node will create it when it starts up, and store the value as 0 in the file. - cacheLRU contains the list of 'number' i.e. int used for representing a file in it's file system. when node shutsdown, cache is externalized to this file. - kwrd_index this file is used to externalize the kwrd_index in memory, whenevr node shutsdown. the kwrd_index in memory has been implemnetd using STL MAPS, where the key is '128-byte string' and the value corresponding to the key is list of numbers, representing the files in the nodes file system. format of the file is give as:- <number of files corresponding to a key> <space> <256 characters represnting 128byte of bit-vectors> <space> <list of numbers, representing the file names in it's file system> e.g 3 000000000000000000000000002000000000000000000000000000000000000000000000000000002008000000000000000000000000000000040000000000000000000000000000 000000000000000000000000000040000800000000000000000000000000000000000000000000000000000000c000000000000000000000 4 5 6 where, 3 is the number of files stored corresponding to the bitvector, and 4, 5 and 6 are the name of files in it's filesystem - sha1_index this file is used to externalize the sha1_index in memory, whenevr node shutsdown. the sha1_index in memory has been implemnetd using STL MAPS, where the key is '20-byte string' and the value corresponding to the key is list of numbers, representing the files in the node's file system. format of the file is give as:- <number of files corresponding to a key> <space> <40 characters represnting 20byte of sha1 of file> <space> <list of numbers, representing the file names in it's file system> e.g 3 e2d306e2b2000ebbe9060637d2a349b83c588b68 4 5 6 where, 3 is the number of files stored corresponding to the 40 char long sha1, and 4, 5 and 6 are the names of files in it's filesystem - name_index this file is used to externalize the name_index in memory, whenevr node shutsdown. the name_index in memory has been implemnetd using STL MAPS, where the key is a 'String' and the value corresponding to the key is list of numbers, representing the files in the node's file system. format of the file is give as:- <number of files corresponding to a key> <space> <name of the file, represented by a String> <space> <list of numbers, representing the file names in it's file system> e.g 3 v.gif 4 5 6 where, 3 is the number of files stored corresponding to the 'v.gif' file name, and 4, 5 and 6 are the names of files in it's filesystem - More files created in 'files' directory in homeDir:- - '.data' - '.meta' - '.pass' above files are created as the files are created or stored using 'store', 'get'. '.pass' is only created at the node which inititates the 'store' command. .pass file consist of 20 byte long password in binary mode. DESIGN DECISIONS : For BEACON NODE:- Parent thread creates the thread for Accept and creates thread for Connect, which keeps on trying whenever the connection breaks with the other beacon node, this thread gaurantees to attempt connection if any beacon node gets disconnected. Whenevr the connection takes place, a read and write thread is also created, which reads and writes on the connection to the neighbor. For NON-BEACN NODE:- Parent thread creats the accpet thread and then tries to connect to the neighbors as per the init_neighbor_list. If it does not get connected to min Neighbors, it inittaies the Soft Restart, which free up all the other resources. Whenevr the connection takes place, a read and write thread is also created, which reads and writes on the connection to the neighbor. Refrences abd Credits - Refered to "Begining Linux programming" by Wrox, taken thread code from that book - UOID code fragment used from: http://merlot.usc.edu/cs551-s11/projects/final.html#uoid
About
Distributed File sharing
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published