Q: How does the internet work? by @cba (slides for a talk given to - - PowerPoint PPT Presentation

q how does the internet work by cba
SMART_READER_LITE
LIVE PREVIEW

Q: How does the internet work? by @cba (slides for a talk given to - - PowerPoint PPT Presentation

Q: How does the internet work? by @cba (slides for a talk given to hackbright on 3/16/16) Bare bones: how can we send a message between two computers connected by a metal wire? digital signals 0 11 0 11 0 frame =datagram = packet


slide-1
SLIDE 1

Q: How does the internet work? by @cba

(slides for a talk given to hackbright

  • n 3/16/16)
slide-2
SLIDE 2

Bare bones: how can we send a message between two computers connected by a metal wire?

slide-3
SLIDE 3

0 11 0 11 0 digital signals

slide-4
SLIDE 4

frame =datagram = packet

0110110101100001

slide-5
SLIDE 5

0110110101100001 1110001010000000

slide-6
SLIDE 6

0110110101100001 1110001010000000

if you detect a request while you are writing a request, back off for a random amount of time and try again until you succeed

Collisions:

slide-7
SLIDE 7

There are more than two computers on the internet

slide-8
SLIDE 8

1110001010000000 1110001010000000 1 1 1 1 1

Broadcasting:

every message is received by every node.

slide-9
SLIDE 9

1110001010000000 1110001010000000 1 1 1 1 1

How can you tell if the message was for you?

slide-10
SLIDE 10

Names! (addresses)

A B C

slide-11
SLIDE 11

A B C

t

  • :

A f r

  • m

: C m e s s a g e : h e y !

reads but discards message reads message you’ve got mail

slide-12
SLIDE 12

00 01 10

destination: 00 source: 10 payload: a

0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 0

dest 2 bits payload 12 bits src 2 bits

  • ur simplistic totally

made up data frame specification

slide-13
SLIDE 13

The Real World, part 1

MAC Addresses:

  • physical addresses hard coded into

networking equipment.

  • never changes for the lifetime of the

device.

slide-14
SLIDE 14

Ethernet

Frame Specification

7 1 6 6 2 1500 4

size in 8 bit bytes

  • family of physical layer protocols
  • 802.11 = wifi, 802.3= wired
  • many versions
slide-15
SLIDE 15

a8:66:7f:04:41:3d 0a:66:7f:04:41:3d ee:e3:8f:ab:a3:d7

with MAC and Ethernet, we can form a basic network, where all participants are directly connected and receive/filter all traffic, but…

slide-16
SLIDE 16

There are more than three computers on the internet

slide-17
SLIDE 17

The entire world can’t be a physically linked broadcast network…

  • too many MAC address

to know

  • not enough bandwidth
  • many other problems.
slide-18
SLIDE 18

Internet Protocol

(you can call me IP)

Every node no longer needs to be physically connected. Messages travel through other nodes, hop by hop, only receiving messages destined for them. Comes with a fancy new global dynamic address space.

slide-19
SLIDE 19

IP addresses

  • globally unique
  • managed by ICANN
  • have a known location
  • are not fixed to your device,

but acquired every time you connect to a network.

  • ipv4: 73.170.239.3
  • ipv6: fe80::aa66:7fff:fe04:413
slide-20
SLIDE 20

header payload same idea as ethernet frame

  • has a source, destination and payload
  • now it’s called a packet

IP Packet - variable width, max 65,000 bytes

slide-21
SLIDE 21
  • what do we do with our IP packet?
  • we can’t write it directly to the wire

payload IP Source IP Dest IP Packet

slide-22
SLIDE 22

Data Encapsulation!

  • Hitch a ride on an ethernet frame

Ethernet Frame payload MAC Source MAC Dest payload IP Source IP Dest IP Packet

slide-23
SLIDE 23

Ethernet IP Link/Physical Layer Internet Layer ?? ??

protocols all the way down

slide-24
SLIDE 24

A A A A 1 1 2 A IP packet: passed along each hop on a new ethernet frame Ethernet Frame: exists for 1 hop then is unpacked 2 A

slide-25
SLIDE 25

When you send an IP packet, routers all over the world forward it in ~ the right direction until it reaches its destination. If an optimal node goes missing, the message will get passed in a different direction, slower and more hops, but it will usually* arrive

slide-26
SLIDE 26
slide-27
SLIDE 27
slide-28
SLIDE 28

we can now send a message to any computer in the world

What’s not to love?

  • packets can go

missing

  • they can arrive out of
  • rder
  • they can be corrupted

in transit

  • they have a size limit

IP Layer:

slide-29
SLIDE 29

Ethernet IP Link/Physical Layer Internet Layer ?? ??

Time for another protocol: ?

slide-30
SLIDE 30

Ethernet IP Link/Physical Layer Internet Layer Transport Layer ??

Time for another protocol: TCP

TCP

slide-31
SLIDE 31

TCP

slide-32
SLIDE 32

message delivery over the connection is

  • reliable
  • ordered
  • corruption free

TCP provides a new abstraction: connections

slide-33
SLIDE 33

Connections:

  • tied to a port number
  • state is kept on both machines for

longer than a single packet

handshake, agree to open connection either side can send data over the connection

slide-34
SLIDE 34

Reliability: segments and acks sk8er-boi.mp3

ACK 1 1 1 2 3 ACK 2 2

slide-35
SLIDE 35

Data Encapsulation!

  • Hitch a ride on an IP packet

payload

MAC src MAC dest

Ethernet payload

IP src IP dest

TCP Segment IP Packet

dest port sequence # payload src port

slide-36
SLIDE 36

h = 104 = 01101000 e = 101 = 01100101 y = 121 = 01111001 Corruption free: checksums Message: hey

101000110 +

ascii decimal ascii binary

<- basic checksum

slide-37
SLIDE 37

Ports

  • port numbers identify TCP connections
  • allows a computer to have multiple

simultaneous connections open

  • many are “reserved” for certain

applications (more on this later) port 80: HTTP port 403: HTTPS port 22: SSH

slide-38
SLIDE 38

we can now send and receive arbitrary length messages reliably

What’s not to love?

  • nothing really, TCP is awesome and

there are countless user applications we can build on top of it.

TCP layer:

slide-39
SLIDE 39

Ethernet IP Link/Physical Layer Internet Layer Transport Layer Application Layer

Time for another protocol: HTTP

TCP HTTP

slide-40
SLIDE 40

Userland

Link/Physical Layer Internet Layer Transport Layer

Application

implemented in networking hardware implemented by the operating system kernel implemented by user programs exposed to the user through “sockets” api no direct user access

slide-41
SLIDE 41

the internet is

  • lder than the

web

Link/Physical Layer Internet Layer Transport Layer

Application

world wide web

[http, html, urls]

ARPANET: 1960s TCP/IP: 1970s Ethernet: 1980s Built by Tim Berners Lee in Fall of 1990 at CERN

slide-42
SLIDE 42

A Start-line Zero or more header fields followed by CRLF An empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fields Optionally a message-body

Hypertext Transfer Protocol

This is the first protocol that is ascii text not binary

slide-43
SLIDE 43

in the TCP segment, the sequence # is binary the bit field for sequence number is filled with the bits that represent a binary number, 6 for example: 110 In an http request, the number 6 is encoded as the ASCII value for 6, 00110110 Text vs Binary

slide-44
SLIDE 44

A Start-line Zero or more header fields followed by CRLF An empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fields Optionally a message-body

“ GET / HTTP/1.0 Host: www.w3.org ”

“ POST /users HTTP/1.1 User-Agent: Mozilla/4.0 Host: twitter.com Content-Type: application/json Content-Length: length Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: Keep-Alive {name: sarah} ”

slide-45
SLIDE 45

Data Encapsulation!

  • HTTP requests are sent over TCP connections

payload

MAC src MAC dest

Ethernet payload

IP src IP dest

TCP Segment IP Packet

dest port sequence # payload src port

ASCII Text

HTTP Request

ASCII Text ASCII Text

slide-46
SLIDE 46

Domain Name System (DNS)

converts urls into ip addresses

web server client dns server root dns server

what is the ip for google.com? what is the ip for google.com? 216.58.192.4 216.58.192.4 216.58.192.4

GET / HTTP/1.0

<p> hello world </p>

slide-47
SLIDE 47

Berkeley Sockets

A Unix API for opening TCP connections or sending raw IP data. Sockets are one API, not a fundamental part of the

  • internet. You can use the internet without them, but you

probably never will.

slide-48
SLIDE 48

Thanks!!!