Top Banner
1 © From Computer Networking, by Kurose&Ross 2: Application Layer 2-1 Introduction to Computer Networking Guy Leduc Chapter 2 Application Layer Computer Networking: A Top Down Approach, 6 th edition. Jim Kurose, Keith Ross Addison-Wesley, March 2012 © From Computer Networking, by Kurose&Ross 2: Application Layer 2-2 Chapter 2: outline 2.1 Principles of network applications 2.2 Web and HTTP 2.3 DNS 2.4 Socket programming with UDP and TCP
35

Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

Jan 06, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

1

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-1

Introduction toComputer Networking

Guy Leduc

Chapter 2Application Layer Computer Networking:

A Top Down Approach,6th edition.Jim Kurose, Keith RossAddison-Wesley, March2012

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-2

Chapter 2: outline

❒ 2.1 Principles of network applications❒ 2.2 Web and HTTP❒ 2.3 DNS❒ 2.4 Socket programming with UDP and TCP

Page 2: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

2

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-3

Chapter 2: Application LayerOur goals:❒ conceptual,

implementationaspects of networkapplication protocols transport-layer

service models client-server

paradigm peer-to-peer

paradigm

❒ learn about protocolsby examining popularapplication-levelprotocols HTTP DNS

❒ creating networkapplications socket API

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-4

Some network apps

❒ e-mail❒ web❒ instant messaging❒ remote login❒ P2P file sharing❒ multi-user network

games❒ streaming stored video

(YouTube, Hulu,Netflix)

❒ voice over IP (e.g.,Skype)

❒ real-time videoconferencing

❒ social networking❒ search❒ …❒ …

Page 3: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

3

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-5

Creating a network appwrite programs that:❒ run on (different) end systems❒ communicate over network❒ e.g., web server software

communicates with browsersoftware

no need to write software fornetwork-core devices

❒ network-core devices do notrun user applications

❒ applications on end systemsallows for rapid appdevelopment, propagation

applicationtransportnetworkdata linkphysical

applicationtransportnetworkdata linkphysical

applicationtransportnetworkdata linkphysical

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-6

Application architectures

Possible structure of applications: Client-server Peer-to-peer (P2P)

Page 4: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

4

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-7

Client-server architecture

server:❒ always-on host❒ permanent IP address❒ data centers for scaling

clients:❒ communicate with server❒ may be intermittently

connected❒ may have dynamic IP

addresses❒ do not communicate directly

with each other

client/server

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-8

P2P architecture❒ no always-on server❒ arbitrary end systems

directly communicate❒ peers request service from

other peers, provide servicein return to other peers self scalability – new

peers bring new servicecapacity, as well as newservice demands

❒ peers are intermittentlyconnected and change IPaddresses complex management

peer-peer

Page 5: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

5

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-9

Hybrid of client-server and P2PSkype

voice-over-IP P2P application centralized server: finding address of remote

party client-client connection: direct (not through

server)Instant messaging

chatting between two users is P2P centralized service: client presence

detection/locationBitTorrent

exchanging file chunks between users is P2P tracker: maintains list of peers participating in

torrent

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-10

Processes communicating

process: programrunning within a host

❒ within same host, twoprocesses communicateusing inter-processcommunication (definedby OS)

❒ processes in differenthosts communicate byexchanging messages

client process: processthat initiatescommunication

server process: processthat waits to be contacted

aside: applications withP2P architectures haveclient processes & serverprocesses

clients, servers

Page 6: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

6

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-11

Sockets❒ process sends/receives messages to/from its socket❒ socket analogous to door

sending process shoves message out door sending process relies on transport infrastructure

on other side of door to deliver message to socketat receiving process

Internet

controlledby OS

controlled byapp developer

transport

application

physical

link

network

process

transport

application

physical

link

network

processsocket

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-12

Addressing processes

❒ to receive messages,process must haveidentifier

❒ host device has unique32-bit IP address

❒ Q: does IP address ofhost on which processruns suffice foridentifying the process?

❒ identifier includes bothIP address and portnumbers associated withprocess on host

❒ example port numbers: HTTP server: 80 mail server: 25

❒ to send HTTP messageto gaia.cs.umass.edu webserver: IP address: 128.119.245.12 port number: 80

❒ more shortly…

A: no, manyprocesses can berunning on same host

Page 7: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

7

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-13

App-layer protocol defines

❒ Types of messagesexchanged: e.g., request, response

❒ Message syntax: what fields in messages &

how fields are delineated❒ Message semantics:

meaning of information infields

❒ Rules for when and howprocesses send &respond to messages

Open protocols:❒ defined in RFCs❒ allows for

interoperability❒ e.g., HTTP, SMTP

Proprietary protocols:❒ e.g., Skype

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-14

What transport service does an app need?Data loss❒ some apps (e.g., file

transfer, webtransactions) require 100%reliable data transfer

❒ other apps (e.g., audio) cantolerate some loss

Timing❒ some apps (e.g.,

Internet telephony,interactive games)require low delay to be“effective”

Bandwidth❒ some apps (e.g.,

multimedia) requireminimum amount ofthroughput to be“effective”

❒ other apps (“elasticapps”) make use ofwhatever throughputthey get

Security❒ encryption, data

integrity, …

Page 8: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

8

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-15

Transport service requirements of common apps

Application

file transfere-mail

Web documentsreal-time audio/video

stored audio/videointeractive gamesinstant messaging

Data loss

no lossno lossno lossloss-tolerant

loss-tolerantloss-tolerantno loss

Bandwidth

elasticelasticelasticaudio: 5kbps-1Mbpsvideo:10kbps-5Mbpssame as abovefew kbps upelastic

Time Sensitive

nononoyes, 100’s msec

yes, few secsyes, 100’s msecyes and no

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-16

Internet transport protocols services

TCP service:❒ reliable transport between

sending and receiving process❒ flow control: sender won’t

overwhelm receiver❒ congestion control: throttle

sender when networkoverloaded

❒ does not provide: timing,minimum throughputguarantees, security

❒ connection-oriented: setuprequired between client andserver processes

UDP service:❒ unreliable data transfer

between sending andreceiving process

❒ does not provide:reliability, flow control,congestion control, timing,trhoughput guarantee,security, connection setup

Q: why bother? Why isthere a UDP?

Page 9: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

9

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-17

Internet apps: application, transport protocols

Application

e-mailremote terminal access

Web file transfer

streaming multimedia

Internet telephony

Applicationlayer protocol

SMTP [RFC 2821]Telnet [RFC 854]HTTP [RFC 2616]FTP [RFC 959]HTTP (e.g. Youtube),RTP [RFC 1889]SIP, RTP, proprietary(e.g., Skype)

Underlyingtransport protocol

TCPTCPTCPTCPTCP or UDP

typically UDP

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-18

Securing TCP

TCP & UDP❒ no encryption❒ cleartext passwords

sent into sockettraverse Internet incleartext

SSL❒ provides encrypted

TCP connection❒ data integrity❒ end-point

authentication

SSL is at app layer❒ Apps use SSL

libraries, which “talk”to TCP

SSL socket API cleartext passwords

sent into sockettraverse Internetencrypted

See Chapter 7 of book

Page 10: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

10

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-19

Chapter 2: outline

❒ 2.1 Principles of network applications❒ 2.2 Web and HTTP❒ 2.3 DNS❒ 2.4 Socket programming with UDP and TCP

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-20

Web and HTTP

First, a review…❒ Web page consists of objects❒ Object can be HTML file, JPEG image, Java

applet, audio file,…❒ Web page consists of base HTML-file which

includes several referenced objects❒ Each object is addressable by a URL❒ Example URL:

http://www.someschool.edu:8080/someDept/pic.gif

host name path nameport (if nonstandard)

protocolname

Page 11: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

11

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-21

HTTP overview

HTTP: hypertexttransfer protocol

❒ Web’s application layerprotocol

❒ client/server model client: browser that

requests, receives,(using HTTPprotocol) and“displays” Webobjects

server: Web serversends (using HTTPprotocol) objects inresponse torequests

PC runningFirefox browser

server running

Apache Webserver

iphone runningSafari browser

HTTP requestHTTP responseHTTP request

HTTP response

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-22

HTTP overview (continued)

Uses TCP:❒ client initiates TCP

connection (creates socket)to server, port 80

❒ server accepts TCPconnection from client

❒ HTTP messages (application-layer protocol messages)exchanged between browser(HTTP client) and Webserver (HTTP server)

❒ TCP connection closed

HTTP is “stateless”❒ server maintains no

information aboutpast client requests

Protocols that maintain“state” are complex!

❒ past history (state) mustbe maintained

❒ if server/client crashes,their views of “state” maybe inconsistent, must bereconciled

aside

Page 12: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

12

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-23

HTTP connections

non-persistent HTTP❒ at most one object

sent over TCPconnectionconnection then

closed❒ downloading

multiple objectsrequired multipleconnections

persistent HTTP❒ multiple objects

can be sent oversingle TCPconnection betweenclient, server

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-24

Non-persistent HTTPSuppose user enters URL

www.someSchool.edu/someDepartment/home.index

1a. HTTP client initiates TCPconnection to HTTP server(process) atwww.someSchool.edu on port 80

2. HTTP client sends HTTPrequest message (containingURL) into TCP connectionsocket. Message indicatesthat client wants objectsomeDepartment/home.index

1b. HTTP server at hostwww.someSchool.edu waitingfor TCP connection at port 80.“accepts” connection, notifyingclient

3. HTTP server receives requestmessage, forms responsemessage containing requestedobject, and sends messageinto its socket

time

(contains text, references to 10

jpeg images)

Page 13: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

13

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-25

Non-persistent HTTP (cont.)

5. HTTP client receives responsemessage containing html file,displays html. Parsing htmlfile, finds 10 referenced jpegobjects

6. Steps 1-5 repeated for eachof 10 jpeg objects

4. HTTP server closes TCPconnection.

time

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-26

Non-persistent HTTP: response timeRTT (definition): time to send a

small packet to travel fromclient to server and back

HTTP response time:❒ one RTT to initiate TCP

connection❒ one RTT for HTTP request

and first few bytes of HTTPresponse to return

❒ file transmission time❒ non-persistent HTTP

response time =

2RTT + file transmission time

time to transmit file

initiate TCPconnection

RTT

requestfile

RTT

filereceived

time time

Page 14: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

14

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-27

Persistent HTTP

Non-persistent HTTPissues:

❒ requires 2 RTTs perobject

❒ OS overhead for eachTCP connection

❒ browsers often openparallel TCPconnections to fetchreferenced objects

Persistent HTTP:❒ server leaves connection

open after sendingresponse

❒ subsequent HTTP messagesbetween sameclient/server sent overopen connection

❒ client sends requests assoon as it encounters areferenced object

❒ as little as one RTT for allthe referenced objects

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-28

HTTP request message

❒ two types of HTTP messages: request, response❒ HTTP request message:

ASCII (human-readable format)

request line(GET, POST, HEAD commands)

header lines

carriage return, line feed at startof line indicatesend of header lines

GET /index.html HTTP/1.1\r\nHost: www-net.cs.umass.edu\r\nUser-Agent: Firefox/3.6.10\r\nAccept: text/html,application/xhtml+xml\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7\r\nKeep-Alive: 115\r\nConnection: keep-alive\r\n\r\n

carriage return characterline-feed character

Page 15: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

15

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-29

HTTP request message: general format

requestline

headerlines

body

method sp sp cr lfversionURL

cr lfvalueheader field name

cr lfvalueheader field name

~~ ~~

cr lf

entity body~~ ~~

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-30

Uploading form input

Post method:❒ Web page often includes form input❒ Input is uploaded to server in entity body

URL method:❒ Uses GET method❒ Input is uploaded in URL field of request line:http://www.somesite.com/animalsearch?monkeys&banana

Page 16: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

16

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-31

Method types

HTTP/1.0❒ GET❒ POST❒ HEAD

asks server to leaverequested object out ofresponse

HTTP/1.1❒ GET, POST, HEAD❒ PUT

uploads file in entitybody to path specifiedin URL field

❒ DELETE deletes file specified in

the URL field

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-32

HTTP response message

status line(protocolstatus codestatus phrase)

header lines

data, e.g., requestedHTML file

HTTP/1.1 200 OK\r\nDate: Sun, 26 Sep 2010 20:09:20 GMT\r\nServer: Apache/2.0.52 (CentOS)\r\nLast-Modified: Tue, 30 Oct 2007 17:00:02 GMT\r\nETag: "17dc6-a5c-bf716880"\r\nAccept-Ranges: bytes\r\nContent-Length: 2652\r\nKeep-Alive: timeout=10, max=100\r\nConnection: Keep-Alive\r\nContent-Type: text/html; charset=ISO-8859-1\r\n\r\ndata data data data data ...

Page 17: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

17

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-33

HTTP response status codes

200 OK request succeeded, requested object later in this msg

301 Moved Permanently requested object moved, new location specified later in

this msg (Location:)400 Bad Request

request msg not understood by server404 Not Found

requested document not found on this server505 HTTP Version Not Supported

status code appears in 1st line in server-to-client response message.

some sample codes:

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-34

Trying out HTTP (client side) for yourself

1. Telnet to your favorite Web server:Opens TCP connection to port 80(default HTTP server port) at cis.poly.edu.Anything typed in sent to port 80 at cis.poly.edu

telnet cis.poly.edu 80

2. Type in a GET HTTP request:GET /~ross/ HTTP/1.1Host: cis.poly.edu

By typing this in (hit carriagereturn twice), you sendthis minimal (but complete) GET request to HTTP server

3. Look at response message sent by HTTP server!

Page 18: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

18

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-35

User-server state: cookies

Many major Web sitesuse cookies

Four components:1) cookie header line of

HTTP response message2) cookie header line in

HTTP request message3) cookie file kept on

user’s host, managed byuser’s browser

4) back-end database atWeb site

Example:❒ Susan always access

Internet from PC❒ visits specific e-

commerce site for firsttime

❒ when initial HTTPrequest arrives at site,site creates: unique ID entry in backend

database for ID

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-36

Cookies: keeping “state” (cont.)client server

usual http response msg

usual http response msg

cookie file

one week later:

usual http request msgcookie: 1678 cookie-

specificaction

access

ebay 8734 usual http request msg Amazon servercreates ID

1678 for user create entry

usual http responseset-cookie: 1678ebay 8734

amazon 1678

usual http request msgcookie: 1678 cookie-

specificaction

accessebay 8734amazon 1678

backenddatabase

Page 19: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

19

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-37

Cookies (continued)What cookies can be

used for:❒ authorization❒ shopping carts❒ recommendations❒ user session state

(Web e-mail)

Cookies and privacy:❒ cookies permit sites to

learn a lot about you❒ you may supply name

and e-mail to sites

aside

How to keep “state”:❒ protocol endpoints: maintain state at

sender/receiver over multiple transactions❒ cookies: http messages carry state

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-38

Web caches (proxy server)

❒ user sets browser:Web accesses via cache

❒ browser sends all HTTPrequests to cache object in cache:

cache returns object else cache requests

object from originserver, then returnsobject to client

goal: satisfy client request without involving originserver

client

proxyserver

client

HTTP request

HTTP response

HTTP request HTTP request

origin server

origin server

HTTP response HTTP response

Page 20: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

20

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-39

More about Web caching

❒ cache acts as bothclient and server server for original

requesting client client to origin server

❒ typically cache isinstalled by ISP(university, company,residential ISP)

Why Web caching?❒ reduce response time

for client request❒ reduce traffic on an

institution’s accesslink

❒ Internet dense withcaches: enables “poor”content providers toeffectively delivercontent (but so toodoes P2P file sharing)

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-40

Caching example:

originservers

public Internet

institutionalnetwork

1 Gbps LAN

1.54 Mbps access link

assumptions: avg object size: 100 Kbits avg request rate from browsers

to origin servers: 15/sec avg data rate to browsers:

1.5 Mbps RTT from institutional router to

any origin server: 2 sec access link rate: 1.54 Mbps

consequences: LAN utilization: 0.15% access link utilization = 99% total delay = Internet delay +

access delay + LAN delay = 2 sec + minutes + µsecs

problem!

Page 21: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

21

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-41

assumptions: avg object size: 100 Kbits avg request rate from browsers

to origin servers: 15/sec avg data rate to browsers:

1.5 Mbps RTT from institutional router to

any origin server: 2 sec access link rate: 1.54 Mbps

consequences: LAN utilization: 0.15% access link utilization = 99% total delay = Internet delay +

access delay + LAN delay = 2 sec + minutes + usecs

Caching example: fatter access link

originservers

1.54 Mbps access link

15.4 Mbps

15.4 Mbps

msecsCost: increased access link speed (not cheap!)

9.9%

public Internet

institutionalnetwork

1 Gbps LAN

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-42

assumptions: avg object size: 100 Kbits avg request rate from browsers

to origin servers: 15/sec avg data rate to browsers:

1.5 Mbps RTT from institutional router to

any origin server: 2 sec access link rate: 1.54 Mbps

consequences: LAN utilization: access link utilization =

institutionalnetwork

1 Gbps LAN

Application Layer 2-42

Caching example: install local cache

originservers

1.54 Mbps access link

local web cache

??

How to compute link utilization, delay?

Cost: web cache (cheap!)

public Internet

Page 22: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

22

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-43

Caching example: install local cacheCalculating access link

utilization, delay with cache:suppose cache hit rate is 0.4

40% requests satisfied at cache,60% requests satisfied at origin

originservers

1.54 Mbps access link

access link utilization:60% of requests use access link

data rate to browsers over access link= 0.6*1.5 Mbps = 0.9 Mbps

utilization = 0.9/1.54 = 58%

total delay = 0.6 * (delay from origin servers)

+ 0.4 * (delay when satisfied at cache) = 0.6 (2.01) + 0.4 (~msecs) = ~ 1.2 secs less than with 15.4 Mbps link (and cheaper too!)

public Internet

institutionalnetwork

1 Gbps LAN

local web cache

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-44

Conditional GET

❒ Goal: don’t send object ifcache has up-to-datecached version no object transmission

delay lower link utilization

❒ cache: specify date ofcached copy in HTTPrequestIf-modified-since:

<date>

❒ server: response containsno object if cached copy isup-to-date:HTTP/1.0 304 Not

Modified

HTTP request msgIf-modified-since: <date>

HTTP responseHTTP/1.0

304 Not Modified

object not

modifiedbefore<date>

HTTP request msgIf-modified-since: <date>

HTTP responseHTTP/1.0 200 OK

<data>

object modified

after <date>

client server

Page 23: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

23

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-45

Chapter 2: outline

❒ 2.1 Principles of network applications❒ 2.2 Web and HTTP❒ 2.3 DNS❒ 2.4 Socket programming with UDP and TCP

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-46

DNS: Domain Name System

People: many identifiers: SSN, name, passport #

Internet hosts, routers: IP address (32 bit) -

used for addressingdatagrams

“name”, e.g.,www.yahoo.com - usedby humans

Q: how to map betweenIP address and name,and vice versa?

Domain Name System:❒ distributed database

implemented in hierarchy ofmany name servers

❒ application-layer protocolhost, name serverscommunicate to resolve names(address/name translation) note: core Internet

function, implemented asapplication-layer protocol

complexity at network’s“edge”

Page 24: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

24

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-47

DNS: services, structure

why not centralize DNS?❒ single point of failure❒ traffic volume❒ distant centralized

database❒ maintenance

DNS services❒ hostname to IP

address translation❒ host aliasing

canonical, alias names❒ mail server aliasing❒ load distribution

replicated Webservers: many IPaddressescorrespond to onename

A: doesn’t scale!

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-48

Root DNS Servers

com DNS servers org DNS servers edu DNS servers

poly.eduDNS servers

umass.eduDNS serversyahoo.com

DNS serversamazon.comDNS servers

pbs.orgDNS servers

DNS: a distributed, hierarchicaldatabase

Client wants IP for www.amazon.com; 1st approx:❒ client queries root server to find com DNS server❒ client queries com DNS server to get amazon.com

DNS server❒ client queries amazon.com DNS server to get IP

address for www.amazon.com

Page 25: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

25

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-49

DNS: root name servers❒ contacted by local name server that can not resolve name❒ root name server:

contacts authoritative name server if name mapping notknown

gets mapping returns mapping to local name server

13 root name“servers”worldwide

a. Verisign, Los Angeles CA (5 other sites)b. USC-ISI Marina del Rey, CAl. ICANN Los Angeles, CA (41 other sites)

e. NASA Mt View, CAf. Internet Software C.Palo Alto, CA (and 48 othersites)

i. Netnod, Stockholm (37 other sites)

k. RIPE London (17 other sites)

m. WIDE Tokyo(5 other sites)

c. Cogent, Herndon, VA (5 other sites)d. U Maryland College Park, MDh. ARL Aberdeen, MDj. Verisign, Dulles VA (69 other sites )

g. US DoD Columbus,OH (5 other sites)

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-50

DNS: Root name servers❒ contacted by local name server that cannot resolve name❒ root name server:

contacts authoritative name server if name mapping not known gets mapping returns mapping to local name server

13 root nameservers worldwide

b USC-ISI Marina del Rey, CAl ICANN Los Angeles, CA

e NASA Mt View, CAf Internet Software C. Palo Alto,CA (and 36 other locations)

i Autonomica, Stockholm (plus28 other locations)

k RIPE London (also 16 other locations)

m WIDE Tokyo (also Seoul,Paris, SF)

a Verisign, Dulles, VAc Cogent, Herndon, VA (also LA)d U Maryland College Park, MDg US DoD Vienna, VAh ARL Aberdeen, MDj Verisign, ( 21 locations)

Page 26: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

26

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-51

TLD, authoritative servers

❒ Top-level domain (TLD) servers: responsible for com, org, net, edu,aero, jobs,

museums, and all top-level country domains, e.g.:uk,fr, ca, jp, be

Network Solutions maintains servers for com TLD Educause for edu TLD

❒ Authoritative DNS servers: organization’s own DNS server(s), providing

authoritative hostname to IP mappings fororganization’s named hosts

can be maintained by organization or serviceprovider

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-52

Local DNS name server

❒ does not strictly belong to hierarchy❒ each ISP (residential ISP, company,

university) has one. also called “default name server”

❒ when host makes DNS query, query is sentto its local DNS server has local cache of recent name-to-address

translation pairs (but may be out of date!) acts as proxy, forwards query into hierarchy

Page 27: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

27

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-53

requesting hostcis.poly.edu

gaia.cs.umass.edu

root DNS server

local DNS serverdns.poly.edu

1

23

4

5

6

authoritative DNS serverdns.cs.umass.edu

78

TLD DNS server

DNS nameresolution example

❒ host at cis.poly.eduwants IP address forgaia.cs.umass.edu

iterated query: contacted server

replies with name ofserver to contact

“I don’t know thisname, but ask thisserver”

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-54

45

6

3

recursive query: puts burden of

name resolution oncontacted nameserver

heavy load atupper levels ofhierarchy?

requesting hostcis.poly.edu

gaia.cs.umass.edu

root DNS server

local DNS serverdns.poly.edu

1

27

authoritative DNS serverdns.cs.umass.edu

8

TLD DNSserver

DNS nameresolution example

Page 28: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

28

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-55

DNS: caching, updating records

❒ once (any) name server learns mapping, it cachesmapping cache entries timeout (disappear) after some time (TTL) TLD servers typically cached in local name servers

• Thus root name servers not often visited❒ cached entries may be out-of-date (best effort

name-to-address translation!) if name host changes IP address, may not be known

Internet-wide until all TTLs expire❒ update/notify mechanisms under design by IETF

RFC 2136

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-56

DNS recordsDNS: distributed db storing resource records (RR)

❒ Type=NS name is domain

(e.g. foo.com) value is hostname of

authoritative name serverfor this domain

RR format: (name, value, type, ttl)

❒ Type=A name is hostname value is IP address

❒ Type=CNAME name is alias name for some

“canonical” (the real) name www.ibm.com is really servereast.backup2.ibm.com

value is canonical name

❒ Type=MX value is name of mailserver

associated with name

Page 29: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

29

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-57

DNS protocol, messages

❒ query and reply messages, both with same messageformat

msg header identification: 16 bit # for

query, reply to query usessame #

flags: query or reply recursion desired recursion available reply is authoritative

identification flags

# questions

questions (variable # of questions)

# additional RRs# authority RRs

# answer RRs

answers (variable # of RRs)

authority (variable # of RRs)

additional info (variable # of RRs)

2 bytes 2 bytes

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-58

name, type fields for a query

RRs in responseto query

records forauthoritative servers

additional “helpful”info that may be used

identification flags

# questions

questions (variable # of questions)

# additional RRs# authority RRs

# answer RRs

answers (variable # of RRs)

authority (variable # of RRs)

additional info (variable # of RRs)

2 bytes 2 bytes

DNS protocol, messages

Page 30: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

30

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-59

Inserting records into DNS

❒ example: new startup “Network Utopia”❒ register name networkuptopia.com at DNS registrar

(e.g., Network Solutions) provide names, IP addresses of authoritative name server

(primary and secondary) registrar inserts two RRs into com TLD server:

(networkutopia.com, dns1.networkutopia.com, NS)(dns1.networkutopia.com, 212.212.212.1, A)

❒ create authoritative server Type A record forwww.networkuptopia.com; Type MX record fornetworkutopia.com

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-60

Chapter 2: outline

❒ 2.1 Principles of network applications❒ 2.2 Web and HTTP❒ 2.3 DNS❒ 2.4 Socket programming with UDP and TCP

Page 31: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

31

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-61

Socket programming

goal: learn how to build client/server applications thatcommunicate using sockets

socket: door between application process and end-end-transport protocolSocket API introduced in BSD4.1 UNIX, 1981

Internet

controlledby OS

controlled byapp developer

transport

application

physical

link

network

process

transport

application

physical

link

network

processsocket

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-62

Socket programming

Two socket types for two transport services: UDP: unreliable datagram TCP: reliable, byte stream-oriented

Application Example:1. Client reads a line of characters (data) from its

keyboard and sends the data to the server.2. The server receives the data and converts characters

to uppercase.3. The server sends the modified data to the client.4. The client receives the modified data and displays the

line on its screen.

Page 32: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

32

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-63

Socket programming with UDP

UDP: no “connection” between client &server

❒ no handshaking before sending data❒ sender explicitly attaches IP destination

address and port # to each packet❒ rcvr extracts sender IP address and port#

from received packetUDP: transmitted data may be lost or

received out-of-orderApplication viewpoint:❒ UDP provides unreliable transfer of groups of

bytes (“datagrams”) between client and server

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-64

Client/server socket interaction: UDP

closeclientSocket

Server (running on hostid)

read datagram fromclientSocket

create socket,clientSocket = DatagramSocket()

Client

Create datagram with server IP and port=x; send datagram request via clientSocket

create socket,port=x, forincoming request:serverSocket = DatagramSocket(x)

read request fromserverSocket

write reply toserverSocketspecifying clienthost address,port number

Page 33: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

33

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-65

UDP observations & questions❒ Both client and server use DatagramSocket❒ Dest IP and port are explicitly attached to

segment by client and server❒ Can the client send a segment to server without

knowing the server’s IP address and/or portnumber?

❒ Can multiple clients use the server?

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-66

Socket programming with TCPClient must contact server❒ server process must first

be running❒ server must have created

socket (door) thatwelcomes client’s contact(welcoming socket)

Client contacts server by:❒ creating TCP socket

specifying IP address, portnumber of server process

❒ When client createssocket: client TCPestablishes connection toserver TCP

❒ When contacted by client,server TCP creates new socketfor server process tocommunicate with thatparticular client allows server to talk with

multiple clients source IP and source port

numbers used to distinguishclients (more in Chap 3)

TCP provides reliable, in-order transfer of bytes (“pipe”) between client and server

application viewpoint

Page 34: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

34

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-67

Client/server socket interaction: TCP

wait for incomingconnection requestconnectionSocket =welcomeSocket.accept()

closeconnectionSocket

read reply fromclientSocket

closeclientSocket

create socket, port=x, for incoming request:welcomeSocket =

ServerSocket(x)

Server (running on hostid) Client

send request usingclientSocketread request from

connectionSocket

write reply toconnectionSocket

TCP connection setup

create socket,connect to hostid, port=x

clientSocket = Socket(hostid,x)

parametersof server

connection socket≠

welcome socket,

but same port x

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-68

TCP observations & questions

❒ Two types of sockets: ServerSocket and Socket

❒ When client knocks on serverSocket’s “door,”server creates connectionSocket and completesTCP connection

❒ Dest IP and port are not explicitly attached tosegment by client and server

❒ Can multiple clients use the server?

Page 35: Introduction to Computer Networking Guy Leduc Chapter 2 ...fuuu.be/polytech/INFOF303/INFOF303_ch2.pdfchatting between two users is P2P ... Web documents real-time audio/video stored

35

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-69

Chapter 2: Summary

❒ applicationarchitectures client-server P2P

❒ application servicerequirements: reliability, bandwidth,

delay❒ Internet transport

service model connection-oriented,

reliable: TCP unreliable, datagrams:

UDP

our study of network apps now complete!❒ specific protocols:

HTTP DNS

❒ socket programming: TCP, UDP sockets

© From Computer Networking, by Kurose&Ross 2: Application Layer 2-70

Chapter 2: Summary

❒ typical request/replymessage exchange: client requests info or

service server responds with

data, status code❒ message formats:

headers: fields givinginfo about data

data: info beingcommunicated

Most importantly: learned about protocols

Important themes:❒ control vs. data msgs❒ centralized vs.

decentralized❒ stateless vs. stateful❒ reliable vs. unreliable

msg transfer❒ “complexity at network

edge”