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. Pat Packet Visits Ruby Rails by: Jeremy Fairbank @elpapapollo |

    github.com/jfairbank illustrations: Marissa Roeper marissaroeper.com
  2. We help brands excel. pushagency.io Your website, SimplyBuilt. simplybuilt.com

  3. None
  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
  6. HTTP DNS TCP/IP ROUTING The Destination rubyonrails.org 192.30.252.153

  7. The Transportation HTTP DNS TCP/IP ROUTING

  8. The Directions HTTP DNS TCP/IP ROUTING

  9. Package Address Continent Kingdom Train Router Station Network Packet IP

    Address Physical Device Software Server Connection Router/Switch Legend
  10. None
  11. None
  12. None
  13. None
  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
  15. Can you send me your home page? Request Sure thing!

    Here you go! Reply
  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
  17. GET POST PUT DELETE HTTP Methods

  18. GET Can you send me your home page? GET /

    HTTP/1.1 POST PUT DELETE HTTP Methods
  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
  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
  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
  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
  23. Accept: */* Accept: text/html Content-Type: application/json Host: rubyonrails.org Content-Length: 42

    Key Value HTTP Headers
  24. Send back whatever you have. Accept: */* Accept: text/html Content-Type:

    application/json Host: rubyonrails.org Content-Length: 42 Key Value HTTP Headers
  25. Send back HTML please. Accept: */* Accept: text/html Content-Type: application/json

    Host: rubyonrails.org Content-Length: 42 Key Value HTTP Headers
  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
  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
  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
  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
  30. 200 304 404 401 500 HTTP Statuses

  31. HTTP/1.1 200 OK 200 All good. Here’s your reply. 304

    404 401 500 HTTP Statuses
  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
  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
  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
  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
  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
  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
  38. None
  39. None
  40. None
  41. None
  42. None
  43. None
  44. None
  45. None
  46. None
  47. Local Resolver (e.g. at internet service provider) Root Kingdoms DNS

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

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

    Kingdoms DNS ? ITERATIVE (keep trying)
  50. Local Resolver (e.g. at internet service provider) rubyonrails.org? RECURSIVE Root

    Kingdoms DNS TLDs .org .com .net .io ? ITERATIVE (keep trying)
  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)
  52. Local Resolver (e.g. at internet service provider) TLD Kingdoms DNS

    NS Kingdoms
  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.
  54. Local Resolver (e.g. at internet service provider) TLD Kingdoms DNS

    ? NS ns1.gratisdns.dk. ns2.gratisdns.dk. Try these kingdoms. NS Kingdoms
  55. Local Resolver (e.g. at internet service provider) DNS NS Kingdoms

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

    rubyonrails.org?
  57. Local Resolver (e.g. at internet service provider) DNS NS Kingdoms

    rubyonrails.org? A 192.30.252.153
  58. Local Resolver (e.g. at internet service provider) DNS NS Kingdoms

    rubyonrails.org? A 192.30.252.153 rubyonrailsftw.com?
  59. Local Resolver (e.g. at internet service provider) DNS NS Kingdoms

    rubyonrails.org? A 192.30.252.153 rubyonrailsftw.com? CNAME rubyonrails.org.
  60. Local Resolver (e.g. at internet service provider) Root Kingdoms TLD

    Kingdoms DNS NS Kingdoms A Hierarchy
  61. Local Resolver (e.g. at internet service provider) Root Kingdoms TLD

    Kingdoms DNS NS Kingdoms A Hierarchy
  62. x 4 billion IP addresses = LOTS of storage Can

    you all update my address?
  63. None
  64. None
  65. TCP/IP Transmission Control Protocol

  66. TCP/IP Transmission Control Protocol

  67. None
  68. ACKnowledging the package. Here’s your reply. ACK

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

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

    X X X Congestion
  72. Sliding Window (being delivered) Awaiting delivery 1 TCP Congestion Control

  73. Sliding Window (being delivered) Awaiting delivery 1 1 TCP Congestion

    Control
  74. Sliding Window (being delivered) Awaiting delivery 1 ACK 1 1

    TCP Congestion Control
  75. ACK 1 1 Awaiting delivery 2 Delivered Sliding Window (being

    delivered) TCP Congestion Control
  76. 2 3 ACK 1 1 Awaiting delivery 2 Delivered Sliding

    Window (being delivered) TCP Congestion Control
  77. 2 3 ACK 1 1 Awaiting delivery 2 Delivered Sliding

    Window (being delivered) TCP Congestion Control X X
  78. 2 3 ACK 1 1 Awaiting delivery 1 Delivered Sliding

    Window (being delivered) TCP Congestion Control X X
  79. 2 3 ACK 1 1 Awaiting delivery 1 Delivered Sliding

    Window (being delivered) TCP Congestion Control X X 2
  80. None
  81. TCP Connections - 3 way handshake

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

    requests connection with SYNchronize packet. 1
  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
  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
  85. None
  86. 1 Sliding Window 1 2 2 1 Sequence Numbers

  87. 1 Sliding Window 1 2 2 1 Sequence Numbers Got

    #1… ACK 1
  88. Sliding Window 1 2 2 1 Sequence Numbers Got #1…

    And #2! 2 ACK 1 ACK 2
  89. None
  90. None
  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
  92. CIDR — Classless Inter-domain Routing 192.30.0.0/16

  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
  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
  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).
  96. None
  97. None
  98. Router Buffer (hold unprocessed packets)

  99. Router Buffer (hold unprocessed packets)

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

    must be dropped. Requester must try again and potentially slow down sending rate.
  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
  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
  103. None
  104. None
  105. None
  106. None
  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
  108. None
  109. None
  110. DNS Destination Next Hop 192.30.0.0/16 192.168.3.1 Routing TCP/IP ACK Recap

  111. DNS Destination Next Hop 192.30.0.0/16 192.168.3.1 Routing TCP/IP ACK Recap

  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!
  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
  114. Acknowledgement Illustrations by Marissa Roeper marissaroeper.com

  115. Thanks! by: Jeremy Fairbank @elpapapollo | github.com/jfairbank illustrations: Marissa Roeper

    marissaroeper.com