In the following system architecture we implemented two types of communications one is Client-to-Server Communication and other is Server-to-Server Communication. In client-to-server communication we have implemented our own protocols to request and receive the services between a client and server. All the message between a client and server are encrypted by using a binary key addition method to each character in the message which is subtracted and decrypted at the other end before processing. Server-to-server communication takes care of the synchronization between both servers so that they maintain the latest copy of the files.
The client creates a socket for end point communication with the server. Initially if the Client boots up after the crash recovery, the client is prompted to use “-recover” option to download all the files from the server repository. After this process, the ClientD (Client Daemon) is synced with server’s repository, else the client populates its directory information using struct dirent. When the client populates the directory information, the client requests ServerD (Server Daemon) using REQ_DIRINFO message. The server in response sends all the file’s modified access time and file names. The ‘ClientD’ compares the file names and modified access time with its directory containing the files. The ClientD creates a ‘upload list’ for all the files to be uploaded, ‘modification list’ for the files whose diff is to be calculated and ‘remove list’ for files to be removed from the server replica.
In server-to-server communication both Servers open two sockets named Slave and Master. A list of files is maintained on both servers with last modified time which can be sent and compared to get the latest file. A deleted file list is maintained on both sides. Whenever other server stops working, this deleted file list is shared to handle deleted file synchronization. Master Sockets waits for slave request from other server. When request comes on Master socket, it identifies the request as if Request is Client_Liast then send the list of all the files with file name and timestamp, if Request is Sync_Delete file list then send number of files deleted with names, and if Request is File_Request, sends the requested filename with data. This process is repeated between both servers after every 5 sec delay.