View
233
Download
9
Tags:
Embed Size (px)
Citation preview
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
44Kyung Hee University
General Issues of Application LayerGeneral Issues of Application Layer
Client-server Paradigm
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
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
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.
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
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
1414Kyung Hee University
HTTP (cont’d)HTTP (cont’d)
Methods
GET, HEAD, POST, PUSH, etc.
Response Message
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
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
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).
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
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.
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
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
2525Kyung Hee University
WWW (cont’d)WWW (cont’d)
The service provided is distributed over many
locations called websites.
Distributed Services
2626Kyung Hee University
WWW (cont’d)WWW (cont’d)
Hypertext
Hypermedia documents
- including pictures, graphics and sound
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.
3030Kyung Hee University
WWW (cont’d)WWW (cont’d)
HTML (Hypertext Markup Language)
- is a language for creating Web services
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
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
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
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>
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>
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>
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.
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
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
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
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
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
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.*.
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); }}
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.
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); }}