Unit-5_Application Layer Protocols
Unit-5_Application Layer Protocols
Application Layer
Protocols
The linking of web pages was achieved using a concept called hypertext.
Today, the term hypertext, coined to mean linked text documents, has been changed to
hypermedia, to show that a web page can be a text document, an image, an audio file,
or a video file.
The purpose of the Web has gone beyond the simple retrieving of linked documents.
One can use the Web to listen to radio programs or view television programs whenever
one desires without being forced to listen to or view these programs when they are
broadcast.
2
Application Layer Protocols
Architecture of WWW
The WWW today is a distributed client-server service, in which a client using a browser
can access a service from a server.
However, the service provided is distributed over many locations called sites. Each site
holds one or more web pages.
Each web page, however, can contain some links to other web pages in the same or
other sites.
web page can be simple or composite. A simple web page has no links to other web
pages; a composite web page has one or more links to other web pages.
3
Application Layer Protocols
Architecture of WWW
Application Layer Protocols
A variety of vendors offer commercial browsers that interpret and display a web
page, and all of them use nearly the same architecture.
Each browser usually consists of three parts: a controller, client protocols, and
interpreters.
4
Application Layer Protocols
The controller receives input from the keyboard or the mouse and uses the client
programs to access the document.
After the document has been accessed, the controller uses one of the interpreters to
display the document on the screen.
The client protocol can be one of the protocols described later, such as HTTP or FTP.
The interpreter can be HTML, Java, or JavaScript, depending on the type of document.
Some commercial browsers include Internet Explorer, Netscape Navigator, and Firefox.
5
Application Layer Protocols
Web Server
6
Application Layer Protocols
A web page, as a file, needs to have a unique identifier to distinguish it from other web
pages.
To define a web page, we need four identifiers: protocol, host, port, and path.
However, before defining the web page, we need to tell the browser what client server
application we want to use, which is called the protocol.
7
Application Layer Protocols
To combine these four pieces together, the uniform resource locator (URL) has been
designed;
It uses three different separators between the four pieces as shown below:
https://msbte.org/rop/home.html
https://172.22.34.114/chl/login.aspx
https://msbte.org:8090/home.html
8
Application Layer Protocols
9
Application Layer Protocols
The path identifies the location and the name of the file in the underlying
operating system.
For example, /top/next/last/myfile is a path that uniquely defines a file named
myfile, stored in the directory last, which itself is part of the directory next,
which itself is under the directory top. 10
Application Layer Protocols
Web Documents
The documents in the WWW can be grouped into three broad categories: static,
dynamic, and active.
1. Static Documents
Static documents are fixed-content documents that are created and stored in a
server.
The client can get a copy of the document only.
In other words, the contents of the file are determined when the file is created, not
when it is used.
The contents in the server can be changed, but the user cannot change them.
11
Application Layer Protocols
Web Documents
2. Dynamic Documents
A dynamic document is created by a web server whenever a browser requests the
document.
When a request arrives, the web server runs an application program or a script that
creates the dynamic document.
The server returns the result of the program or script as a response to the browser
that requested the document.
A very simple example of a dynamic document is the retrieval of the time and date
from a server.
Time and date are kinds of information that are dynamic in that they change from
moment to moment 12
Application Layer Protocols
Web Documents
3. Active Documents
We need a program or a script to be run at the client site. These are called active
documents.
When a browser requests an active document, the server sends a copy of the document
or a script.
The document is then run at the client (browser) site.
One way to create an active document is to use Java applets, a program written in Java
on the server. It is compiled and ready to be run.
13
Application Layer Protocols
The HyperText Transfer Protocol (HTTP) is used to define how the client server
programs can be written to retrieve web pages from the Web.
An HTTP client sends a request; an HTTP server returns a response.
The server uses the port number 80; the client uses a temporary port number.
HTTP uses the services of TCP.
The client and server never worry about errors in messages exchanged or loss of any
message, because the TCP is reliable and will take care of this matter.
14
Application Layer Protocols
If the web pages, objects to be retrieved, are located on different servers, we do not
have any other choice than to create a new TCP connection for retrieving each object.
However, if some of the objects are located on the same server, we have two choices:
to retrieve each object using a new TCP connection or to make a TCP connection and
retrieve them all.
The first approach is called as non-persistent connection and second approach is called
persistent connection.
15
Application Layer Protocols
Non-persistent Connections
In a non-persistent connection, one TCP connection is made for each
request/response.
The following lists the steps in this strategy:
3. The client reads the data until it encounters an end-of-file marker; it then closes the
connection.
16
Application Layer Protocols
Non-persistent Connections
17
Application Layer Protocols
Persistent Connections
HTTP version 1.1 specifies a persistent connection by default.
In a persistent connection, the server leaves the connection open for more requests
after sending a response.
The server can close the connection at the request of a client or if a time-out has been
reached.
18
Application Layer Protocols
Persistent Connections
19
Application Layer Protocols
Message Formats
20
Application Layer Protocols
Message Formats
The HTTP protocol defines the format of the request and response messages.
The first section in the request message is called the request line; the first section in
the response message is called the status line.
The other three sections have the same names in the request and response messages.
21
Application Layer Protocols
There are three fields in this line separated by one space and terminated by two
characters (carriage return and line feed)
22
Application Layer Protocols
The second field, URL. It defines the address and name of the corresponding
web page.
The third field, version, gives the version of the protocol; the most current
version of HTTP is 1.1
23
Application Layer Protocols
After the request line, we can have zero or more request header lines.
Each header line sends additional information from the client to the server.
For example, the client can request that the document be sent in a special format.
Each header line has a header name, a colon, a space, and a header value.
24
Application Layer Protocols
25
Application Layer Protocols
Header Values
The value field defines the values associated with each header name.
Accept-Language: en-US
Part3: Body
The codes in the 400 range indicate an error at the client site.
Finally, the codes in the 500 range indicate an error at the server site. 28
Application Layer Protocols
29
Application Layer Protocols
Application Layer Protocols
31
Application Layer Protocols
Content-Length: 348
Content-Encoding: gzip
32
Application Layer Protocols
33
Application Layer Protocols
Cookies
The World Wide Web was originally designed as a stateless entity. A client sends a
request; a server responds. Their relationship is over.
Today the Web has other functions that need to remember some information about
the clients; some are listed below:
34
Application Layer Protocols
Cookies
1. Websites are being used as electronic stores that allow users to browse
through the store, select wanted items, put them in an electronic cart, and
pay at the end with a credit card.
2. Some websites need to allow access to registered clients only.
3. Some websites are just advertising agencies.
4. Some websites are used as portals: the user selects the web pages he wants
to see.
35
Application Layer Protocols
1. When a server receives a request from a client, it stores information about the client in
a file or a string.
The information may include the domain name of the client, registration number, and so
a timestamp etc.
2. The server includes the cookie in the response that it sends to the client.
3. When the client receives the response, the browser stores the cookie in the cookie
directory, which is sorted by the server domain name.
36
Application Layer Protocols
Using Cookies
1. When a client sends a request to a server, the browser looks in the cookie directory to
see if it can find a cookie sent by that server. If found, the cookie is included in the
request.
2. When the server receives the request, it knows that this is an old client, not a new one.
***Note that the contents of the cookie are never read by the browser or disclosed to
the user.
3. It is a cookie made by the server and eaten by the server.
37
Application Layer Protocols
Now let us see how a cookie is used for the four previously mentioned purposes,
An electronic store (e-commerce) can use a cookie for its client shoppers.
When a client selects an item and inserts it in a cart, a cookie that contains information
about the item, such as its number and unit price, is sent to the browser.
If the client selects a second item, the cookie is updated with the new selection
information, and so on.
When the client finishes shopping and wants to check out, the last cookie is retrieved
and the total charge is calculated.
40
Application Layer Protocols
41
Application Layer Protocols
42
Application Layer Protocols
43
Application Layer Protocols
Although transferring files from one system to another seems simple and
straightforward.
All of these problems have been solved by FTP in a very simple and elegant approach.
Although we can transfer files using HTTP, FTP is a better choice to transfer large files
or to transfer files using different formats.
44
Application Layer Protocols
45
Application Layer Protocols
Two Connections
FTP uses two well-known TCP ports: port 21 is used for the control connection, and port
20 is used for the data connection.
46
Application Layer Protocols
FTP
Commands
47
Application Layer Protocols
FTP
Responses
48
Application Layer Protocols
Transmission Modes
FTP can transfer a file across the data connection using one of the following three
transmission modes: stream mode, block mode, or compressed mode.
The stream mode is the default mode; data are delivered from FTP to TCP as a
continuous stream of bytes.
In the block mode, data can be delivered from FTP to TCP in blocks. In this case, each
block is preceded by a 3-byte header. The first byte is called the block descriptor; the
next two bytes define the size of the block in bytes.
Compressed mode is often used when transferring large files. Data compression can
improve transfer times, especially when the network connection is slow and the CPU is
fast.
49
Application Layer Protocols
File Transfer
File transfer occurs over the data connection under the control of the commands sent
over the control connection.
However, we should remember that file transfer in FTP means one of three things:
50
Application Layer Protocols
TFTP is defined as a protocol that is used to transfer a file from a client to a server and
from a server to a client.
TFTP is majorly used when no complex interactions are required by the client and server.
The service of TFTP is provided by UDP (User Datagram Protocol) and works on port
number 69.
51
Working of TFTP
• TFTP makes use of port number 69 as it uses User Datagram Protocol (UDP).
• When the connection is established successfully between client and server, the client makes a
Read Request (RRQ) or Write Request( WRQ).
• If a client wants to only read the file it requests RRQ and if the client wants to write some data
into a server then it requests for WRQ.
• Once the connection is established and a request is made communication of files takes place in
the form of small packets. These packets are 512 bytes each.
• The server then communicates the packet back to the client and waits until it receives an
acknowledgment from the client that the packet has been received.
• When the acknowledgment is received from the client side, the server again sends the next
packet which is 512 bytes each.
• The same steps as mentioned above continue until the last packet is sent by the server to the
client. 52
Application Layer Protocols
53
Application Layer Protocols
• In an application such as HTTP or FTP, the server program is running all the time,
waiting for a request from a client.
• When the request arrives, the server provides the service. There is a request and
there is a response.
• In the case of electronic mail, the situation is different. First, e-mail is considered a
one-way transaction.
54
Application Layer Protocols
Bob may or may not respond. If he does respond, it is another one-way transaction.
Second, it is neither feasible nor logical for Bob to run a server program and wait
until someone sends an e-mail to him.
Bob may turn off his computer when he is not using it.
The users run only client programs when they want and the intermediate servers
apply the client/server paradigm
55
Application Layer Protocols
Email Architecture
56
Application Layer Protocols
Email Architecture
• In the common scenario, the sender and the receiver of the e-mail, Alice and Bob
respectively, are connected via a LAN or a WAN to two mail servers.
• The administrator has created one mailbox for each user where the received
messages are stored.
• A mailbox is part of a server hard drive, a special file with permission restrictions.
• Only the owner of the mailbox has access to it. The administrator has also created a
queue (spool) to store messages waiting to be sent.
57
Application Layer Protocols
Email Architecture
• A simple e-mail from Alice to Bob takes nine different steps, as shown in the figure.
• Alice and Bob use three different agents: a user agent (UA), a message transfer
agent (MTA), and a message access agent (MAA).
58
Application Layer Protocols
Email Architecture
• The first component of an electronic mail system is the user agent (UA).
• It provides service to the user to make the process of sending and receiving a
message easier.
• A user agent is a software package (program) that composes, reads, replies to, and
forwards messages.
59
Application Layer Protocols
• The formal protocol that defines the MTA client and server in the Internet is called
Simple Mail Transfer Protocol (SMTP).
• SMTP is used two times, between the sender and the sender’s mail server and
between the two mail servers.
60
Application Layer Protocols
• SMTP uses commands and responses to transfer messages between an MTA client and
an MTA server.
• The command is from an MTA client to an MTA server; the response is from an MTA
server to the MTA client.
61
Application Layer Protocols
Responses
Commands
Application Layer Protocols
1. Connection Establishment
After a client has made a TCP connection to the well known port 25, the SMTP
server starts the connection phase.
2. Message Transfer
After connection has been established between the SMTP client and server, a
single message between a sender and one or more recipients can be exchanged.
3. Connection Termination
• However, SMTP is not involved in the third stage because SMTP is a push protocol; it
pushes the message from the client to the server
• The third stage needs a pull protocol; the client must pull messages from the server.
• The direction of the bulk data is from the server to the client.
• Currently two message access protocols are available: Post Office Protocol, version 3
(POP3) and Internet Mail Access Protocol, version 4 (IMAP4).
64
Application Layer Protocols
POP3
• The client POP3 software is installed on the recipient computer; the server POP3
software is installed on the mail server.
• Mail access starts with the client when the user needs to download its e-mail from
the mailbox on the mail server.
65
Application Layer Protocols
66
Application Layer Protocols
IMAP4
Another mail access protocol is Internet Mail Access Protocol, version 4 (IMAP4).
IMAP4 is similar to POP3, but it has more features; IMAP4 is more powerful and more
complex.
a. It does not allow the user to organize her mail on the server; the user
cannot have different folders on the server.
b. In addition, POP3 does not allow the user to partially check the contents
of the mail before downloading.
67
Application Layer Protocols
❑ A user can search the contents of the e-mail for a specific string of characters prior
to downloading.
❑ A user can partially download e-mail. This is especially useful if bandwidth is limited
and the e-mail contains multimedia with high bandwidth requirements.
68
Application Layer Protocols
Remote Login:
1. TELNET (Terminal Network)
• If a student needs to use the Java compiler program at her university lab, there is
no need for separate Java compiler client and a Java compiler server.
• The student can use a client logging program to log into the university server and
use the compiler program at the university.
69
Application Layer Protocols
• One of the original remote logging protocols is TELNET, which is an abbreviation for
TErminaL NETwork.
• Because of this security issue, the use of TELNET has diminished in favor of another
protocol, Secure Shell (SSH).
70
Application Layer Protocols
71
Application Layer Protocols
72
Application Layer Protocols
• Although Secure Shell (SSH) is a secure application program that can be used today
for several purposes such as remote logging and file transfer.
• It is a cryptographic network protocol that is used for transferring encrypted data over
the network. The port number of SSH is 22.
74
Application Layer Protocols
2. Data integrity, which means that it is guaranteed that the messages exchanged
between the client and server are not changed/altered by an intruder.
3. Server authentication, which means that the client is now sure that the server is the
one that it claims to be .
4. Compression of the messages, which improves the efficiency of the system and
makes attack more difficult.
75
Application Layer Protocols
• To identify an entity, TCP/IP protocols use the IP address, which uniquely identifies
the connection of a host to the Internet.
• Therefore, the Internet needs to have a directory system that can map a name to an
address.
76
Application Layer Protocols
• Internet is so huge today, a central directory system cannot hold all the mapping.
• In addition, if the central computer fails, the whole communication network will
collapse.
• A better solution is to distribute the information among many computers in the world.
• In this method, the host that needs mapping can contact the closest computer holding
the needed information.
77
Application Layer Protocols
Name Space
• The names must be unique because the addresses are unique.
• A name space that maps each address to a unique name can be organized in two
ways: flat or hierarchical.
• The third part can define departments in the organization, and so on.
• A central authority can assign the part of the name that defines the nature of the
organization and the name of the organization.
• The responsibility for the rest of the name can be given to the organization itself.
• The organization can add suffixes (or prefixes) to the name to define its host or
resources. 80
Application Layer Protocols
• In this design the names are defined in an inverted-tree structure with the root at
the top.
• The tree can have only 128 levels: level 0 (root) to level 127
Application Layer Protocols
Label
Each node in the tree has a label, which is a string with a maximum of 63
characters.
The root label is a null string (empty string).
DNS requires that children of a node have different labels, which guarantees the
uniqueness of the domain names.
Domain Name
• Each node in the tree has a domain name.
• A full domain name is a sequence of labels separated by dots (.).
• The domain names are always read from the node up to the root.
• The last label is the label of the root (null).
• This means that a full domain name always ends in a null label, which means
the last character is a dot because the null string is nothing.
Application Layer Protocols
Domain
• A domain is a subtree of the domain name space.
• The name of the domain is the name of the node at the top of the subtree.
• Figure shows some domains. Note that a domain may itself be divided into domains.
Application Layer Protocols
Application Layer Protocols
Application Layer Protocols
DHCP (Dynamic Host Configuration Protocol) is a client-server protocol that uses DHCP servers and
DHCP clients.
A DHCP server is a machine that runs a service that can lease out IP addresses and other TCP/IP
information to any client that requests them.
The DHCP server typically has a pool of IP addresses that it is allowed to distribute to clients, and
these clients lease an IP address from the pool for a specific period of time, usually several days.
Once the lease is ready to expire, the client contacts the server to arrange for renewal.
DHCP clients are client machines that run special DHCP client software enabling them to
communicate with DHCP server.
Application Layer Protocols
DHCP clients obtain a DHCP lease for an IP address, a subnet mask, and various DHCP
options from DHCP servers in a four-step process:
4. DHCPACK: The DHCP server that the client responds to acknowledges the client,
assigns it any configured DHCP options, and updates its DHCP database. The client
then initializes and binds its TCP/IP protocol stack and can begin network
communication.
Application Layer Protocols