Project3

advertisement
Project 3
Summary:
In this project, you will add two new programs named “BBclient” and “BBserve.r” These will use the services
of the “Hierarchical server” in project 2 with an additional record type, and you will construct a simple bulletin
board system.
Languages:
You will use Java, C++, C#, or C to implement the client and the server. Your program must be able to be
compiled by the compilers and run on the following environment: thunder.cise.ufl.edu
1. Hierarchical Server Modifications
Records:
In addition to the record in Project 2, the Hierarchical Server will store BBserver records:
BBserverName: dotted 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
2. BBserver
BBserver needs to store the following two types of records:
BB Records:
BB Name: Alphanumeric ASCII string no greater than 80 characters long
BB Creator: Name of BB client who registered the BB Name
BB Creation Time: ASCII string with the following structure: yy/MM/dd HH:mm:ss. For example '2002/1/1
17:55:00'
BB Last Modification Time: ASCII string with the following structure: yy/MM/dd HH:mm:ss. For example
'2002/1/1 17:55:00'
Comment Records:
Comment Records have the following structure.
BB Name: Name of bulletin board with which the comment is associated (must be BB Name in BB Record).
Subject: Alphanumeric ASCII string no greater than 80 characters long.
Date: ASCII string with the following structure: yy/MM/dd HH:mm:ss. For example '2002/1/1 17:55:00'
Comment: Alphanumeric ASCII string no greater than 1000 characters long.
Author name: The name of the BBclient who posted the comment.
Comment Number: an ASCII sequence number starting with 1 and incremented with each comment posted to a
given bulletin board. These are unique for a comment and BB Name, but are not unique across different BB
Names on the same BBserver.
BBserver Operation
The BBserver must be able to be started on a host with a name and open a TCP port number specified either in a
configuration file or on the command line. You should also set the default hierarchical server and the top level
hierarchical server either in a configuration file or on the command line. Note that the top level hierarchical
server cannot be same as the default hierarchical server.
Similar to hierarchical server, the name of the BBserver is a dotted alphanumeric ASCII string. For example, if
a server’s name is a.b.c.d, its parent will be a hierarchical server whose name is b.c.d, and the hierarchical
server is its default hierarchical server. A server should be started after initialization of the hierarchy.
The BBserver is not a hierarchical server, but rather only handles the records associated with the bulletin boards
that have been registered on it. A BBserver needs to contact the hierarchical server(s) only to register with them
so that clients can find it.
When the BBserver is started, it should try to connect with its parent; failing which, it shall try to connect with
the default hierarchical server. If the connection successful, it will send its name, its IP address and its port
number to the default hierarchical server and the hierarchical server will insert a new BB record for it. Failures
should be reported.
The server must at least accept the following types of messages:
1. Register BB name
2. Deregister BB name
3. List BBserver
4. List comment messages associated with a BB
5. Post comment to a BB
6. Read comment from a BB
7. Quit
8. Kill
Register BB name causes the BBserver to register a bulletin board name associated with the requesting
BBclient. If the name is already in the database, then this is an error and should be reported (If the name is
registered with another BBserver this is OK.).
Deregister name causes the BBserver to remove a bulletin board name. If the name is not in the database, then
this is an error and should be reported.
List BBserver causes the BBserver to provide the BBclient with a list of all BB names registered with the
BBserver with which the BBclient is connected, whose name should also be displayed. The BBclient must be
able to specify either a wildcard requesting all BBserver names, or a specific name. Likewise the BBclient must
be able to specify a specific BBserver or all BBservers in its request. Reasonable error conditions must be
detected and reported (e.g., invalid BBserver name, etc.).
ListComment causes the BBserver to provide the BBclient with a list of comments posted to the bulletin board
named in the request. The comment number, subject, author, date, BB name and the BBserver name should be
displayed. The BB name and author name must be able to specify either a wildcard requesting all names, or a
specific name. Reasonable error conditions must be detected and reported.
The BBserver does not have to find the address of another BBserver; rather the client shall use the hierarchical
servers to find the IP address and port of a BBserver.
Post causes the BBserver to insert a comment record associated with a bulletin board. The subject of the
comment need not be unique. Date is automatically generated according to the local time.
Read causes the BBserver to provide the BBclient with a list of comments including contents associated with
the bulletin board named in the request. The comment subject, the BB name, the BBserver name and the
comment header and contents should be displayed. The BB and BBserver name must be able to specify either a
wildcard requesting all names, or a specific name. Reasonable error conditions must be detected and reported.
In all cases, the BBserver shall send at least one reply message indicating the result of the request (successful or
error). In the case of a retrieve message, the BBserver may send multiple messages to the BBclient. It is up to
the protocol you design to specify how the client and the server interact if multiple records are retrieved.
The BBserver must be able to receive and process messages from multiple BBclients as long as it is alive,
servicing multiple requests at the same time (since you will use TCP for BBclient connections).
2. BBClient:
The BBclient program must accept commands from the user via the standard input and print results to the
standard output. The IP address and port of each hierarchical server used by the BBClient shall be provided on
the command line or in a configuration file, or both.
The client must accept the following user commands:
1. Server <IP address> <port number>
2. Register <BB name>
3. Deregister <BB name>
4. List <BBserver name list>
5. ListComment <BB name list>
6. Post <BB name> <subject> <author> <comment>
7. Read <BB name> <number>
8. Quit
9. Kill
The Server command causes the BBclient to establish a TCP connection with the named BBserver. All
subsequent commands that involve sending messages use that connection, until another Server command or Kill
command is issued. The BBclient 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 BBserver IP address and port have been
specified, or if the BBserver has been terminated, then any commands that would otherwise result in sending a
message must instead print an error message indicating that the BBserver connection has not been initialized.
Register <BB name> causes the BBclient to send the BBserver a register message and print the server’s result
message. BB names are alphanumeric strings and should be unique for a BBserver.
Deregister <client name> causes the BBclient to send the BBserver a deregister message and print the
BBserver’s result message.
List <BBserver name list> causes the BBclient to send the BBserver a list message and print the result. A
BBserver 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 the BBserver one one
line, and then one BB name per line with the number of comments associated with that BB name.
ListComment <BB name list> causes the BBclient to send the BBserver a listComment message and print the
result. The BB 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 the BBserver
name on the first line, then the bulletin board name on a line indicating that this is a bulletin board name, and
then the subject of the comments associated with that BB name, one per line with the comment number, author,
and date. If more than one bulletin board’s comments are listed, a blank line shall be inserted before the line
with the BB name on it.
Post <subject> <author> <comment> causes the BBclient to send the BBserver a post message and print the
result. The comment 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). Subject should be unique for each BBclient.
The BBserver shall insert the date automatically using the local system time function.
Read <BB name> <number> causes the BBclient to send the BBserver a Read message and print the result. The
BB name is exactly one name. Output should list one BBserver name, one BBclient name on which it is
registered, the subject of the comment per line. The comment content should start on the next 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.
4. Example
We provide an example to show how to read a comment from one BBclient.
Same as the project 2, we first construct the hierarchical structure. Start a top level hierarchical server named
“cnt5106” listening on 127.0.0.1:9000. As “cnt5106” is the top level hierarchical server, it does not have parent.
Then we start two second level servers “exam.cnt5106” and “project.cnt5106” listening on 127.0.0.1:7000 and
127.0.0.1:8000 separately. When we start “project.cnt5106” and “exam.cnt5106”, we set “cnt5106” as their
parent. So they will try to connect to “cnt5106”. If the connection is successful, “cnt5106” will insert two
hierarchical records. Otherwise, they will return errors and exit. The process will continue until we finish
building the hierarchical environment shown in Figure 1.
After we initialize the hierarchical environment, we start two BBservers: “L1.p1.project.cnt5106” and
“L2.e1.exam.cnt5106”. The hierarchical server “p1.project.cnt5106” is set to be the default hierarchical server
of “L1.p1.project.cnt5106”, and the “e1.exam.cnt5106” is set to be the default hierarchical server of
“L2.e1.exam.cnt5106”. The hierarchical server “cnt5106” is their top level hierarchical server. Also, we start
three BBclients: “Alice” and “Bob”.
Figure 1. The procedure of reading a comment
Suppose “Bob” has registered a bulletin board “CNT5106” and posted two comments whose subjects are
“project 1 released” and “project 2 released”. Alice first run the command: List L2.e1.exam.cnt5106 to find out
the list of BB names registered with “L2.e1.exam.cnt5106”
(1) As “Alice” cannot find the address of “L2.e1.exam.cnt5106”. “Alice” has to search the address of
“L2.e1.exam.cnt5106”.
(2) “Alice” first gets the address of the default hierarchical server “p1.project.cnt5106” and sends it a request.
(3) The default hierarchical server “p1.project.cnt5106” cannot find the address of “L2.e1.exam.cnt5106”; it
will return an error message to “Alice”.
(4) After receiving the error message, “Alice” will send a request to the top level hierarchical server “cnt5106”.
(5) According to the server name “L2.e1.exam.cnt5106”, the top level hierarchical server “cnt5106” will return
the address of the second level hierarchical server “exam.cnt5106”.
(6) “Alice” will send a request to “exam.cnt5106”.
(7) According to the server name “L2.e1.exam.cnt5106”, “exam.cnt5106” will return the address of the third
level hierarchical server “e1.exam.cnt5106”.
(8) “Alice” will send a request to “e1.exam.cnt5106”.
(9) “e1.exam.cnt5106” finds the address of “L2.e1.exam.cnt5106” and returns the address to “Alice”. Now
“Alice” has the address of “L2.e1.exam.5106”.
(10) “Alice” sends the list command to “L2.e1.exam.5106” and “L2.e1.exam.5106” will return the list of the
BB names: “CNT5106”.
(11) Alice runs the command: ListComment “CNT5106”. The command is sent to “L2.e1.exam.5106”.
“L2.e1.exam.5106” will return the list of comments “project 1 released” and “project 2 released”.
(13) Alice runs the command: Read “project 1 released”. Similar to ListComment command,
“L2.e1.exam.5106” will return the content of the comment “project 1 released”.
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)
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. We urge you to test it on that environment before you submit it.
Download