application layer of tcp/ip. application layer application layer architecture transport-layer...

Click here to load reader

Upload: delilah-mathews

Post on 03-Jan-2016

229 views

Category:

Documents


0 download

TRANSCRIPT

Application Layer of TCP/IP

Application Layer of TCP/IP Application LayerApplication Layer Architecturetransport-layer service modelsclient-server paradigmpeer-to-peer paradigm

ProcessesSocketsTransport layer interfaceApplication Layer ProtocolsHTTP, SMTP, POP3, FTP etc.Application LayerPrinciples of network applicationsWeb and HTTPFTP Electronic MailSMTP, POP3, IMAPDNSP2P applicationsSocket programming with TCPSocket programming with UDP

2: Application Layer4Some network appse-mailwebinstant messagingremote loginP2P file sharingmulti-user network gamesstreaming stored video clips

voice over IPreal-time video conferencinggrid computing 2: Application Layer5

Creating a network appwrite programs thatrun on (different) end systemscommunicate over networke.g., web server software communicates with browser softwareNo need to write software for network-core devicesNetwork-core devices do not run user applications applications on end systems allows for rapid app development, propagationapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysicalPrinciples of network applicationsApplication Architectures

Client-serverPeer-to-peer (P2P)Hybrid of client-server and P2P

2: Application Layer7Client-server architectureserver: always-on hostpermanent IP addressserver farms for scalingclients:communicate with servermay be intermittently connectedmay have dynamic IP addressesdo not communicate directly with each other

client/server2: Application Layer8Pure P2P architectureno always-on serverarbitrary end systems directly communicatepeers are intermittently connected and change IP addresses

Highly scalable but difficult to manage

peer-peer2: Application Layer9Hybrid of client-server and P2PSkypevoice-over-IP P2P applicationcentralized server: finding address of remote party: client-client connection: direct (not through server) Instant messagingchatting between two users is P2Pcentralized service: client presence detection/locationuser registers its IP address with central server when it comes onlineuser contacts central server to find IP addresses of buddies

2: Application Layer10Processes communicatingProcess: program running within a host.within same host, two processes communicate using inter-process communication (defined by OS).processes in different hosts communicate by exchanging messagesClient process: process that initiates communicationServer process: process that waits to be contacted

Note: applications with P2P architectures have client processes & server processes2: Application Layer11Socketsprocess sends/receives messages to/from its socketsocket analogous to doorsending process shoves message out doorsending process relies on transport infrastructure on other side of door which brings message to socket at receiving process

processTCP withbuffers,variablessockethost orserver

processTCP withbuffers,variablessockethost orserverInternetcontrolledby OS

controlled byapp developerAPI: (1) choice of transport protocol; (2) ability to fix a few parameters (lots more on this later) 2: Application Layer12Addressing processesto receive messages, process must have identifierhost device has unique 32-bit IP addressQ: does IP address of host suffice for identifying the process?2: Application Layer13Addressing processesto receive messages, process must have identifierhost device has unique 32-bit IP addressQ: does IP address of host on which process runs suffice for identifying the process?A: No, many processes can be running on same hostidentifier includes both IP address and port numbers associated with process on host.Example port numbers:HTTP server: 80Mail server: 25to send HTTP message to gaia.cs.umass.edu web server:IP address: 128.119.245.12Port number: 80more shortly2: Application Layer14App-layer protocol definesTypes of messages exchanged, e.g., request, response Message syntax:what fields in messages & how fields are delineatedMessage semantics meaning of information in fieldsRules for when and how processes send & respond to messagesPublic-domain protocols:defined in RFCsallows for interoperabilitye.g., HTTP, SMTPProprietary protocols:e.g., Skype2: Application Layer15What transport service does an app need?Data losssome apps (e.g., audio) can tolerate some lossother apps (e.g., file transfer, telnet) require 100% reliable data transfer Timingsome apps (e.g., Internet telephony, interactive games) require low delay to be effectiveThroughputsome apps (e.g., multimedia) require minimum amount of throughput to be effectiveother apps (elastic apps) make use of whatever throughput they get SecurityEncryption, data integrity, 2: Application Layer16Transport service requirements of common appsApplication

file transfere-mailWeb documentsreal-time audio/video

stored audio/videointeractive gamesinstant messagingData loss

no lossno lossno lossloss-tolerant

loss-tolerantloss-tolerantno lossThroughput

elasticelasticelasticaudio: 5kbps-1Mbpsvideo:10kbps-5Mbpssame as above few kbps upelasticTime Sensitive

nononoyes, 100s msec

yes, few secsyes, 100s msecyes and no2: Application Layer17Internet transport protocols servicesTCP service:connection-oriented: setup required between client and server processesreliable transport between sending and receiving processflow control: sender wont overwhelm receiver congestion control: throttle sender when network overloadeddoes not provide: timing, minimum throughput guarantees, securityUDP service:unreliable data transfer between sending and receiving processdoes not provide: connection setup, reliability, flow control, congestion control, timing, throughput guarantee, or security

Q: why bother? Why is there a UDP?2: Application Layer18Internet apps: application, transport protocolsApplication

e-mailremote terminal accessWeb file transferstreaming multimedia

Internet telephony

Applicationlayer protocol

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

TCPTCPTCPTCPTCP or UDP

typically UDP2: Application Layer19Web and HTTPFirst some jargonBrowser: User agent for Web. Displays requested web pages and provides navigational and configuration featuresBrowser also implements client side of HTTP.Web page consists of objectsObject can be HTML file, JPEG image, Java applet, audio file,Web page consists of base HTML-file which includes several referenced objectsEach object is addressable by a URLExample URL:

www.someschool.edu/someDept/pic.gifhost namepath name2: Application Layer20HTTP overviewHTTP: hypertext transfer protocolWebs application layer protocolclient/server modelclient: browser that requests, receives, displays Web objectsserver: Web server sends objects in response to requests

PC runningExplorer

Server runningApache WebserverMac runningNavigatorHTTP requestHTTP requestHTTP responseHTTP response2: Application Layer21HTTP overview (continued)Uses TCP:client initiates TCP connection (creates socket) to server, port 80server accepts TCP connection from clientHTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)TCP connection closedHTTP is statelessserver maintains no information about past client requestsProtocols that maintain state are complex!past history (state) must be maintainedif server/client crashes, their views of state may be inconsistent, must be reconciled

aside2: Application Layer22HTTP connectionsNonpersistent HTTPAt most one object is sent over a TCP connection.

Persistent HTTPMultiple objects can be sent over single TCP connection between client and server.

2: Application Layer23Nonpersistent HTTPSuppose user enters URL www.someSchool.edu/someDepartment/home.index1a. HTTP client initiates TCP connection to HTTP server (process) at www.someSchool.edu on port 802. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index1b. HTTP server at host www.someSchool.edu waiting for TCP connection at port 80. accepts connection, notifying client3. HTTP server receives request message, forms response message containing requested object, and sends message into its sockettime(contains text, references to 10 jpeg images)2: Application Layer24Nonpersistent HTTP (cont.)5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects6. Steps 1-5 repeated for each of 10 jpeg objects4. HTTP server closes TCP connection. time2: Application Layer25Non-Persistent HTTP: Response timeDefinition of RTT: time for a small packet to travel from client to server and back.Response time:one RTT to initiate TCP connectionone RTT for HTTP request and first few bytes of HTTP response to returnfile transmission timetotal = 2RTT+transmit time

time to transmit fileinitiate TCPconnectionRTTrequestfileRTTfilereceivedtimetime2: Application Layer26Persistent HTTPNonpersistent HTTP issues:requires 2 RTTs per objectOS overhead for each TCP connectionbrowsers often open parallel TCP connections to fetch referenced objects

Persistent HTTPserver leaves connection open after sending responsesubsequent HTTP messages between same client/server sent over open connectionclient sends requests as soon as it encounters a referenced objectas little as one RTT for all the referenced objects2: Application Layer27HTTP request messagetwo types of HTTP messages: request, responseHTTP 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 linesCarriage return, line feed indicates end of message2: Application Layer28HTTP request message: general format

2: Application Layer29Uploading form inputPost method:Web page often includes form inputInput is uploaded to server in entity bodyURL method:Uses GET methodInput is uploaded in URL field of request line:

www.somesite.com/animalsearch?monkeys&banana2: Application Layer30Method typesHTTP/1.0GETPOSTHEADasks server to leave requested object out of responseHTTP/1.1GET, POST, HEADPUTuploads file in entity body to path specified in URL fieldDELETEdeletes file specified in the URL field2: Application Layer31HTTP response messageHTTP/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(protocolstatus codestatus phrase)header linesdata, e.g., requestedHTML file2: Application Layer32HTTP response status codes200 OKrequest succeeded, requested object later in this message301 Moved Permanentlyrequested object moved, new location specified later in this message (Location:)400 Bad Requestrequest message not understood by server404 Not Foundrequested document not found on this server505 HTTP Version Not SupportedIn first line in server->client response message.A few sample codes:2: Application Layer33Trying out HTTP (client side) for yourself1. 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.edutelnet cis.poly.edu 802. Type in a GET HTTP request:

GET /~ross/ HTTP/1.1Host: cis.poly.eduBy typing this in (hit carriagereturn twice), you sendthis minimal (but complete) GET request to HTTP server3. Look at response message sent by HTTP server!2: Application Layer34User-server state: cookiesMany major Web sites use cookiesFour components:1) cookie header line of HTTP response message2) cookie header line in HTTP request message3) cookie file kept on users host, managed by users browser4) back-end database at Web siteExample:Susan always access Internet always from PCvisits specific e-commerce site for first timewhen initial HTTP requests arrives at site, site creates: unique IDentry in backend database for ID2: Application Layer35Cookies: keeping state (cont.)clientserverusual http response msgusual http response msgcookie fileone week later:usual http request msgcookie: 1678cookie-specificactionaccessebay 8734usual http request msgAmazon servercreates ID1678 for usercreate entryusual http response Set-cookie: 1678 ebay 8734amazon 1678usual http request msgcookie: 1678cookie-spectificactionaccessebay 8734amazon 1678backenddatabase2: Application Layer36Cookies (continued)What cookies can bring:authorizationshopping cartsrecommendationsuser session state (Web e-mail)Cookies and privacy:cookies permit sites to learn a lot about youyou may supply name and e-mail to sitesasideHow to keep state:protocol endpoints: maintain state at sender/receiver over multiple transactionscookies: http messages carry state2: Application Layer37Web caches (proxy server)user sets browser: Web accesses via cachebrowser sends all HTTP requests to cacheobject in cache: cache returns object else cache requests object from origin server, then returns object to clientGoal: satisfy client request without involving origin server

client

ProxyserverclientHTTP requestHTTP responseHTTP requestHTTP requestorigin serverorigin server

HTTP responseHTTP response

2: Application Layer38More about Web cachingcache acts as both client and servertypically cache is installed by ISP (university, company, residential ISP)Why Web caching?reduce response time for client requestreduce traffic on an institutions access link.Internet dense with caches: enables poor content providers to effectively deliver content (but so does P2P file sharing)2: Application Layer39Caching example Assumptionsaverage object size = 100,000 bitsavg. request rate from institutions browsers to origin servers = 15/secdelay from institutional router to any origin server and back to router = 2 secConsequencesutilization on LAN = 15%utilization on access link = 100%total delay = Internet delay + access delay + LAN delay = 2 sec + minutes + milliseconds

originserverspublic Internet

institutionalnetwork10 Mbps LAN1.5 Mbps access linkinstitutionalcache2: Application Layer40Caching example (cont)possible solutionincrease bandwidth of access link to, say, 10 Mbpsconsequenceutilization on LAN = 15%utilization on access link = 15%Total delay = Internet delay + access delay + LAN delay = 2 sec + msecs + msecsoften a costly upgrade

originserverspublic Internet

institutionalnetwork10 Mbps LAN10 Mbps access linkinstitutionalcache2: Application Layer41Caching example (cont)possible solution: install cachesuppose hit rate is 0.4consequence40% requests will be satisfied almost immediately60% requests satisfied by origin serverutilization 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

originserverspublic Internet

institutionalnetwork10 Mbps LAN1.5 Mbps access linkinstitutionalcache2: Application Layer42Conditional GETGoal: dont send object if cache has up-to-date cached versioncache: specify date of cached copy in HTTP requestIf-modified-since: server: response contains no object if cached copy is up-to-date: HTTP/1.0 304 Not ModifiedcacheserverHTTP request msgIf-modified-since: HTTP responseHTTP/1.0 304 Not Modifiedobject not modifiedHTTP request msgIf-modified-since: HTTP responseHTTP/1.0 200 OK

object modified