Fishnet Assignment 5: The Web and Sockets

Due: Monday Dec. 3, 2001 at the beginning of class. Out: Monday Nov. 19, 2001.

CSE/EE461 Autumn 2001; Wetherall.

In this assignment, you will work in teams of two to integrate external Web browsers and servers into your existing Fishnet node. The goal of this assignment is for you to understand network applications and socket programming. "Sockets" are the programming interface used most often to write most real-world distributed applications.

  1. What You Need To Write

Write a C program in a single file called hw5.c that does the following:

 

  1. Development and Test Instructions

Here is a suggested set of tasks to help you break down and understand the required functionality.

  1. Understanding HTTP. Try downloading a page from your Web server "by hand". Instead of using a browser, use the telnet Unix command to make a TCP connection to the Web server port on the Web server, e.g., "telnet server 80". Then type the HTTP download command as though you were the browser sending the request, e.g., "GET /homes/djw/mypage.html\n\n". This is the kind of request that will arrive at your Fishnet node in the first data packet. After typing, you should observe the raw response of HTTP headers and HTML source being sent from the server and then the connection being closed by the server. Once you have done this, you should have a good idea of what is happening during Web surfing at a very low level.
  2. Configuring your browser. You must configure your browser in two ways. Set it up to use the wrasse node as a proxy by entering the host on which your wrasse node is running and the proxy port on which you told wrasse to listen. This will make your browser contact the wrasse node for every download, rather than the destination server. Also configure your browser to disable Web document caching. This ensures that every time you click on a link a Web request will be generated, making the setup easier to understand.
  3. Running wrasse. Get wrasse running and working with your Web browser and Web server. Wrasse implements both the client side (which you do not have to write) and the server side (which you do) in one program. So you should be able to use your browser, wrasse, and Web server to download a page with a URL of the form, e.g., http://8/mypage.html. To determine the command line arguments for wrasse, run it and look at the error message. In addition to the usual Fishnet arguments you will need to tell it what TCP port to listen on for browser requests, and what Web server and root prefix to contact to provide Web pages that are served with URLs pointing directly at the wrasse node. You will also note that instead of a Web server and prefix you can tell wrasse to proxy the fishhead. This will cause downloads from http://<wrasse-node-address> to show a Fishnet entry page with one link to the top level of every node currently alive in the Fishnet. This provides an easy way to surf the Fishnet when you have your program working. To make sure you understand this, try running your own Fishnet with two wrasse nodes, one serving content from your Web pages and the other proxying the fishhead from where you start surfing.
  4. Improve your code to handle multiple concurrent Fishnet connections and data transfer in both directions. You should be able to sanity check this code by using the multiple sendfile commands from the previous assignment.
  5. Write the code that munges a request to add the prefix. You could put this in your Fishnet node, invoke it via a Web browser, print out the munged request, and return a canned reply, e.g., "<HTML><BODY><H1>I was here!</H1></BODY></HTML>" that should appear on your Web server.
  6. Write the code that makes a TCP connection to the Web server, sends the request, reads the response, and closes the connection. Make sure you read the socket handout before doing this. This code is logically quite separate from much of your Fishnet code. To test it, you could get all of this functionality running as a separate program, and have it send a canned request and print out the response. The effect should be similar to using telnet to observe the underlying HTTP behavior.
  7. Put all the pieces together and download pages over your local Fishnet.
  8. You’re done! Read and do any turnin work now.
  9. For Fun. Join the class Fishnet and surf it. We now have a complete, running network.
  10. For Fun. If you really want to learn about sockets, implement the client side that is in wrasse too. You will need to have fish_main() upcall to your code when a new request arrives from the browser. There is a special fishnet API function in fish.h, fish_internal_readhook() that registers a function to be called when a given socket becomes readable.
  1. Turn In and Discussion Questions
  1. Turn in your program source code using turnin, as well as a printed copy for us.
  2. (14 points for the program above and its output here.) Use wrasse and your node to download the reference Web page that we will tell you about. Save the output of your program during the download, print it and turn it in to us.
  3. Question (2 points) Tell us how layering was able to simplify your program development. Tell us where layering did not translate into simple modularity.
  4. Question (2 points) Given that both your node and TCP/IP in the kernel are written in C and ignoring small implementation details, what protocol design factors cause surfing over the Fishnet to be slower than surfing the Web?
  5. Question (2 points) Compare the socket API to the Fishnet API. What are the key differences? Give one advantage of each over the other.

 

—END—