1 / 20

Proxy & Networking 15-213: Introduction to Computer Systems – Recitation H April 11, 2011

Carnegie Mellon. Proxy & Networking 15-213: Introduction to Computer Systems – Recitation H April 11, 2011. Carnegie Mellon. Today. News Proxy Networking. Carnegie Mellon. News. Proxylab out last Thursday Exam in two weeks. Carnegie Mellon. Proxy. Carnegie Mellon. What is a Proxy?.

amma
Download Presentation

Proxy & Networking 15-213: Introduction to Computer Systems – Recitation H April 11, 2011

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Carnegie Mellon Proxy & Networking15-213: Introduction to Computer Systems – Recitation HApril 11, 2011

  2. Carnegie Mellon Today • News • Proxy • Networking

  3. Carnegie Mellon News • Proxylab out last Thursday • Exam in two weeks

  4. Carnegie Mellon Proxy

  5. Carnegie Mellon What is a Proxy? • Intermediary between client and server

  6. Carnegie Mellon Your Proxy • Threaded • Client requests must use different threads • Caching • Content is cached locally and served from there • IPv4 • Only 32-bit addresses: 192.168.99.211 • HTTP • Only serve HTTP/1.0 GET requests

  7. Carnegie Mellon Your Proxy • Both client and server

  8. Carnegie Mellon Recommended Progress • Implement a sequential proxy • Upgrade to a threaded proxy • Make into a caching proxy • Worry about race conditions and proper locking of data structures! (next recitation)

  9. Carnegie Mellon Testing • No autograder • Test simple pages at the beginning and more complicated ones as your proxy improves • Not all pages will work! • Useful: netcat • Client: nc <host> <port> • Server nc –l <port>

  10. Carnegie Mellon Networking

  11. Carnegie Mellon Server • Berkeley Sockets Interface • For making a server: • socket • bind • listen • accept • close

  12. Carnegie Mellon socket(domain, type, protool) intsock_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); • Through which all communication goes through • Domain: Protocol family to use • PF_INET is IPv4 • Type: Type of protocol to use • SOCK_STREAM stream with in-order delivery • Protocol: Specific protocol to use • IPPROTO_TCP means TCP

  13. Carnegie Mellon bind(sock_fd, my_addr, addrlen) structsockaddr_insockaddr; memset(&sockaddr, 0, sizeof(sockaddr); sockaddr.sin_family = AF_INET; sockaddr.sin_addr.s_addr = INADDR_ANY; sockaddr.sin_port = htons(listenPort) err = bind(sock_fd, (structsockaddr *) sockaddr, sizeof(sockaddr)); • sock_fd: file descriptor of socket • my_addr: address to bind to (where we are registering this server) • Information about what the socket will be used for: internet, listening any address, port • addrlen: size of addrstruct

  14. Carnegie Mellon listen(sock_fd, backlog) err = listen(sock_fd, MAX_WAITING_CONNECTIONS); • sock_fd: Socket to listen on • backlog: maximum number of waiting connections

  15. Carnegie Mellon accept(sock_fd, addr, addrlen) structsockaddr_inclient_addr; socklen_tmy_addr_len = sizeof(client_addr); client_fd = accept(listener_fd, &client_addr, &my_addr_len); • sock_fd: Socket to listen on • addr: pointer to sockaddrstruct to hold clisnt information • Find out who connected to you • addrlen: length of the addrstruct • Return: File descriptor!

  16. Carnegie Mellon Client • For connecting to a server: • socket • connect • close

  17. Carnegie Mellon connect(sock_fd, addr, addrlen) structsockaddr_inremote_addr; /* initialize remote_addr */ err = connect(listener_fd, &remote_addr, sizeof(remote_addr)); • sock_fd: Socket to connect with • addr: pointer to sockaddrstruct that holds information about who to connect to • addrlen: length of the addrstruct

  18. Carnegie Mellon close(sock_fd) err = close(sock_fd); • sock_fd: Socket to close

  19. Carnegie Mellon Sending/Receiving Data • send/recv • write/read • func(fd, buffer, buffer_len) • fd: File to write to • buffer: What to write • buffer_len: How many bytes to write • send/recv have extra flags parameter

  20. Carnegie Mellon Questions?

More Related