© 2023 Robin Pottathuparambil XXXXXXXXXXPage 1 of 5 Programming Assignment #3 CSCE 3530 – Introduction to Computer Networks Spring 2023 100 Points Due:...

1 answer below »
Follow instructions in the file


© 2023 Robin Pottathuparambil Page 1 of 5 Programming Assignment #3 CSCE 3530 – Introduction to Computer Networks Spring 2023 100 Points Due: 03/29/2023, 11:55 PM Instructions: Compile the C programs in one of the Cell (cell01 – cell06) servers and make sure it’s working. Comment your code. Create a Makefile to compile the source code and to clean the executable. Create a readme file that describes how to compile, execute, and test the code. Create an assignment folder with folder name as euid_PA3 (example: xyz0202_PA3) and add the source file, Makefile, and the readme file to the folder. Please create a zip archive of your assignment folder and upload the zip file to Canvas. Not following the above instructions could result in not accepting your programming assignment. Late submissions are not allowed. Objective: Create a web cache that can cache up to six recent webpages and checks if the pages are up to date. Requirements: 1. Create a C-based client using TCP sockets 2. The client should run on any Cell (cell01 – cell06) machine 3. The client should be able to accept and service http requests 4. The client should be able to cache up to six recent requested webpages, if available 5. The client should check if an updated webpage is available using If-Modified-Since header and replace the old webpage with new webpage in the cache if a updated webpage is available. Procedure: 1. Create a C-based client using TCP sockets 2. The client should run on any Cell (cell01 – cell06) machine and the created client should be able to accept a HTTP website URL using the below format ./wcclient URL: Port: © 2023 Robin Pottathuparambil Page 2 of 5 where wcclient is the client executable, url is the requested hostname and port_number is the port number that the web server is listening 3. Once the client gets an URL input from the user, it checks the cache for the requested page. If the page is not found in the cache, proceed to the below steps a. The client makes a connection to the requested URL using the connect system call. The connect system call needs the IP address of the input URL. Use the gethostbyname system call to find the IP address of the input URL b. Once the connection is made, a GET request is made to the web server by client program. Figure 1 shows the overall architecture c. A sample GET request is shown below to request the landing page from google website GET / HTTP/1.1\r\n Host: www.google.com\r\n Connection: Close\r\n\r\n d. The above GET request lines are packed as a single string and written to the webserver by client using write or send system call e. The client sleeps for a second and then reads (read or recv system call) the incoming stream of data (response) and stores the received data in a buffer. The client then checks for the HTTP response status code in the received response f. If the HTTP response status code is 200, the returned web page from the web server is cached (stored as a file). Verify manually to see if the returned page is same as the browser returned page g. The client stores the webpage in a file and assigns a filename based on the time of visit (available in the response header). The filename format is YYYYMMDDhhmmss. Where YYYY is the year, MM is the month, DD is the day, hh is the hour in 24-hour format, mm is the minutes, and ss is the seconds when the website was visited h. A list file (list.txt) is created which stores the URL of the webpage and the associated cached web page filename i. The list file stores six recent URLs. The cached websites that are not listed in the list file should be deleted from the cache j. Once the returned web page is cached, the client waits for the next URL input from the user k. If the HTTP response status code is not 200, do not cache the web page instead print the HTTP response status code © 2023 Robin Pottathuparambil Page 3 of 5 4. When the user requests a webpage that is in the list.txt file (cache) the client simply prints that the page is found in cache along with the filename and proceeds to the below steps a. The client will ask the user to check if the page was modified. If the user responds with a ‘Yes’, the user inputs the date and time to check if the page was modified since the input date and time b. Do Step 3a for the connection and once the connection is made, a GET request along with If-Modified-Since header is sent to the web server to check if the page is modified since the input date and time c. A sample GET request with If-Modified-Since header is shown below to request the updated page from example.com website GET / HTTP/1.1\r\n Host: www.example.com\r\n If-Modified-Since: Thu, 16 Oct 2019 07:18:26 GMT\r\n Connection: Close\r\n\r\n d. If the HTTP response status code is 200, the returned web page from the web server is cached (stored as a new file with filename based on the time of visit). The old, cached file is deleted. The list file is updated accordingly with necessary changes e. If the HTTP response status code is 304, do not cache the web page instead print the HTTP response status code f. If the user responds with a ‘No’ to check if the page was modified, then the client proceeds to ask the user for the next URL 5. The client program should exit or end execution when a quit expression is given as an input 6. Test web caching by accessing multiple websites. Most websites are not http websites so only select http websites using this website 7. Most websites do not support If-Modified-Since header, so use this website to check if a http website supports If-Modified-Since header 8. A sample list.txt is available on Canvas for reference. Deliverables: 1. Commented client C code 2. A Makefile to compile (make) the source code and to clean (make clean) the executable 3. A readme file that describes how to compile, execute, and test the code. 4. Create an assignment folder with folder name as euid_PA3 (example: xyz0202_PA2) and add the source file, Makefile, and the readme file to the folder. https://whynohttps.com/ https://en.web-tool.org/check-last-modified/ © 2023 Robin Pottathuparambil Page 4 of 5 Please create a zip archive of your assignment folder and upload the zip file to Canvas on or before due date. Client-side input/output: ./wcclient URL: www.google.com Port: 80 Response: 200 Action: Page cached as filename - 20230308101001 URL: www.dmoz.org Port: 80 Response: 400 Action: Not cached URL: www.example.com Port: 80 Response: 200 Action: Page cached as filename - 20230308101020 URL: icio.us Port: 80 Response: 200 Action: Page cached as filename - 20230308101044 URL: www.example.com Port: 80 Response: 200 Action: Page found in cache, filename – 20230308101020 Check if modified: Yes Date: Thu, 16 Oct 2019 07:18:26 GMT Response: 200 Action: Updated web page cached as filename – 20230308101110, deleted old page with filename - 20230308101020 URL: www.example.com Port: 80 Response: 200 Action: Page found in cache, filename – 20230308101110 Check if modified: Yes Date: Thu, 18 Oct 2019 07:18:26 GMT Response: 304 Action: Not cached URL: www.example.com Port: 80 Response: 200 Action: Page found in cache, filename – 20230308111110 Check if modified: No URL: quit cya! © 2023 Robin Pottathuparambil Page 5 of 5 Figure 1. Overall Architecture. www.example.com 20230308101110 icio.us 20230308101044 www.google.com 20230308101001
Answered 1 days AfterMar 26, 2023

Answer To: © 2023 Robin Pottathuparambil XXXXXXXXXXPage 1 of 5 Programming...

Adyasha answered on Mar 27 2023
38 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here