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

Post on 19-Jun-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CS 43: Computer Networks

Layering&HTTPSeptember7,2018

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)

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

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

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

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

Putting this all together

•  ROUGHLY,whathappenswhenIclickonaWebpagefromSwarthmore?

www.google.com

?Mycomputer

Internet

Lecture3-Slide7

Web request (HTTP)

•  TurnclickintoHTTPrequest

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

Lecture3-Slide8

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

Data transport (TCP)

•  Breakmessageintopackets(TCPsegments)•  Shouldbedeliveredreliably&in-order

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

GEThtt1

Lecture3-Slide10

p://www2google.c3

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

(IP) At Each Router

•  WheredoIsendthistogetitclosertoGoogle?

•  Whichisthebestroutetotake?

Lecture3-Slide12

Link & Physical Layers

•  Forwardtothenextnode!

•  Sharethephysicalmedium.

•  Detecterrors.

Lecture3-Slide13

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

Today

•  Applicationlayerprotocol:HTTP•  HTTPandtheWeb

•  HTTPRequests:GET,POST•  HTTPResponsemessage

•  Cookies

Slide15

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

A.  Requestline

B.  Headerline

C.  Username

D.  Object/Entitybody

Slide16

Web services often use cookies, which are designed to…

A.  Keepstateforauseronasinglewebsite.

B.  Keepstateforauseracrossallwebsitestheyvisit.

C.  Ensureauser’sprivacywhilewebbrowsing.

Slide17

A Web cache…

A.  Compresseswebobjects.

B.  Encryptswebobjects.

C.  Savesdownloadedobjectsclosertotheuser.

Slide18

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

What IS A Web Browser?

Lecture3-Slide20

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

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

HTTP Overview

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

Lecture3-Slide23

host name path name

HTTP Overview

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

Lecture3-Slide24

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

HTTP Overview

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

Lecture3-Slide26

HTTP Overview

5.Browserrenderstheresponse,fetchesanyadditionalobjects,andclosestheconnection.

Lecture3-Slide27

HTTP Overview

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

objects,andclosestheconnection.

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

Lecture3-Slide28

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

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

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

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

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

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

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

How else might we delineate messages?

A.  There’snotmuchelsewecando.

B.  Forceallmessagestobethesamesize.

C.  Sendthemessagesizepriortothemessage.

D.  Someotherway(discuss).

Lecture3-Slide36

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

top related