CNT 5106C

Project 1 ver. 1

16 March 2012

Due Date: 30 March 2012

Summary:

You will modify the two programs you wrote for project 1. You will also develop and document the protocols used by the two processes. In addition to the messages accepted for project 1, the server will accept messages that allow it to connect to another server (create a logical link), to send information to and retrieve information from any server with which it shares a logical link, and to send messages from any client connected to it to any client connected to it or to another server with which it shares a link. In addition to the commands and messages used for project 1, the client will be able to instruct a server to form or break a logical link with another server, to register a name for itself, to obtain a list of names registered on any server to which it is connected directly or indirectly (one hop only), and to send and receive messages from the other clients. The client must accept asynchronous input on a thread so that messages show up when they are forwarded to the client by the server on which the client has registered.

Languages:

You will use Java, C++, C#, or C to implement the client and the server.

Records:

Server Records have the following structure.

Name: alphanumeric ASCII string no greater than 80 characters long

IP address: dotted decimal notation in ASCII characters

Port number: decimal unsigned integer in range 1024..65535

Logical Link: Boolean (TRUE if the link is active, FALSE otherwise)

Server:

The server must be able to be started on a host and open a port number specified either in a configuration file or on the command line.

The server must at least accept four types of messages:

1.  Insert record

2.  Delete record

3.  Retrieve record

4.  Die

5.  Link server

6.  Unlink server

7.  Register name

8.  Unregister name

9.  List names

10.  Send name message

The first four messages are as in project 1, except that the Logical Link field is absent in the message and is set to FALSE when the record is first entered.

Link is used to cause the server to send one or more messages to the indicated server to try to establish a logical link. If the other server responds, then the Logical Link value is set to TRUE, and the two servers should exchange information on registered clients. Unlink is used to cause the server to break its logical link with the named server, and to set the Logical Link value to FALSE. Reasonable error conditions must be detected and reported (e.g., invalid server name, unable to connect, etc.).

Register name causes the server to register a name associated with the requesting client. If the name is already in the database, then this is an error and should be reported. (If the name is registered with another server this is OK.) The client shall include a port on which it will receive incoming messages from the server sent by other clients.

List names causes the server to provide the client with a list of all client names registered with it or with any server to which it is connected. The server with which the client is registered should also be displayed. The client must be able to specify either a wildcard requesting all names, or a specific name. Likewise the client must be able to specify a specific server or all servers in its request. Reasonable error conditions must be detected and reported (e.g., invalid server name, server not logically linked, etc.).

Send message shall indicate the registered client and optionally the server on which it is registered. If the registering server is not indicated, then the sender’s server must find the appropriate server to send the message. If there is none, then this is an error. If there are multiple servers with the same name registered, then the message shall be sent to all of them. Other errors should be detected and reported as appropriate.

A server receiving a message from another server destined for one of its registered clients shall forward the message to that client. To this end, the client must have a thread that listens on the port it provided when it registered with its server. The client shall receive and display the message, and shall acknowledge receipt to its server.

In all cases, the server shall send at least one reply message indicating the result of the request (successful or error). In the case of a retrieve message, the server may send multiple messages to the client. It is up to the protocol you design to specify how the client and the server interact if multiple records are retrieved.

The server must be able to receive and process messages from multiple clients as long as it is alive, one request at a time.

Client:

The client program must accept commands from the user via the standard input and print results to the standard output.

The client must accept the following user commands:

1.  Server <IP address> <port number>

2.  Insert <server name> <IP address> <port number>

3.  Delete <server name> [<IP address>] [<port number>]

4.  Find <wild_name> <wild_IP>

5.  Kill

6.  Quit

7.  Link <server name>

8.  Unlink <server name>

9.  Register <client name> <port number>

10.  Unregister <client name>

11.  List <client name list> <server name list>

12.  Send <client name> <server name> <message>

The Server command sends no messages, but sets local variables used by the client to contact the server. All subsequent commands that involve sending messages use the values set by this command, until another Server command or Kill command is issued. The client checks for validity of IP address and port number, and either prints an error message or echoes the valid IP address and port number. If no server IP address and port have been specified, or if the server has been terminated, then any commands that would otherwise result in sending a message must instead print an error message indicating that the server parameters have not been initialized.

Insert causes the client to check validity of the remaining fields and either print an error message or send an insert message to the server with the fields provided. In the latter case, the results from the server are printed.

Delete causes the client to check validity of the remaining fields and either print an error message or send a delete message to the server with the fields provided. In the latter case, the results from the server are printed.

Find causes the client to check validity of the remaining fields and either print an error message or send a retrieve message to the server with the fields provided. In the latter case, the results from the server are printed, including all matching records formatted reasonably (one record per line).

Kill causes the client to send a kill message to the current server and print the server’s result message (sent before it dies).

Quit causes the client to quit, without sending any further messages.

Link <server name> causes the client to send the server a link message and print the server’s result message.

Unlink <server name> causes the client to send the server an unlink message and print the server’s result message.

Register <client name> <port number> causes the client to send the server a register message and print the server’s result message. Client names are alphanumeric strings.

Unregister <client name> causes the client to send the server an unregister message and print the server’s result message.

List <client name list> <server name list> causes the client to send the server a list message and print the server’s result message. A name list is one or more names or the ‘*’ wildcard. If the list has more than one name, then it shall be enclosed in double quotes “” and names shall be separated by commas. Output should list one client name and the server on which it is registered, one pair per line.

Send <client name list> <server name list> <message> causes the client to send the server send message and print the server’s result message. Name lists are as for the List command. The message shall start on the next line following the send command line, and shall terminate with a line containing a period ‘.’ by itself (i.e., newline period newline).

Deliverables:

You will submit a tar file containing the following files.

1.  Server source code

2.  Client source code

3.  Makefile, if appropriate

4.  Configuration files, if appropriate

5.  Documentation of protocol (exact message formats, tests, actions)

6.  User documentation of server and of client (how to install, configure, and use)

7.  In Java, C++, or C. Your program must be able to be compiled by the compilers and run on the following environment: thunder.cise.ufl.edu