02152  Concurrent Systems - Mandatory Assignment 2: ITTP Server
Technical University of Denmark DTU
02152 Concurrent Systems        Fall 2008
Mandatory Assignment 2: ITTP Server
Home Plan Material  
Your are supposed to implement and document a simple Web server as specified in the document:

Amendments, clarifications and FAQ are to be found at the

Remember to check this page regularly. Major issues will be announced via CampusNet.

Information about practical matters is found below.

Observe that this assigment is fairly realistic and hence requires more coding than the first assigment including "plain" coding of string recognition etc.

Groups

The assignment is intended to be solved and reported in 30-35 hours each for a group of 2-3 (well-prepared) students.

You are expected to continue the group formation from the first assignment. If you would like to form new groups, you must inform HHLin due time.

Groups of 3 students are expected to make more elaborate solutions including at least one of the two extensions marked in the problem description:

Reporting

The general report requirements also apply to this assignment.

The main report text (not including appendices) is expected to be brief, about 7-10 pages. See further documentation hints below.

Each group must hand in one paper copy of the report no later than

Thursday, December 4, at 12.45

in the mail-boxes in the West entrance of Building 322

Specific contributions by the individual group members should be stated, and the report must be signed by all participants.

Also, the program files for this assignment must be handed in electronically as well (also before the deadline). See details below.

Documentation hints

Implementation hints

The Java API provides a number of classes which may be very useful to you in solving some of more syntactically oriented parts of this task. In addition to the java.net.Socket and java.net.ServerSocket classes referred to in [PMG] you may find it helpful to look at the descriptions of the classes:

In addition, you can find in various repositories on the Web a number of classes which contain methods for encoding and decoding data in base64 representation. You may, for instance, find a couple of packages at www.sourceforge.net.

 
Observe that your server must accept all requests that follow the given syntax, but you need not reject requests which are not syntactically perfect. For example, you may tolerate extra space between tokens or more general URIs. Since the protocol syntax is quite simple, a straight-forward, but systematic, parsing approach should suffice.

You are recommended to start with implementing a single method, e.g. GET, without consideration for header lines in order to get the basic functionality to work. Then you may add header lines, more methods, and management control.

The program will be tested with the Java SE 6 platform and you may use any class libraries within this. Other class libraries must be delivered with your solution.

Body representation

Both when reading requests and when generating responses, you should be very careful about the representation you use. You will probably like to treat header lines as strings. However, body content should not be converted to/from the String type, since that involves decoding/encoding which may change the length of the body as well as being dependent on the current locale settings. Rather body content should be read and written as raw octets (bytes).

 
There are various ways you may do this:

User interface

As stated in the problem description, you may design the management user interface as you like. Note, however, that an elaborate user interface is not appreciated if the basic functionality is not in order. Thus, you should give priority to functionality and usefulness rather than appearance.

Program parameters

For testing purposes, it must be possible to pass the port number, base directory, and user credential to your program as optional parameters. The parameters must be of the form:

Note that there should be no space between the = and the value.

The default value of the server port should be 36000 and the default value of the basedir should be the user's current working directory (Java property user.dir). You may define the default values of the userid and password (for PUT) yourselves.

You may add other program options, parameters or Java properties if you like, e.g. if you are using RMI.

Packaging

Since this is a larger programming project, you are recommended to organize your code using the Java package notion. The toplevel package should be named ittp and the server could occur within that as ittp.server. If you have a separate control client program it may be named ittp.control. Otherwise you may organize your classes in subpackages as you like. Remember that in Java, the package structure must be reflected by the file structure.

Concurrent File Access

The presence of the PUT request raises the question whether the resources (files) should be protected against concurrent access.

For the given assignment, this issue is not central. First of all, you may assume that your server is the only OS-process accessing these files. With respect to the internal concurrency in your server, you may consider the following approaches depending on your level of ambition:

  1. Ignore the problem of concurrent access to external files.
  2. Write to a unique, temporary file and then rename it (see File class).
  3. Implement an internal locking system within the server.
  4. Use the file locking of java.nio

In all cases, the problem should be mentioned in the report.

Testing

For functional testing of the server, you will need a client, which can send both correct and incorrect ITTP requests to the server and collect up the responses. A starting point for such a client is given by the program TCP_Client.java. This will enable you to test out the server with several simultaneous clients, each running in a separate window, while the server management interface runs in yet another window. You may also study the program code to see how to make timeout on a connection. The client program may be modified as you like.

Initially, you are recommended to test your system with the server and all clients running on the same host, i.e. the one you are logged in on. If this works, you should also to try it out in a truly distributed system, with clients on different hosts and so on. Note that this may mean that you need to set up suitable permissions. The information on RMI in [PMG] and the page on RMI details should help you to find an appropriate setup in this respect.

Program Delivery

Help

There will be assistance for the assignment in the G-databar, building 308, rooms 15+16, as indicated on the activity plan.

Hans Henrik Løvengreen, Nov 10, 2008