[Solved] CS3516 Assignment 1-Socket Programming

$25

File Name: CS3516_Assignment_1_Socket_Programming.zip
File Size: 357.96 KB

SKU: [Solved] CS3516 Assignment 1-Socket Programming Category: Tag:
5/5 - (1 vote)

In this assignment you will be asked to implement an HTTP client and server running a simplified version of the HTTP/1.1 protocol. This project will be completed in either C/C++ using the Unix Socket commands. The program has to run without errors in any CCC machine.

Step 1: The HTTP Client

Execution: Your client should take command line arguments and the GET method to download a web-page. The arguments are as follows:

  • The server URL (http://www.server.com/path/to/file) or an IP address
  • The port number on which to contact the server
  • The options that which add functionality to the client o p: prints the RTT for accessing the URL on the terminal before servers response (i.e., the webpage)

For example

./http_client [-options] server_url port_number

Workflow: The client should work as follows:

  • Connect to the server via a TCP socket
  • Submit a valid HTTP/1.1 GET request for the supplied URL.
    • Note that: HTTP expects all lines in a request to be terminated with a r
      . The last line of the request should only contain a r
      (i.e., empty line)
    • Read the servers response and display it on the terminal
  • Submit a valid HTTP/1.1 GET request for the supplied URL with the p option.
    • Print the RTT for accessing the URL on the terminal o Read the servers response and display it on the terminal

Testing: Use the client to get a file of your choosing from an actual webserver on the Internet. For example,

./http_client www.cnn.com 80

Use the client to get the provided index.html from your own server program. For example,

./http_client cccworks4.wpi.edu/index.html 7890

Use the client to get a file of your choosing an actual webserver (of your choosing) on the Internet and your own web server using the p option to compute the RTT between you and the webserver. For example,

./http_client p www.cnn.com 80

./http_client p cccworks4.wpi.edu/index.html 7890

  • Do this 10 times and compute the average RTT time for both cases. Create a table and show each of the RTT values and the average value.
  • You should print the RTT value in milliseconds.

Step 2: The HTTP Server

Execution: Your server should start first (i.e., before the client) and take a command line argument specifying a port number. For example,

./http_server 7890

Workflow: The basic workflow of the server is as follows

  • Start the server in an infinite loop (you must interrupt your server with a termination signal (e.g., SIGTERM) to stop it)
  • Wait for a client connection on the port number specified by command line argument.
  • When a client connection is accepted, read the HTTP request.
  • Construct a valid HTTP response including status line, any headers you feel are appropriate, and, of course, the requested file in the response body.
    • For example, if the server receives the GET index.html HTTP/1.1 request, it sends out 200 OK to the client, followed by the file index.html.
    • The file index.html has been provided.
    • If the requested file doesnt exist, the server sends out 404 Not Found response to the client.
  • Close the client connection and loop back to wait for the next client connection to arrive.
  • Make sure your server code shuts down gracefully when terminated. That means closing any open sockets, freeing allocated memory, etc.
  • [BONUS POINTS:] Make the server multi-threaded, which means it can handle as multiple clients at the same time. We will test with at least 5 to 10 clients. (10 extra points)
  • The link to the file html to be downloaded from your implementation of the web server is available in project documents. Use this as your index.html file at the server.

Testing: Use an ordinary browser such as Firefox or Chrome to get an html file from your server. For example, your server is running at host cccworks4.wpi.edu on port number 7890, and there is a file index.html (or TMDG.html) in the current directory. In the URL box of the web browser, type in cccworks4.wpi.edu:7890/index.html or cccworks4.wpi.edu:7890/TMDG.html, the browser should fetch the file and display it.

Deliverables

  1. All the code for the web client and the web server (.c and .h files)
  2. A makefile that compiles the client and the server code (Tutorial on writing a makefile)
  3. A README (txt) file that spells out exactly how to compile and run the client and the server
  4. A PDF file that lists the RTT for an actual web server (e.g., www.cnn.com) you connected to.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS3516 Assignment 1-Socket Programming[Solved] CS3516 Assignment 1-Socket Programming
$25