Carnegie Mellon Proxy Lab Networking Demos and Important Concepts

carnegie mellon n.w
1 / 19
Embed
Share

"Explore Carnegie Mellon's Proxy Lab recitation on networking and proxies, covering the functionality of proxies, data transfer in HTTP, Telnet demonstrations, and more. Dive into the world of proxies as servers and clients to understand their crucial role in networking."

  • Carnegie Mellon
  • Proxy Lab
  • Networking
  • Proxies
  • HTTP

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Carnegie Mellon Recitation 12: ProxyLab Part 1 Instructor: TA(s) 1 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  2. Carnegie Mellon Outline Proxies Networking Networking Demos 2 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  3. Carnegie Mellon Proxy Lab There are no grace days / late submissions 8% of final grade You are submitting an entire project Modify the makefile Split source file into separate pieces Submit regularly to verify proxy builds on Autolab Your proxy is a server, it should not crash! 3 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  4. Carnegie Mellon Why Proxies? Proxies are both clients and servers Can perform useful functions as requests and responses pass by Examples: Caching, logging, anonymization, filtering, transcoding Request foo.html Client A Request foo.html foo.html Origin Server Proxy cache foo.html Request foo.html foo.html Client B 4 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  5. Carnegie Mellon 2. Start client Client 1. Start server Server Echo Server + Client Structure open_listenfd open_clientfd Connection request Await connection request from client accept 3. Exchange fgets rio_writen data rio_readlineb Client / Server Session rio_readlineb fputs rio_writen EOF rio_readlineb close 5. Drop client 4. Disconnect client close 5 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  6. Carnegie Mellon Transferring HTTP Data If something requests a file from a web server, how does it know that the transfer is complete? A) It reads a NULL byte. B) The connection closes. C) It reads a blank line. D) The HTTP header specifies the number of bytes to receive. E) The reading function receives EOF. 6 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  7. Carnegie Mellon Telnet Demo Telnet is valuable for manually testing your proxy What are valid requests to web servers? What do valid replies look like? Connect to a shark machine $ telnet www.cs.cmu.edu 80 GET /~213/recitations/rec12.html HTTP/1.0 <press enter> <press enter> 7 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  8. Carnegie Mellon Echo Demo See the instructions written in the telnet results to set up the echo server. Get someone nearby to connect using the echo client. What does echoserver output? 8 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  9. Carnegie Mellon Echo Demo See the instructions written in the telnet results to set up the echo server. Get someone nearby to connect using the echo client. What does echoserver output? (Sample output:) $ ./echoserver 10101 Accepted connection from hammerheadshark.ics.cs.cmu.edu:46422 hammerheadshark.ics.cs.cmu.edu:46422 sent 6 bytes Disconnected from hammerheadshark.ics.cs.cmu.edu:46422 9 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  10. Carnegie Mellon Echo Demo See the instructions written in the telnet results to set up the echo server. Get someone nearby to connect using the echo client. What does echoserver output? (Sample output:) $ ./echoserver 10101 Accepted connection from hammerheadshark.ics.cs.cmu.edu:46422 hammerheadshark.ics.cs.cmu.edu:46422 sent 6 bytes Disconnected from hammerheadshark.ics.cs.cmu.edu:46422 Server listening port Client port Client host 10 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  11. Carnegie Mellon Echo Demo Look at echoclient.c Opens a connection to the server Reads/writes from the server Look at echoserver output Why is the printed client port different from the server s listening port? 11 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  12. Carnegie Mellon Echo Demo Look at echoclient.c Opens a connection to the server Reads/writes from the server Look at echoserver output Why is the printed client port different from the server s listening port? Server opens one listening port Incoming clients connect to this port Once server accepts a connection, it talks to client on a different ephemeral port Listening port Client connects to server GET /~213/recitations/rec12.html HTTP/1.0 Ephemeral port HTTP/1.1 200 OK Content-Type: text/html 12 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  13. Carnegie Mellon Echo Demo Try to connect two clients to the same server. What happens? 13 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  14. Carnegie Mellon Echo Demo Try to connect two clients to the same server. What happens? Second client has to wait for first client to finish! Server doesn t even accept second client s connection Where/why are we getting stuck? 14 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  15. Carnegie Mellon Echo Demo Try to connect two clients to the same server. What happens? Second client has to wait for first client to finish! Server doesn t even accept second client s connection Where/why are we getting stuck? Because we re stuck in echo() talking to the first client, echoserver can t handle any more clients Solution: multi-threading 15 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  16. Carnegie Mellon Echo Server Multithreaded How might we make this server multithreaded? (Don t look at echoserver_t.c) while (1) { // Allocate space on the stack for client info client_info client_data; client_info *client = &client_data; // Initialize the length of the address client->addrlen = sizeof(client->addr); // Accept() will block until a client connects to the port client->connfd = Accept(listenfd, (SA *) &client->addr, &client->addrlen); // Connection is established; echo to client echo(client); } 16 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  17. Carnegie Mellon Echo Server Multithreaded View the code in echoserver_t.c Nominate one student in class to run the echoserver_t Have several others connect to it 17 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  18. Carnegie Mellon Echo Server Multithreaded echoserver_t.c isn t too different from echoserver.c To see the changes: `diff echoserver.c echoserver_t.c` Making your proxy multithreaded will be very similar However, don t underestimate the difficulty of addressing race conditions between threads! Definitely the hardest part of proxylab More on this next time... 18 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

  19. Carnegie Mellon Reminders Read the writeup Start early Remember, no late submissions Come to office hours this week, before it gets crowded! Work incrementally and take breaks 19 Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Related


More Related Content