meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
courses:ct30a5000:assignment3 [2012/08/22 14:37]
julaakko [Requirements]
courses:ct30a5000:assignment3 [2012/09/10 13:26] (current)
julaakko
Line 1: Line 1:
-Network programming [[https://​noppa.lut.fi/​noppa/​opintojakso/​ct30a5000/etusivu|@ Noppa]] | [[courses:​ct30a5000:​start|@ wiki]] -  +Network programming [[https://​noppa.lut.fi/​noppa/​opintojakso/​ct30a5001/etusivu|@ Noppa]] | [[courses:​ct30a5000:​start|@ wiki]] -  
-Updated: ​ --- //​[[jussi.laakkonen@lut.fi|Jussi Laakkonen]] 2012/08/22 11:46//+Updated: ​ --- //​[[jussi.laakkonen@lut.fi|Jussi Laakkonen]] 2012/09/10 11:42//
  
 ---- ----
Line 6: Line 6:
 Updates: Updates:
 > 22.8.2012: Initial version. > 22.8.2012: Initial version.
 +> 22.8.2012: Text-file based database set as a requirement.
 +> 22.8.2012: Added sequence diagram.
 +> 10.9.2012: Added clarification for error message sending.
  
 ====== Assignment3:​ Aphorism exchange system ​ ====== ====== Assignment3:​ Aphorism exchange system ​ ======
  
-Third assignment is to implement an aphorism exchange system according to protocol described below. The system must be implemented with UDP. One has to implement a client and a server. Server listens in certain port (remember that you have no rights to use system ports between 1 – 1024 on class 6325 machines) and client sends UDP datagrams into that particular port using the IP address of the server and server responds based on the message contents.+Third assignment is to implement an aphorism exchange system according to protocol described below. The system must be implemented with UDP. One has to implement a client and a server. Server listens in certain port (remember that you have no rights to use system ports between 1 – 1024 on class 6325 machines) and client sends UDP datagrams into that particular port using the IP address ​or the hostname ​of the server and server responds based on the message contents.
  
 ===== Description ===== ===== Description =====
Line 15: Line 18:
 Client can either add aphorisms to the database of the server or retrieve them from the server'​s database. The client sends a message to server, waits for a response from the server, informs the user about response and then quits. Client should get the command from a command line parameter. When adding an aphorism the client must request the aphorism from the user (via standard input). Client can either add aphorisms to the database of the server or retrieve them from the server'​s database. The client sends a message to server, waits for a response from the server, informs the user about response and then quits. Client should get the command from a command line parameter. When adding an aphorism the client must request the aphorism from the user (via standard input).
  
-Server can store up to 10 aphorisms and serves one request at a time. It is required to store the IP-address of the sender with the exact date and time along the sent aphorism. If the database is full server should response with appropriate message. If the command is not recognized server should return usage instructions in a message.+Server can store up to 10 aphorisms and serves one request at a time. It is required to store the IP-address of the sender with the exact date and time along the sent aphorism ​(feel free to select the format). Save this information to a text file when server is quitting and load it at startup. When server is run for the first time (no database exists yet) it will start with an empty database and the text file is created. **OPTIONAL** update the content of the text file every time new aphorism is added. If the database is full server should response with appropriate message. If the command is not recognized server should return usage instructions in a message.
  
 Server must not crash if it receives something else than described in the protocol. Same applies for client. Client must inform the user if server is not found. Client must not Server must not crash if it receives something else than described in the protocol. Same applies for client. Client must inform the user if server is not found. Client must not
 crash because of the invalid input given by user. crash because of the invalid input given by user.
  
-IPv4 and IPv6 must be supported. Use ''​AF_INET6''​ type socket and allow data from IPv4 mapped addresses although there exists some risks with this. For more details see [[http://​tldp.org/​HOWTO/​html_single/​Linux+IPv6-HOWTO/#​CHAPTER-SECTION-USING-API|TLDP.org Linux IPv6 HOWTO 23.1.3.1. IPv4 Mapped Addresses]] and/or read chapter 4.3 in IPv6 Network Programming book.+IPv4 and IPv6 must be supported. Use ''​PF_INET6''​ type socket and allow data from IPv4 mapped addresses although there exists some risks with this. For more details see [[http://​tldp.org/​HOWTO/​html_single/​Linux+IPv6-HOWTO/#​CHAPTER-SECTION-USING-API|TLDP.org Linux IPv6 HOWTO 23.1.3.1. IPv4 Mapped Addresses]] and/or read chapter 4.3 in IPv6 Network Programming book.
  
 ==== Requirements ==== ==== Requirements ====
Line 41: Line 44:
         * <​listening port> - Port that server listens for incoming datagrams         * <​listening port> - Port that server listens for incoming datagrams
       * Can store 10 aphorisms.       * Can store 10 aphorisms.
-        * Save aphorisms into text-file when the server is terminated. +        ​* Data to save: aphorism, who sent (IP), when (date & time) 
-        * Read aphorisms from text-file into database when starting the server.+        ​* Save aphorisms into text-file when the server is terminated. 
 +        * Read aphorisms from text-file into database when starting the server.
       * Runs until is stopped with Ctrl-C or ''​quit''​ command from command line.       * Runs until is stopped with Ctrl-C or ''​quit''​ command from command line.
       * Server must serve one request at a time. After serving one request process the next one.       * Server must serve one request at a time. After serving one request process the next one.
       * Iterative, no threads or ''​fork()''​.       * Iterative, no threads or ''​fork()''​.
-==== Protocol messages ==== 
  
-Add an aphorism:+===== Protocol ===== 
 + 
 +==== Protocol packets and data types from client to server ==== 
 + 
 +=== Add an aphorism ​=== 
 ^ 3 characters ^ 10 to 509 characters ​ ^ ^ 3 characters ^ 10 to 509 characters ​ ^
 | ADD          | aphorism ​      | | ADD          | aphorism ​      |
Line 54: Line 62:
 For adding an aphorism to server. If the adding of an aphorism succeeded (database not full) server responds with AOK -message, otherwise with ERR. Minimum length for an aphorism is 10 characters. If the aphorism is less than this server responds with ERR. For adding an aphorism to server. If the adding of an aphorism succeeded (database not full) server responds with AOK -message, otherwise with ERR. Minimum length for an aphorism is 10 characters. If the aphorism is less than this server responds with ERR.
 Example: ADDThat which does not kill us makes us stronger.\0 Example: ADDThat which does not kill us makes us stronger.\0
 +
 +----
 +
 +=== Get an aphorism ===
  
 ^ 3 characters ^ ^ 3 characters ^
Line 59: Line 71:
  
 For requesting an aphorism from server. Server responds with an aphorism (APH message). Or if there is no aphorisms an ERR message is sent. For requesting an aphorism from server. Server responds with an aphorism (APH message). Or if there is no aphorisms an ERR message is sent.
-==== Protocol packets and data types from server to client====+==== Protocol packets and data types from server to client ==== 
 + 
 +=== AOK (Aphorism OK) message ​===
  
-AOK (Aphorism OK) message 
  
 ^ 3 characters ^ ^ 3 characters ^
Line 68: Line 81:
 Sent by server when adding of an aphorism was a success. Sent by server when adding of an aphorism was a success.
  
-APH message+---- 
 + 
 +=== Aphorism reply message ​===
  
 ^ 3 characters ^ 10 to 509 characters ^ ^ 3 characters ^ 10 to 509 characters ^
Line 76: Line 91:
 Example: APHBelieve nothing you hear, and only half of what you see.\0 Example: APHBelieve nothing you hear, and only half of what you see.\0
  
-ERR message+---- 
 + 
 +=== Error message ​===
  
 ^ 3 characters ^ 0 to 509 characters ^ ^ 3 characters ^ 0 to 509 characters ^
 | ERR          | Error message ​      | | ERR          | Error message ​      |
  
-Error message, sent when database is empty (response to GET) or full (response to ADD). Sent also when command is not recognized, in this case usage instructions are sent to client (separate commands to multiple lines).+Error message, sent when database is empty (response to GET) or full (response to ADD). Sent also when the aphorism is too long or command is not recognized, in this case usage instructions are sent to client (separate commands to multiple lines).
 Example:​ERRDatabase is full.\0 Example:​ERRDatabase is full.\0
 +
 +==== Sequence diagram ====
 +
 +{{:​courses:​ct30a5000:​2012_third_assignment_sequence.png?​400|}}
 +
  
 ===== Additional notes and hints ===== ===== Additional notes and hints =====