cs8803 Pr4 RPC: Remote Procedure Call Solved

35.00 $ 17.50 $

Category:

Description

Foreword
In this project, you will work with Remote Procedure Calls, specifically with Sun RPC. The RPC server will accept a jpeg image as input, downsample it to a lower resolution, and return the resulting image.

For extra credit, you may modify the code automatically generated by the rpcgen tool so that the RPC server is multithreaded.

Setup
If you haven’t done so already, please follow the installation instructions found in project 1 to set up your virtual environment.

Note: if you choose to fork the repository, please remove the class access to it. You can do this by going to the “Settings” (on github.gatech.edu) for your repository. On the left there is a tab for “Collaborators and Teams”. When you choose this it will show the class team membership. Simply remove it (there is an “x” on the right hand side). Your repository is now private and only accessible to you and class instructors.

If you do not remove team access, your code is visible to everyone in class. This is the same as sharing your code.

Submission Instructions
All code should be submitted through the submit.py script given at the top level of this repository. For instructions on how to submit individual components of the assignment see the instructions below. You may submit as many times as you like. Your last submission before the project deadline will be downloaded by the teaching assistants and graded according to the assignment rubric.

After submitting, you may double-check the results of your submission by visiting the Udacity/GT autograding website and going to the student portal.

If you wish to submit the extra-credit portion, please read below in the Extra-Credit section for instructions.

README
Throughout the project, we encourage you to keep notes on what you have done, how you have approached each part of the project and what resources you used in preparing your work. We have provided you with a prototype file, readme-student.md that you should use throughout the project.

You may submit your readme-student.md file with the command

python submit.py readme
At the prompt, please provide your GT username and password.

If this is your first time submitting, the program will then ask you if you want to save the jwt. If you reply yes, it will save a token on your filesystem so that you don’t have to provide your username and password each time that you submit.

The Udacity site will store your readme-student.md file in a database. This will be used during grading. The submit script will acknowledge receipt of your README file.

For this and all assignments, you may submit your code as many times as you like. After the deadline, we download your last submission prior to the deadline, review your submission and assign a grade.

Directions
Begin programming by modifying only those specified below.

Building an RPC Server
Your first task will be to define the RPC interface through the XDR file minifyjpeg.x. The syntax and semantics of this type files are explained in the course videos as well as the documentation for rpcgen.

The rpcgen tool will generate much of the C code that you will need. It is recommended that you use the -N option for the “newer” rpc style that allows for multiple arguments. If you intend to make your server multithreaded, then you should also use the -M option.

In the generated file minifyjpeg.h, you will find the definitions of functions that you will need to implement. On the server side, you need to take the input image, reduce its resolution by a factor of 2, and return the result. A library that does this with ImageMagick is provided in the files magickminify.[ch].

On the client side, the provided file minifyjpeg_main.c acts as a workload generator for the RPC server. It calls two functions which you should implement in the file minify_via_rpc.c.

get_minify_client – should connect to the rpc server and return the CLIENT* pointer.
minify_via_rpc – should call the remote procedure on the client specified as a parameter.
In order to support images of arbitrary size and not worry about implementing packet ordering, the communication should use TCP as the transport protocol. Keep in mind that you should not be limiting the size of the image file. This means you have to pay attention to how you define the data structures in your “.x” file to support files of any size.

Here is a summary of the relevant files and their roles.

Makefile – (do not modify) file used to compile the code. Run ‘make minifyjpeg_main’ and ‘make minifyjpeg_svc’ to compile the client and server programs.
magickminify.[ch] – (do not modify) a library with a simple interface that downsamples jpeg files to half their original resolution.
minify_via_rpc.c – (modify) implement the client-side functions here so that the client sends the input file to server for downsampling.
minifyjpeg.h – (to be generated by rpcgen from minifyjpeg.x) you will need to implement the server-side functions listed here in minifyjpeg.c
minifyjpeg.c – (modify) implement the needed server-side function here.
minifyjpeg.x – (modify) define the RPC/XDR interface here.
minifyjpeg_clnt.c – (to be generated by rpcgen from minifyjpeg.x) contains the client side code that executes the RPC call.
minifyjpeg_main.c – (do not modify) a workload generator for the RPC server.
minifyjpeg_svc.c – (to be generated by rpcgen from minifyjpeg.x) this contains the entry point for the server code. You may modify to make your code * multithreaded. Otherwise, this is not recommended.
minifyjpeg_xdr.c – (to be generated by rpcgen from minifyjpeg.x) contains code related to data structures defined in minifyjpeg.x
workload.txt – (modify for your own testing purposes) an example workload file that can be passed into the client main program minifyjpeg_main.c
RPC Diagram

Extra Credit
For extra credit, you may modify the server-side file minifyjpeg_svc.c so as to make the server multithreaded. Note that it is the svc_getargs function that copies global data from the rpc library into memory that you control. This must be done before the function registered with svc_register returns. The function svc_sendreply can be called later.

NOTE: You have the choice of either making the minifyjpeg_svc.c main method accept a command-line parameter (-t) to indicate the number of threads to be created or to spawn a thread per request. If you decide to accept the parameter it will follow a similar syntax as what has been done for the previous projects in this class, and it will be graded by the auto-grader:

minify_svc -t X
Where X is the number of threads to be created by the main method. No other command-line parameters will be passed to it, so you can write your code assuming that you only need to handle that parameter. If you chose to spawn a thread per request you can ignore the test failure from the auto-grader about you not creating the requested number of threads, and we will manually grade that portion of your submission. The auto-grader will still be used for the other tests in either case.

To submit the extra-credit portion, please place your code in the rpc_mt directory and run the submit.py script in that directory. The command to submit the extra-credit is:

python submit.py rpc_mt
If you want to write a separate readme file for the MT portion, please use the readme-student.md file in the rpc_mt directory and it will be automatically submitted together with the rest of the MT code when you run the command above. Notice that there is no separate command to submit the readme-student. It is submitted along with your code by the command above.

Please keep in mind that only the submit.py located in the rpc_mt directory will submit and grade the MT portion of your code.

Submission
Once you have completed your program, you can submit it with the command

python submit.py
Note: you may optionally specify rpc as the argument to the submit.py script as well (it is the default).

This will run various tests. If you did not do the (multi-threading) extra credit, you can simply ignore the failures related to the code not being multithreaded.

References
Relevant Lecture Material
P4L1 Remote Procedure Calls
RPC Material
Sun RPC Example
Sun RPC Documentation (maintained by Oracle; similar semantics, updated API.)
From C to RPC Tutorial
Project Design Recommendations
When testing and debugging, start with running small/light client workloads If your server is slow in responding, you may start timing out at the TCP socket and then the RPC runtime layer — thus, look for options to change the timeout values used with RPCs.

NOTE: RPC will setup a default timeout value in the minifyjpeg_clnt.c file. This file is generated each time you run “rpcgen” and the default value put back in place. The minifyjpeg_clnt.c file has a comment with a hint on how to set the timeout programmatically, so that it doesn’t get overwritten.

Rubric
RPC Client (50 points)
RPC initiation and binding
Correct communication with RPC server
Multithreaded operation
Proper clean up of memory and RPC resources
Proper handling of a server that takes too long to complete the request. The client should time out after between 5 and 10 seconds
RPC Server (50 points)
Interface specification (.x)
Service implementation
Accepts and processes RPC client requests
Proper clean up of memory and RPC resources
Extra Credit (15 points total possible)
Multithreaded RPC Server (+10 points)
Readme file. (+5 points)
Summary of the project design
Any observations or insights
or

Complete implementation of Getfile proxy server that downsamples (minifies) jpeg images. (+10 points)
Readme file. (+5 points)
Summary of the project design
Any observations or insights