Computer Networks - CSE 30264 - Programming Assignment 4


Total Points: 100 points
Goal: Program a Prototype of a Message Board Forum application
Assigned: Oct. 28, 2016
Due: Nov. 16, 2016 by the beginning of class
Grouping: Completed by a group


Background

In this programing assignment, you will implement the client and server sides of a message board forum. The data transfer itself will take place using TCP and UDP with the client determining the operation to be performed (Create or delete a board, leave a message on a board, edit or delete messages, add and dowload attachments to/from boards, read boards, list boards, and shutting down the server). Even though only one port is being used, both UDP and TCP sockets can be active at the same time. This is because the same port can be reused as long as the protocol using it is different. Since TCP and UDP are different protocols, they can both use the same port without any issues. Use UDP for small transfers and TCP for potentially large transfers when the board is read or if files are transfered. The server should respond appropriately to the specific command. The specifics of the protocol are detailed in this handout. You are free to reuse part of your programs in the programming assignments 1, 2, and 3 to finish this programming assignment. Note: please refer to appendix A for the port number assigned to your group for the assignment.

For the assignment, you will turn in a gzipped tar file to your dropbox. The gzipped tar file should contain:

Message Board Forum

  1. Server opens port, creates UDP socket and TCP socket, and goes into “wait for connection” state.
  2. Client connects to the server on the appropriate port.
  3. Server sends request for username.
  4. Client sends username.
  5. Server checks to see if it is a new user or existing user and requests a password.
  6. Client sends password.
  7. Server either registers new user or checks to see if the password matches. Server then sends acknowledgement to the client.
  8. Server goes into “wait for operation from client” state and waits for operation command from the client.
  9. Client goes into “prompt user for operation” state and prompts user for operation.
  10. Client passes operation (CRT: Create Board, LIS: List Boards, MSG: Leave Message, DLT: Delete Message, RDB: Read Board, EDT: Edit Message, APN: Append File, DWN: Download File, DST: Destroy Board, XIT: Exit, SHT: Shutdown Server) to server. The operations that need to make use of TCP are RDB, APN, and DWN, and all other operations can be done using UDP only.
  11. Operation is executed as follows:
    1. CRT:
      1. Client sends operation (CRT) to create a new message board on the server. Each board should be represented by a file in the server directory. The first line of each board should contain the name of the user who created it, and each line after should be a message.
      2. Client sends the name of the board to be created.
      3. Server receives the board name and creates a new board (file) with that name if no file with that name already exists and writes at the top of the board which user created it. Note: The server should keep track of the boards it has created since the program began running.
      4. Server sends the results (either a confirmation that the board has been created or an error message) to the client.
      5. Client receives and prints the results.
      6. Client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
    2. MSG:
      1. Client sends operation (MSG) to leave a message on a board.
      2. Client prompts the user for and sends the name of the board to leave a message on.
      3. The client then prompts for and sends the message to be added.
      4. Server receives the above information, and checks to make sure the board exists.
      5. If the board exists, the server leaves the message along with the user who posted it on the board. The server should do this by appending the username and message to the end of the file representing the board.
      6. The server then sends the results (either a confirmation that the message was added or an error saying the board does not exist) to the client
      7. Client receives the results from the server and prints it out.
      8. Client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
    3. DLT:
      1. Client sends operation (DLT) to delete a message on a board.
      2. Client prompts the user for and sends the name of the board to delete a message from.
      3. The client then prompts the user for which message to delete and sends an indication to the server of which message should be deleted. Note: How the specific message is identified is up to you.
      4. Server receives the above information, checks to see if the board exists and that the current user is the same user who posted the message to be deleted, and then deletes the message if valid. The server then sends the results (either a confirmation that the message was deleted or an error statement) to the client. Note: How the server keeps track and checks if the users match is again up to you.
      5. Client receives the results from the server and prints it out.
      6. Client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
    4. EDT:
      1. Client sends operation (EDT) to edit a message on a board.
      2. Client sends the name of the board to edit a message on. The client then sends the server which message should be replaced, and then it sends the new version of the message. Note: How the specific message is identified is up to you.
      3. Server receives the above information, checks to see if the board exists and that the current user is the same user who posted the message to be replaced, and then edits the message if valid. The server then sends the results (either a confirmation or error message) to the client. Note: How the server keeps track and checks if the users match is again up to you.
      4. Client receives the results from the server and prints it out.
      5. Client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
    5. LIS:
      1. Client sends operation (LIS) to list the boards on the server. Note: Only the board names should be listed, not any of the messages.
      2. Server obtains listing of it's boards and sends the list to the client.
      3. Client receives listing and prints it out.
      4. Client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
    6. RDB:
      1. Client sends operation (RDB) to read a board.
      2. Client prompts the user for and sends the name of the board to read.
      3. Server receives the above information, checks to see if the board exists.
        1. If board does not exist, server sends a negative filesize to the client, and client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
        2. If board does exist, server calculates filesize and sends the filesize to the client.
      4. Server enters loop and starts sending the contents of the file representing the correct board to the client in chunks. Note: This file transfer should take place using TCP.
      5. Client enters loop and starts receiving the contents of the board and printing them until the total data received == the filesize .
      6. Client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
    7. APN:
      1. Client sends operation (APN) to append a file to a board. Note: This operation appends a file to the *board* not to a message.
      2. Client prompts the user for and sends the name of the board to append to.
      3. Client prompts the user for and sends and the name of the file to be appended.
      4. Server receives the above information, checks to see if the board exists and that the file can be appended. (Note: The appended files should be named in the format of boardName-filename where boardName is the name of the board and filename is the name of the file being appended on the server. For example, if the board is named "myboard", and the file being appended is named "info.txt", the server should have a file named "myboard-info.txt")
        1. If board does not exist or if that attachment already exists or if a file with the required name already exists then send an error message to the client and client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
        2. If board does exist and the file can be created, send a confirmation message to the client.
      5. Client calculates the filesize and sends it to the server. If there is an error or file does not exist, filesize is negative and client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
      6. Client then enters loop and starts sending the file. Note: This file transfer should take place using TCP.
      7. Server enters loop and starts receiving the file and writing to a file that follows the naming convention described above. Note:The server should keep track of the files appended to each board and the original filenames.
      8. The server should then add a message to the board stating the original name of the file appended and the user that attached it. Note: Do not worry about editing or deleting these messages.
      9. Client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
      10. Note: You do not have to worry about removing or deleting these attachments, except for when the program is shutting down with the SHT operation.
    8. DWN:
      1. Client sends operation (DWN) to download a file from a board.
      2. Client prompts the user for and sends the name of the board to download from.
      3. Client prompts the user for and sends the name of the file to be downloaded.
      4. Server receives the above information, checks to see if the board exists and that the file is appended to it.
        1. If board does not exist or if the file is not appended to the board, server sends a negative filesize to the client and client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
        2. If board does exist and the file is appended to it, server calculates the size of the file and sends it to the client.
      5. Server then enters loop and starts sending the file in chunks to the client.
      6. Client enters loop and starts receiving the file and writing it to a local file with the same name as the attachment. Client receives the data in chunks until the amount of data received is the same as the filesize sent from the server. Note: This file transfer should take place using TCP.
      7. Client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
    9. DST:
      1. Client sends operation (DST) to destroy a board.
      2. Client prompts the user for and sends the name of the board to be destroyed.
      3. Server gets the board name, checks to see if the current user is the user who created the board and deletes it and files associated with it. The server then sends the results (either a confirmation or error message) to the client.
      4. Client receives the results from the server and prints it out.
      5. Client and server return to “prompt user for operation" and "wait for operation from client” state respectively.
    10. XIT:
      1. Client sends operation (XIT) to exit.
      2. Client closes sockets, and exits.
      3. Server closes current tcp socket and goes to "wait for connection” state.
    11. SHT:
      1. Client sends operation (SHT) to shutdown the server.
      2. Client prompts user for and sends the admin password to the server.
      3. Server receives the admin password from the client and compares it to the actual admin password (argv[2]).
        1. If passwords don't match, Server sends error message to user and goes back to "wait for operation from client” state, and client receives the message and goes back to "prompt user for operation" state.
        2. If passwords match, server sends acknowledgement to the client. The client closes its sockets and the program ends. The server deletes all board files and all appended files, closes all sockets and returns.

    Note: If it is not explicitly specified, the client and server will return to “prompt user for operation" and "wait for operation from client” state respectively after a succesful operation and wait for the next operation.

General Notes

Server Side Design

The server is responsible for handling the connection request from a single client, processing the request, then looping back to handle further requests. For this particular assignment, your code only needs to handle one client at a time. The server binary should be named myfrmd.

The server should listen on the specified port number [refer to Appendix for the port number for your group] that is given by command line argument. Your server should bind to the port and then listen for incoming client connections. You may decide if you would like to allow timeouts for better responsiveness but any sort of a timeout is purely optional. You may want to allow for port reuse for quicker recovery after a crash.

Once a new client request arrives, your server should use the accept function to create a new client socket. Once the file has been transmitted, return to the state where your server is waiting for a new command. Your server should be invoked as follows:
./myfrmd Port password

Client Side Design

The client is responsible for initiating a connection to a server. Once connected, the client code should prompt the user for an operation (CRT, MSG, DLT, EDT, RDB, LIS, APN, DWN, DST, XIT, SHT), and should transmit the operation to the server. Your client executable should be named myfrm. Your client should be invoked as follows:
./myfrm Server_Name Port

The first argument is the hostname of the server to connect to (this will depend on what machine you start your server code on). The second argument is the port number..

Submission

Submit a gzipped tar file of your entire assignment package to your dropbox/program4 directory. The archive must include the following:

Grading Rubric


Appendix A

Table 1. Group Port/ Assignment
TCP Ports to UseGroup Members
41001, 41002Nicholas Aiello, Rosalyn Tan
41003, 41004, 41005Christopher Beaufils, David Lewis, John Ryan
41006, 41007, 41008Theodore Brombach, Emily Obaditch, Matt Reilly
41009, 41010Timothy Chang, Christopher Syers
41011, 41012, 41013Mary Connolly, Paul Dowling, John Rocha
41014John Considine
41015, 41016Aaron Crawfis, Kurt Davis
41017, 41018Jorge Diaz-Ortiz, Jose SuarezMartinez
41019, 41020Jacob Dumford, Tyler Sammons
41021, 41022, 41023Robert Freedy, Nicholas Haydel, Patrick Schurr
41024, 41025Luke Garrison, Nicholas Ward
41026, 41027, 41028Michael Hillmer, Michael Hutchinson, James Ryan
41029Cory Jbara
41030, 41031, 41032Jacob Kassman, Lauren Kuta, Matt Paulson
41033, 41034Reilly Kearney, Ann Keenan
41035, 41036John Klamer, Elizabeth Vista
41037Harrison Le
41038, 41039Andrew Lubera, Alan Vuong
41040, 41041Ryan McMullen, Matthew Perez
41042, 41043Madelyn Nelson, Jenna Wilson
41044, 41045John Nolan, John Riordan