proxy networking 15 213 introduction to computer systems recitation h april 11 2011 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Proxy & Networking 15-213: Introduction to Computer Systems – Recitation H April 11, 2011 PowerPoint Presentation
Download Presentation
Proxy & Networking 15-213: Introduction to Computer Systems – Recitation H April 11, 2011

Loading in 2 Seconds...

play fullscreen
1 / 20

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


  • 107 Views
  • Uploaded on

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?.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Proxy & Networking 15-213: Introduction to Computer Systems – Recitation H April 11, 2011' - amma


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
today

Carnegie Mellon

Today
  • News
  • Proxy
  • Networking
slide3

Carnegie Mellon

News
  • Proxylab out last Thursday
  • Exam in two weeks
what is a proxy

Carnegie Mellon

What is a Proxy?
  • Intermediary between client and server
your proxy

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
your proxy1

Carnegie Mellon

Your Proxy
  • Both client and server
recommended progress

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)
testing

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>
server

Carnegie Mellon

Server
  • Berkeley Sockets Interface
  • For making a server:
    • socket
    • bind
    • listen
    • accept
    • close
socket domain type protool

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
bind sock fd my addr addrlen

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
listen sock fd backlog

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
accept sock fd addr addrlen

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!
client

Carnegie Mellon

Client
  • For connecting to a server:
    • socket
    • connect
    • close
connect sock fd addr addrlen

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
close sock fd

Carnegie Mellon

close(sock_fd)

err = close(sock_fd);

  • sock_fd: Socket to close
sending receiving data

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