EEC-484/584 Computer Networks Lecture 4 Wenbing Zhao [email protected] (Part of the slides are based...

46
EEC-484/584 EEC-484/584 Computer Networks Computer Networks Lecture 4 Lecture 4 Wenbing Zhao Wenbing Zhao [email protected] [email protected] (Part of the slides are based on Drs. Kurose & (Part of the slides are based on Drs. Kurose & Ross’s slides for their Ross’s slides for their Computer Networking Computer Networking book book)
  • date post

    18-Dec-2015
  • Category

    Documents

  • view

    213
  • download

    0

Transcript of EEC-484/584 Computer Networks Lecture 4 Wenbing Zhao [email protected] (Part of the slides are based...

EEC-484/584EEC-484/584Computer NetworksComputer Networks

Lecture 4Lecture 4

Wenbing ZhaoWenbing Zhao

[email protected]@ieee.org(Part of the slides are based on Drs. Kurose & Ross’s slides (Part of the slides are based on Drs. Kurose & Ross’s slides

for their for their Computer Networking Computer Networking bookbook))

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

22

OutlineOutline

• Principles of networked applications

• Web and HTTP

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

33

Application Layer ProtocolsApplication Layer Protocols

• Principles of networked applications– Client server model– Sockets– Addressing– Protocol– What do we need from transport layer?

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

44

Creating a Network ApplicationCreating a Network Application

• Write programs that– run on different end

systems and– communicate over a

network

• No need to write code for devices in subnet– Subnet devices do not run

user application code– application on end systems

allows for rapid app development, propagation

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

55

Inter-Process CommunicationsInter-Process Communications

• Process: program running within a host

• Processes in different hosts communicate by exchanging messages

• Client process: process that initiates communication

• Server process: process that waits to be contacted

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

66

SocketsSockets

• Process sends/receives messages to/from its socket

• For each point-to-point connection, there are two sockets, one on each side

• API: (1) choice of transport protocol; (2) ability to fix a few parameters

process

TCP withbuffers,variables

socket

host orserver

process

TCP withbuffers,variables

socket

host orserver

Internet

Controlledby OS

Controlled byapp developer

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

77

AddressingAddressing• To receive messages, process must have

identifier• Host device has unique 32-bit IP address• Question: Does IP address of host on which

process runs suffice for identifying the process?

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

88

AddressingAddressing• Identifier includes both IP address and port

numbers (16-bit) associated with process on host

• Example port numbers:– HTTP server: 80– SSH server: 22

• To send HTTP request to academic.csuohio.edu Web server:– IP address: 137.148.49.46– Port number: 80

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

99

Application Layer Protocol DefinesApplication Layer Protocol Defines

• Types of messages exchanged – e.g., request, response

• Message syntax– what fields in messages & how

fields are delineated

• Message semantics – meaning of information in fields

• Rules for when and how processes send & respond to messages

Public-domain protocols:• defined in RFCs• allows for

interoperability• e.g., HTTP, SMTP

Proprietary protocols:• e.g., KaZaA

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1010

What Transport Service Does an What Transport Service Does an Application Need?Application Need?

Data loss• some apps (e.g., audio) can

tolerate some loss• other apps (e.g., file

transfer, telnet) require 100% reliable data transfer

Timing• some apps (e.g.,

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

Bandwidth• some apps (e.g.,

multimedia) require minimum amount of bandwidth to be “effective”

• other apps (“elastic apps”) make use of whatever bandwidth they get

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1111

Transport Service Requirements of Transport Service Requirements of Common ApplicationsCommon Applications

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 above few kbps upelastic

Time Sensitive

nononoyes, 100’s msec

yes, few secsyes, 100’s msecyes and no

Large Scale Internet Application ArchitectureLarge Scale Internet Application Architecture

http://img.microsoft.com/resources/documentation/wss/2/all/adminguide/en-us/stsb02b.gif

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1313

The World Wide WebThe World Wide Web

• Creation of Tim Berners-Lee, in 1989 CERN nuclear physics research– Mosaic – first graphical interface, creation of Marc

Andersson (and others), precursor to Netscape

• Uses a client-server architecture– Web server– Web browser

• Runs on HTTP over TCP

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1414

Web and HTTPWeb and HTTP

• 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• The idea of having one page point to another is

called hypertext– Invented by Vannevar Bush, a MIT EE professor, in

1945

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1515

URL – Uniform Resource LocaterURL – Uniform Resource Locater

• Example URL:

• URL encodes three types of information– What is the page called – local path name uniquely

indicating the specific page– Where is the page located – Host name of the

server on which the page is located– How can the page be accessed – protocol, e.g.,

http, ftp

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

host name path nameprotocol name

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1616

Some Common URLsSome Common URLs

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1717

HTTP overviewHTTP overview

HTTP: HyperText Transfer Protocol

• Web’s application layer protocol

• client/server model• HTTP 1.0: RFC 1945• HTTP 1.1: RFC 2068

PC runningExplorer

Server running

Apache Webserver

Mac runningNavigator

HTTP request

HTTP request

HTTP response

HTTP response

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1818

HTTP OverviewHTTP Overview

• Uses TCP:– Client initiates TCP connection (creates

socket) to server, port 80– Server accepts TCP connection from client– HTTP messages (application-layer protocol

messages) exchanged between browser (HTTP client) and Web server (HTTP server)

– TCP connection closed

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1919

HTTP OverviewHTTP Overview

• HTTP is “stateless”– Server maintains no information about past

client requests

• Protocols that maintain “state” are complex!– Past history (state) must be maintained– If server/client crashes, their views of “state”

may be inconsistent, must be reconciled

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2020

HTTP ConnectionsHTTP Connections

Nonpersistent HTTP• At most one object is

sent over a TCP connection

• HTTP/1.0 uses nonpersistent HTTP

Persistent HTTP• Multiple objects can

be sent over single TCP connection between client and server

• HTTP/1.1 uses persistent connections in default mode

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2121

Nonpersistent HTTPNonpersistent HTTPSuppose user enters URL http://www.someSchool.edu/someDept/home.index

1a. HTTP client initiates TCP connection to HTTP server at www.someSchool.edu on port 80

2. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDept/home.index

1b. HTTP server at host www.someSchool.edu waiting for TCP connection at port 80. “accepts” connection, notifying client

3. HTTP server receives request message, forms response message containing requested object, and sends message into its socket

time

(contains text, references to 10

jpeg images)

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2222

Nonpersistent HTTPNonpersistent HTTP

5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects

6. Steps 1-5 repeated for each of 10 jpeg objects

4. HTTP server closes TCP connection.

time

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2323

Non-Persistent HTTP: Non-Persistent HTTP: Response TimeResponse Time

Definition of RTT: time to send a small packet to travel from client to server and back (Round Trip Time)

time to transmit file

initiate TCPconnection

RTT

requestfile

RTT

filereceived

time time

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2424

Non-Persistent HTTP: Non-Persistent HTTP: Response TimeResponse Time

Response time:

• one RTT to initiate TCP connection

• one RTT for HTTP request and first few bytes of HTTP response to return

• file transmission time

Total = 2RTT+transmit time

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2525

Non-Persistent HTTP Issues

• Requires 2 RTTs per object

• OS overhead for each TCP connection

• Browsers often open parallel TCP connections to fetch referenced objects (to reduce response time)

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2626

Persistent HTTPPersistent HTTP

• Server leaves connection open after sending response

• Subsequent HTTP messages between same client/server sent over open connection

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2727

Persistent HTTPPersistent HTTP

Persistent without pipelining:• Client issues new request only when previous

response has been received• One RTT for each referenced object

Persistent with pipelining:• Default in HTTP/1.1• Client sends requests as soon as it encounters a

referenced object• As little as one RTT for all the referenced objects

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2828

HTTP Request MessageHTTP Request Message

• Two types of HTTP messages: request, response• HTTP request message:

– ASCII (human-readable format)

GET /somedir/page.html HTTP/1.1Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:fr

(extra carriage return, line feed)

request line(GET, POST,

HEAD commands)

header lines

Carriage return, line feed

indicates end of message

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2929

HTTP Request Message: HTTP Request Message: General FormatGeneral Format

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3030

Uploading Form InputUploading 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

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3131

Method typesMethod types

HTTP/1.0• GET• POST• HEAD

– Asks server to include only the header part in response

HTTP/1.1• GET, POST, HEAD• PUT

– Uploads file in entity body to path specified in URL field

• DELETE– Deletes file specified

in the URL field

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3232

HTTP Response MessageHTTP Response Message

HTTP/1.1 200 OK Connection closeDate: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ...

status line(protocol

status codestatus phrase)

header lines

data, e.g., requestedHTML file

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3333

HTTP Response Status CodesHTTP Response Status Codes

200 OK– request succeeded, requested object later in this message

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

message (Location:)

400 Bad Request– request message not understood by server

404 Not Found– requested document not found on this server

505 HTTP Version Not Supported

Status code is in first line of the response message:

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3434

Trying out HTTPTrying out HTTP1. 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!

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3535

User-Server State: CookiesUser-Server State: Cookies

Many major Web sites use cookies

Four components:1) cookie header line in HTTP response message

2) cookie header line in HTTP request message

3) cookie file kept on user’s host, managed by user’s browser

4) back-end database at Web site

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3636

User-Server State: CookiesUser-Server State: Cookies

Example:– Susan access Internet always from same PC– She visits a specific e-commerce site for first

time– When initial HTTP requests arrives at site, site

creates a unique ID and creates an entry in backend database for ID

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3737

Cookies: Keeping “State”Cookies: Keeping “State”client server

usual http request msgusual http response

+Set-cookie: 1678

usual http request msg

cookie: 1678usual http response

msg

usual http request msg

cookie: 1678usual http response msg

cookie-specificaction

cookie-spectificaction

servercreates ID

1678 for user

entry in backend

database

access

acce

ss

Cookie file

amazon: 1678ebay: 8734

Cookie file

ebay: 8734

Cookie file

amazon: 1678ebay: 8734

one week later:

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3838

CookiesCookies

What cookies can bring:• authorization• shopping carts• recommendations• user session state (Web e-mail)

How to keep “state”:• Protocol endpoints: maintain state at

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

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3939

Performance EnhancementPerformance Enhancement

• Caching– Save pages that have been requested in case they are

used again– Client-side technique

• Server replication– Replicate server’s contents at multiple locations– Sometimes called mirroring

• Content delivery networks– Deliver contents for their providers to end users

efficiently for a fee

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

4040

Web CachingWeb Caching

• user sets browser: Web accesses via proxy server

• browser sends all HTTP requests to proxy server– object in cache: returns

cached object

– else cache requests object from origin server, then returns object to client

Goal: satisfy client request without involving origin server

client

Proxyserver

client

HTTP request

HTTP request

HTTP response

HTTP response

HTTP request

HTTP response

origin server

origin server

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

4141

More about Web CachingMore about Web Caching

• Proxy server acts as both client and server

• Typically proxy server is installed by ISP (university, company, residential ISP)

Why Web caching?• Reduce response time for

client request• Reduce traffic on an

institution’s access link• Internet dense with

caches: enables “poor” content providers to effectively deliver content

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

4242

Non-Caching Example Non-Caching Example

Assumptions• Average object size =

100,000 bits• Avg. request rate from

institution’s browsers to origin servers = 15/sec

• Delay from institutional router to any origin server and back to router = 2 sec

originservers

public Internet

institutionalnetwork 10 Mbps LAN

1.5 Mbps access link

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

4343

Non-Caching Example Non-Caching Example

Consequences• Utilization on LAN = 15%• Utilization on access link =

100%• Total delay = Internet

delay + access delay + LAN delay

= 2 sec + minutes + milliseconds

originservers

public Internet

institutionalnetwork 10 Mbps LAN

1.5 Mbps access link

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

4444

Non-Caching ExampleNon-Caching Example

Possible solution• Increase bandwidth of

access link to, say, 10 Mbps

Consequences• Utilization on LAN = 15%• Utilization on access link = 15%• Total delay = Internet delay +

access delay + LAN delay

= 2 sec + msecs + msecs• Often a costly upgrade

originservers

public Internet

institutionalnetwork 10 Mbps LAN

10 Mbps access link

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

4545

Caching ExampleCaching Example

Install proxy server• Suppose hit rate is 0.4

Consequence• 40% requests will be satisfied almost

immediately• 60% requests satisfied by origin

server• Utilization of access link

reduced to 60%, resulting in negligible delays (say 10 msec)

• Total avg delay = Internet delay + access delay + LAN delay = .6*(2.01) secs + .4*milliseconds < 1.4 secs

originservers

public Internet

institutionalnetwork 10 Mbps LAN

1.5 Mbps access link

InstitutionalProxy server

Spring Semester 2007Spring Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

4646

Conditional GETConditional GET

• Goal: don’t send object if cache is up-to-date

• Proxy server: specify date of cached copy in HTTP requestIf-modified-since: <date>

• Origin server: response contains no object if cached copy is up-to-date: HTTP/1.0 304 Not Modified

Proxy server

Origin Server

HTTP request msgIf-modified-since:

<date>

HTTP responseHTTP/1.0

304 Not Modified

object not

modified

HTTP request msgIf-modified-since:

<date>

HTTP responseHTTP/1.0 200 OK

<data>

object modified