You are on page 1of 32

Department of Electrical and Computer Engineering University of Waterloo

Chapter 6: Application Layer


ECE 610 Winter 2013

Dr. Mohamed Mahmoud


http://ece.uwaterloo.ca/~mmabdels/ mmabdels@bbcr.uwaterloo.ca

Outline
6.1 Introduction 6.2 Web and HTTP 6.3 FTP 6.4 Electronic Mail 6.5 DNS 6.6 P2P applications

- Application layer: Communicating distributed processes - Running in network hosts in user space - Exchange messages to implement applications, e.g., email, file transfer, the Web - Application-layer protocols use communication services provided by lower layer. -Application-layer protocols define: 1- Types of messages exchanged: e.g., request, response 2- Message syntax: what fields in messages & how fields are delineated 3- Message semantics: meaning of information in fields
application transport network data link physical application transport network data link physical

application transport network data link physical

6-1

4- Rules for when and how processes send & respond to messages and actions taken. - A user agent is an interface between the user and the network application. - Web: browser - E-mail: mail reader - Streaming audio/video: media player

Application architectures
1- Client-server 2- Peer-to-peer (P2P) 3- Hybrid of client-server and P2P
2-4

6-2

1- Client-server architecture
Server: - Always-on host - Permanent IP address - Respond to requests from clients by providing requested service, e.g., Web server sends requested Web page, mail server client/server delivers e-mail Client: - Initiates contact with server (speaks first) - Typically requests service from server - May have dynamic IP addresses
6-3

2- P2P architecture
- Arbitrary end systems directly communicate - Peers request service from other peers, provide service in return to other peers - Highly scalable - But difficult to manage - Peers are intermittently connected and change IP addresses
peer-peer

2-6 6-4

3- Hybrid of client-server and P2P


- Napster - File transfer P2P - File search centralized: - Peers register content at central server - Peers inquiry same central server to locate content - Instant messaging - Chatting between two users is P2P - Presence detection/location centralized: - User registers its IP address with central server when it comes online - User contacts central server to find IP addresses of buddies
6-5

What transport service does an application need?


Reliable data tarnsfer - Some apps (e.g., file transfer, web transactions) require 100% reliable data transfer - Other apps (e.g., audio) can tolerate some loss Timing - Some applications (e.g., Internet telephony, interactive games) require low delay to be effective - Throughput - Some apps (e.g., multimedia) require minimum amount of throughput to be effective. Other apps (elastic apps) make use of whatever throughput they get - Security - Encryption, data integrity,
6-6

Transport service requirements of common apps

Application file transfer e-mail Web documents real-time audio/video stored audio/video interactive games financial apps

Data loss no loss no loss loss-tolerant loss-tolerant loss-tolerant loss-tolerant no loss

Bandwidth elastic elastic elastic audio: 5Kb-1Mb video:10Kb-5Mb same as above few Kbps up elastic

Time Sensitive no no no yes, 100s msec yes, few secs yes, 100s msec yes and no

6-7

Internet transport protocols services


TCP service: - Reliable transport between sending and receiving process - Flow control - Congestion control - Does not provide: timing, minimum throughput guarantee, security - Connection-oriented: setup required between client and server processes
2-10

UDP service: - Unreliable data transfer between sending and receiving processes - Does not provide: reliability, flow control, congestion control, timing, throughput guarantee, security, or connection setup

6-8

Internet apps: their protocols and transport protocols

Application e-mail remote terminal access Web file transfer streaming multimedia remote file server Internet telephony

Application layer protocol smtp [RFC 821] telnet [RFC 854] http [RFC 2068] ftp [RFC 959] proprietary (e.g. RealNetworks) NSF proprietary (e.g., Vocaltec)

Underlying transport protocol TCP TCP TCP TCP TCP or UDP TCP or UDP typically UDP

6-9

Outline
6.1 Introduction 6.2 Web and HTTP 6.3 FTP 6.4 Electronic Mail 6.5 DNS 6.6 P2P applications

- Web page consists of base HTML-file which includes several referenced objects - Object can be JPEG image, Java applet, audio file, - Each object is addressable by a URL, e.g.,

http://ece.uwaterloo.ca/~mmabdels/Data/photo.jpg
Protocol host name File path on host

- HTTP is used across the World Wide Web for data transfer and is one of the most used application protocols - What is a Web Browser: A software application that enables a user to display and interact with html, text, images, audio, and other information located on a web page at a web server.
6 - 10

HTTP overview
- HTTP: hypertext transfer protocol - Webs application layer protocol - Client/server model - Client: browser that requests, receives, (using HTTP protocol) and displays Web objects - Server: Web server sends (using HTTP protocol) objects in response to requests - HTTP uses TCP - Client initiates TCP connection (creates socket) to server, 2-14 port 80 6 - 11
PC running Firefox browser

server running Apache Web server iphone running Safari browser

- 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

HTTP connections
1- Nonpersistent HTTP: At most one object is sent over a TCP connection. Used by HTTP/1.0 2- Persistent HTTP: Multiple objects can be sent over single TCP connection between client and server. Used by HTTP/1.1 in default mode
6 - 12

1- Nonpersistent HTTP
Suppose user enters URL
www.someSchool.edu/someDepartment/home.index 1a. HTTP client initiates TCP connection to
HTTP server (process) at www.someSchool.edu on port 80 (contains text, references to 10 jpeg images)

1b. HTTP server at host


www.someSchool.edu waiting for TCP connection at port 80. accepts connection, notifying client

2. HTTP client sends HTTP


request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index (the base file) time

3. HTTP server receives request


message, forms response message containing requested object, and sends message into its socket

6 - 13

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

4. HTTP server closes TCP connection.

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


- Client creates several TCP connections with the server(s) simultaneously (parallel TCP connections) - OS must work and allocate host resources for each TCP connection - Client requests one object on each connection. - Each TCP connection is terminated when the requested object is retrieved.

6 - 14

- An example of a nonpersistent connection: The client needs to access a file that contains two links to images. 6 - 15

Non-Persistent HTTP: Response time


- Definition of RTT: time for a small packet to travel from client to server and back. - 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
initiate TCP connection RTT Request file RTT File received time to transmit file

time

time

Total response time to fetch one object = 2RTT + transmit time


6 - 16

2- Persistent HTTP

- An example of a persistent connection: The client needs to access a file that contains two links to images. 6 - 17

Persistent HTTP - server leaves connection open after sending response - Subsequent HTTP messages between same client/server are sent over connection 1- Persistent without pipelining: - Client sends new request only when previous response has been received - One RTT for each referenced object, see slide 6-17 2- Persistent with pipelining: - default in HTTP/1.1 - Client sends requests for all referenced objects as soon as it receives base HTML. - As little as one RTT for all the referenced objects, i.e., a total of 3 RTTs Fewer RTTs and less slow start.

6 - 18

Persistent HTTP With Pipeline

initiate TCP connection RTT Request base (html) file RTT Base file received 1- Request first object 2- Request second object 10- Tenth second object First object received Tenth object received time
10 2 1

time to transmit base file

time to transmit first object

Response Time 3RTT+ files transmit time


6 - 19

HTTP request message


Format of the request message

2-23

6 - 20

Example:

request line (GET, POST, HEAD commands) header lines carriage return, line feed at start of line indicates end of header lines

carriage return character line-feed character

GET /index.html HTTP/1.1\r\n Host: www-net.cs.umass.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

6 - 21

Methods

HTTP Methods

Head Post

read information about the web page but not the page itself send information from client to server - when user has filled out a form and sending information to the server Example: words in a search engine 6 - 22 send a webpage and objects from the server to the client

Put

HTTP Message Headers

6 - 23

Uploading form input


1- Post method: - Web page often includes form input - Input is uploaded to server in entity body 2- URL method: - Uses GET method - Input is uploaded in URL field of request line:
www.somesite.com/animalsearch?monkeys&banana www.somesite.com/cgi.bin/form.cgi?firstname=morteza&las tnme=analoui

6 - 24

HTTP response message


Format of the response message

6 - 25

Example:
status line (protocol status code status phrase)

header lines

data, e.g., requested HTML file


2-29

HTTP/1.1 200 OK\r\n Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n Server: Apache/2.0.52 (CentOS)\r\n Last-Modified: Tue, 30 Oct 2007 17:00:02 GMT\r\n ETag: "17dc6-a5c-bf716880"\r\n Accept-Ranges: bytes\r\n Content-Length: 2652\r\n Keep-Alive: timeout=10, max=100\r\n Connection: Keep-Alive\r\n Content-Type: text/html; charset=ISO-88591\r\n \r\n data data data data data ...

6 - 26

HTTP response status codes


some sample 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 2-30 HTTP Version Not Supported
6 - 27

Example 1 - The example (shown on slide 6-29) retrieves a document. - We use the GET method to retrieve an image with the path /usr/bin/image1. - The request line shows the method (GET), the URL, and the HTTP version (1.1). - The header has two lines that show that the client can accept images in GIF and JPEG format. - The request does not have a body. - The response message contains the status line and four lines of header. - The header lines define the date, server, MIME version, and length of the document. - The body of the document follows the header.
6 - 28

32

6 - 29

You might also like