Top Banner
1 Kyung Hee University PART 6 PART 6 Application Application Layer Layer
53

1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

Dec 18, 2015

Download

Documents

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: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

11Kyung Hee University

PART 6 PART 6 Application LayerApplication Layer

Page 2: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

22Kyung Hee University

Position of Application LayerPosition of Application Layer

Page 3: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

33Kyung Hee University

Role of Application LayerRole of Application Layer

Enables the user, whether human or software, to

access the network

Provides user interfaces and support for services

such as electronic mail, remote file access and transfer,

and access to the World Wide Web

Page 4: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

44Kyung Hee University

General Issues of Application LayerGeneral Issues of Application Layer

Client-server Paradigm

Page 5: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

55Kyung Hee University

General Issues of Application LayerGeneral Issues of Application Layer

Addressing

Email address

address to access a web page

Types of Service

Application layer is designed to give different services to the user or user programs.

SMTP FTP WWW HTTP

Page 6: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

66Kyung Hee University

Chapter 27 HTTP and WWWChapter 27 HTTP and WWW

Page 7: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

77Kyung Hee University

27.1 HTTP27.1 HTTP

HTTP is used mainly to access data on the WWW

The protocol transfers data in the form of plain text, hypertext, audio, video, and so on.

HTTP functions like a combination of FTP and SMTP.

HTTP is much simpler than FTP because it uses only one TCP connection (well-known port 80)

HTTP is like SMTP because the data transferred between the client and the server are similar to SMTP messages.

SMTP messages are stored and forward, but HTTP messages are delivered immediately

HTTP uses the services of TCP on well-known port 80

Page 8: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

88Kyung Hee University

About SMTPAbout SMTP

Architecture of Simple Mail Transfer Protocol (SMTP)

Page 9: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

99Kyung Hee University

HTTP (cont’d)HTTP (cont’d) The request and response messages carry data in the

form of a letter with a MIME-like format.

letter-like request and letter-like response messages

* MIME :Multipurpose Internet Mail Extensions

Transaction

HTTP is stateless protocol; Each time you need something from the server, your client (browser) makes a connection, gets that file, and then the connection is closed.

The client initializes the transaction by sending a request message.

The sever replies by sending a response.

Page 10: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

1010Kyung Hee University

HTTP (cont’d)HTTP (cont’d)

HTTP Transaction

Page 11: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

1111Kyung Hee University

HTTP (cont’d)HTTP (cont’d)

Request Messages

Page 12: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

1212Kyung Hee University

HTTP (cont’d)HTTP (cont’d)

Request line

Request type : categorizing the request messages into several methods

URL defines four things : method, host computer, port and path

Page 13: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

1313Kyung Hee University

HTTP (cont’d)HTTP (cont’d)

The method is the protocol used to retrieve the document– ex) FTP, HTTP

The host is the computer where the information is located The port number of the server is optional. Path is the path name of the file where the information is

located. Version of HTTP

Page 14: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

1414Kyung Hee University

HTTP (cont’d)HTTP (cont’d)

Methods

GET, HEAD, POST, PUSH, etc.

Response Message

Page 15: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

1515Kyung Hee University

HTTP (cont’d)HTTP (cont’d)

Status line

Status code field is similar to those in the FTP and the

SMTP Status phrase : explain the status code in text form

Page 16: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

1616Kyung Hee University

HTTP (cont’d)HTTP (cont’d)

Headers

Header format

Page 17: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

1717Kyung Hee University

HTTP (cont’d)HTTP (cont’d)

General Header : gives general information about the

messages

Request Header : specifies the server’s configuration

and special information about the request

Response Header : specifies the server’s configuration

and special information about the request

Entity Header : gives information about the body of the

document

Page 18: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

1818Kyung Hee University

Example 1Example 1

This example 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 (see Fig. 27.9, next slide).

Page 19: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

1919Kyung Hee University

Example 1 (cont’d)Example 1 (cont’d)

Page 20: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

2020Kyung Hee University

Example 2Example 2

This example retrieves information about a document. We use the HEAD method to retrieve information about an HTML document (see the next section). The request line shows the method (HEAD), URL, and HTTP version (1.1). The header is one line showing that the client can accept the document in any format (wild card). The request does not have a body. The response message contains the status line and five lines of header. The header lines define the date, server, MIME version, type of document, and length of the document (see Fig. 27.10, next slide). Note that the response message does not contain a body

Page 21: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

2121Kyung Hee University

Example 2 (cont’d)Example 2 (cont’d)

Page 22: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

2222Kyung Hee University

HTTP (cont’d) – Some Other FeaturesHTTP (cont’d) – Some Other Features

Nonpersistent Connection

1. The client opens a TCP connection

2. The server sends the response and closes the connection

3. The client reads the data until it encounters an end-of-file marker

Persistent connection

The server leaves the connection open for more request after sending a response

HTTP version 1.1 specifies a persistent connection by default.

Page 23: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

2323Kyung Hee University

HTTP (cont’d)HTTP (cont’d)

Proxy server

HTTP supports proxy servers

A proxy server is a computer that keeps copies of response to recent requests

Reducing the load on the original sever, decreasing traffic, and improving latency

Page 24: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

2424Kyung Hee University

World Wide Web (WWW)World Wide Web (WWW)

A repository of information spread all over the world

and linked together.

The WWW project was initiated by CERN (European

Laboratory for Particle Physics) to create a system to

handle distributed resources necessary for scientific

research.

The WWW today is a distributed client-sever service, in

which a client using a browser can access a service

using a server

Page 25: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

2525Kyung Hee University

WWW (cont’d)WWW (cont’d)

The service provided is distributed over many

locations called websites.

Distributed Services

Page 26: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

2626Kyung Hee University

WWW (cont’d)WWW (cont’d)

Hypertext

Hypermedia documents

- including pictures, graphics and sound

Page 27: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

2727Kyung Hee University

WWW (cont’d)WWW (cont’d)

Browser architecture

Page 28: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

2828Kyung Hee University

WWW (cont’d)WWW (cont’d)

Categories of Web documents

Static documents are fixed-content document that are created and stored in a server. The contents in the server can be changed, but the user cannot change it.

Page 29: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

2929Kyung Hee University

WWW (cont’d)WWW (cont’d)

Static document

Page 30: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

3030Kyung Hee University

WWW (cont’d)WWW (cont’d)

HTML (Hypertext Markup Language)

- is a language for creating Web services

Page 31: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

3131Kyung Hee University

WWW (cont’d)WWW (cont’d)

Effect of boldface tags

Page 32: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

3232Kyung Hee University

WWW (cont’d)WWW (cont’d)

Beginning and ending tag

= =

Page 33: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

3333Kyung Hee University

WWW (cont’d)WWW (cont’d)

Common tags

Beginning

Tag

Ending

TagMeaning

Skeletal Tags

<HTML> </HTML> Defines an HTML document

<HEAD> </HEAD> Defines the head of the document

<BODY> </BODY> Defines the body of the document

Title and Header Tags

<TITLE> </TITLE> Defines the title of the document

<Hn> </Hn> Defines the title of the document

Page 34: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

3434Kyung Hee University

WWW (cont’d)WWW (cont’d)

Common tags

Beginning

Tag

Ending

TagMeaning

Text Formatting Tags

<B> </B> Boldface

<I> </I> Italic

<U> </U> Underlined

<SUB> </SUB> Subscript

<SUP> </SUP> Superscript

Data Flow Tag

<CENTER> </CENTER> Centered

<BR> </BR> Line break

Page 35: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

3535Kyung Hee University

WWW (cont’d)WWW (cont’d)

Beginning

Tag

Ending

TagMeaning

List Tags

<OL> </OL> Ordered list

<UL> </UL> Unordered list

<LI> </LI> An item in a list

Image Tag

<IMG> Defines an image

Hyperlink Tag

<A> </A> Defines an address (hyperlink)

Executable Contents

<APPLET> </APPLET> The document is an applet

Page 36: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

3636Kyung Hee University

Example 3Example 3

This example shows how tags are used to let the

browser format the appearance of the text

<HTML> <HEAD> <TITLE> First Sample Document </TITLE> </HEAD> <BODY> <CENTER> <H1><B> ATTENTION </B></H1> </CENTER> You can get a copy of this document by: <UL> <LI> Writing to the publisher <LI> Ordering online <LI> Ordering through a bookstore </UL> </BODY></HTML>

Page 37: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

3737Kyung Hee University

Example 4Example 4

This example shows how tags are used to import an image

and insert it into the text

<HTML> <HEAD> <TITLE> Second Sample Document </TITLE> </HEAD> <BODY> This is the picture of a book: <IMG SRC="Pictures/book1.gif" ALIGN=MIDDLE> </BODY></HTML>

Page 38: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

3838Kyung Hee University

Example 5Example 5

This example shows how tags are used to make a

hyperlink to another document.

<HTML> <HEAD> <TITLE> Third Sample Document </TITLE> </HEAD> <BODY> This is a wonderful product that can save you money and time. To get information about the producer, click on <A HREF="http://www.phony.producer"> Producer </A> </BODY></HTML>

Page 39: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

3939Kyung Hee University

WWW (cont’d)WWW (cont’d) Dynamic document

does not exist in a predefined format.

is created by a Web server whenever a browser requests the document.

Page 40: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

4040Kyung Hee University

WWW (cont’d)WWW (cont’d)

Common Gateway Interface

is a technology that creates and handles dynamic documents

CGI program

~ is code written in one the languages supporting CGI

Page 41: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

4141Kyung Hee University

WWW (cont’d)WWW (cont’d)

Example 6 is a CGI program written in Bourne shell script. The progra

m accesses the UNIX utility (date) that returns the date and the time. No

te that the program output is in plain text.

#!/bin/sh

# The head of the program

echo Content_type: text/plain

echo

# The body of the program

now='date'

echo $now

exit 0

Page 42: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

4242Kyung Hee University

Example 7Example 7

Example 7 is similar to Example 6 except that program

output is in HTML.

#!/bin/sh # The head of the programecho Content_type: text/htmlecho# The body of the programecho <HTML>echo <HEAD><TITLE> Date and Time </TITLE></HEAD>echo <BODY>now='date'echo <CENTER><B> $now </B></CENTER>echo </BODY>echo </HTML>exit 0

Page 43: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

4343Kyung Hee University

Example 8Example 8

Example 8 is similar to Example 7 except that the program is written in

Perl.

#!/bin/perl # The head of the programprint "Content_type: text/html\n";print "\n";# The body of the programprint "<HTML>\n";print "<HEAD><TITLE> Date and Time </TITLE></HEAD>\n";print "<BODY>\n";$now = 'date';print "<CENTER><B> $now </B></CENTER>\n";print "</BODY>\n";print "</HTML>\n";exit 0

Page 44: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

4444Kyung Hee University

WWW (cont’d)WWW (cont’d) Active Documents

For many applications, we need a program to be run at the client site.

These are called active documents

Page 45: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

4545Kyung Hee University

Example 9Example 9

JAVA

Skeleton of an Applet

Page 46: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

4646Kyung Hee University

WWW (cont’d)WWW (cont’d)

Installation of the object defined by an applet.

Page 47: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

4747Kyung Hee University

WWW (cont’d)WWW (cont’d)

Creation and compilation

Page 48: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

4848Kyung Hee University

WWW (cont’d)WWW (cont’d)

HTML document carrying an applet

=

=

=

Page 49: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

4949Kyung Hee University

Example 9Example 9

In this example, we first import two packages, java.awt

and java.applet. They contain the declarations and defin

itions of classes and methods that we need. Our examp

le uses only one publicly inherited class called First. W

e define only one public method, paint. The browser ca

n access the instance of First through the public metho

d paint. The paint method, however, calls another meth

od called drawString, which is defined in java.awt.*.

Page 50: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

5050Kyung Hee University

Example 9Example 9

First Example of Java

import java.applet.*;import java.awt.*;

public class First extends Applet{ public void paint (Graphics g) { g.drawString ("Hello World", 100, 100); }}

Page 51: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

5151Kyung Hee University

Example 10Example 10

In this example, we modify the program in Example 9 t

o draw a line. Instead of method drawString, we use an

other method called drawLine. This method needs four

parameters: the x and y coordinates at the beginning of

the line and the x and y coordinates at the end of the lin

e. We use 0, 0 for the beginning and 80, 90 for the end.

Page 52: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

5252Kyung Hee University

Example 10Example 10

Second example of Java

import java.applet.*;import java.awt.*;

public class Second extends Applet{ public void paint (Graphics g) { g.drawLine (0, 0, 80, 90); }}

Page 53: 1 Kyung Hee University PART 6 Application Layer. 2 Kyung Hee University Position of Application Layer

5353Kyung Hee University

Thanks !Thanks !