1 / 33

Network Servers: URIs, HTTP, RPC

Network Servers: URIs, HTTP, RPC. Jeff Chase Duke University. Heap manager. Hours spent for 90+ points: 4, 4, 5, 6, 6, 8, 10, 10, 10, 10, 12,… 20, 20+, 24, 40, 65 If it were a contest, winners are: 13 students: 92-93% success rate on canned test

christiew
Download Presentation

Network Servers: URIs, HTTP, RPC

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. Network Servers: URIs, HTTP, RPC Jeff Chase Duke University

  2. Heap manager • Hours spent for 90+ points: • 4, 4, 5, 6, 6, 8, 10, 10, 10, 10, 12,… • 20, 20+, 24, • 40, 65 • If it were a contest, winners are: • 13 students: 92-93% success rate on canned test • Tyler Nisonoff: consumes half the CPU as runner up, 92% • Ben Berg • Tamara Silbergleit • Ang Li • Kuang Han • Matthew Tse

  3. MacOS X “tiny” heap

  4. MacOS X “small” heap

  5. Heap manager: lessons • “Real” heap managers are more complex: • They maintain multiple free lists for different size blocks. • And possibly different data structures for different size blocks. • Be sure that you understand why. • Debugging takes a lot of time and doesn’t teach you much and forces you to sit in front of a computer which is unhealthy and painful and frustrating when you could be outside in sunlight and fresh air. • Thought question: what do you wish we had told you?

  6. End-to-end application delivery Where is your application? Where is your data? Where is your OS? Cloud and Software-as-a-Service (SaaS) Rapid evolution, no user upgrade, no user data management. Agile/elastic deployment on virtual infrastructure.

  7. Services RPC service GET (HTTP) etc. content provider Server listens for and accepts clients, handles requests, sends replies Clients initiate connection and send requests.

  8. Networking endpoint port operations advertise (bind) listen connect (bind) close write/send read/receive channel binding connection node A node B Some IPC mechanisms allow communication across a network. E.g.: sockets using Internet communication protocols (TCP/IP). Each endpoint on a node (host) has a port number. Each node has one or more interfaces, each on at most one network. Each interface may be reachable on its network by one or more names. E.g. an IP address and an (optional) DNS name.

  9. A simple, familiar example “GET /images/fish.gif HTTP/1.1”

  10. URL

  11. URIs and URLs [image: msdn.microsoft.com]

  12. Android content providers: URIs Define the provider's authority string, its content URIs, and column names….To avoid conflicts with other providers, you should use Internet domain ownership (in reverse) as the basis …for Android package names…define your provider authority as an extension of the name of the package containing [it]… Developers usually create content URIs from the authority by appending paths that point to individual tables… By convention, providers offer access to a single row in a table by accepting a content URI with an ID value for the row at the end of the URI. … [images from http://www.tutos-android.com/contentprovider-android]

  13. Taking it to the net

  14. The network stack NFS (files) HTTP (web) SMTP (email) SSH (login) Applications RPC Abstraction Transport (L4) UDP TCP Network packet (L3) IP Ethernet ATM PPP Interfaces

  15. RPC call send Client stub recv return send return Server stub call recv

  16. RPC: Language Integration Stubs link with the client/server code to “hide” the boundary crossing. • Marshal arguments/results • Propagate exceptions • Binding: need some way to name the server • Stubs are auto-generated from an Interface Description Language (IDL) file.

  17. RPC Execution • How is this different from a local procedure call? • How is it different from a system call?

  18. The network stack, simplified Internet client host Internet server host Client Server User code Sockets interface (system calls) TCP/IP TCP/IP Kernel code Hardware interface (interrupts) Hardware and firmware Network adapter Network adapter Global IP Internet

  19. Web services • HTTP is the standard for web systems. • GET, PUT, POST, DELETE • Various standards and styles layer above it. • The Android content provider URI form is in the style of REST, as used in popular SaaS frameworks. • What’s important is that the URI/URL authority always has the info to bind a channel to the server. • Translate domain name to an IP address and port using DNS service (later). • The URI path is interpreted by the server: it may encode the name of a file on the server, or a program entry point and arguments, or…

  20. “Web-oriented architecture” “CRUD”

  21. TCP/IP connection socket socket Client Server TCP byte-stream connection (128.2.194.242, 208.216.181.15) Client host address 128.2.194.242 Server host address 208.216.181.15 [adapted from CMU 15-213]

  22. TCP/IP connection Client socket address 128.2.194.242:51213 Server socket address 208.216.181.15:80 Client Server (port 80) Connection socket pair (128.2.194.242:51213, 208.216.181.15:80) Client host address 128.2.194.242 Server host address 208.216.181.15 Note: 80 is a well-known port associated with Web servers Note: 51213 is an ephemeral port allocated by the kernel [adapted from CMU 15-213]

  23. TCP/IP Ports • What port number to connect to? • We have to agree on well-known ports for common services • Look at /etc/services • Ports 1023 and below are ‘reserved’ This port abstraction is an Internet Protocol (L4) concept. • Source/dest port is named in every packet. • Kernel looks at port to demultiplex incoming traffic. • Clients need a return port, but it can be an ephemeral port assigned dynamically by the kernel.

  24. Packet demultiplexing

  25. 128.36.232.5128.36.230.2 TCP socket space state: listening address: {*.6789, *.*} completed connection queue: sendbuf: recvbuf: state: established address: {128.36.232.5:6789, 198.69.10.10.1500} sendbuf: recvbuf: state: listening address: {*.25, *.*} completed connection queue: sendbuf: recvbuf: WebServer Flow Create ServerSocket connSocket = accept() read request from connSocket read local file write file to connSocket close connSocket Discussion: what does step do and how longdoes it take?

  26. Server listens on a socket struct sockaddr_in socket_addr; sock = socket(PF_INET, SOCK_STREAM, 0); int on = 1; setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on); memset(&socket_addr, 0, sizeof socket_addr); socket_addr.sin_family = PF_INET; socket_addr.sin_port = htons(port); socket_addr.sin_addr.s_addr = htonl(INADDR_ANY); if (bind(sock, (struct sockaddr *)&socket_addr, sizeof socket_addr) < 0) { perror("couldn't bind"); exit(1); } listen(sock, 10);

  27. Accept loop while (1) { int acceptsock = accept(sock, NULL, NULL); char *input = (char *)malloc(1024*sizeof (char)); recv(acceptsock, input, 1024, 0); int is_html = 0; char *contents = handle(input,&is_html); free(input); …send response… close(acceptsock); }

  28. Send HTTP/HTML response const char *resp_ok = "HTTP/1.1 200 OK\nServer: BuggyServer/1.0\n"; const char *content_html = "Content-type: text/html\n\n"; send(acceptsock, resp_ok, strlen(resp_ok), 0); send(acceptsock, content_html, strlen(content_html), 0); send(acceptsock, contents, strlen(contents), 0); send(acceptsock, "\n", 1, 0); free(contents);

  29. Anatomy of an HTTP Transaction unix> telnet www.aol.com 80Client: open connection to server Trying 205.188.146.23... Telnet prints 3 lines to the terminal Connected to aol.com. Escape character is '^]'. GET / HTTP/1.1 Client: request line host: www.aol.com Client: required HTTP/1.1 HOST header Client: empty line terminates headers. HTTP/1.0 200 OK Server: response line MIME-Version: 1.0 Server: followed by five response headers Date: Mon, 08 Jan 2001 04:59:42 GMT Server: NaviServer/2.0 AOLserver/2.3.3 Content-Type: text/html Server: expect HTML in the response body Content-Length: 42092 Server: expect 42,092 bytes in the resp body Server: empty line (“\r\n”) terminates hdrs <html> Server: first HTML line in response body ... Server: 766 lines of HTML not shown. </html> Server: last HTML line in response body Connection closed by foreign host. Server: closes connection unix> Client: closes connection and terminates [CMU 15-213]

  30. A Short Quiz: HTTPS/SSL • What is the most important advantage of symmetric crypto (DES) relative to asymmetric crypto (RSA)? • What is the most important advantage of asymmetric crypto relative to symmetric crypto? • What is the most important limitation/challenge for asymmetric crypto with respect to security? • Why does SSL “change ciphers” during the handshake? • How does SSL solve the key distribution problem for symmetric crypto? • Is key exchange vulnerable to man-in-the-middle attacks?

More Related