Programming Assignment 1.
This assignment is to be done either individually or in
pairs. Do not show your code to any other group and do not look at any other
group's code. Do not put your code in a public directory or otherwise make it
public. However, you may get all the help you need from the TAs or the
instructor. You are encouraged to use the WebCT Discussions page to post
problems so that other students can also see the answers.
The objectives of this assignment are:
- To familiarize you with some of implementation techniques of communication
- To help you understand the User Datagram Protocol (UDP),
- To acquaint you with the unreliability issues of UDP, and
- To introduce you to some of the simple loss recovery techniques such as
In this assignment, you will write a client and a server that communicate
using a simple UDP protocol called the Simple Drawing Protocol (SDP). The Client
has a GUI that is capable of drawing dots, circles, and rectangles. The
server has a set of drawing instructions that are stored in a file. Upon the
client's request, the server sends the set of objects to be drawn at the client
side. The server should be multithreaded to allow many SDP clients to
connect to it simultaneously. You will be give the client GUI code and the protocol description.
You task consists of writing the server and client protocol code
- <NEW> : a request message sent from the client to the server
- <DIM x, y>: once the server receives the NEW messages, it responds with
the DIM messages which sends the size of the canvas that will be used to hold
the objects to be drawn.
- <ACK x, y > : a message sent from the client to the server as an
acknowledgement that the DIM message has been received. The server should not
send any shape messages before receiving an ACK message.
- The last message takes different formats depending on the type of object
that need to be drawn. We have three possible messages:
- <POINT x, y>: to draw a point.
- <CIRCLE x, y, r>: draws a circle with radius r at (x, y).
- <RECT x, y, w, h>: draws a rectangle starting at (x, y) with width w and
What happens if one of these messages gets lost?
- If 1) or 2) are lost the client needs to send another NEW message after a
timeout of 5 seconds.
- for message 3), if the dimensions (x, y) received in the ACK message are
different from the ones the server sent initially or a timeout of 5 seconds
passes by, the server will send a new DIM message.
- If any shape message (4 in the protocol) is lost, both the client and server
are ignorant of the situation under this protocol.
Client GUI Code:
Server Sample Drawing File:
As mentioned earlier, the server uses a drawing files where it stores
all the objects that will be sent to the client. A typical drawing file
will look this:
POINT 1 1
CIRCLE 3 2 7
RECT 5 5 8 7
The first line gives the (x, y) dimensions of the canvas.
The subsequent lines
hold the actual objects with their characteristics. The End of File
(EOF) maker marks the ends of the drawing commands.
All exceptions must be properly handled.
Completion of one of this extensions will result in a better grade; however,
groups of more than one person MUST complete this extension to receive a full
grade. It should also be noted that, if you have an idea for a different
extension, ask either the instructor or TAs for approval:
- Create a trace log file that tracks the packets transmission between the
clients and servers indicating if any transmission was successful or not. The
file should show the source and destination IP address, the type of message
sent, the number of bytes sent, and if the the transmission was successful or
- Modify the SDP server to support UDP-multicasting in order to contact many
SDP clients at once from the server side.
- The current SDP protocol is faulty because it doesn't guarantee
reliability. Modify the current SDP protocol to guarantee reliable drawing.
- We want to have a " Writable Canvas" that allows the clients to connect to
the server and draw different elements. The server will act in this case as a
"Collaborative Whiteboard" that accepts client drawing commands. Modify the
SDP protocol to support writing drawing commands to the server.
- Enhance the Client GUI so that it is capable of drawing more interesting
figures such as filled rectangles, filled ovals, filled circles, etc. Enhance the
server to be a random object generator. In other word the
server will not send all the time the same number and set of objects. It
should be able to generate different picture sequences of different sizes.
Grading will be split in the following way:
- 60% correctness (Does it do what it's supposed to?)
- 20% error handling (Can it easily be crashed?)
- 20% documentation (Is it easy to read and understand the code?)
The due date for this project is September 17th, 2002, 11:55pm EST. You
should use the assignments drop-off box located at the course's WebCT page.
Upload a JAR file containing all the relevant documented Java files,
along with a README file describing the project and its usage.
- 10% penalty for a one-day late submission.
- 25% penalty for up to a three-day late submission.
- Submissions more than 3 days late will not be accepted.