Assignment # 8

Playing Network Ping Pong

Due: Friday, December 4th by midnight.

Deliverables: Email all files that you create to cis3931@cs.fsu.edu by the due date, including a journal/diary of the steps you went through during this assignment. Since many of the assignments involve writing Java applets it will greatly assist the grading of the assignments if you create HTML on your home page that includes the assignment's applets. Please include the web address of your applet in the journal/diary. Note that for assignments that require you to create source code yourself rather than type in existing code (like this one) you should take careful measures not to accidentally make your .java files world-readable within your HTML directory.

When emailing your files it can be problematic to faithfully re-create the file names. Here are detailed instructions that you can use for this and future assignments. If you use xi.cs.fsu.edu (which is running Solaris) you can create a single compress "tar" file that can then be emailed to cis3931@cs.fsu.edu.

cd location_of_P8_source
gnutar czvf ~/P8.tar.gz .

If you use an email client that supports attachments then you can just attach the file P8.tar.gz to your email submission. If you do not use an email client that supports attachments you will first have to convert the binary compressed "tar" file into a format suitable for an email message, such as uuencoding. Here is an example of encoding the P8.tar.gz file and sending it via a UNIX pipe to a mail client:

uuencode P8.tar.gz < P8.tar.gz | /usr/ucb/mail -s "P8.tar.gz" cis3931@cs.fsu.edu

If you choose to use some other operating system, such as Windows '95, Windows NT or Windows '98 be careful that you use a compression agent that correctly preserves both case sensitivity and the entire file name length, such as WinZip.

You will be asked to re-submit your assignment via email if the format you use is not correctly identified and/or formatted. Please do not email all the files separately.

Assignment:

This lesson uses the material in Lesson 24 (All About Sockets). Specifically, you are to write a Java network client applet (pongClient) and a Java network server application (pongServer). When completed, your program, along with a masterServer and other student's solutions, will interact in an exciting fashion. To understand what is required a discussion of the protocols needed for client to server and server to master server is presented, followed by specific requirements for the client and server.

The Pong protocol was developed to allow you to interrogate a number of servers from a single client. It will be used by your pongClient to measure how long it takes to contact a list of Pong servers. One of the applet security manager rules enforced within typical browsers is that a network connection between an applet can only be made back to the host machine that served up the web pages containing the applet. For this reason you must develop a Pong server that runs as a standalone Java application on the same machine as the web server. Your Pong server will act as an intermediary, performing as a relay agent for the Pong protocol.

You are provided a Java file containing all of the definitions you will need for the following protocols (you can find it here, in Pong.java). It is important that you use these values, otherwise your client and server will not properly interact with the other Pong servers and the master Pong server. In addition to the public constants, you need to use the pongIdentity class to correctly identify your pongServer to the masterServer. All communication between clients and servers is through the Socket and ServerSocket class. All data sent through the sockets is serialized.

pongClient to pongServer Protocol

pongClient request

pongServer response

Pong.CLIENT_LIST

If OK, Hashtable of pongIdentitys, else Pong.CLIENT_NAK

Pong.SERVER_PING, pongIdentity of server to ping

IF OK, Pong.CLIENT_ACK, else Pong.CLIENT_NAK

pongServer to masterServer Protocol

pongServer request

masterServer response

Pong.SERVER_LOGIN, pongIdentity of this pongServer

If successful, Pong.SERVER_ACK, else Pong.SERVER_ALREADY_LOGGED_IN

Pong.SERVER_LOGOUT, pongIdentity of this pongServer

If successful, Pong.SERVER_ACK, else Pong.SERVER_NOT_LOGGED_IN

Pong.SERVER_LIST, pongIdentity of this pongServer

If successful, Hashtable of pongIdentitys of all logged-in pongServers, else Pong.SERVER_NAK

Pong.CLIENT_PING, pongIdentity of this pongServer

If successful, Pong.CLIENT_ACK, else Pong.CLIENT_NAK

Pong.SERVER_PING, pongIdentity of pongServer to ping

If successful, Pong.CLIENT_ACK, else Pong.CLIENT_NAK

To see the protocol in action, look at the pongClient applet. It will help to see how it runs before trying to figure out how the pongClient and pongServer are supposed to work.

pongClient Specification

pongServer Specification

Notes