Computer Science 308-435B
Basics of Computer Networks
McGill University, Winter 2001
Assignment 4: client-server programming using TCP/IP
Due date
Tuesday 10 April, official deadline. VisualCM will stay open
for submission until Monday 23 April, 23:59 (no penalty for delayed
submission).
Submission medium
VisualCM
Group work
This assignment may be done in groups of (up to) 3 people.
The names and student IDs of all group members should appear on
all submitted documents. The whole work should be submitted by each
individual (copies).
Assignment
The deliverable for this assignment consists of a number of files, all
to be submitted via VisualCM.
All files are submitted either separately or in the form of a single .tar.gz
file.
All submissions must run on the SOCS UNIX Sun servers (willy, mimi, ...) !
- One HTML file index.html. The document discusses
your design and implementation and gives some examples of use.
The file should only refer to files in the same directory.
Also document your code lavishly !
- One Makefile. Typing "make" should build the executables.
- One services.h to be included in various places
which lists symbolic names for the services (SUM and PRODUCT).
- Once net_client.c. The net_client.c provides services to
access the network, namely access remote procedures.
The user must be able to link a client.c application
with net_client.c to access functions int plus(int, int)
and int product(int, int) on a server as if they were local.
To find out which server (IP address and port number)
provides plus() and product(), the client will contact the
dispatcher. If the connection to the dispatcher fails,
the client retries upto
MAX_RETRIES times after a certain delay time. The delay time
is initially RETRY_DELAY. Upon each retry, the delay is doubled.
If the connection to the server fails, the client exits.
A more realistic application would contact the dispatcher again.
- Once net_server.c. The net_server.c provides (remote)
procedure/function services to connecting clients.
The user must be able to link a server.c application
with net_server.c to provide the actual function implementations
int plus(int, int) and int product(int, int).
Both functions will call sleep(DELAY) to emulate major computation
(DELAY=30s).
A server will announce its availability as well as services
it offers and on which IP address/port to the dispatcher.
Once it has finished doing so, it will listen to the advertised
IP address/port to service client calls.
The server should handle the SIGINT interrupt gracefully: before
terminating, it must warn the dispatcher it is no longer
available.
The server must be implemented as a concurrent server.
- One dispatch.c (iterative server) which accepts connections
from clients as well as from servers. The server will announce
its availability as well as services it offers and on which
IP address/port. This information will be stored in a table in
the dispatcher. A lookup in this table will be perfomed to answer
a client query (which server can process its requrest). Come up with a
"reasonably fair" way of performing the lookup (such as round-robin).
Some remarks:
- As client and server machines may use a different byte order,
care must be taken when transmitting function arguments.
- The IP address and port number of the dispatcher should
be command line arguments (use getopt() for example) for clients
and servers.
Optionally, they may be #define'd in the source code.
- Use TCP/IP (not UDP).
- The dispatcher may receive messages from both clients and servers.
Either the dispatcher listens (I/O multiplexing with select()) to
multiple ports or it listens to a single port. In the latter
(simplest implementation) case, the message must contain a code
indicating the message type (from client or from server).
Note how in this case, using select() is overkill, so you are advised
to use a code.
- Client, dispatcher, server should all do verbose logging of their
activities to stderr.
- The above specification does not go into detail which leaves many
options open. Use common sense and document your
design/implementation decisions !
- Implement 3 prototypes: client-iterative server only,
client-concurrent server only, client-dispatcher-concurrent server.
Partial marks will be given for working prototypes.
If your full solution works, there is no need to submit more
than that. The prototypes will help you tackle the complexity
and allow for partial marks.
Resources
Check the Class
Transparencies page to find more information about TCP/IP.
Hans Vangheluwe