Unit-5 Application Layer
Unit-5 Application Layer
Application Layer
o Peer-To-Peer network
o Client/Server network
Peer-To-Peer network
o Peer-To-Peer network is a network in which all the computers are linked together with
equal privilege and responsibilities for processing the data.
o Peer-To-Peer network is useful for small environments, usually up to 10 computers.
o Peer-To-Peer network has no dedicated server.
o Special permissions are assigned to each computer for sharing the resources, but this can
lead to a problem if the computer with the resource is down.
Advantages of Peer-To-Peer Network:
o It is less costly as it does not contain any dedicated server.
o If one computer stops working but, other computers will not stop working.
o It is easy to set up and maintain as each computer manages itself.
Client/Server Network
o Client/Server network is a network model designed for the end users called clients, to
access the resources such as songs, video, etc. from a central computer known as Server.
o The central controller is known as a server while all other computers in the network are
called clients.
o A server performs all the major operations such as security and network management.
o A server is responsible for managing all the resources such as files, directories, printer,
etc.
o All the clients communicate with each other through a server. For example, if client1
wants to send some data to client 2, then it first sends the request to the server for the
permission. The server sends the response to the client 1 to initiate its communication
with the client 2.
Advantages of Client/Server network:
o A Client/Server network contains the centralized system. Therefore we can back up the
data easily.
o A Client/Server network has a dedicated server that improves the overall performance of
the whole system.
o A server has a Network Operating System (NOS) to provide the resources to the clients,
but the cost of NOS is very high.
Processes Communicating:
Processes Communicating
Processes on two different end systems communicate with each other by exchanging messages
across the computer network.
With Peer to Peer file sharing, the peer that is downloading the file is labeled as the client, and
the peer that is uploading the file is labeled as the server.
In the context of a communication session between a pair of processes, the process that initiates
the communication (that is, initially contacts the other process at the beginning of the session) is
labeled as the client. The process that waits to be contacted to begin the session is the server.
A process sends messages into, and receives messages from, the network through a software
interface called a socket.
A socket is the interface between the application layer and the transport layer within a host. It is
also referred to as the Application Programming Interface (API) between the application and the
network.
On the transport-layer side, the application developer can only control: (1) the choice of transport
protocol and (2) a few transport-layer parameters such as maximum buffer and maximum
segment sizes.
Many networks, including the internet, provide more than one transport-layer protocol. When
you develop an application, you must choose one of the available transport-layer protocols. How
do you make this choice? Most likely, you would study the services provided by the available
transport-layer protocols, and then pick the protocol with the services that best match your
application’s needs. The situation is similar to choosing either train or airplane transport for
travel between two cities. You have to choose one of the other, and each transportation mode
offers different services. (for example, the train offers downtown pickup and drop-off, whereas
the plane offers shorted travel time).
What are the services that a transport-layer protocol can offer to applications invoking it? We
can broadly classify the possible services along four dimensions: reliable data transfer,
throughput, and security.
As discussed in module 1, packets can get lost within a computer network. For example, a packet
can overflow a buffer in a router, or can be discarded by a host or router after having some of its
bits corrupted. For many applications – such as electronic mail, file transfer, remote host access,
web document transfers, and financial applications – data loss can have devastating
consequences (in the latter case, for either bank of the customer!). Thus, to support these
applications, something has to be done to guarantee that the data sent by one end of the
application is delivered correctly and completely to the other end of the application. If a protocol
provides such a guaranteed data delivery service, it is said to provide reliable data transfer . One
important service that a transport-layer protocol can potentially provide to an application is
process-to-process reliable data transfer. When a transport protocol provides this service, the
sending process can just pass its data into the socket and know with complete confidence that the
data will arrive without errors at the receiving process.
When a transport-layer protocol does not provide reliable data transfer, some of the data sent by
the sending process may never arrive at the receiving process. This data may be acceptable
for loss-tolerant applications, most notably multimedia applications such as conversational
audio/video that can tolerate some amount of data loss. In these multimedia applications, lost
data might result in a small glitch in the audio/video – not a crucial impairment.
Throughput
Timing
A transport-layer protocol can also provide timing guarantees. As with throughput guarantees,
timing guarantees can come in many shapes and forms. An example guarantee might be that
every bit that the sender pumps into the socket arrives at the receiver’s socket no more than 100
msec later. Such a service would be appealing to interactive real-time applications, such as
internet telephony, virtual environments, teleconferencing, and multiplayer games, all of which
require tight timing constrains on data delivery in order to be effective. Long delays in internet
telephony, for example, tend to result in unnatural pauses in the conversation; in a multiplayer
game or virtual interactive environment, a long delay between taking an action and seeing the
response from the environment (for example, from another player at the end of an end-to-end
connection) makes the application feel less realistic. For non-real-time applications, lower delay
is always preferable to higher delay, but no tight constraint is placed on the end-to-end delays.
Security
Finally, a transport protocol can provide an application with one or more security services. For
example, in the sending host, a transport protocol can encrypt all data transmitted by the sending
process, and in the receiving host, the transport-layer protocol can decrypt the data before
delivering the data to the receiving processes. A transport protocol can also provide other
security services in addition to confidentiality, including data integrity and end-point
authentication.
Data connection:-
For sending the actual file, FTP makes use of a data connection. A data connection is initiated on
port number 20. FTP sends the control information out-of-band as it uses a separate control
connection. Some protocols send their request and response header lines and the data in the same
TCP connection. For this reason, they are said to send their control information in-band. HTTP
and SMTP are such examples.
FTP Session:
When an FTP session is started between a client and a server, the client initiates a control TCP
connection with the server-side. The client sends control information over this. When the server
receives this, it initiates a data connection to the client-side. Only one file can be sent over one
data connection. But the control connection remains active throughout the user session.
File size limit is the drawback of FTP only 2 GB size files can be transferred.
Multiple receivers are not supported by the FTP.
FTP does not encrypt the data this is one of the biggest drawbacks of FTP.
FTP is unsecured we use login IDs and passwords making it secure but they can be
attacked by hackers.
In this topic, we will be covering one of the most popular Internet services that is Electronic Mail
(E-mail) in detail.
Electronic mail is often referred to as E-mail and it is a method used for exchanging digital
messages.
This service allows one message to be sent to one or more than one recipient.
The E-mail systems are mainly based on the store-and-forward model where the E-mail
server system accepts, forwards, deliver and store the messages on behalf of users who
only need to connect to the infrastructure of the Email.
The Person who sends the email is referred to as the Sender while the person who
receives an email is referred to as the Recipient.
Need of an Email:
By making use of Email, we can send any message at any time to anyone.
We can send the same message to several peoples at the same time.
1. User Agent(UA)
It is a program that is mainly used to send and receive an email. It is also known as an email
reader. User-Agent is used to compose, send and receive emails.
The User-agent mainly provides the services to the user in order to make the sending and
receiving process of message easier.
The actual process of transferring the email is done through the Message Transfer Agent(MTA).
The protocol that is mainly used to define the MTA client and MTA server on the internet
is called SMTP (Simple Mail Transfer Protocol).
The SMTP mainly defines how the commands and responses must be sent back and forth
In the first and second stages of email delivery, we make use of SMTP.
The third stage of the email delivery mainly needs the pull protocol, and at this stage, the
message access agent is used.
The two protocols used to access messages are POP (Post Office Protocol) and IMAP4
(Internet Message Access Protocol).
Architecture of Email
Now its time to take a look at the architecture of e-mail with the help of four scenarios:
First Scenario
When the sender and the receiver of an E-mail are on the same system, then there is the need for
only two user agents.
Second Scenario
In this scenario, the sender and receiver of an e-mail are basically users on the two
different systems. Also, the message needs to send over the Internet. In this case, we need to
make use of User Agents and Message transfer agents(MTA).
Third Scenario
In this scenario, the sender is connected to the system via a point-to-point WAN it can be either a
dial-up modem or a cable modem. While the receiver is directly connected to the system like it
was connected in the second scenario.
Also in this case sender needs a User agent(UA) in order to prepare the message. After preparing
the message the sender sends the message via a pair of MTA through LAN or WAN.
Fourth Scenario
In this scenario, the receiver is also connected to his mail server with the help of WAN or LAN.
When the message arrives the receiver needs to retrieve the message; thus there is a need for
another set of client/server agents. The recipient makes use of MAA(Message access agent)
client in order to retrieve the message.
In this, the client sends the request to the Mail Access agent(MAA) server and then makes a
request for the transfer of messages.
Structure of Email
Header
The header part of the email generally contains the sender's address as well as the receiver's
address and the subject of the message.
Body
The Body of the message contains the actual information that is meant for the receiver.
Email Address:
In order to deliver the email, the mail handling system must make use of an addressing system
with unique addresses.
Local part
Domain Name
Local Part
It is used to define the name of the special file, which is commonly called a user mailbox; it is
the place where all the mails received for the user is stored for retrieval by the Message Access
Agent.
Domain Name
Both local part and domain name are separated with the help of @.
o It is a program used for sending messages to other computer users based on e-mail
addresses.
o It provides a mail exchange between users on the same or different computers, and it also
supports:
o The main purpose of SMTP is used to set up communication rules between servers. The
servers have a way of identifying themselves and announcing what kind of
communication they are trying to perform. They also have a way of handling the errors
such as incorrect email address. For example, if the recipient address is wrong, then
receiving server reply with an error message of some kind.
Components of SMTP
o First, we will break the SMTP client and SMTP server into two components such as user
agent (UA) and mail transfer agent (MTA). The user agent (UA) prepares the message,
creates the envelope and then puts the message in the envelope. The mail transfer agent
(MTA) transfers this mail across the internet.
o SMTP allows a more complex system by adding a relaying system. Instead of just
having one MTA at sending side and one at receiving side, more MTAs can be
added, acting either as a client or server to relay the email.
o The relaying system without TCP/IP protocol can also be used to send the emails
to users, and this is achieved by the use of the mail gateway. The mail gateway is
a relay MTA that can be used to receive an email.
Working of SMTP
1. Composition of Mail: A user sends an e-mail by composing an electronic mail
message using a Mail User Agent (MUA). Mail User Agent is a program which is
used to send and receive mail. The message contains two parts: body and header.
The body is the main part of the message while the header includes information
such as the sender and recipient address. The header also includes descriptive
information such as the subject of the message. In this case, the message body is
like a letter and header is like an envelope that contains the recipient's address.
2. Submission of Mail: After composing an email, the mail client then submits the
completed e-mail to the SMTP server by using SMTP on TCP port 25.
3. Delivery of Mail: E-mail addresses contain two parts: username of the recipient
and domain name. For example, vivek@gmail.com, where "vivek" is the username
of the recipient and "gmail.com" is the domain name.
If the domain name of the recipient's email address is different from the sender's
domain name, then MSA will send the mail to the Mail Transfer Agent (MTA). To
relay the email, the MTA will find the target domain. It checks the MX record from
Domain Name System to obtain the target domain. The MX record contains the
domain name and IP address of the recipient's domain. Once the record is
located, MTA connects to the exchange server to relay the message.
4. Receipt and Processing of Mail: Once the incoming message is received, the
exchange server delivers it to the incoming server (Mail Delivery Agent) which
stores the e-mail where it waits for the user to retrieve it.
5. Access and Retrieval of Mail: The stored email in MDA can be retrieved by
using MUA (Mail User Agent). MUA can be accessed by using login and
password.
DNS is an application layer protocol defines how the application processes running on different
systems, pass the messages to each other.
o DNS is a directory service that provides a mapping between the name of a host on the
network and its numerical address.
o Each node in a tree has a domain name, and a full domain name is a sequence of symbols
specified by dots.
o DNS is a service that translates the domain name into IP addresses. This allows the users
of networks to utilize user-friendly names when looking for other hosts instead of
remembering the IP addresses.
o For example, suppose the FTP site at EduSoft had an IP address of 132.147.165.50, most
people would reach this site by specifying ftp.EduSoft.com. Therefore, the domain name
is more reliable than IP address.
DNS is a TCP/IP protocol used on different platforms. The domain name space is divided into
three different sections: generic domains, country domains, and inverse domain.
Generic Domains
o Each node in a tree defines the domain name, which is an index to the DNS database.
o It uses three-character labels, and these labels describe the organization type.
Label Description
The format of country domain is same as a generic domain, but it uses two-character country
abbreviations (e.g., us for the United States) in place of three character organizational
abbreviations.
Inverse Domain
The inverse domain is used for mapping an address to a name. When the server has received a
request from the client, and the server contains the files of only authorized clients. To determine
whether the client is on the authorized list or not, it sends a query to the DNS server and ask for
mapping an address to the name.
Working of DNS
o DNS is a client/server network communication protocol. DNS clients send requests to the
server while DNS servers send responses to the client.
o Client requests contain a name which is converted into an IP address known as a forward
DNS lookups while requests containing an IP address which is converted into a name
known as reverse DNS lookups.
o DNS implements a distributed database to store the name of all the hosts available on the
internet.
o If a client like a web browser sends a request containing a hostname, then a piece of
software such as DNS resolver sends a request to the DNS server to obtain the IP address
of a hostname. If DNS server does not contain the IP address associated with a hostname,
then it forwards the request to another DNS server. If IP address has arrived at the
resolver, which in turn completes the request over the internet protocol
We have just seen that there are two ways to identify a host – by a hostname and
by an IP address. People prefer the more mnemonic hostname identifier, while
routers prefer fixed-length, hierarchical structured IP addresses. In order to
reconcile these preferences, we need a directory service that translates hostnames
to IP addresses. This is the main task of the Internet’s domain name system (DNS).
The DNS is a distributed database implemented in a hierarchy of DNS servers, and
an application-layer protocol that allows hosts to query the distributed database.
The DNS servers are often UNIX machines running the Berkeley Internet Domain
(BIND) software [BIND 2012] . The DNS protocol runs over UDP and uses port
53.
As an example, consider what happens when a browser (that is, an HTTP client),
running on some user’s host, requests the URL www.someschool.edy/index.html .
In order for the user’s host to be able to send an HTTP request message to the web
server www.someschool.edu, the user’s host must first obtain the IP address of
www.someschool.edu .This is done as follows:
1. The same user machine runs the client side of the DNS application
3. The DNS client sends a query containing the hostname to a DNS server
4. The DNS client eventually receives a reply, which includes the IP address
for the hostname
5. Once the browser receives the IP address from DNS, it can initiate a TCP
connection to the HTTP server process located at port 80 and that IP
address.
We see from this example that DNS adds an additional delay – sometimes
substantial – to the internet applications that use it. Fortunately, as we discuss
below, the desired IP address is often cached in a “nearby” DNS server, which
helps to reduce DNS network traffic as well as the average DNS delay.
Host Aliasing
A host with a complicated hostname can have one or more alias names. For
example, a hostname such as relay1.west-coast.enterprise.com could have , say,
two aliases such as enterprise.com and www.enterprise.com . In this case, the
hostname relay1.west-coast.enterprise.com is said to be canonical hostname.
Alias hostnames, when present, are typically more mnemonic than canonical
hostnames. DNS can be invoked b an application to obtain the canonical hostname
for a supplied alias hostname as well as the IP address of the host.
For obvious reasons, it is highly desirable that e-mail addresses by mnemonic. For
example, if Bob has an account with Hotmail, Bob’s e-mail address might be as
simple as bob@hotmail.com. However, the hostname of Hotmail mail server is
more complicated and much less mnemonic than simply Hotmail.com (for
example, the canonical hostname might be something like relay1.west-
coast.hotmail.com). DNS can be invoked by a mail application to obtain the
canonical hostname for a supplied alias hostname as well as the IP address of the
host. In fact, the MX record (see below) permits a company’s mail server and web
server to have identical (aliased) hostnames; for example, a company’s web server
and mail server can both be called enterprise.com.
Load Distribution
DNS is also used to perform load distribution among replicated servers, such as
replicated Web servers. Busy sites, such as cnn.com, are replicated over multiple
servers, with each running on a different end system and having a different IP
address. For replicated web servers, a set of IP addresses is thus associated with
one canonical hostname. The DNS database contains this set of IP addresses.
When clients make a DNS query for a name mapped to a set of addresses, the
server responds with the entire set of IP addresses, by rotates the ordering of the
addresses within each reply. Because a client typically sends its HTTP request
message to the IP address that is listed first in the set, DNS rotation distributes the
traffic among the replicated servers.
DNA rotation is also used for e-mail so that multiple mail servers can have the
same alias name. also, content distribution companies such as Akamai have used
DNS in more sophisticated ways to provide web content distribution.
TTL is the time to live of the resource record; it determines when a resource should
•If Type=NS, then Name is a domain (such as foo.com) and Value is the hostname
of an authoritative DNS server that knows how to obtain the IP addresses for
•If Type=CNAME, then Value is a canonical hostname for the alias hostname
Name. This record can provide querying hosts the canonical name for
a host name.
•If Type=MX, then Value is the canonical name of a mail server that has an alias
DNS Messages
The first 12 bytes is the header section, which has a number of fields.
•The first field is a 16-bit number that identifies the query. This identifier is
copied into the reply message to a query, allowing the client to match received
reply (1). A1-bit authoritative flag is set in a reply message when a DNS server
A 1-bit recursion-desired flag is set when a client (host or DNS server) desires
that the DNS server perform recursion when it doesn’t have the record.
A 1-bit recursion available field is set in a reply if the DNS server supports
recursion.
•In the header, there are also four number-of fields. These fields indicate the
number of occurrences of the four types of data sections that follow the
header.
•The question section contains information about the query that is being made.
This section includes (1) a name field that contains the name that is being
queried, and (2) a type field that indicates the type of question being asked
•In a reply from a DNS server, the answer section contains the resource records