分布式系统 网络socket代写 COMPSCI 711 Assignment Y1

COMPSCI 711 Assignment Y1 Due date: 21:00 5th October

The purpose of this assignment is to understand the techniques used by the CDN in reducing the amount of data transmission and practice developing distributed applications.

The system consists of three components as shown in the figure below.

The server provides a service that allows users to browse and download files. The cache caches the data previously downloaded by the client. It should be assumed that the three components reside at different locations. The client program interacts with the server through the cache. That is, when the client wants to browse the list of files available on the server or to download a file from the server, the client’s requests are sent to the cache first and the cache forwards the requests to the server. Similarly, the server also sends the replies to the clients through the cache.

Your implementation can be in either C# or Java. Client, cache and server MUST be implemented as separate programs.
Part 1 and Part 2 must be implemented using separate programs.

Part 1 (50 marks)

In this part, you are required to implement the client program, the cache and the server. The requirements for the three programs are as below:

  •   The client program should provide a GUI interface that (a) allows the user to display

    the list of files that are available on the server, (b) allows the user to select a file from the list of available files to download, and, (c) allows the user to display the contents of the downloaded file.

  •   The cache should cache the files previously downloaded by the client.

o If the user requests for a file that has the same name as a previously

downloaded file, the cached copy of the file should be returned to the user.
o The cache should keep a log to record of the activities of the cache. For each user’s file downloading request, the log should indicate whether the request is satisfied by a cached file or the requested file needs to be downloaded from the server. For example, when a user’s request is received, the following log

entry might be created:
user request: file xyz at 10:27:00 2018-07-01 response: cached file xyz
or

user request: file xyz at 10:27:00 2018-07-01

response: file xyz downloaded from the server
o The cache should provide a GUI interface that allows the user to view the

contents of the cache’s log and the list of files that are cached on the server.
o The interface should provide a function (e.g. a clear button) that allows the

files in the cache to be cleared (i.e. deleted).
o It should be assumed that the cache has sufficient space to hold all the

downloaded files. That is, you do not need to consider cache replacement

policy.
 The server program should provide (a) an operation that allows the user to download

a file with a given name, and, (b) an operation that lists the names of the files available on the server.

Part 2 (30 marks)

In this part, you are required to implement the client program, the cache and the server. The cache and the server should allow fragments of the files to be cached. In your implementation, the fragmentation of the files should be carried out automatically. That is, the users do not need to rewrite the files for caching purpose. The requirements for the client program are the same as in part 1. The requirements for the cache are as below:

o When a user requests for a file, if there are some cached data that can be used to construct the requested file, the cached data should be used, and, only the data that do not exist on the cache should be downloaded from the server.

o The cache should keep a log to record of the activities of the cache. For each user’s file downloading request, the log should indicate the percentage of the file that is constructed using the data cached on the server. The percentage is defined as “the size of the cached data used to construct the file / the size of the file” where the size is measured in bytes. For example, when a user’s request is received, the following log entry might be created:

user request: file xyz at 10:27:00 2018-07-01

response: 82% of file xyz was constructed with the cached data
o The cache should provide a GUI interface that allows the user to view the contents of

the cache’s log and the contents of the data being cached on the cache server. The contents of the data should be displayed a sequence of bytes in hexadecimal numbers. Each byte consists of two hexadecimal digits. For example, the contents of a data segment might be “1F02…” where “…” denotes more hexadecimal digits. Your program must display the exact contents. That is, you cannot display “…” as output.

o The size of each data fragment should be around 2KB. Otherwise, your programs might not work properly for the test cases used by the marker.

o The interface should provide a function (e.g. a clear button) that allows the files in the cache to be cleared (i.e. deleted).

o It should be assumed that the cache has sufficient space.
For the server program, in addition to the requirements specified in part 1, the server program should also provide operations that are necessary to allow the cache to download fragments of the files.

The files to be downloaded can be any type of files, e.g. text, image, video, etc. The mark that you gain depends on whether the scheme that you use can maximize the reusable data on the cache.

Report (20 marks)

Write a report about your implementation. Your report should include the following.

  1. (a)  Clearly indicate whether you have tested your programs on a lab machine.
  2. (b)  Instructions on how to run your programs.
  3. (c)  For part 2, describe the techniques that you use to determine which portions of a file

    need to be downloaded from the server. Compare and contrast the techniques that you used in part 1 and 2 of the assignment in terms of the response time perceived by the user, the amount of network bandwidth that can be saved, and the amount of computation being carried out by the cache and the origin server.

Save your report as a PDF file. Name it as report.pdf. Submission

You MUST test your programs on a lab machine. If your program does not run on a lab machine, you will get NO marks.
Pack your implementations and report into file Y1.7z using 7-zip. Submit Y1.7z through Canvas.

NO email submission will be accepted.

Marking Schedule

Part 1

Client & Server

mark

A GUI interface that allows the user to display the list of files that are available on the server

5

A GUI interface that allows the user to select a file from the list of available files to download

5

A GUI interface that allows the user to display the contents of the downloaded file.

10

Cache

If the user requests for a file that has the same name as a previously downloaded file, the cached copy of the file should be returned to the user.

15

A GUI interface for viewing the cache’s log and the log is kept correctly.

5

A GUI interface for clearing the contents of the cache and the content can be cleared correctly.

5

A GUI interface for viewing the list of cached files and the list is kept correctly.

5

Part 2

Client & Server

mark

The GUI interface works fine as in Part 1

3

Cache

If there are some cached data that can be used to construct the requested file, only the data that do not exist on the cache should be downloaded from the server

Case 1: Download files with different names but similar contents.

12

Case 2: Download files with the same name but slightly different contents.

12

Working GUI interfaces as required in Part 1

3

Report

Mark

Clearly indicate whether you have tested your programs on a lab machine

1

Instructions on how to run your programs

2

For part 2, describe the techniques that you use to determine which portions of a file need to be downloaded from the server

12

Reasonable compare and contrast

5