Slide 1

Slide 1 text

Pat Packet Visits Ruby Rails by: Jeremy Fairbank @elpapapollo | github.com/jfairbank illustrations: Marissa Roeper marissaroeper.com

Slide 2

Slide 2 text

We help brands excel. pushagency.io Your website, SimplyBuilt. simplybuilt.com

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

?

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

HTTP DNS TCP/IP ROUTING The Destination rubyonrails.org 192.30.252.153

Slide 7

Slide 7 text

The Transportation HTTP DNS TCP/IP ROUTING

Slide 8

Slide 8 text

The Directions HTTP DNS TCP/IP ROUTING

Slide 9

Slide 9 text

Package Address Continent Kingdom Train Router Station Network Packet IP Address Physical Device Software Server Connection Router/Switch Legend

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Can you send me your home page? Request Sure thing! Here you go! Reply

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

GET POST PUT DELETE HTTP Methods

Slide 18

Slide 18 text

GET Can you send me your home page? GET / HTTP/1.1 POST PUT DELETE HTTP Methods

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

Send back whatever you have. Accept: */* Accept: text/html Content-Type: application/json Host: rubyonrails.org Content-Length: 42 Key Value HTTP Headers

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

I’m sending you some JSON. Accept: */* Accept: text/html Content-Type: application/json Host: rubyonrails.org Content-Length: 42 Key Value HTTP Headers

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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 
 Ruby on Rails! HTTP Version Status Code Status Description HTTP Reply

Slide 30

Slide 30 text

200 304 404 401 500 HTTP Statuses

Slide 31

Slide 31 text

HTTP/1.1 200 OK 200 All good. Here’s your reply. 304 404 401 500 HTTP Statuses

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

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)

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

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.

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

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

Slide 57

Slide 57 text

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

Slide 58

Slide 58 text

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

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

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

Slide 61

Slide 61 text

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

Slide 62

Slide 62 text

x 4 billion IP addresses = LOTS of storage Can you all update my address?

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

TCP/IP Transmission Control Protocol

Slide 66

Slide 66 text

TCP/IP Transmission Control Protocol

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

ACKnowledging the package. Here’s your reply. ACK

Slide 69

Slide 69 text

ACKnowledging the package. Here’s your reply. ACK I’m not sure you got that package. I’ll try again! ? X

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

X X X X X X X X X X X X X Congestion

Slide 72

Slide 72 text

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

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

Sliding Window (being delivered) Awaiting delivery 1 ACK 1 1 TCP Congestion Control

Slide 75

Slide 75 text

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

Slide 76

Slide 76 text

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

Slide 77

Slide 77 text

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

Slide 78

Slide 78 text

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

Slide 79

Slide 79 text

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

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

TCP Connections - 3 way handshake

Slide 82

Slide 82 text

SYN TCP Connections - 3 way handshake 1. Client (requester) requests connection with SYNchronize packet. 1

Slide 83

Slide 83 text

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

Slide 84

Slide 84 text

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

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

1 Sliding Window 1 2 2 1 Sequence Numbers

Slide 87

Slide 87 text

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

Slide 88

Slide 88 text

Sliding Window 1 2 2 1 Sequence Numbers Got #1… And #2! 2 ACK 1 ACK 2

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

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

Slide 92

Slide 92 text

CIDR — Classless Inter-domain Routing 192.30.0.0/16

Slide 93

Slide 93 text

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

Slide 94

Slide 94 text

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

Slide 95

Slide 95 text

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

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

Router Buffer (hold unprocessed packets)

Slide 99

Slide 99 text

Router Buffer (hold unprocessed packets)

Slide 100

Slide 100 text

Router Buffer (hold unprocessed packets) No room for packets. They must be dropped. Requester must try again and potentially slow down sending rate.

Slide 101

Slide 101 text

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

Slide 102

Slide 102 text

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

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

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

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

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

Slide 111

Slide 111 text

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

Slide 112

Slide 112 text

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

Slide 113

Slide 113 text

• 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

Slide 114

Slide 114 text

Acknowledgement Illustrations by Marissa Roeper marissaroeper.com

Slide 115

Slide 115 text

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