CSE 132 (Spring 2015)
Lab 4: Networked HaWUp

In this lab you will apply what you have learned about network programming to make a networked version of your HaWUp cluster. This document specifies the protocol by which a client should connect to your server. A client will be provided to test your server.

Introduction

Programs communicate across the Internet by using protocols, which specify the order and content of messages. In class, we discussed various aspects of such a protocol for telling a HaWUp server that it should perform one of a prespecified set of tasks. The result of that discussion appears below.

In writing your server, it is important that you conform to this protocol. Failure to do so will prevent the client from communicating with your server, and a crash or failure of some sort will surely ensue. There are two aspects of a protocol that are especially important:

Some types of data and their associated Java DataOutputStream and DataInputStream methods are summarized below:
Description send receive
A single byte void writeByte(int) byte readByte()
Two-byte integer void writeShort(int) short readShort()
Four-byte integer void writeInt(int) int readInt()
Java String void writeUTF(String) String readUTF()

Protocol

The server and client observe the following protocol. Any information appearing in quotes, such as "example" is sent as a String.
Server Client
Makes service available at port 3000 and waits for a connection  
  Connects to the server at port 3000
When a connection is made, spawns a new thread to service the client. In that thread, send the following:
  • A String with this server's name
  • A 2-byte integer specifying this server's number of nodes
  • A 2-byte integer specifying the max queue size for each node
 
  Receives what was sent in the row above
  Sends the following:
  • This client's name as a String. It will help if this String is something unique.
  • The password for connection "xyzzy", as a String
Receives what was sent in the row above.  
Sends one of two messages as a String:
  • "ok", if the password is accepted
  • "bye", if the password is rejected
The connection is closed if "bye" is sent
 
  Receives what was sent in the row above.
  Submits a job using one of the following messages:
Sleep job
  • "sleep"
  • number of tasks, as a 4-byte integer
  • maximum sleep time in milliseconds, as a 4-byte integer
Sum job
  • "sum"
  • first integer lo in the range of the sum, inclusively, as a two-byte integer
  • last integer hi in the range of the sum, inclusive, as a two-byte integer
RSA job
  • "rsa"
  • a (perhaps large) integer num, sent as a String
  • an integer value lo, sent as a String
  • an integer value hi, sent as a String
Receives what was sent in the row above.  
Sends one of two messages as a String:
  • "ok", if the job is accepted
  • "bye", if the job is rejected
The connection is closed if "bye" is sent
 
  Receives and displays the ok or bye message
It is up to the server to take the job and break it into pieces (if possible) to run on the server's nodes.

For example, if sum is requested on the integers between 10,001 and 20,000, inclusively, and the server has 10 nodes, then each node should perform a sum of 1,000 integers to contribute to the server's overall answer.

An exception is sleep, whose behavior is simply as described below.

Sleep job
Each task deployed on the server for this job will sleep for a random amont of time, up to the specified number of milliseconds. When all sleeping is done for this job, send "done" as a String.
Sum job
The server computes the sum from lo to hi, inclusively, and sends the result as a String.
RSA job
The server tries each integer in the range [lohi] (inclusively).
  • If one of them is a factor of num, then send that factor to the client as a String.
  • If none of the integers in the specified range is a factor of num, send the integer 0 to the client as a String.
 
  Waits for server to send answer as a String
When answer is ready, send to client as a String  
  After receiving answer, close connection

Procedure

As given, the sum and rsa code assumes a lower bound that is not part of the specification. You will have to modify those classes in your workspace so that they take in not only an upper bound but also a lower bound.

Demo

Show the TA your work by launching the RSASubmitter client and submitting the following jobs to your server:
Note!

Demo

When you done with this studio, you must be cleared by the TA to receive credit.


Last name WUSTL Key Propagate?
(or your numeric ID) Do not propagate
e.g. Smith j.smith
1 Copy from 1 to all others
2 Copy from 2 to all others

TA: Make sure they commit their code before you sign them out!

TA: Password:




Last modified 15:05:38 CDT 03 April 2015 by Ron K. Cytron