CS 33600 Exam 2 Review The exam is on Tuesday, May 5, at 2:45 pm. These problems review the material we covered since the last exam. The topics include the client/server model, URLs, fetching URLs, sockets, network connections, application layer protocols, and HTTP. http://cs.pnw.edu/~rlkraft/cs33600/for-class/readmes/Readme_10_network_clients/ http://cs.pnw.edu/~rlkraft/cs33600/for-class/readmes/Readme_11_sockets/ http://cs.pnw.edu/~rlkraft/cs33600/for-class/readmes/Readme_12_http/ http://cs.pnw.edu/~rlkraft/cs33600/for-class/HTTP-1.1_Syntax.txt http://cs.pnw.edu/~rlkraft/cs33600/for-class/Web_and_HTTP.pdf http://cs.pnw.edu/~rlkraft/cs33600/for-class/Socket_API.png https://csapp.cs.cmu.edu/2e/ch11-preview.pdf https://link.springer.com/content/pdf/10.1007/978-1-4842-7135-3_8#page=22 http://cs.pnw.edu/~rlkraft/cs33600/for-class/network_clients.zip http://cs.pnw.edu/~rlkraft/cs33600/for-class/simple_client-server_pairs.zip http://cs.pnw.edu/~rlkraft/cs33600/for-class/http_server.zip Here are a few review problems. Problem 1.) Identify all the parts of the following URLs. (See http://cs.pnw.edu/~rlkraft/cs33600/for-class/readmes/Readme_10_network_clients/#url-and-uri http://www.bigcompany.com:42/consumer/products/lookup.php?sku=0&color=greenish http://www.bigcompany.edu:4242/where/was/that/file?x=2+2&bob=a4s56d7v83n https://people.scs.carleton.ca/~lanthier/teaching/COMP1406/Notes/COMP1406_Ch12_NetworkProgramming.pdf#page=6 Problem 2.) What does a hostname identify? What does an IP address identify? What does a port number identify? Problem 3.) Here is an IP address in binary form. 1011 0011 0001 0011 1010 1000 1110 1010 Write the IP address in "dotted-quad" notation. (See http://cs.pnw.edu/~rlkraft/cs33600/for-class/readmes/Readme_10_network_clients/#host-hostname-ip-address-port-number Problem 4.) The following picture is a picture of a TCP connection that is not yet a communicating TCP connection. Explain why. Also explain why this connection may stay in this state for a long time. Then draw a new picture that describes the communicating TCP connection. (See http://cs.pnw.edu/~rlkraft/cs33600/for-class/readmes/Readme_11_sockets/#bind-listen-accept-connect Socket ServerSocket +----------------+ +------------------+ | | tcp connection | | | 16.52.9.4:75 O----------------------O 10.12.3.2:1234 | | | | | | | | | +----------------+ +------------------+ Problem 5.) Fill in as much detail as you can in this outline of a client/server socket connection. +----------------+ | | | | | | +----------------+ | | | +----------------+ | | | | | | +----------------+ | | | +-------------+ +----------------+ | | | | | | | | | | | | +-------------+ +----------------+ | | | | | | +-------------+ +----------------+ | | | | | |- - - - - - - - - ->| |<--------+ | | | | | +-------------+ +----------------+ | | | | +-------------------------------------------------------------+ | | | | | | | +-------------+ +----------------+ | | | | | | | | | | | |--------------------| | | | | | | | | | | | +-------------+ +----------------+ | | | | | | | | | | | | | | | | | | +-------------+ +----------------+ | | | | | | | | | | | |--------------------| | | | | | | | | | | | +-------------+ +----------------+ } | | | | | | +-------------------------------------------------------------+ | | | | +-------------+ +----------------+ | | | | | | | | | |---------+ | | | | +-------------+ +----------------+ Problem 6.) Write five lines of Java code that creates a server socket, waits for a connection on that socket, reads one line from the connecting process, writes that line back to the process, and then closes the communicating socket, but not the server socket. (See http://cs.pnw.edu/~rlkraft/cs33600/for-class/readmes/Readme_11_sockets/#using-jshell Problem 7.) Suppose we have three processes, P1, P2, and P3 that communicate using sockets. The processes are supposed to form a ring in which P1 can send messages to P2, P2 can send messages to P3, and P3 can send messages to P1, and the processes do not communicate in any other way. More specifically, suppose that when process P1 starts, it prompts a user at a console to type in a message, and then P1 sends that message to P2. P2 receives the message and prints it on its console and then prompts a user at the console to type a new message that P2 sends to P3. P3 receives its message, prints it to its console, prompts a user for a new message, and sends that to P1. P1 receives the message from P3, prints it to its console window, and prompts its user for a message to send to P2, etc. Write a Java pseudo-code outline of the steps that P1 must go through to implement this "ring protocol". How many sockets, and what kind of sockets, will P1 need? What information would P1 need at its startup time? Would the pseudo-code for processes P2 and P3 be the same or different than P1's? Problem 8.) Suppose we have this base URL. http://myCompany.com/our/private/information/index.html Using that base URL, what do the following relative URIs resolve to? myVacation.html ../../public/info/index.html /index.html /catalog/index.html ../../../catalog/index.html Write a few lines of Java code that would solve this problem. See http://cs.pnw.edu/~rlkraft/cs33600/for-class/readmes/Readme_10_network_clients/#url-and-uri Problem 9.) A web page with this URL, http://www.interesting.org/reports/june/doucument.html contains the following fragment of html.