Computer Networks
Chapter 2
Application Layer
1.1 WWW and HTTP
Logical connection at the Application layer
Application-Layer Paradigms
1. Traditional Paradigm: Client-Server
• Most popular paradigm.
• The service provider is an application program, called the server
process; it runs continuously, waiting for another application program,
called the client process, to make a connection through the Internet and
ask for service.
• There are normally some server processes that can provide a specific
type of service, but there are many clients that request service from any
of these server processes.
• The server process must be running all the time; the client process is
started when the client needs to receive service.
Application-Layer Paradigms
2. New Paradigm: Peer-to-Peer
• Often abbreviated P2P paradigm.
• has emerged to respond to the needs of some new applications.
• In this paradigm, there is no need for a server process to be running all
the time and waiting for the client processes to connect.
• The responsibility is shared between peers.
• A computer connected to the Internet can provide service at one time
and receive service at another time.
• A computer can even provide and receive services at the same time
Application-Layer Paradigms
3. Mixed Paradigm:
• An application may choose to use a mixture of the two
paradigms by combining the advantages of both.
• For example, a light-load client-server communication
can be used to find the address of the peer that can offer
a service.
• When the address of the peer is found, the actual service
can be received from the peer by using the peer-to peer
paradigm
CLIENT-SERVER PROGRAMMING
Application Programming Interface
• If we need a process to be able to communicate with another process, we need a new set
of instructions to tell the lowest four layers of the TCP/IP suite to open the connection, send
and receive data from the other end, and close the connection.
• A set of instructions of this kind is normally referred to as an application programming
interface (API).
• An interface in programming is a set of instructions between two entities. In this case, one
of the entities is the process at the application layer and the other is the operating system
that encapsulates the first four layers of the TCP/IP protocol suite.
• Therefore, a computer manufacturer needs to build the first four layers of the suite in the
operating system and include an API. The processes running at the application layer are
able to communicate with the operating system when sending and receiving messages
through the Internet.
• common APIs :
• socket interface,
• Transport Layer Interface (TLI),
• and STREAM.
Application-Layer Paradigms
Position of the socket interface
Figure : Use of sockets in process-to-process communication
Architecture of WWW
ARCHITECTURE
• The WWW today is a distributed client/server service, in which a
client using a browser can access a service using a server.
However, the service provided is distributed over many locations
called sites.
• The World Wide Web is the universe of network accessible
information.
• In simple terms, The World Wide Web is a way of exchanging
information between computers on the Internet.
• The World Wide Web is based on several different Technologies :
• Web browsers,
• Hypertext Markup Language (HTML) and
• Hypertext Transfer Protocol (HTTP).
Components of WWW
There are 5 Components of WWW:
1. Uniform Resource Locator (URL): serves as system for resources on
web.
2. HyperText Transfer Protocol (HTTP): specifies communication of
browser and server.
3. Hyper Text Markup Language (HTML): It Defines structure,
organisation and content of webpage.
4. Web Server : A web server is computer software and underlying
hardware that accepts requests via HTTP, the network protocol created
to distribute web pages.
5. Web Browser : A web browser (commonly referred to as a browser or
internet browser). • It is an application software for accessing the World
Wide Web. • When a user requests a web page from a particular
website, the web browser retrieves the necessary content from a web
server and then displays the page on the user's device.
Architecture of WWW
Browser
Port numbers are a component in web or other uniform resource locators (URLs), but are
omitted in most cases. By default, HTTP uses port 80 and HTTPS uses port 443, but a URL
like http://www.example.com:8080/path/ specifies that the web browser connects to
port 8080 of the HTTP server, instead of the default value.
WEB DOCUMENTS
The documents in the WWW can be grouped into three
broad categories: static, dynamic, and active. The
category is based on the time at which the contents of
the document are determined.
Topics discussed in this section:
Static Documents
Dynamic Documents
Active Documents
Static document
Boldface tags
Effect of boldface tags
Dynamic document using CGI
Dynamic document using server-site script
Note
Dynamic documents are sometimes
referred to as server-site dynamic
documents.
Active document using client-site script
Note
Active documents are sometimes
referred to as client-site dynamic
documents.
HTTP
The Hypertext Transfer Protocol (HTTP) is a protocol
used mainly to access data on the World Wide Web.
HTTP functions as a combination of FTP and SMTP.
Topics discussed in this section:
HTTP Transaction
Persistent Versus Nonpersistent Connection
Non Persistent Connection
Persistent Connection
Note
HTTP uses the services of TCP on well-
known port 80.
HTTP transaction
Request and response messages
Request and status lines
Methods
Status codes
Table 27.2 Status codes (continued)
Header format
Request header Names
Response headers
Example
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 the GIF or 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 .
Example
In this example, the client wants to send data to the server. We use the POST
method. The request line shows the method (POST), URL, and HTTP version
(1.1). There are four lines of headers. The request body contains the input
information. The response message contains the status line and four lines of
headers. The created document, which is a CGI document, is included as the
body.
Note
HTTP version 1.1 specifies a persistent
connection by default.