Ask Question, Ask an Expert

+1-415-315-9853

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

Develop a pac and flowcharts for a program that does the

Develop a PAC and flowcharts for a program that does the following. A warehousing company has contracted you to develop a computer program that determines shipping costs for items by size. If the item is over 4 cubic fee ...

Fr each of the following c assignment statementsa x a

For each of the following C assignment statements a) x = a + b*c; b) x = a/(b+c) - d*(e+f); c) x = a[i] + 1; d) a[i] = b[c[i]]; e) a[i][j] = b[i][k] + c[k][j]; f) *p++ = *q++; generate three-address code, assuming that a ...

Note that these regular expressions give all of the

Note that these regular expressions give all of the following symbols (operator characters) a special meaning: \ " . - $ [ ] * + ? { } | / Their special meaning must be turned off if they are needed to represent them-sel ...

Assignmentscenariosummaryin this lab you will create one

Assignment Scenario/Summary In this lab, you will create one project that reads from a file, one project that writes to a file, and one project drawing a snowman. Program files for each of the following programs. Write o ...

Assignment- computer applications for businesslearning

Assignment- Computer Applications for Business Learning Objectives: This assignment is designed to practice: 1. Basic understanding of JavaScript variables, including; a The declaration, initialization and assignment pro ...

Create a new class called soda that is also a caffeinated

Create a new class called Soda that is also a caffeinated beverage by default it will have no option for condiments. Have it called in main. Main also calls the old addLemon function on Tea so that the customer gets two ...

Assignmentanalyze each problem develop a solution and

Assignment Analyze each problem, develop a solution and implement your solution. Copy and paste your program and a sample output below each problem. Define the class Point in a rectangular coordinate system. This class m ...

Assignmentcollege maintains a file of credit hours

Assignment College maintains a file of credit hours completed for their students, named CREDITS.TXT. Each line of the file contains: • the student's ID number (an 8-character string, containing 2 letters followed by 6 di ...

Asignmentbe sure to follow the coding standard guidelines

Assignment Be sure to follow the Coding Standard Guidelines. You must properly indent and comment your code. Indent code and insert comments to document your program. Program must be implemented and run as instructed. So ...

Spreadsheet exercise1 run the spreadsheet program in your

Spreadsheet Exercise 1. Run the spreadsheet program in your computer and type the following:   A B C D E F 1 PAYROLL 2 XYZ COMPANY Employee Name Department Degree Salary Need Increase? 3 Nasser Mechanical Master 15000   ...

  • 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

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro