cs 43: computer networkschaganti/cs43/f18/... · global network addressing • address each packet...

37
CS 43: Computer Networks Layering & HTTP September 7, 2018

Upload: others

Post on 19-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

CS 43: Computer Networks

Layering&HTTPSeptember7,2018

Page 2: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Last Class: Five-layer Internet Model

Lecture3-Slide2

Application:theapplication(e.g.,theWeb,Email)

Transport:end-to-endconnections,reliability

Network:routing

Link(data-link):framing,errordetection

Physical:1’sand0’s/bitsacrossamedium(copper,theair,fiber)

Page 3: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Last Class: Five-layer Internet Model

Lecture3-Slide3

Receiver

Physical layer (Cat 5, Coax, Air, Fiber Optics)

Link Layer (Ethernet, WIFI, Cable)

Network Layer (IP): Choose paths for data

Application Layer

-sharecapacity,ordering,errorchecking,congestioncontrol,…

Transport Layer

Page 4: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

OSI Seven-Layer Model

Application:theapplication(e.g.,theWeb,Email)

Transport:end-to-endconnections,reliability

Network:routing

Link(data-link):framing,errordetection

Physical:1’sand0’s/bitsacrossamedium(copper,theair,fiber)

Presentation:formatting,encoding,encryption

Session:sockets,remoteprocedurecall

Lecture3-Slide4

Page 5: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Because of our layering abstractions, we can use any technology we want at any layer.

A.  Always

B.  Usually

C.  Sometimes

D.  Never

Lecture3-Slide5

Page 6: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Data Link

Physical

Applications

The Hourglass Model

“Thin Waist”

FTP HTTP TFTP VoIP

TCP UDP

IP

NET1 NET2 NETn …

Transport

Internet Protocol Suite

Lecture3-Slide6

Page 7: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Putting this all together

•  ROUGHLY,whathappenswhenIclickonaWebpagefromSwarthmore?

www.google.com

?Mycomputer

Internet

Lecture3-Slide7

Page 8: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Web request (HTTP)

•  TurnclickintoHTTPrequest

GEThttp://www.google.com/HTTP/1.1Host:www.google.com…

Lecture3-Slide8

Page 9: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Name resolution (DNS)

•  Whereiswww.google.com?

Addressforwww.google.com?

Mycomputer(132.239.9.64)

Oh,youcanfinditat66.102.7.104

LocalDNSserver(132.239.51.18)

Lecture3-Slide9

Page 10: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Data transport (TCP)

•  Breakmessageintopackets(TCPsegments)•  Shouldbedeliveredreliably&in-order

GEThttp://www.google.comHTTP/1.1Host:www.google.com…

GEThtt1

Lecture3-Slide10

p://www2google.c3

Page 11: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Global Network Addressing

•  Addresseachpacketsoitcantraversenetworkandarriveathost

Mycomputer(132.239.9.64) www.google.com

(66.102.7.104)

GETrequest66.102.7.104 132.239.9.64

Lecture3-Slide11

DataSourceDestination

Page 12: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

(IP) At Each Router

•  WheredoIsendthistogetitclosertoGoogle?

•  Whichisthebestroutetotake?

Lecture3-Slide12

Page 13: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Link & Physical Layers

•  Forwardtothenextnode!

•  Sharethephysicalmedium.

•  Detecterrors.

Lecture3-Slide13

Page 14: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

TCP/IPProtocolStack

HTTP

TCP

IP

Ethernet interface

HTTP

TCP

IP

Ethernet interface

IP IP

Ethernet interface

Ethernet interface

SONET interface

SONET interface

host host

router router

Application Layer

Transport Layer

Link Layer

Network Layer

Lecture3-Slide14

Page 15: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Today

•  Applicationlayerprotocol:HTTP•  HTTPandtheWeb

•  HTTPRequests:GET,POST•  HTTPResponsemessage

•  Cookies

Slide15

Page 16: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Which of these is NOT a component of a typical HTTP transaction?

A.  Requestline

B.  Headerline

C.  Username

D.  Object/Entitybody

Slide16

Page 17: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Web services often use cookies, which are designed to…

A.  Keepstateforauseronasinglewebsite.

B.  Keepstateforauseracrossallwebsitestheyvisit.

C.  Ensureauser’sprivacywhilewebbrowsing.

Slide17

Page 18: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

A Web cache…

A.  Compresseswebobjects.

B.  Encryptswebobjects.

C.  Savesdownloadedobjectsclosertotheuser.

Slide18

Page 19: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Adapted from Kurose and Ross

Creating a network app

write programs that: •  run on (different) end systems •  communicate over network •  e.g., web server software

communicates with browser software

no need to write software for network-core devices

•  network-core devices do not run user applications

•  applications on end systems allows for rapid app development, propagation

application transport network data link physical

application transport network data link physical

application transport network data link physical

Lecture3-Slide19

Page 20: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

What IS A Web Browser?

Lecture3-Slide20

Page 21: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Adapted from: Kurose & Ross

HTTP and the Web

First,areview…•  webpageconsistsofobjects•  objectcanbeHTMLfile,JPEGimage,Javaapplet,audiofile,…

•  webpageconsistsofbaseHTML-filewhichincludesseveralreferencedobjects

•  eachobjectisaddressablebyaURL,e.g., www.someschool.edu/someDept/pic.gif

host name path name

Lecture3-Slide21

Page 22: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Adapted from: Kurose and Ross

HTTP: Hypertext transfer protocol

§ client/servermodel

•  client:browserthatrequests,receives,(usingHTTPprotocol)and“displays”Webobjects

•  server:Webserversends(usingHTTPprotocol)objectsinresponsetorequests

PC running Firefox browser

server running

Apache Web server

iPhone running Safari browser

Lecture3-Slide22

Page 23: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

HTTP Overview

1.UsertypesinaURL.http://some.host.name.tld/directory/name/file.ext

Lecture3-Slide23

host name path name

Page 24: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

HTTP Overview

2.Browserestablishesconnectionwithserver.Looksup“some.host.name.tld”Callsconnect()

Lecture3-Slide24

Page 25: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

HTTP Overview

3.Browserrequeststhecorrespondingdata.GET/directory/name/file.extHTTP/1.0Host:some.host.name.tld[otheroptionalfields,forexample:]User-agent:Mozilla/5.0(WindowsNT6.1;WOW64)Accept-language:en

Lecture3-Slide25

Page 26: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

HTTP Overview

4.Serverrespondswiththerequesteddata.HTTP/1.0200OKContent-Type:text/htmlContent-Length:1299Date:Sun,01Sep201321:26:38GMT[Blankline](Datadatadatadata…)

Lecture3-Slide26

Page 27: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

HTTP Overview

5.Browserrenderstheresponse,fetchesanyadditionalobjects,andclosestheconnection.

Lecture3-Slide27

Page 28: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

HTTP Overview

1.  UsertypesinaURL.2.  Browserestablishesconnectionwithserver.3.  Browserrequeststhecorrespondingdata.4.  Serverrespondswiththerequesteddata.5.  Browserrenderstheresponse,fetchesother

objects,andclosestheconnection.

It’sadocumentretrievalsystem,wheredocumentspointto(linkto)eachother,forminga“web”.

Lecture3-Slide28

Page 29: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

HTTP Overview (Lab 1)

1.  UsertypesinaURL.2.  Browserestablishesconnectionwithserver.3.  Browserrequeststhecorrespondingdata.4.  Serverrespondswiththerequesteddata.5.  Browserrenderstheresponse,fetchesother

objects,andclosestheconnection.

It’sadocumentretrievalsystem,wheredocumentspointto(linkto)eachother,forminga“web”.

Lecture3-Slide29

Page 30: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Trying out HTTP (client side) for yourself

1. Telnet to your favorite Web server:

OpensTCPconnectiontoport80(defaultHTTPserverport)atexampleserver.Anythingtypedissenttoserveronport80atdemo.cs.swarthmore.edu

telnet demo.cs.swarthmore.edu 80

2.TypeinaGETHTTPrequest:

GET / HTTP/1.1 Host: demo.cs.swarthmore.edu (blank line)

(Hitcarriagereturntwice)Thisisaminimal,butcomplete,GETrequesttotheHTTPserver.

3.LookatresponsemessagesentbyHTTPserver!Lecture3-Slide30

Page 31: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Example $telnetdemo.cs.swarthmore.edu80Trying130.58.68.26...Connectedtodemo.cs.swarthmore.edu.Escapecharacteris'^]'.GET/HTTP/1.1Host:demo.cs.swarthmore.eduHTTP/1.1200OKVary:Accept-EncodingContent-Type:text/htmlAccept-Ranges:bytesETag:"316912886"Last-Modified:Wed,04Jan201717:47:31GMTContent-Length:1062Date:Wed,05Sep201817:27:34GMTServer:lighttpd/1.4.35<html><head><title>DemoServer</title></head><body>.....</body></html> Lecture3-Slide31

Page 32: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Example $ telnet demo.cs.swarthmore.edu 80 Trying 130.58.68.26... Connected to demo.cs.swarthmore.edu. Escape character is '^]'. GET / HTTP/1.1 Host: demo.cs.swarthmore.edu HTTP/1.1 200 OK Vary: Accept-Encoding Content-Type: text/html Accept-Ranges: bytes ETag: "316912886" Last-Modified: Wed, 04 Jan 2017 17:47:31 GMT Content-Length: 1062 Date: Wed, 05 Sep 2018 17:27:34 GMT Server: lighttpd/1.4.35 Lecture3-Slide32

Responseheaders

Page 33: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Example $ telnet demo.cs.swarthmore.edu 80 Trying 130.58.68.26... Connected to demo.cs.swarthmore.edu. Escape character is '^]'. GET / HTTP/1.1 Host: demo.cs.swarthmore.edu <html><head><title>Demo Server</title></head> <body> ..... </body> </html>

Lecture3-Slide33

Responseheaders

Responsebody(Thisiswhatyoushouldbesavinginlab1.)

Page 34: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

HTTP request message •  twotypesofHTTPmessages:request,response•  HTTPrequestmessage:ASCII(human-readableformat)

requestline(GET,POST,HEAD,etc.commands)

headerlines

carriagereturn,linefeed

GET /index.html HTTP/1.1\r\n Host: web.cs.swarthmore.edu\r\n User-Agent: Firefox/3.6.10\r\n Accept: text/html,application/xhtml+xml\r\n Accept-Language: en-us,en;q=0.5\r\n Accept-Encoding: gzip,deflate\r\n Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n Keep-Alive: 115\r\n Connection: keep-alive\r\n \r\n

carriagereturncharacterline-feedcharacter

Lecture3-Slide34

Page 35: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

Why do we have these \r\n (CRLF) things all over the place?

A.  They’regeneratedwhentheuserhits‘enter’.B.  Theysignaltheendofafieldorsection.C.  They’reimportantforsomeotherreason.D.  They’reanunnecessaryprotocolartifact.

GET /index.html HTTP/1.1\r\n Host: web.cs.swarthmore.edu\r\n User-Agent: Firefox/3.6.10\r\n Accept: text/html,application/xhtml+xml\r\n Accept-Language: en-us,en;q=0.5\r\n Accept-Encoding: gzip,deflate\r\n Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n Keep-Alive: 115\r\n Connection: keep-alive\r\n \r\n

Lecture3-Slide35

Page 36: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

How else might we delineate messages?

A.  There’snotmuchelsewecando.

B.  Forceallmessagestobethesamesize.

C.  Sendthemessagesizepriortothemessage.

D.  Someotherway(discuss).

Lecture3-Slide36

Page 37: CS 43: Computer Networkschaganti/cs43/f18/... · Global Network Addressing • Address each packet so it can traverse network and arrive at host My computer (132.239.9.64) (66.102.7.104)

HTTP is all text…

•  Makestheprotocol simple –  Easytodelineatemessage(\r\n)–  (Relatively)human-readable–  Noworriesaboutencodingorformattingdata–  Variablelengthdata

•  Not the most efficient – Manyprotocolsusebinaryfields

•  Sending“12345678”asastringis8bytes•  Asaninteger,12345678needsonly4bytes

–  Theheadersmaycomeinanyorder–  Requiresstringparsing/processing

Lecture3-Slide37