RailsConf 2016: Pat Packet visits Ruby Rails

RailsConf 2016: Pat Packet visits Ruby Rails

94bd558238b69c45d3d3e15797ae94f7?s=128

Jeremy Fairbank

May 04, 2016
Tweet

Transcript

  1. 1.

    Pat Packet Visits Ruby Rails by: Jeremy Fairbank @elpapapollo |

    github.com/jfairbank illustrations: Marissa Roeper marissaroeper.com
  2. 3.
  3. 4.

    ?

  4. 5.

    HTTP DNS TCP/IP ROUTING GET / HTTP/1.1 
 Host: rubyonrails.org

    Accept: text/html Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8 Cache-Control: no-cache Connection: keep-alive 
 Hello World The Message
  5. 9.

    Package Address Continent Kingdom Train Router Station Network Packet IP

    Address Physical Device Software Server Connection Router/Switch Legend
  6. 10.
  7. 11.
  8. 12.
  9. 13.
  10. 14.

    WAN - Wide Area Network The Internet LAN - Local

    Area Network Router + computers Protocol Official rules/guidelines to follow HTTP - Hyper Text Transfer Protocol Protocol for HTML, JSON, XML
  11. 16.

    GET / HTTP/1.1 Host: rubyonrails.org Accept: text/html Accept-Encoding: gzip, deflate,

    sdch Accept-Language: en-US,en;q=0.8 Cache-Control: no-cache Connection: keep-alive 
 Hello World Request Line Method Resource HTTP Version HTTP Request Headers Optional Message
  12. 18.

    GET Can you send me your home page? GET /

    HTTP/1.1 POST PUT DELETE HTTP Methods
  13. 19.

    GET Can you send me your home page? POST Here

    is my shopping cart for checkout. PUT DELETE POST /checkout HTTP/1.1 HTTP Methods
  14. 20.

    GET Can you send me your home page? POST Here

    is my shopping cart for checkout. PUT I changed my name. Can you please update your records? DELETE PUT /user/info HTTP/1.1 HTTP Methods
  15. 21.

    GET Can you send me your home page? POST Here

    is my shopping cart for checkout. PUT I changed my name. Can you please update your records? DELETE I no longer use this address. Can you remove it? DELETE /address/2 HTTP/1.1 HTTP Methods
  16. 22.

    Meta data is like saying I’d prefer the list of

    friends in HTML. Data is like saying Please send me a list of my friends. HTTP Headers
  17. 24.

    Send back whatever you have. Accept: */* Accept: text/html Content-Type:

    application/json Host: rubyonrails.org Content-Length: 42 Key Value HTTP Headers
  18. 25.

    Send back HTML please. Accept: */* Accept: text/html Content-Type: application/json

    Host: rubyonrails.org Content-Length: 42 Key Value HTTP Headers
  19. 26.

    I’m sending you some JSON. Accept: */* Accept: text/html Content-Type:

    application/json Host: rubyonrails.org Content-Length: 42 Key Value HTTP Headers
  20. 27.

    Please give this message to rubyonrails.org. Accept: */* Accept: text/html

    Content-Type: application/json Host: rubyonrails.org Content-Length: 42 Key Value HTTP Headers
  21. 28.

    Here’s how much information I’m sending. Accept: */* Accept: text/html

    Content-Type: application/json Host: rubyonrails.org Content-Length: 42 Key Value HTTP Headers
  22. 29.

    Status Line Headers Message HTTP/1.1 200 OK Server: GitHub.com Date:

    Sun, 17 Apr 2016 11:19:48 GMT Content-Type: text/html; charset=utf-8 Content-Length: 4127 Last-Modified: Tue, 01 Mar 2016 10:32:49 GMT 
 <html><body>Ruby on Rails!</body></html> HTTP Version Status Code Status Description HTTP Reply
  23. 32.

    HTTP/1.1 304 Not Modified 200 All good. Here’s your reply.

    304 Nothing changed. Keep what you already have. 404 401 500 HTTP Statuses
  24. 33.

    HTTP/1.1 404 Not Found 200 All good. Here’s your reply.

    304 Nothing changed. Keep what you already have. 404 Sorry, I can’t find that. 401 500 HTTP Statuses
  25. 34.

    HTTP/1.1 401 Unauthorized 200 All good. Here’s your reply. 304

    Nothing changed. Keep what you already have. 404 Sorry, I can’t find that. 401 Sorry, you’re not allowed to request that. 500 HTTP Statuses
  26. 35.

    HTTP/1.1 500 Internal Server Error 200 All good. Here’s your

    reply. 304 Nothing changed. Keep what you already have. 404 Sorry, I can’t find that. 401 Sorry, you’re not allowed to request that. 500 Sorry, we’re having problems right now. HTTP Statuses
  27. 36.

    GET / HTTP/1.1 Host: rubyonrails.org Accept: text/html Accept-Encoding: gzip, deflate,

    sdch Accept-Language: en-US,en;q=0.8 Cache-Control: no-cache Connection: keep-alive
  28. 37.

    DNS - Domain Name System Where is rubyonrails.org? Oh, you

    can find it at 192.30.252.153. Translate domain names into IP addresses. Client DNS Server
  29. 38.
  30. 39.
  31. 40.
  32. 41.
  33. 42.
  34. 43.
  35. 44.
  36. 45.
  37. 46.
  38. 50.

    Local Resolver (e.g. at internet service provider) rubyonrails.org? RECURSIVE Root

    Kingdoms DNS TLDs .org .com .net .io ? ITERATIVE (keep trying)
  39. 51.

    Local Resolver (e.g. at internet service provider) rubyonrails.org? RECURSIVE Root

    Kingdoms DNS TLDs .org .com .net .io NS a0.org… a2.org… ? Try these kingdoms. ITERATIVE (keep trying)
  40. 53.

    Local Resolver (e.g. at internet service provider) TLD Kingdoms DNS

    Please associate rubyonrails.org with my IP address. ns1.gratisdns.dk. ns2.gratisdns.dk. NS Kingdoms Please associate us with rubyonrails.org.
  41. 54.

    Local Resolver (e.g. at internet service provider) TLD Kingdoms DNS

    ? NS ns1.gratisdns.dk. ns2.gratisdns.dk. Try these kingdoms. NS Kingdoms
  42. 58.

    Local Resolver (e.g. at internet service provider) DNS NS Kingdoms

    rubyonrails.org? A 192.30.252.153 rubyonrailsftw.com?
  43. 59.

    Local Resolver (e.g. at internet service provider) DNS NS Kingdoms

    rubyonrails.org? A 192.30.252.153 rubyonrailsftw.com? CNAME rubyonrails.org.
  44. 62.
  45. 63.
  46. 64.
  47. 67.
  48. 69.

    ACKnowledging the package. Here’s your reply. ACK I’m not sure

    you got that package. I’ll try again! ? X
  49. 70.
  50. 71.

    X X X X X X X X X X

    X X X Congestion
  51. 75.
  52. 76.

    2 3 ACK 1 1 Awaiting delivery 2 Delivered Sliding

    Window (being delivered) TCP Congestion Control
  53. 77.

    2 3 ACK 1 1 Awaiting delivery 2 Delivered Sliding

    Window (being delivered) TCP Congestion Control X X
  54. 78.

    2 3 ACK 1 1 Awaiting delivery 1 Delivered Sliding

    Window (being delivered) TCP Congestion Control X X
  55. 79.

    2 3 ACK 1 1 Awaiting delivery 1 Delivered Sliding

    Window (being delivered) TCP Congestion Control X X 2
  56. 80.
  57. 82.

    SYN TCP Connections - 3 way handshake 1. Client (requester)

    requests connection with SYNchronize packet. 1
  58. 83.

    ACK-SYN Window = 1 SYN TCP Connections - 3 way

    handshake 1. Client (requester) requests connection with SYNchronize packet. 2. Server (recipient) ACKnowledges SYN and sends its own SYN. Server can specify initial window size to prevent too much coming in. 1 2
  59. 84.

    ACK-SYN Window = 1 SYN TCP Connections - 3 way

    handshake ACK 1. Client (requester) requests connection with SYNchronize packet. 2. Server (recipient) ACKnowledges SYN and sends its own SYN. Server can specify initial window size to prevent too much coming in. 3. Client ACKnowledges server’s SYN and connection is established. 1 3 2
  60. 85.
  61. 89.
  62. 90.
  63. 91.

    Destination Next Hop 23.235.44.0/24 192.168.1.1 104.0.0.0/8 192.168.2.1 192.30.0.0/16 192.168.3.1 23.21.0.0/16

    192.168.4.1 Routing Tables Tell which location to go to next for a range of IP addresses. IP Address Range with CIDR Path to follow, i.e. the next router
  64. 93.

    192.30.252.153 8 bits = 2^8 = 256 numbers => 0-255

    4 of 2^8 => 0-255.0-255.0-255.0-255 IPV4 Addresses - Dotted Quads 0—255 1st quad 0—255 2nd quad 0—255 3rd quad 0—255 4th quad
  65. 94.

    CIDR — Classless Inter-domain Routing 192.30.0.0/16 192.30.0.0/8 1. Use the

    first /8 bits to mask the first quad. Masks “lock” a number in. 2. Use the next /8 bits to mask the second quad. 3. This leaves a range of possible IP addresses to find a match in. 192.30.0.0/0 192.30.0-255.0-255 -or- 192.30.0.0 - 192.30.255.255
  66. 95.

    Destination Next Hop 23.235.44.0/24 192.168.1.1 192.30.0.0/16 192.168.3.1 23.21.0.0/16 192.168.4.1 Destination

    Next Hop 107.20.0.0/16 192.168.5.1 192.30.252.0/24 192.168.6.1 Destination Next Hop 192.30.252.50.144/28 192.168.7.1 192.30.0.0/16 192.168.8.1 192.30.252.153? Routing Range grows smaller and more specific (mask grows larger).
  67. 96.
  68. 97.
  69. 100.

    Router Buffer (hold unprocessed packets) No room for packets. They

    must be dropped. Requester must try again and potentially slow down sending rate.
  70. 101.

    Router Buffer (hold unprocessed packets) No room for packets. They

    must be dropped. Requester must try again and potentially slow down sending rate. Slow down please! X X
  71. 102.

    Router Buffer (hold unprocessed packets) No room for packets. They

    must be dropped. Requester must try again and potentially slow down sending rate. Slow down please! X X
  72. 103.
  73. 104.
  74. 105.
  75. 106.
  76. 107.

    GET / HTTP/1.1 Host: rubyonrails.org Accept: text/html Accept-Encoding: gzip, deflate,

    sdch Accept-Language: en-US,en;q=0.8 Cache-Control: no-cache Connection: keep-alive
  77. 108.
  78. 109.
  79. 112.

    • Physical distance and latency unavoidable • Persistent/shared TCP connections

    • Caching DNS queries • Caching HTML, scripts, images, etc. • Content distribution networks (CDNs) and mirrors • HTTP 2 Performance Matters!
  80. 113.

    • https://commons.wikimedia.org/wiki/File:Cartoon_cloud.svg • https://commons.wikimedia.org/wiki/File:Checkmark_green.svg • https://commons.wikimedia.org/wiki/File:Computer.svg • https://commons.wikimedia.org/wiki/File:Gnome-web-browser.svg • https://commons.wikimedia.org/wiki/File:Modern_clock_chris_kemps_01.svg

    • https://commons.wikimedia.org/wiki/File:Network-server.svg • https://commons.wikimedia.org/wiki/File:Server-web.svg • https://commons.wikimedia.org/wiki/File:Server.svg • https://commons.wikimedia.org/wiki/File:Simple_crown_icon.svg • https://pixabay.com/en/metro-subway-tramway-159004/ • https://pixabay.com/en/postal-parcel-post-package-32383/ • https://pixabay.com/en/subway-map-transportation-metro-576776/ • https://upload.wikimedia.org/wikipedia/commons/3/3e/I-80_Eastshore_Fwy.jpg • https://commons.wikimedia.org/wiki/File:Osa_device-wireless-router.svg Sources