4/4/2019 gios-spr-19/pr4: Project 4 Repository
https://github.gatech.edu/gios-spr-19/pr4
/5
gios-spr-19 / pr4 Project 4 Repository
Private
7 commits 1 branch 0 releases 1 contributor
Branch: master
New pull request
Create new file
Upload files
Find file
Clone or download
pward8 Correction to submit.py Latest commit 561b5e9 2 hours ago
docs Initial commit for gios-spr-19 a day ago
rpc Initial commit for gios-spr-19 a day ago
rpc_mt Initial commit for gios-spr-19 a day ago
workload Initial commit for gios-spr-19 a day ago
.gitignore Initial commit for gios-spr-19 a day ago
readme-student.md Initial commit for gios-spr-19 a day ago
readme.md Updating readme 15 hours ago
submit.py Correction to submit.py 2 hours ago
readme.md
RPC: Remote Procedure Call 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.
Setup
You can clone the code in the project 4 repository with the command
Submission Instructions
All code should be submitted through the submit.py script given at the top level of the corresponding folder in the repository. For instructions on how to submit individual components of the assignment see the instructions below.
For this assignment, you may submit your code up to 10 times in a 24 hour period. After the deadline, we download your last submission prior to the deadline, review your submission and assign a grade. There is no limit to the number of times you may submit your readme-student.md file.
After submitting, you may double-check the results of your submission by visiting the Udacity/GT autograding website and going to the student portal.
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:
git clone https://github.gatech.edu/gios-spr-19/pr4.git
python submit.py readme
1
4/4
https://github.gatech.edu/gios-spr-19/pr4
/2019 gios-spr-19/pr4: Project 4 Repository
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 project, like in Project 3, you only need to submit one README file for both parts of the project.
Note: you may choose to submit a PDF version of this file instead, readme-student.pdf in addition to the markdown version. The submission script will automatically detect and submit this file, if it is present in the project root directory. If you submit both files, we will give the PDF version preference.
Directions
Begin programming by modifying only the files specified below.
Part 1 – Building a Single-Threaded RPC Server
Your first task will be to define the RPC interface through the XDR file . The syntax and semantics of these file types are explained in the course videos as well as the documentation for .
The rpcgen tool will generate much of the C code that you will need.
You should use the -MN option for the “multi-threaded” support and the ¡°newer¡± rpc style that allows for multiple
arguments.
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] . For the sake of this project only JPEG (JPG) images will be used.
On the client side, the provided file acts as a workload generator for the RPC server. It calls two functions which you should implement in the file.
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.
rpc/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.
rpc/magickminify.[ch] – (do not modify) a library with a simple interface that downsamples jpeg files to half their original resolution.
rpc/minify_via_rpc.c – (modify) implement the client-side functions here so that the client sends the input file to server for downsampling.
rpc/minifyjpeg.h – (to be generated by rpcgen from minifyjpeg.x and modified by you) you will need to implement the server-side functions listed here in minifyjpeg.c
rpc/minifyjpeg.c – (modify) implement the needed server-side function here.
rpc/minifyjpeg.x – (modify) define the RPC/XDR interface here.
rpc/minifyjpeg_clnt.c – (to be generated by rpcgen from minifyjpeg.x and modified by you) contains the client side code that executes the RPC call.
rpc/minifyjpeg_main.c – (do not modify) a workload generator for the RPC server.
rpc/minifyjpeg_svc.c – (to be generated by rpcgen from minifyjpeg.x and modified by you) this contains the entry point for the server code. You will need to modify this file to make your code multithreaded.
minifyjpeg.x
minifyjpeg_main.c
rpcgen
minify_via_rpc.c
2/5
4/4
https://github.gatech.edu/gios-spr-19/pr4
/2019 gios-spr-19/pr4: Project 4 Repository
– (to be generated by rpcgen from minifyjpeg.x and modified by you) contains code related to data structures defined in minifyjpeg.x
workload/workload.txt – (modify for your own testing purposes) an example workload file that can be passed into the client main program minifyjpeg_main.c
workload/input – (modify for your own testing purposes) the input directory for images listed in the workload.txt file. workload/output – the output directory for minimized images returned via RPC
Submitting Part 1
You may submit your Part 1 implementation with the following command:
Part 2 – Building a Multi-Threaded RPC Server
For part 2, you will modify the server-side file rpc-mt/minifyjpeg_svc.c to make the server multithreaded. For Part 2, you should work with the files located under the rpc-mt folder.
The descriptions of these files are the same as Part 1.
A few notes about the multithreaded RPC development project:
svc_getargs
It’s important to note that the svc_getargs function copies global data from the rpc library into memory that you control. Therefore, this must be done before the function registered with svc_register returns or that data will not be available. The function svc_sendreply can be called later.
main
You will need to change the minifyjpeg_svc.c main method to accept a command-line parameter (-t) to indicate the number of threads to be created. This will be similar to what you have done in P1 and P3 when it comes to creating a pool of threads. You can copy the argument parsing logic from one of those earlier projects, or you can write your own.
In either case your minifyjpeg_svc.c main function will receive a command line parameter (-t) to indicate the number of threads to be used. The autograder will test to ensure you are creating the requested number of threads.
The syntax used to run the service will be: 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.
Submitting Part 2
You may submit your Part 2 implementation with the following command:
References
Relevant Lecture Material
python submit.py rpc
python submit.py rpc_mt
rpc/minifyjpeg_xdr.c
3/5
4/4
https://github.gatech.edu/gios-spr-19/pr4
/2019 gios-spr-19/pr4: Project 4 Repository
P4L1 Remote Procedure Calls
RPC Material
Sun RPC Example
Sun RPC Documentation (maintained by Oracle; similar semantics, updated API.)
RFC 1057 – RPC: Remote Procedure Calls (this is the official RPC specification)
From C to RPC Tutorial
RPC MAN Pages
XDR MAN Pages
Reading the source rpc include files can also be very useful. You can find those in Ubuntu under the /usr/include/rpc directory.
For further research, if you would like to see where RPC came from and where it’s going with newer protocols such as gRPC, then the following article may be of some interest to you: RPC is Not Dead: Rise, Fall, and the Rise of Remote Procedure Calls.
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.
For the timeout test, you need to make sure that you modify the default timeout value that is generated by RPC as it is larger than the timeout value for the grader. Next you need to detect the timeout condition and return the appropriate code (hint look at the return codes from RPC and return the one that indicates a timeout).
NOTE: RPC will setup a default timeout value in the file. This file is generated each time you run rpcgen and the default value put back in place. The file has a comment with a hint on how to set the
timeout programmatically, so that it doesn’t get overwritten.
RPCBind Notes
If you find you are getting errors such as RPC: unable to receive or Cannot register service, then the rpcbind service may not
have started. You can try any of the following in your virtual environment.
minifyjpeg_clnt.c
minifyjpeg_clnt.c
# OPTIMAL: Ensure the service is started
# note that both of these do the same thing on Ubuntu 18.04 sudo systemctl start rpcbind
sudo service rpcbind start
# Probe the rpcbind host – tends to kick it off rpcinfo -p
# Run it in the background sudo rpcbind &
Rubric
Your project will be graded at least on the following items:
Interface specification (.x)
Service implementation
RPC initiation and binding
Proper clean up of memory and RPC resources Proper communication with the server
Proper handling of a server that takes too long to complete the request. The client should time out after between 5 and 10 seconds
Insightful observations in the Readme file and suggestions for improving the class for future semesters
RPC Single-Threaded (40 points) RPC Multi-Threaded (50 points)
4/5
4/4
https://github.gatech.edu/gios-spr-19/pr4 5/5
/2019 gios-spr-19/pr4: Project 4 Repository
Readme file (10 points)
Questions
For all questions, please use the class Piazza forum or the class Slack channel so that TA’s and other students can assist you.