Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Introduction

Dropbox is a service that permits a user to save files onto their server, and automatically synchronize the files between the server and a number of devices comprising computers, phones, and tablets. The user installs client software onto their computer, and the client software takes care of automatically synchronizing files between client and server.

Your task in this assignment is to apply a simple version of Dropbox, using the file, socket and select system calls. While you may find it interesting to read more about Dropbox itself, the specifications in this document describe your task for assignment. Dbclient
When the dbclient is run, it will first establish a socket connection to dbserver, and will send a message having the userid, and the name of the directory that the client wants to synchronize. We will restrict synchronization to files in one directory and will not handle subdirectories. Every N seconds, client will initiate a synchronization operation.

A synchronization operation uses the subsequent algorithm:

For every file in the local directory get the last modified time and size send a sync_message request to the server containing the filename, last modified time, and size. Read a sync_message response from server having filename, the server's last modified time for the file, and size of the file on the server. If the last modified time in message from server is more recent that the local last modified time the client will read the file from server one CHUNKSIZE chunk at a time and will replace the local file with the contents from the server. Or else, the client will send the local file one CHUNKSIZE chunk at a time to the server. After iterating over all files in the local directory, the client checks to see if the server has any new files to send by sending an "empty" sync_message (a message with an empty string for the file name, a last modified time of 0, and a size of 0). It reads the response message from the server. If the server's response message is also an empty message, then client knows there are no new files.

If the server's response message has a non-empty file name, a non-zero last modified time, then the client will read file from the server as above. After it has completed reading file, it will repeat the procedure of sending a new file request (by sending an empty sync_message) and reading new files from server till it receives an empty message from the server.

dbserver

The server is a little more difficult. It will generate a directory for each user under the directory name provided by user. If two users use the same directory name, we will assume they are sharing the directory.

Since the server is maintaining multiple connections, we do not want the server to block on a read or accept from any client. To solve this problem, we will employ select to multiplex between clients. This also means that we will need to keep track of the type of message that the server anticipates to receive from a client depending on state of the client. When the server is notified (via select), that a message is accessible to read from the client, there are several possible options. The server may be expecting a login_message, if it hasn't read anything from the client yet.

A CHUNKSIZE chunk of a file, if server has realized that a file is newer on client than on server. A sync_message, otherwise, the server will store the following information for each client:

- The user id of the client
- The socket files descriptor
- The directory name where the client's files are stored
- A list of the files that the client has synchronized with server. Information about each file includes:
- The file name
- The last modified time sent by the client.

A partial algorithm that describes the communication between the server and a single client follows. Note that the server only acts in response to a message from the client. Apart from the initial setup, it does not initiate any operations. Handle a read from a client

case LOGIN:
        read login message and store userid and dir in client array
        create dir if doesn't exist
        set state = SYNC
    case SYNC:
        read sync_message
        if sync_message is an empty message
            figure out how to identify a file on the server that is not on
            the client, and add it to the client list
        else
            find filename in client's files array
           
        prepare response (if there are no new files to send, then send an empty response)
        if file's mtime is newer in clients' files array on server than in sync_message
            prepare file to client
            set state = SYNC
        else
            set state GETFILE
            (keep track of which file we are expecting to read)
    case GETFILE:
        read chunk
        prepare chunk
        if finished reading file (keep track of size vs bytes read)
            set state SYNC

Part of algorithm is missing. In particular, the server needs to handle an empty sync_message from the client which is an indication that the client is checking if the server has a file that the client does not. You will need to figure out a strategy to identify the files that the server is storing in the appropriate directory that are not in the client's list of files, so that they can be added to the client's list.

Tips:

Take advantage of the ex code shown in class and given on the course web site. The ex code will help you set up the sockets and the select call.

prepare the code incrementally. Make sure each step compiles and runs before moving on. It will save you time!! The first step might be to prepare a client that just sends the login message, and the server that receives only the login message a store’s the client info. An intermediate step might be one where no file data is transferred, but the sync_messages are sent. prepare and test a function that fills in a sync_message for a file.

Note that we have taken lots of shortcuts with the starter code. In particular, the number of clients and the number of files are artificially limited. I would not prepare production code this way, but it simplifies this part of the assignment.

Also note that we don't allow file deletion on the server. Once a file has been synchronized to the server, it stays there.
Be careful to handle the case where a client connection is closed.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91485

Have any Question?


Related Questions in Programming Language

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As