0% found this document useful (0 votes)
14 views32 pages

Understanding Domain Name System (DNS)

The document discusses the Application Layer of Computer Networks, focusing on the Domain Name System (DNS) which maps human-readable domain names to IP addresses. It explains the evolution from host files to a distributed DNS architecture to manage the growing size of the Internet, detailing the hierarchical structure of domain names and the roles of primary and secondary DNS servers. Additionally, it covers the processes of name resolution, including recursive and iterative resolution, and the importance of caching for efficiency.

Uploaded by

kasmadeking
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views32 pages

Understanding Domain Name System (DNS)

The document discusses the Application Layer of Computer Networks, focusing on the Domain Name System (DNS) which maps human-readable domain names to IP addresses. It explains the evolution from host files to a distributed DNS architecture to manage the growing size of the Internet, detailing the hierarchical structure of domain names and the roles of primary and secondary DNS servers. Additionally, it covers the processes of name resolution, including recursive and iterative resolution, and the importance of caching for efficiency.

Uploaded by

kasmadeking
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Networks - II Application Layer

• We knew that network layer provides unique identification and source to destination
delivery for a host on the Internet. For this, network layer uses its own IP protocol (for
source to destination delivery) and IP addressing (for unique identification).
• However, people prefer to use names instead of numeric addresses. Therefore, we
need a system that can map a name to an address or an address to a name.
• When the Internet was small, mapping was done by using a host file. Every host stores
these hosts file on its disk and update it periodically from a master file. This file had
two columns i.e., name and address.
• When a program or a user wanted to map a name to an address, the host consulted the
host file and found the mapping.
• Today, since the size of Internet is so large and growing day-by-day, the host file
becomes too large to store on every host. It would also be impossible to update all host
files every time there was a change.
• One solution to this problem is, instead of storing the host file on every computer, the
host file is stored on single computer and allows access to this centralized information
to every computer who needs mapping.
• But it will create large traffic on the Internet and number of users will not get the
mapping. So this solution also not works.
• Another solution is, instead of storing this huge information on single computer,
divide this huge information into smaller parts and store each part on a different
computer.
• The host that needs mapping can contact the closest computer holding the needed
information. This method is Doman Name System (DNS).
• Domain Name Systems (DNS) is mechanisms that assign easy to remember names to IP
address. Domain is a large group of computers on the Internet. Under this scheme
each computer has an IP address and a domain name.
• Domains have been made on the base of organization type or geographical locations,
e.g., the domain name [Link] (where, .com indicates that Google is a commercial
organization).
• In Fig. 1.1, a user wants to use a file transfer client to access the corresponding file
transfer server running on a remote host. The user knows only the file transfer server
name, such as [Link].
• However, the TCP/IP suite needs the IP address of the file transfer server to make the
connection. The following six steps map the host name to an IP address:
Step 1: The user passes the host name to the file transfer client.
Step 2: The file transfer client passes the host name to the DNS client.
Step 3: Each computer, after being booted, knows the address of one DNS server. The
DNS client sends a message to a DNS server with a query that gives the file
transfer server name using the known IP address of the DNS server.
Step 4: The DNS server responds with the IP address of the desired file transfer
server.
1.2
Computer Networks - II Application Layer

Step 5: The DNS client passes the IP address to the file transfer server.
Step 6: The file transfer client now uses the received IP address to access the file
transfer server.

Fig. 1.1: How TCP/IP uses a DNS Client and a DNS Server to
Map a Name to an Address
• Fig. 1.2 shows an example of how a DNS client/server program supports a user to find
IP address.

Fig. 1.2: Example of DNS Service

1.1.1 Name Space


• The names assigned to machines must be carefully selected from a name space with
complete control over the binding between the names and IP addresses.
• 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 i.e., flat or hierarchical.
1.3
Computer Networks - II Application Layer

1. Flat Name Space:


• In flat name space, a name is assigned to an address. A name in this space is a
sequence of characters without structure.
• The names may or may not have common section. But this name space cannot be used
in Internet because ambiguity and duplication is not avoided.
• For example, a Uniform Resource Locator (URL) which uniquely identifies a resource
over the network likes nashik or rediff or google.
2. Hierarchical Name Space: (April 19)
• In hierarchical name space, every name is made up of several parts. The first part can
define the nature or organization, the second part defines name of organization and
third part defines departments in the organization, if any and so on.
• A central authority can assign the part of the name that defines nature of the
organization and name of organization. The organization can add suffixes or prefixes
to the name.
• These names are unique and cannot be duplicated. For examples, [Link],
[Link], [Link], [Link], [Link] etc.
1.1.2 Domain Name Space (April 16)

• The domain name space refers a hierarchy in the internet naming structure. In this
space, the names are defined in an inverted tree structure with the root at the top.
• The Fig. 1.3 shows the domain name space hierarchy.

Fig. 1.3: Domain Name Space

1.4
Computer Networks - II Application Layer

• To have a hierarchical name space, a domain name space was designed. The names
are defined in an inverted-tree structure (Refer Fig. 1.3) with root at the top.
Label:
• Each node in the tree has a label, which is a string with a maximum of 63 characters.
The root label is null string.
Domain Name:
• Every node in the tree has a domain name. A full domain name is a sequence of labels
separated by dots (.).
• Domain names are always read from the node up to the root. Fig. 1.4 shows some
domain names.
1. Fully Qualified Domain Name:
• If a label is terminated by a null string, it is called a Fully Qualified Domain Name
(FQDN).
• A FQDN is the complete domain name for a specific computer, or host, on the Internet.
FQDN contains full name and all labels of a host.
• For example: [Link], [Link], [Link] etc.
2. Partially Qualified Domain Name:
• If a label is not terminated by a null string, it is called a Partially Qualified Domain
Name (PQDN).
• A PQDN starts from a node, but it does not reach the root.
• For example: unipune.
Root

edu
edu.

Label Domain name


fhda [Link].

atc [Link].

challenger [Link].

Fig. 1.4: Domain Names and Labels


1.5
Computer Networks - II Application Layer

3. Domain:
• A domain is a subtree of the domain name space.
• The name of the domain is the domain name of the node at the top of the subtree. A
domain may be divided into sub-domains.

edu
Domain
com

Domain

Domain

Domain

Domain

Fig. 1.5: Domains in Internet Naming Structure

• Domain Name is a symbolic string associated with an IP address.


• There are several domain names available; some of them are generic such as .com,
.edu, .gov, .net etc, while some country level domain names such as .au, .in, .za, .us etc.

1.1.3 Distribution of Name Space


• The information contained in the domain name space must be stored. Storing this
huge information on single computer is inefficient and unreliable.
• It is inefficient because all users from the world send their requests to this computer,
which places a heavy load. If this computer fails then data becomes inaccessible, so it
is unreliable.
• The solution of above problem is to distribute the information among many computers
called DNS Servers.
Hierarchy of Name Servers:
• Name server contains the DNS database. DNS database comprises of various names
and their corresponding IP addresses.
• Since it is not possible for a single server to maintain entire DNS database, therefore,
the information is distributed among many DNS servers.
• Hierarchy of server is same as hierarchy of names. The entire name space is divided
into the zones.
1.6
Computer Networks - II Application Layer

Root server

arpa server edu server com server us server

[Link] [Link] [Link] [Link]

Fig. 1.6: Hierarchy of Name Servers

• DNS allows domains to be divided further into sub-domains. Each server can be
responsible for either a large or small domain. We have hierarchy of servers in the
same way as hierarchy of names.
• If the server divides the domain into sub-domains and assigns responsibility to
different servers, zone and domain are different. Each server has authority over a
zone.
• A DNS zone is a portion of the global Domain Name System (DNS) net-nuance for
which administrative responsibility has been delegated.
• The authority over each DNS zone is delegated to a legal entity or organization (i.e. a
country-code lop-level domain registry) or a company/individual.
• A zone is created mainly for administrative purposes. If a server stores the entire
domain, the zone and domain are the same.
Zone:
• Since, the complete domain name hierarchy cannot be stored on a single server, it is
divided among many servers. What a server is responsible for or has authority over is
called a zone.
• If a server accepts responsibility for a domain and does not divide the domain into
smaller domains (sub-domains), the "domain" and the 'zone" refers to the same thing.
• The server makes a database called a zone file and keeps all the information for every
node under that domain.

1.7
Computer Networks - II Application Layer

Root

com
Zone
Domain

Zone and Domain

Fig. 1.7: Zones and domains

Root Server:
• Root servers are DNS name servers that operate in the root zone. Root Server is the top
level server which consists of the entire DNS tree.
• It does not contain the information about domains but delegates the authority to the
other server.
• Root servers are an essential part of the infrastructure of the Internet; web browsers
and many other internet tools would not work without them.
Primary and Secondary Servers:
• DNS defines two types of servers i.e., Primary and Secondary.
1. Primary Servers:
• A primary server is a server that stores a file about the zone for which it is an
authority.
• It is responsible for creating, maintaining and updating the zone file. It stores the zone
file on a local disk.
2. Secondary Server:
• A secondary server is a server that transfers all information from the primary server.
• When the secondary downloads information from the primary, it is called zone
transfer.
Zone Transfer:
• A primary server loads all information from the disk file; the secondary DNS Server
loads all information from the primary server.
• When the primary DNS server downloads information from the secondary, it is called
zone transfer.

1.1.4 DNS in the Internet


• In the Internet, the domain name space is divided into three different sections
i.e., generic domains, country domains and the inverse domain.
1.8
Computer Networks - II Application Layer

Fig. 1.8: DNS used in the Internet

• The domain names in Fig. 1.8 are explained below:


1. Generic Domains: (April 17)
• The generic domains define registered host according to their generic behavior.
• In generic domains each node in the tree defines a domain, which is an index to the
domain name space database as shown Fig. 1.9.
Root level

coop gov mus- org pro


aero biz com edu info int mil eum
name net

fhda

atc

chal

[Link].
Index to addresses

Fig. 1.9: Generic Domains

• Table 1.1 gives list of labels used in generic domain.

1.9
Computer Networks - II Application Layer

Table 1.1: Generic Domain Labels


Label Description
aero Airlines and aerospace companies.
biz Business or firms.
com Commercial organizations.
coop Co-operative business organizations.
edu Educational institutions.
gov Government institutions.
info Information service providers.
int International organizations.
mil Military groups.
museum Museums and other non-profit organizations.
name Personal names.
net Network support centers.
org Non-profit organizations.
2. Country Domains:
• Country domains uses two characters country abbreviations (e.g. in for India). Second
labels can be organizational or national designations.
• Fig. 1.10 shows the country domains.

Fig. 1.10: Country Domains

3. Inverse Domain:
• The inverse domain is used to map an address to a name. This can be happen, for
example, server want to check his authorized client.
• Fig. 1.11 shows example of inverse domain.

1.10
Computer Networks - II Application Layer

Index to names

Fig. 1.11: Inverse Domain

1.1.5 Resolution (Oct. 18, April 19)


• Mapping a name to an address or an address to a name is called as address resolution.
Resolver:
• DNS is a client/server application. When a host requires mapping of name to an
address or an address to a name, it calls DNS client called a resolver.
• The resolver accesses the closest DNS sever with mapping request. If the server knows
the mapping, it gives it to resolver or it redirects the resolver to other server.
Mapping Names to Addresses:
• The resolver gives a domain name to the server and asks for the correct address. The
server either checks the generic domains or the country domains for the mapping.
• Query is sent by the resolver to the local DNS server for resolution. If the local server
cannot resolve the query, it either refers the resolver to other servers or asks other
servers directly.
Mapping Addresses to Names:
• A client can send an IP address to a server to be mapped to a domain name.
• To answer such type of query, DNS server uses inverse domain.
1.11
Computer Networks - II Application Layer

Recursive Resolution:
• If the client (resolver) sends recursive query to the DNS server and expects the server
to supply the final answer, if that server is the authority for the domain name, it
checks the database and responds.
• If the server is not authority, it sends the request to another server and waits for
response. If this server is authority, it responds, otherwise it sends the query to yet
another server.
• When the query is finally resolved, the response travels back up to the requesting
client. This is called recursive resolution and it is shown in Fig. 1.12.
Root server

3
4
8
7

com

2 ac
6
9
1 5

10
[Link]
Client [Link]

Fig. 1.12: Recursive Resolution


Iterative Resolution:
• If the client does not ask for a recursive query, the mapping can be iterative. If the
server is authority for the name it gives reply to the client. Otherwise it returns the IP
address of a server that it thinks can resolve the query.
• Now client again ask to that new server about mapping, if it knows, it gives reply,
otherwise it gives the IP address of server which he thinks solve the query.
• Now, the client must repeat the query to the third server and so on. This process is
called iterative resolution because the client repeats the same query to multiple
servers.
• Fig. 1.13 shows iterative resolution.
Caching:
• Every time when DNS server receives a request from client, it has to search in its
database and then gives reply. If this search time reduces, efficiency increases.
• DNS use caching to do this. When a server asks for a mapping from another server
and receives the response, it stores the information in its cache memory before
sending it to the client.

1.12
Computer Networks - II Application Layer

• If the same or another client asks for the same mapping, it can check its cache memory
and gives reply. The server marks such type of response as un-authoritative.
• Caching speeds up the resolution but sometimes it can also be problematic.

Fig. 1.13: Iterative Resolution

1.1.6 DNS Messages


• DNS has two types of messages namely, query and response. Both types of messages
have the same format.
• The query message consists of a header and question records as shown in
Fig. 1.14 (a).
• The response message consists of a header, question records, answer records,
authoritative records, and additional records as shown in Fig. 1.14 (b).

(a) DNS Query Message (b) DNS Response Message


Fig. 1.14: DNS Messages
1.13
Computer Networks - II Application Layer

Header:
• Both query and response messages have the same header format with some fields set
to zero for the query messages.
• The header is 12 bytes and its format is shown in Fig. 1.15.

Identification Flags

Number of question records Number of answer records (all 0s in


query message)

Number of authoritative records Number of additional records (all 0s


(all 0s in query message) in query message)

Fig. 1.15: Header Format


• The header fields are as follows:
o Identification is a 16-bit field used by the client to match the response with the
query. The client uses a different identification number each time it sends a query.
The server duplicates this number in the corresponding response.
o Flags, is a 16-bit field consisting of the subfields shown in Fig. 1.16.

Fig. 1.16: Flag Fields


A brief description of each flag subfield follows:
QR (Query/Response) is a 1-bit subfield that defines the type of message. If it
is 0, the message is a query. If it is 1, the message is a response.
OpCode is a 4-bit subfield that defines the type of query or response (0 if
standard, 1 if inverse, and 2 if a server status request).
AA (Authoritative Answer) is a 1-bit subfield. When it is set (value of 1) it
means that the name server is an authoritative server. It is used only in a
response message.
TC (TrunCated) is a 1-bit subfield. When it is set (value of 1), it means that the
response was more than 512 bytes and truncated to 512. It is used when DNS
uses the services of UDP.
RD (Recursion Desired) is a 1-bit subfield. When it is set (value of 1) it means
the client desires a recursive answer. It is set in the query message and
repeated in the response message.
RA (Recursion Available) is a 1-bit subfield. When it is set in the response, it
means that a recursive response is available. It is set only in the response
message.
1.14
Computer Networks - II Application Layer

Reserved is a 3-bit subfield set to 000.


rCode is a 4-bit field that shows the status of the error in the response.
o Question Section consisting of one or more question records. It is present on both
query and response messages.
o Answer Section consisting of one or more resource records. It is present only on
response messages. This section includes the answer from the server to the client
(resolver).
o Authoritative Section consisting of one or more resource records. It is present
only on response messages. This section gives information (domain name) about
one or more authoritative servers for the query.
o Additional Information Section consisting of one or more resource records. It is
present only on response messages. This section provides additional information
that may help the resolver.

1.2 E-MAIL
• The main task of the Internet is to provide services to users. E-mail is most popular
application of Internet. E-mail is short form of electronic mail.
• At the beginning of the Internet, the messages sent by electronic mail were short and
contains text only. Today, e-mails are much more complex and contains text, audio
and video and one message can be sent to multiple recipients.
• We will study architecture of e-mail and the components of e-mail system in this
section.

1.2.1 Architecture (April 19)

• To understand the architecture of e-mail, we will discuss four scenarios associated


with e-mail system.
First Scenario:
• In this scenario, the sender and the receiver of the e-mail are users on the same
system. Every user is having one mail box created by administrator.
• A mail box is a part of local hard disk. When user Amar (A) wants to send a message to
another user Bhushan (B), Amar runs a User Agent (UA) program to create mail and
store it in Bhushan’s mail box.
• Every mail has sender’s and recipient mail addresses. Bhushan can read the contents
of his mail box at his convenience, using a user agent.
• When the sender and the receiver of an e-mail are on the same system, we need only
two user agents. This is shown in Fig. 1.17.

1.15
Computer Networks - II Application Layer

User Agent (UA) User Agent (UA)

Amar Bhushan

System

Fig. 1.17: First scenario in Electronic Mail

Second Scenario:
• In the second scenario, the sender and receiver of the e-mail are users from different
systems. The message is sent over the Internet. Thus, we need two user agents and
pair of MTAs (client and server).
• Amar, the sender uses user agent program to send her message at her own site.
Bhushan, the receiver needs user agent program to retrieve messages stored in the
mail box of the system at his site.
• To send the messages from Amar’s site to Bhushan’s site, two Message Transfer Agents
(MTAs) are needed, one client and one server. This is shown in Fig. 1.18.

User User
Agent (UA) Agent (UA)

Amar Bhushan
MTA MTA
client Internet client

System System
(mail server) (mail server)

Fig. 1.18: Second scenario in Electronic Mail

Third Scenario:
• In this scenario, Bhushan, the receiver is directly connected to his system. Amar, the
sender is separated from him system. He is connected to the system via dial up modem
or DSL etc.
• Amar uses user agent to prepare his message.
• The message is now send through the LAN or WAN. This is done by using pair of
message transfer agent (client and server).

1.16
Computer Networks - II Application Layer

User MTA
agent Amar client

LAN
or
WAN

MTA
client

User
agent

Bhushan
MTA MTA
client Internet server

System System
(mail server) (mail server)

Fig. 1.19: Third scenario in Electronic Mail

• MTA client establishes a connection with MTA server. MTA client then send the
message to the system at Bhushan’s site.
• System receives it and stores it in Bhushan’s mail box. As per his convenience,
Bhushan uses his user agent to retrieve his message.
• Note that, when the sender is connected to the mail server via a LAN or a WAN, we
need two UAs and two pairs of MTAs (client and server).
Fourth Scenario:
• In the fourth and most common scenario, Bhushan, the receiver is also connected to
his mail server by a WAN or LAN. When the message is arrived at Bhushan’s server,
he retrieves it by using another set of client/server agents also called as Message
Access Agents (MAAs).
• Bhushan uses MAA client to retrieve the message. The MAA client pulls the messages
from the mail server and pushes them into a special MAA server.
• Bhushan uses MAA client to retrieve messages from the MAA server.

1.17
Computer Networks - II Application Layer

• In short, we can say, when both sender and receiver are connected to the mail server
via a LAN or WAN, we need two UAs, two pairs of MTAs, and a pair of MAAs. This is
most common situation today, shown in Fig. 1.20.
User MTA MAA User
agent Amar client client Bhushan agent

LAN LAN
or or
WAN WAN

MTA MTA
client server

MTA MTA
client Internet server

System System
(mail server) (mail server)
Fig. 1.20: Fourth scenario in Electronic Mail

1.2.2 User Agent


• The first component of e-mail system is User Agent (UA). It provides services to user.
The user agent provides service to the user to make the process of sending and
receiving a message easier.
Services Provided by User Agent:
• A user agent is a software that provides following services shown in Fig. 1.21.

Fig. 1.21: Services of User Agent

1.18
Computer Networks - II Application Layer

• Let us see messages in Fig. 1.21 in detail:


1. Composing Messages:
• A user agent helps the user to compose (create) an e-mail. User agent provides a
template on the screen, which helps the user.
• Some even have built in editor that can do spell checking, grammar checking, cut,
copy, paste etc. text formatting functions.
2. Reading Messages:
• Next function of user agent is to read incoming messages. User agent first checks the
mail in the incoming mail box. User agent shows a one line summary of every received
mail.
• Every e-mail contains number field, flag showing status of e-mail like new, read,
replied etc., size of message, the sender and the optional subject field.
3. Replying to Messages:
• After reading a message, user sent reply by using user agent.
• The user agent allows the user to reply to the original sender or to reply all recipients
of the messages.
4. Forwarding Messages:
• User agent allows the receiver to forward the message, with or without extra
comments, to a third party.
5. Handling Mail Boxes:
• A user agent creates two mail boxes i.e., inbox and outbox.
• Inbox keeps all the received e-mails until they are deleted by the user. The outbox
keeps all the sent e-mails until the user deletes them.
Types of User Agent:
• User agent can be of two types:
1. Command Driven:
• Command driven user agents belong to the early days of e-mail.
• A command driven user agent normally accepts one character from the keyboard to
perform its task, e.g. mail, pine and elm.
2. GUI Based:
• Modern user agents are GUI-based, which contains graphical user interface that allow
the user to use keyboard and mouse, e.g. Outlook, Netscape, Eudor(a)
Sending Mail:
• To send mail, user creates a mail. E-mail has an envelope and a message as shown in
Fig. 1.22.
1.19
Computer Networks - II Application Layer

27/11/2015

Fig. 1.22: Format of E-mail


• The fields in email message are explained below:
Envelope:
• The envelope contains sender and receiver addresses.
Message:
• Message contains header and body. In header, sender, receiver, date, subject of e-mail
are defined. Body part contains actual information to be read by the recipient.
Receiving Mail:
• If user has a mail, UA informs the user. A list is displayed to the user in which
summary of e-mail is mentioned.
• The user can selects any of the messages and display its contents on the screen.
Addresses:
• To deliver a mail, a mail handling system must use an addressing system with unique
addresses.
• E-mail address contains two parts, local port and a domain name, separated by @ sign
(Refer Fig. 1.23).
• Local port defines the name of user mail box. And domain name defines the name of
mail server (Refer Fig. 1.24).

Fig. 1.23: E-mail Address Fig. 1.24

1.2.3 MIME
• E-mail system has one limitation, it can send messages only in NVT 7-bit ASCII. It
cannot be used for languages like German, Russian, Chinese, Japanese and Hebrew.
Also it cannot be used to send binary files or video or audio data.
• The Multipurpose Internet Mail Extensions (MIME) is a protocol that allows non-ASCII
data to be sent through e-mail.
1.20
Computer Networks - II Application Layer

• MIME transforms non-ASCII data at sender site to NVT (Network Virtual Terminal)
ASCII and delivers them to the client MTA to be sent through the Internet. The message
at the receiving site is transformed back to the original data
• Suppose a user (Amar) wants to send an email through user agent and it is in a non-
ASCII format so there is a MIME protocol which converts it into 7-bit NVT ASCII
format.
• Message is transferred through e-mail system to the other side in 7-bit format now
MIME protocol again converts it back into non-ASCII code and now the user agent of
receiver side reads it and then information is finally read by the receiver (Bhushan).

Fig. 1.25: MIME


MIME Headers:
• MIME header is basically inserted at the beginning of any e-mail transfer. MIME
defines five headers namely, MIME-Version, Content-Type, Content-Type-Encoding,
Content-Id and Content-Description (Refer Fig. 1.40) that can be added to the original
e-mail header section to define the transformation parameters.

Fig. 1.26: MIME Headers

• MIME headers in Fig. 1.26 are explained below:


1. MIME-Version header defines version of MIME protocol. It must have the
parameter value 1.1, which indicates that message is formatted using MIME.
2. Content-Type header defines type of data used in the body of message. They are of
different types like text data (plain, HTML), image, audio content or video content.
3. Content-Type-Encoding header defines the method used for encoding the
message into 0s and 1s for transport like 7-bit encoding, 8-bit encoding, Base64 etc.
1.21
Computer Networks - II Application Layer

4. Content-Id header is used for uniquely identifying the whole message in a


multiple message environment.
5. Content-Description header defines whether the body is actually image, video or
audio.

1.2.4 Message Transfer Agent: SMTP (April 16, 17, Oct. 17)
• The mail transfer is done by Message Transfer Agents (MTA). To send mail, a system
must have client MTA and to receive mail, a system must have server MTA.
• The protocol that defines the communication between MTA client and MTA server is
called Simple Mail Transfer Protocol (SMTP).
• SMTP is a TCP/IP protocol that specifies how computers exchange electronic mail.
SMTP is used twice, between the sender and the sender’s mail server and between the
two mail servers.
• Another protocol i.e. POP3 or IMAP4 is needed between the mail server and the
receiver.
POP3/
SMTP SMTP IMAP4

Amar Bhushan
sender receiver

LAN LAN
or or
WAN WAN

Mail server Internet Mail server

Fig. 1.27: SMTP, POP3 and IMAP4

Commands and Responses:


• SMTP uses commands and response to transfer messages between MTA client and
MTA server.

Fig. 1.28: Commands and Responses


• Commands are sent by client to server. Command consists of a keyword followed by
zero or more arguments. SMTP uses 14 commands.
• Responses are sent from server to client. A response is a three digit code.
• Table 1.2 shows SMTP commands.
1.22
Computer Networks - II Application Layer

Table 1.2: SMTP Commands


Keyword Argument (s)
HELO Sender’s host name
MAIL FROM Sender of the message
RCPT TO Intended recipient of message
DATA Body of the mail
QUIT 
RSET 
VRFY Name of recipient to be verified
NOOP 
TURN 
EXPN Mailing list to be expanded
HELP Command name
SEND FROM Intended recipient of the message
SMOL FROM Intended recipient of the message
SMAL FROM Intended recipient of the message
Table 1.3: SMTP Responses

Code Description
Positive Completion Reply
211 System status or help reply
214 Help message
220 Service ready
221 Service closing transmission channel
250 Request command completed
251 User not local, the message will be forwarded
Positive Intermediate Reply
354 Start mail input
Transient Negative Completion Reply
421 Service is not available
450 Mail box not available
451 Command aborted: local error
452 Command aborted: insufficient storage
1.23
Computer Networks - II Application Layer

Permanent Negative Completion Reply


500 Syntax error, unrecognized command
501 Syntax error in parameters or arguments
502 Command not implemented
503 Bad sequence of commands
504 Command temporarily not implemented
550 Command is not executed, mail box unavailable
551 User not local
552 Requested action aborted, exceeded storage location
553 Requested action not taken, mail box name not allowed
554 Transaction failed.
Mail Transfer Phases:
• Mail transfer occurs in three phases: connection establishment, mail transfer and
connection termination.
• Now, let us see the typical SMTP procedure with an example:
$ telnet [Link] 25
Trying [Link]….
connected to [Link] ([Link]).
===========Connection Establishment===========
220 mta [Link] SMTP server reday Monday,15 Nov. 2010…
HELO mail⋅[Link]
250 mta [Link]
===========Mail Transfer===========
MAIL FROM: patilra@[Link]
250 sender <patilra@[Link]> OK
RCPT TO: Shindesn@[Link]
250 Recipient <shindesn@[Link]> OK
DATA
354 OK send data ending with <CRLF>.<CRLF>
FROM: Patil RA
TO: Shinde SN
Hi, How are you?
===========Connection Termiation===========
250 message received: mail@[Link]
QUIT
221 mta [Link] SMTP server closing connection
Connection closed by foreign host.
1.24
Computer Networks - II Application Layer

1.2.5 Message Access Agent: POP3 and IMAP4


• SMTP is used in the first and second stage of mail delivery. SMTP is push protocol, it
pushes the message from the client to the server, as shown in Fig. 1.21.
• The third stage needs a pull protocol from receiver to mail server. The third stage uses
a message access agent. Now, two message access protocols are available i.e., Post
Office Protocol (POP Version 3) and Internet Mail Access Protocol (IMAP Version 4).
• SMTP is a push protocol and is used to send the mail whereas POP (post office
protocol) and IMAP (internet message access protocol) are used to retrieve those mails
at the receiver’s side.
• Fig. 1.29 shows the position of these two protocols in the most common situation
(fourth scenario in e-mail).

Fig. 1.29

• Let us see POP3 and IMAP4 in detail:


1. POP3:
• Post Office Protocol (POP) is an application-layer Internet standard protocol used by
local e-mail clients to retrieve e-mail from a remote server over a TCP/IP connection.
• POP supports simple download-and-delete requirements for access to remote
mailboxes. A POP3 server listens on well-known port 110.
• Post Office Protocol version 3 (POP3) is simple protocol with limited functionality. The
client POP3 software is installed on the recipient, the server POP3 software is installed
on the server.
• Mail access starts with the client, when the user wants to access e-mail from the mail
server to mail box. Client opens TCP connection on port 110.
• It then sends its user name and password to access the mail box. User can then
retrieve the mail messages.
• Fig. 1.30 shows example of downloading using POP3.
• POP3 has two modes, the delete mode and the keep mode. In delete mode, the mail is
deleted from the mail box after each retrieval. In the keep mode, the mail remains in
the mail box after retrieval.

1.25
Computer Networks - II Application Layer

Fig. 1.30: Exchange of Commands and Responses in POP3

2. IMAP4:
• IMAP stands for Internet Mail Access Protocol. It was first proposed in 1986. The
current version is Internet Mail Access Protocol, version 4 (IMAP4).
• Another mail access protocol is IMAP4 is similar to POP3 but is more powerful and
more complex.
• POP3 not allows the user to organize mail on the server, the user cannot have different
folders on the server.
• POP3 also does not allow the user to partially check the content of mail before
downloading. All these drawbacks are overcome in IMAP4.
• IMAP4 provides following functions:
(i) User can check e-mail header before downloading.
(ii) User can search the contents of the e-mail for a specific string of characters before
downloading.
(iii) User can partially download e-mail.
(iv) A user can create, delete or rename mailboxes on the mail server.
(v) User can create a hierarchy of mailboxes in a folder for storage.

1.26
Computer Networks - II Application Layer

Comparison between POP and IMAP:

Sr.
POP IMAP
No.
1. Generally used to support single Designed to handle multiple clients.
client.
2. Messages are accessed offline. Messages are accessed online although it
also supports offline mode.
3. POP does not allow search facility. It offers ability to search emails.
4. All the messages have to be It allows selective transfer of messages
downloaded. to the client.
5. Only one mailbox can be created on Multiple mailboxes can be created on
the server. the server.
6. Not suitable for accessing non-mail Suitable for accessing non-mail data i.e.
data attachment.
7. POP commands are generally IMAP commands are not abbreviated,
abbreviated into codes of three or they are full. Example: STATUS.
four letters. Example: STAT.
8. It requires minimum use of server Clients are totally dependent on server.
resources.
9. Mails once downloaded cannot be Allows mails to be accessed from
accessed from some other location. multiple locations.
10. The e-mails are not downloaded Users can view the headings and sender
automatically. of e-mails and then decide to download.
11. POP requires less internet usage IMAP requires more internet usage time.
time.

1.3 FILE TRANSFER


• Transferring files from one computer to another is one of important task of
network/internetworks.
• The greatest volume of data exchange in the Internet today is due to file transfer. For
transferring file over a computer network the File Transfer Protocol (FTP) is used.
• FTP is a standard internet protocol provided by TCP/IP used for transmitting the files
from one host to another in a computer network or Internet.

1.27
Computer Networks - II Application Layer

1.3.1 FTP
• FTP stands for File Transfer Protocol. FTP is the standard mechanism provided by
TCP/IP for copying (transferring) a file from one host to another.
• FTP can transfer files between any computers that have an Internet connection, and
also works between computers using totally different operating systems.
• Transferring files from a client computer to a server computer is called "uploading"
and transferring from a server to a client is "downloading".

FTP commands

FTP replies
Data

FTP client Connection FTP server


on client PC

Fig. 1.31: Function of FTP


• While transferring files from one system to another, several problems can be arises,
e.g. two systems may use different file name conventions, two systems may have
different ways to represent text and data.
• They may have different directory structures etc. All these compatibility problems are
solved by FTP.
• FTP is a client/server application. FTP establishes two connections between hosts. One
connection for data transfer and other for control information (commands and
responses).
• FTP uses the services of TCP. It needs two TCP connections. The well known port 21 is
used for the control connection and the well known port 20 is used for data
connection.
• Fig. 1.32 shows the basic model of FTP.
• The client has following three components:
1. User interface.
2. Client control process.
3. Data transfer process.
• The server has following two components:
1. Control process.
2. Data transfer process.
• Control connection is made between control processes and data connection is made
between data transfer processes. First control connection is established and then data
connection.
• While the control connection is open, data connection can be opened and closed many
times if numbers of files are transferred.
1.28
Computer Networks - II Application Layer

User

User
interface
Control connection
Control Control
process process
TCP/IP
Data transfer Data transfer
process process
Data storage Data connection Data storage
Client Server
Fig. 1.32: Basic Model of FTP
• Communication with an FTP server is done through two connections, a control
connection, and a data connection.
• FTP uses two well-known TCP ports for connections Port 21 is used for the control
connection and port 20 is used for the data connection.

[Link] Control Connection


• There are following two steps for control connection:
Step 1: The server issues a passive open on the well-known port 21 and waits for a
client.
Step 2: The client uses an ephemeral port and issues an active open.
• The connection remains open during the entire process. The service type, used by the
IP protocol, is minimizing delay because this is an interactive connection between a
user (human) and a server.
• The user types commands and expects to receive responses without significant delay.
Fig. 1.33 shows the initial connection between the server and the client.

(a) First, Passive open by Server

(b) Later, Active open by Client


Fig. 1.33: Opening the Control connection

1.29
Computer Networks - II Application Layer

Communication over Control Connection:


• The control connection is always the first/initial connection established with an FTP
server.
• The control connection's purpose is to allow clients to connect and to send commands
to the server (and receive server responses).
• FTP uses 7 bit ASCII character set over the control connection. On control connection,
communication is achieved through commands and responses.
• Every command or response is one short line, so we need not worry about file format
or file structure. Every line is terminated with carriage return and line feed, end of
line token.
Local code Local code

Control NVT ASCII Control


process process
Control connection
Client Server

Fig. 1.34: Control Connection

[Link] Data Connection


• The data connection uses the well-known port 20 at the server site. However, the
creation of a data connection is different from what we have seen so far.
• The following steps shows how FTP creates a data connection:
Step 1: The client, not the server, issues a passive open using an ephemeral port. This
must be done by the client because it is the client that issues the commands for
transferring files.
Step 2: The client sends this port number to the server using the PORT command.
Step 3: The server receives the port number and issues an active open using the well-
known port 20 and the received ephemeral port number.
• The steps for creating the initial data connection are shown in Fig. 1.35.

(a) First, Passive open by Client

(b) Second, Sending of Ephemeral Port


1.30
Computer Networks - II Application Layer

(c) Third, Active open by Server

Fig. 1.35: Creating the Data Connection


Communication over Data Connection:
• Files are transferred using data connection. File transfer over data connection is
under the control of control connection.
• File transfer in FTP means, a file is to be copied from server to the client (retrieving a
file).
o A file is to be copied from the client to the server (storing a file).
o A list of directory or file names is to be sent from server to the client.
• The compatibility problem between client and server must be solved by defining three
attributes of communication i.e., File type, Data structure and Transmission mode.
1. File Type: (Oct. 17)
• FTP can transfer one of the following types across data connection namely, ASCII file,
EBCDIC file or image file.
(i) The ASCII file is default format for transferring text files.
(ii) If one of two machines uses EBCDIC encoding, the EBCDIC file can be transferred
using EBCDIC encoding.
(iii) The image file is the default format for transferring binary files.
2. Data Structure: (Oct. 18)
• FTP allows three different data structure of a file namely, File structure, Record
structure and Page structure.
(i) File Structure: File has no structure, it is continuous stream of bytes.
(ii) Record Structure: File is divided into records.
(iii) Page Structure: The file is divided into pages, each page having page number and
page header.
3. Transmission Mode:
• FTP supports three transmission modes: Stream mode, Block mode and Compressed
mode.
(i) Stream Mode: Stream mode is default mode. Data are delivered from FTP to TCP
as a continuous stream of bytes.
(ii) Block Mode: In block mode the data can be delivered from FTP to TCP in blocks.
(iii) Compressed Mode: If the file is big, data can be compressed using run-length
encoding. In compression mode, consecutive appearances of a data unit are
replaced by one occurrence and the number of repetitions. In a text file, this is
usually spaces (blanks). In a binary file, null characters are usually compressed.
1.31
Computer Networks - II Application Layer

File type, data structure, and


Local data transmission mode Local data
type and are defined by the client type and
structure structure

Control Control
transfer transfer
process Data connection process
Client Server

Fig. 1.36: Communication over Data Connection

1.3.2 Command Processing and File Transfer in FTP


• In this section we will study FTP command processing and file transfer.
Command Processing in FTP:
• The FTP command uses the File Transfer Protocol (FTP) to transfer files between the
local host and a remote host or between two remote hosts.
• Commands, which are sent from the FTP client control process, are in the form of
ASCII uppercase, which may or may not be followed by an argument.
• We can roughly divide the commands into six groups namely, access commands
(USER, PASS, QUIT etc.), file management commands (RNTO, SMNT, LIST, CWD etc.),
data formatting commands (TYPE, MODE etc.), port defining commands (PORT, PSAV
etc.), file transferring commands (RETR, STOR, ALLO, STAT), and miscellaneous
commands (HELP, SITE, SYST etc.).
• FTP uses the control connection to establish a communication between the client
control process and the server control process.
• During this communication, the commands are sent from the client to the server and
the responses are sent from the server to the client as shown in Fig. 1.37.

Fig. 1.37: Command processing in FTP


File Transfer in FTP:
• In FTP the 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 following three
things (Refer Fig. 1.38):
o A file is to be copied from the server to the client (download). This is called
retrieving a file. It is done under the supervision of the RETR command.
o A file is to be copied from the client to the server (upload). This is called storing a
file. It is done under the supervision of the STOR command.
1.32
Computer Networks - II Application Layer

o A list of directory or file names is to be sent from the server to the client. The FTP
treats a list of directory or file names as a file. It is sent over the data connection.

Fig. 1.38: File Transfer in FTP

1.3.3 Anonymous FTP


• To use FTP, a user needs account and password on the remote server. Anonymous FTP
allows users without having account on server. Some sites have a set of files available
for public access, to enable anonymous FTP.
• To access these files, user need not have account, he can use anonymous as user name
and guest as the password.

PRACTICE QUESTIONS
Q.I Multiple Choice Questions:
1. Which is the top most layer in OSI model and TCP/IP model?
(a) Session (b) Physical
(c) Application (d) Transport
2. Consider following different activities related to email:
m1: Send an email from a mail client to a mail server.
m2: Download an email from mailbox server to a mail client.
m3: Checking email in a web browser.
Which is the application level protocol used in each activity?
(a) m1: HTI m2: SMTP m3 POP (b) m1 SMTP m2: FTP m3: HTTP
(c) m1: SMTP m2 POP m3: HTTP (d) m1. POP m2 SMTP m3 IMAP
3. What is the maximum size of data that the application layer can pass on to the TCP
layer below?
16
(a) Any Size (b) 2 bytes- size of TCP header
16
(c) 2 bytes (d) 1500 bytes
4. Identify the correct order in which the following actions take place in an
interaction between a web browser and a web server.
(i) The web browser requests a webpage using HTTP.
(ii) The web browser establishes a TCP connection with the web server.
(iii) The web server sends the requested webpage using HTTP.
1.33

You might also like