Network java program

Part I: Write a SMTP client program and a SMTP server program to implement the following simplified SMTP protocol based on TCP service. Please make sure your program supports multiple clients. You must use the port assigned to you(which is 5120) and you may hard code it in both client and server programs.

  • Telnet <your server’s ip address><port>” can be used to test your SMTP server program first (especially those “503” responses), then your SMTP client can be tested using your SMTP server program.
  • SMTP Client Program (NOT a TELNET client!!!):
    1. Display a message to ask the user to input the Host Name (or ip-address) of your SMTP server.
    2. Buildup the TCP connection to your SMTP server with the Host Name input by User at the given port. Catch the exception, terminate the program, and display error messages on the standard output if any. Wait for, read, and display the “220” response from the SMTP server.
    3. Display prompt messages on the standard output to ask the user to input sender’s email address, receiver’s email address, subject, and email contents, respectively. Since there may be multiple lines in email contents, the prompt message displayed by your Client program MUST prompt the ending signature pattern like “.” on a line by itself.
    4. Use the user inputs collected above in Step 3 for the following 3-phase data transfer procedure (see step 3 on server side). In each of the following steps a. through e., display the RTT (round-trip-time) of each conversation in millisecond (e.g., RTT = 212.08 ms).
      1. Send the “HELO” command followed by sender’s mail server domain name (e.g., xyz.com) to the SMTP server program, wait for server’s response and display it on the standard output.
      2. Send the “MAIL FROM: <sender’s email address>” command to SMTP server, wait for SMTP server’s response and display it on the standard output.
      3. Send the “RCPT TO: <receiver’s email address>” command to the SMTP server program, wait for SMTP server’s response and display it on the standard output.
      4. Send the “DATA” command to the SMTP server program, wait for SMTP server’s response and display it on the standard output.
      5. Send the Mail message to the SMTP server. The format of this Mail message MUST follow the format detailed on the slide titled “Mail message format”. Wait for SMTP server’s response and display it on the standard output.
    5. Display a prompt message to ask the User whether to continue. If yes, repeat steps 3 through 5. Otherwise, send a “QUIT” command to the SMTP server, display SMTP Server’s response, close TCP connection, and terminate the Client program.
  • SMTP Server Program: (server’s ip or client’s ip can be its dns name below.) 1.Listen to the given port and wait for a connection request from a SMTP Client.
    1. Create a new thread for every incoming TCP connection request from a SMTP client. Send the “220” response including server’s ip address or dns name to the SMTP client.
    2. Implement the following 3-phase data transfer procedure (see step 4 on client side):
      1. Wait for, read, and display the “HELO” command from the SMTP client. If the incoming command is NOT HELO, sends “503 5.5.2 Send hello first” response to the SMTP client and repeat step 3.a.
      2. Send the “250 <server’s ip> Hello <client’s ip>” response to the SMTP client.
      3. Wait for, read, and display the “MAIL FROM” command from the SMTP client. If the incoming command is NOT “MAIL FROM”, sends “503 5.5.2 Need mail command” response to the SMTP client and repeat step 3.c.
      4. Send the “250 2.1.0 Sender OK” response to the SMTP client.
      5. Wait for, read, and display the “RCPT TO” command from the SMTP client. If the incoming command is NOT “RCPT TO”, send “503 5.5.2 Need rcpt command” response to the SMTP client and repeat step 3.e.
      6. Send the “250 2.1.5 Recipient OK” response to the SMTP client.
      7. Wait for, read, and display the “DATA” command from the SMTP client. If the incoming command is NOT “DATA”, send “503 5.5.2 Need data command” response to the SMTP client and repeat step 3.g.
      8. Send the “354 Start mail input; end with <CRLF>.<CRLF>” response to the SMTP client.
      9. Wait for, read, and display the Mail message from the SMTP client line by line. (hint: “.” is the ending signature.)
      10. Send the “250 Message received and to be delivered” response to the SMTP client.
    3. Repeat Step 3 until the “QUIT” command is read. Upon receiving “QUIT”, send the “221 <server’s ip> closing connection” response to the SMTP client and go to Step 5.
    4. Close all i/o streams and the TCP socket for THIS Client, and terminate the thread for THIS client.

 

Part II (20%): Test your programs with multiple clients using the Virtual Machine in the cloud.

  1. MAKE a directory “HW02” under your home directory on cs3700a.msdenver.edu and cs3700b.msudenver.edu, a subdirectory “server” under “HW02” on msudenver.edu, and a subdirectory “client” under “HW02” on cs3700b.msudenver.edu.

MSU Denver, M&CS                                             CS 3700-001: Computer Networks, Summer 2017                                                     Dr. Weiying Zhu

  1. UPLOAD and COMPILE the server program under “HW02/server” and the client program under “HW02/client” on the VMs.
  2. TEST theserver program running on cs3700a.msudenver.edu together with a client program running on your laptop or lab computer and another client program, simultaneously, running on cs3700b.msudenver.edu to test all the possible cases.
  3. SAVE a file named txt under “HW02/client” on cs3700b.msudenver.edu, which captures the outputs of your client program when you test it. You can use the following command to redirect the standard output (stdout) and the standard error (stderr) to a file on UNIX, Linux, or Mac, and view the contents of the file

java prog_name_args | tee testResultsClient.txt //copy stdout to the .txt file cat file-name     //display the file’s contents.  

 

 

Order from us and get better grades. We are the service you have been looking for.