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.
You can clone the code in the project 4 repository with the command
git clone https://github.gatech.edu/gios-spr-19/pr4.git
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.
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 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.
Begin programming by modifying only the files specified below.
Your first task will be to define the RPC interface through the XDR file
minifyjpeg.x
. The syntax and semantics of these file types 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.
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 minifyjpeg_main.c
acts as a workload
generator for the RPC server. It calls two functions which you should implement
in the minify_via_rpc.c
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. -
rpc/minifyjpeg_xdr.c
- (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 theworkload.txt
file. -
workload/output
- the output directory for minimized images returned via RPC
You may submit your Part 1 implementation with the following command:
python submit.py rpc
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.
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.
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.
You may submit your Part 2 implementation with the following command:
python submit.py rpc_mt
- 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.
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
minifyjpeg_clnt.c
file. This file is generated each time you runrpcgen
and the default value put back in place. Theminifyjpeg_clnt.c
file has a comment with a hint on how to set the timeout programmatically, so that it doesn't get overwritten.
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.
# 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 &
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
For all questions, please use the class Piazza forum or the class Slack channel so that TA's and other students can assist you.
java代写 c/c++代写 python代写 drracket代写 MIPS汇编代写 matlab代写 R语言代写 javascript代写
prolog代写 haskell代写 processing代写 ruby代写 scheme代写 ocaml代写 lisp代写
- 数据结构算法 data structure algorithm 代写
- 计算机网络 套接字编程 computer network socket programming 代写
- 数据库 DB Database SQL 代写
- 机器学习 machine learning 代写
- 编译器原理 Compiler 代写
- 操作系统OS(Operating System) 代写
- 计算机图形学 Computer Graphics opengl webgl 代写
- 人工智能 AI Artificial Intelligence 代写
- 大数据 Hadoop Map Reduce Spark HBase 代写
- 系统编程 System programming 代写
- 网页应用 Web Application 代写
- 自然语言处理 NLP natural language processing 代写
- 计算机体系结构 Computer Architecture 代写
- 计算机安全密码学computer security cryptography 代写
- 计算机理论 Computation Theory 代写
- 计算机视觉(Compute Vision) 代写