Unit - 6 (Application Layer)
Unit - 6 (Application Layer)
Course Outline:
• Remote Login
Application Layer
• Remote Login
Application Layer I Domain Name Server (DNS)
A system that can map a name to an address or an address to a name.
When the Internet was small, mapping was done using a host file.
The authority to assign and control the name spaces can be decentralized.
The names are unique without the need for assignment by a central authority. The central authority
controls only part of the name, not the whole.
DNS | Domain Name Space
To have a hierarchical name space, a domain name space was designed.
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 (0-Root to 127).
• If a server divides its domain into sub-domains and delegates part of its authority to other servers,
“domain” and “zone” refer to different things. The information about the nodes in the sub-domains
is stored in the servers at the lower levels, with the original server keeping some sort of reference to
there lower-level servers.
A ROOT SERVER is a server whose zone consists of the whole tree. A root server usually does not
store any information about domains but delegates it authority to other servers, keeping references
to those servers.
There are several root servers, each covering the whole domain name space. The servers are
distributed all around the world.
DNS | Domain Name Space
DNS | Domain Name Space
DNS defines two types of servers: PRIMARY and SECONDARY.
A PRIMARY server is a server that stores a file about the zone for which it is an authority.
A SECONDARY server is a server that transfers the complete information about the zone from another
server (primary or secondary) and stores the file on its local disk.
- It neither creates nor updates the zone files.
- If updating is required, it must be done by the primary server, which sends the updated
version to the secondary.
When the primary downloads information from the secondary, it is called ZONE TRANSFER.
DNS | Domain Name Space
In the Internet, the domain name space is divided into three different sections:
Country Domains – Follows same format as the generic domains but uses two-character country
abbreviations in place of three-character organizational abbreviation at the first level.
in – India
us – United States of America
au – Australia
fr – France
DNS | Domain Name Space
Resolver
The resolver gives a domain name to the server and asks for the corresponding address.
The server checks the generic domains or the country domains to find the mapping.
The query is sent by the resolver to the local DNS server for resolution. If the local server cannot
resolvers the query, it either refers the resolver to other servers or asks other servers directly.
If the resolver receives the IP address, the resolver first inverts the address and then adds the two-
labels before sending.
IP address: 132.34.45.121
The response message consists of a HEADER, Question Records, Answer Records, Authoritative
Records, and Additional records.
DNS | Message
Header
Identification (16 bits): Used by 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.
DNS | Message
Flags (16 bits):
• rcode of 4 bits: Shows status of the error in the response. Only an authoritative server can
make such a judgement.
DNS | Message
Question Section:
Example – admin.atc.fhda.edu
DNS | Message
Query Type: This is a 16 bit field defining the type of query.
The resource records are used in the answer, authoritative, and additional information sections of
the response message.
Each domain name is associated with a record called the resource record.
The server database consists of resource records.
• Domain Name, Domain Type and Domain
Class is same as that in the question
section.
A zero value means that the resource record is used only in a single transaction and should not
be cached.
DNS | Message
• Resource Data Length: Defines the length of the resource
data.
The format and contents of this field depend on the value of the type field.
A Number: This is written in Octets. IPv4 address is a 4-octet integer and IPv6 is a 16-octet
integer.
A Domain Name: Expresses as a sequence of labels.
An Offset Pointer: Domain names can be replaced with an Offset Pointer. An offset pointer is a
2-byte field with the 2 high-order bits set to 1 (11).
A Character String: Represented by a 1-byte length field followed by the number of characters
defined in the length field. The character string can be as long as 256 characters.
DNS | Message
Example:
A resolver sends a query message to a local server to find the IP address for the host chal.fhda.edu.
Identifier: 0x1333
Flags: 0x0100
Number of Question: 1
Query Name: 4chal4fhda3edu
Query Type: 1 (IP Address)
Query Class: 1 (Internet)
DNS | Message
Flags: 0x8180
• OpCode: 0000 (Standard Query)
The answer record has a value of 0xC00C (split in two
• Recursion is desired (RD = 1)
lines), which points to the question record instead of
repeating the domain name [An offset pointer is a 2- • Recursion is available (RA = 1)
byte field with the 2 high-order bits set to 1 (11)].
DNS | Encapsulation
DNS can use either UDP or TCP.
In both cases the well-know port used by the server is port 53.
UDP connection is used when the size of the response message is less than 512 bytes
because most UDP packages have a 512-byte packet size limit.
If the size of the response message is more than 512 bytes, a TCP connection is used.
• If the resolver has prior knowledge that the size of the response message is more than 512 bytes,
it uses the TCP connection.
• If the resolver does not know the size of the response message, it can use the UDP connection.
However, if the size of the response message is more than 512 bytes, the server truncates
the message and turns on the TC bit. The resolver now opens a TCP connection and
REPEATS THE REQUEST to get the full response from the server.
Application Layer
• Remote Login
Application Layer I Simple Mail Transfer Protocol (SMTP)
One of the most popular network services is Electronic Mail (email).
The TCP/IP protocol that supports email on the Internet is called Simple Mail Transfer Protocol
(SMTP).
SMTP Supports:
• Sending a single message to one or more recipients.
• Sending messages that include text, voice, video or graphics.
• Sending messages to users on networks outside the Internet.
Application Layer I Simple Mail Transfer Protocol (SMTP)
SMTP client and server has two components: User Agent (UA) and Mail Transfer Agent (MTA).
User Agent (UA):
Relaying could be involved. Instead of just one
• Prepares the message, MTA at the sender site and one at the receiving
• Create the envelope, and site, other MTAs acting either as client or server,
• Puts the message in the envelope. can relay the mail.
This is accomplished through the use of a Mail Gateway, which is a relay MTA that can receive mail
prepared by a protocol other than SMTP and transform it to SMTP format before sending it.
It can also receive mail in SMTP format and change it to another format before sending it.
SMTP | Architecture
Scenario I:
When the sender and the receiver of an email are on the same mail server, we need only two
UAs.
SMTP | Architecture
Scenario II:
When the sender and the receiver of an email are on different mail servers, we need two UAs and
a pair of MTAs (Client and Server).
SMTP | Architecture
Scenario III:
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)
SMTP | Architecture
Scenario IV:
When both sender and receiver are connected to the mail server via a LAN or a WAN, we need
two UAs, two pairs of MTAs, and a pair of Message Access Agents (MAAs).
SMTP | User Agent
Services Provided by a User Agent:
SMTP | User Agent
Types of User Agent:
SMTP | Addresses
To deliver mail, a mail handling system must use an addressing system with unique addresses.
The address consists of two parts: a Local Part and a Domain Name, separated by an @ sign.
SMTP | Delayed Delivery
SMTP allows delayed delivery.
The message does not necessarily have to be delivered immediately but can delayed at the sender
site, the receiver site, or the intermediate server.
Sender-Site Delay:
• UA creates a message.
• It is delivered to the SPOOL (storage Structure). MTA periodically checks the mail stored in
the spool to see if the mail can be sent.
• This depends on whether the IP address of the server has been obtained through DNS, if the
receiver is ready, and so on.
• Not delivered in the time-out period, the mail returns to the sender.
Receiver-Site Delay:
• If it is not read by the recipient immediately.
• The mail can be stored in the mailbox of the receiver.
SMTP | Aliases
SMTP allows one name, an Alias, to represent several different email addresses, this is called One-
to-Many Alias Expansion.
A single user can be defined by several different email addresses, called Many-to-One Alias
Expansion.
• Many-to-One Expansion is used when a user is having several email addresses, but the
user agent recognize only one mailbox name. Usually the local parts of the address will differ.
To handle these, the system must include an Alias Expansion Facility at both sender and receiver
site.
SMTP | Entire Email System
SMTP | Mail Delivery
SMTP | Commands and Responses
SMTP uses COMMANDS and RESPONSES to transfer messages between an MTA clients and an
MTA server.
Commands:
The format of a command consists of a keyword followed by zero or more argument.
Responses:
A response is a three-digit code that may be followed by additional textual information.
The meaning of First Digit are:
2yz (Positive Completion Reply)
Requested command has been successfully completed.
220 – Service Ready
250 – Request Command Complete.
3yz (Positive Intermediate Reply)
Requested command accepted, but the recipient needs some more information
before completion can occur.
354 – Start Mail Input
SMTP | Commands and Responses
4yz (Transient Negative Completion reply)
Requested command has been rejected.
The error condition is temporary. The command can be sent again.
421 – Service Not Available
450 – Mailbox Not Available
451 – Command Aborted – local error
452 – Command Aborted – insufficient storage.
2nd and 3rd Digit provide further details about the response.
SMTP | Mail Transfer Phases
The process of transferring a mail message occurs in three phases:
• Connection Establishment
• Mai Transfer
• Connection Termination
Connection Establishment
After a client has made a TCP connection to the well known port 25, the SMTP server starts the
connection phase.
SMTP | Mail Transfer Phases
Message Transfer
Repeated if more
than one recipient
SMTP | Mail Transfer Phases
Connection Termination
After the connection termination phase, the TCP connection must be closed.
SMTP | Message Access Agent (MAA)
The SMTP transfer scheme implies that a server must remain ready
to accept email at all times; the client attempts to send a message
as soon as a user enters it.
The scenario works well if the server runs on a computer that has a permanent Internet connection.
Two protocols exist that allow a remote user to retrieve mail from a permanent mailbox and allows
user to manipulate the mailbox content:
Post Office Protocol (POP)
Internet Message Access Protocol (IMAP)
SMTP | Message Access Agent (MAA)
Post Office Protocol (POP)
The user invokes a POP Client, which creates a TCP connection to a POP Server (Port no 110)
on a mailbox computer.
The user first send a login and a password to authenticate the session.
A computer with the permanent mailbox must run two servers:
• An SMTP server to accept mail sent to the user and adds each to the user’s permanent
mailbox.
• POP server allows a user to extract messages from the mailbox and delete them (if needed).
POP has two modes: the DELETE mode and the KEEP mode.
• In the Delete Mode, the mail is deleted from the mailbox after each retrieval.
• In the Keep Mode, the mail remains in the mailbox after retrieval.
IMAP works by keeping mail on the server. POP works by downloading your mail to your computer.
Like POP, IMAP also defines an abstraction known as a mailbox; mailbox are located on the same
computer as a server.
Like POP, a user runs an IMAP client that contacts the server to retrieve messages.
Unlike POP, IMAP allows a user to dynamically create, delete, or rename mailboxes.
IMAP also provides extended functionality for message retrieval and processing. A user can obtain
information about a message or examine header fields without retrieving the entire message.
A user can search for a specified string and retrieve specified portions of a message.
SMTP | Extensions (MIME)
Multipurpose Internet Mail Extensions (MIME)
SMTP can send messages only in 7-bit ASCII format. It cannot be used for languages that are not
supported by 7-bit ASCII characters. Also, it cannot be used to send binary files or to send video or
audio data.
MIME is a supplementary protocol that allows non-ASCII data to be sent through SMTP.
MIME is not a mail protocol, it is only an extension to SMTP.
MIME is a set of Software Functions that transforms non-ASCII data to ASCII data and vice-versa.
SMTP | Extensions (MIME)
To accommodate arbitrary data types and representations, each MIME message includes
information that tells the recipient the TYPE of the data and the ENCODING used.
Photograph in standard GIF representation. The GIF image has been converted to a 7-bit ASCII
representation using the base64 Encoding.
From: ck@iitism.ac.in
To: director@iitk.ac.in
MIME-version: 1.1
Content-Type: image/gif
Content-Transfer-Encoding: base64
To view the image, a receiver’s mail system must first convert from base64 encoding back to
binary and then run an application that displays a GIF image on the user’s screen.
Application Layer
• Remote Login
Application Layer I Hypertext Transfer Protocol (HTTP)
World Wide Web (WWW) is a distributed client server service in which a client using a browser can
access a service using a server.
HTTP protocol is used for communication between a browser and a web server or between
intermediate machines and web servers.
Web Documents:
• Static Documents Fixed-content Documents
• Dynamic Documents Created based on request.
• Active Documents A program or a script to be run at the client site.
HTTP | Characteristics
HTTP has the following set of characteristics:
Bi-Directional Transfer.
Capability Negotiation.
Request Line: Defines the Request Type, Resource (URL) and HTTP Version.
• GET: Used when a client wants to retrieve a document from the server.
The address of the document is defined in the URL.
The server usually responds with the contents of the document in the body of the response
message.
HTTP | Transaction
• HEAD: Used when a client wants some information about the document but
not the document itself.
• POST: Used when a client provides some information for the server.
The URL defines four things: Method, Host Computer, Port and Path.
The method is the protocol used to retrieve the document. Like HTTP, FTP, TELNET etc.
The host computer where the information is located. Web pages are usually stored in computers, and
computers are given alias names that usually begin with the character “www”.
Version:
The version of HTTP.
HTTP | Transaction
Headers:
The header exchanges additional information between the client and the
server.
The header can be one or more header lines.
Each header line is made of: Header Name, Colon, Space, Header Value.
Request Headers:
Specifies the client’s configuration and the client’s preferred document format.
• Accept: Shows the media format the client can accept.
• Accept-charset: Shows the character set the client can handle.
• Authorization: Shows what permissions the client has.
• Host: Shows the host and port number of the client.
• From: Shows the email address of the user.
HTTP | Transaction
Entity Headers:
Status Code:
Similar to those in SMTP.
It consists of three digits:
• Codes in the 100 range are Only Informational. • Codes in the 400 indicate an error at the client
site.
• Codes in the 200 range indicate a Successful Request.
• Codes in the 500 range indicate an error at the
• Codes in the 300 range redirect Client to another URL. server site.
HTTP | Transaction
Status Code:
• 100 – The initial part of the request has been received and the client may continue
with its request.
• 200 – The request is successful.
• 201 – A new URL is created.
• 302 – The requested URL is no longer used by the server.
• 400 – There is a syntax error in the request.
• 403 – Service is denied.
• 500 – There is an error, such as a crash, in the server site.
• 503 – The service is temporarily unavailable, but may be requested in the future.
Status Phrase:
This field explains the status code in the text form.
• 100 – Continue • 403 – Forbidden
• 200 – OK • 500 – Internal Server Error
• 201 – Created • 503 – Service Unavailable
• 302 – Moved Permanently
• 400 – Bad request
HTTP | Transaction
A response message can contain only General, Response and Entity Header.
Response Headers:
Specifies the server’s configuration and special information about the request.
• Accept-range: Shows if server accepts the range requested by client.
HTTP/1.1 200 OK
Date: Wed, 17-April-2024 9:45:05 GMT
Server: ns3
MIME-version: 1.0
Content-length: 2048
FTP establishes two connections between the hosts. One connection is used for DATA TRANSFER
and the other for CONTROL INFORMATION (commands and responses).
The control connection uses very simple rules of communication. The data connection, on the
other hand, needs more complex rules due to the variety of data types transferred.
Control Connection
The service type, used by the IP protocol, is MINIMIZE DELAY because this is an interactive
connection between a user and a server.
The client types commands and expects to receive response without significant delay.
FTP | Connections
Data Connection
Uses the well-known port 20 at the server site.
Both computers may use different operating systems, different character sets, different file structures,
and different file formats. FTP must make this HETEROGENEITY COMPATIBLE.
FTP uses two different approaches, one for the control connection and one for the data connection.
Each command or response is only one short line so need not to worry about the file format or file
structure.
Each line is terminated with a 2-character (carriage return and line feed) end-of-line token.
FTP | Communication
Communication over Data Connection
The client must define the type of file to be transferred, the structure of the data, and the
transmission mode.
Before sending the file through the data connection, there is a need to prepare for the
transmission through the control connection.
The heterogeneity problem is resolved by defining three attributes of communication: File Type,
Data Structure, and the Transmission Mode.
FTP | Communication
File Type:
FTP can transfer one of the following file types across the data connection:
• ASCII File: This is the default format for transferring text file.
• EBCDIC File
• Image File: This is the default format for transferring binary files.
Data Structure:
FTP can transfer a file across the data connection using one of the following interpretations about
the structure of the data:
• File Structure (Default): The file has no structure. It is a continuous stream of bytes.
• Record Structure: The file is divided into records. This can be used only with text file.
• Page Structure: The file is divided in to pages, with each page having a page number and a
page header. The pages can be stored and accessed randomly or sequentially.
FTP | Communication
Transmission Modes:
• Stream Mode: It is the default mode. Data are delivered from FTP to TCP as a continuous
stream of bytes. TCP is responsible for fragmenting data into appropriate size. The
connection is automatically closed if the transforming data is in the stream of bytes.
Otherwise, the sender will close the connection (by putting EOF character at the end).
• Block Mode: In block mode, the data is transferred from FTP to TCP in the form of blocks,
and each block is preceded by a 3-byte header. The first byte of the block contains the
information about the block (block descriptor) and the other two bytes contain the size of the
block in bytes.
• Compressed Mode: If the file is big, the data can be compressed. The compression method
normally used in run-length encoding.
FTP | Command Processing & File Transfer
Command Processing
• Miscellaneous Commands
FTP | Command Processing & File Transfer
Command Processing
File Transfer
FTP | Example 1
FTP | Example 2
FTP | Anonymous FTP
Some sites can enable anonymous FTP whose files are available for public access.
The user can access those files without any username or password.
The username is set to anonymous and the password to the guest by default.
The access of the user is very limited. For example, the user can copy the files but not allowed to
navigate through directories.
Trivial FTP (TFPT)
When a diskless workstation or a router is booted, they require to download the bootstrap and
configuration files with minimum overhead.
Trivial File Transfer Protocol (TFTP) is designed for these types of file transfer.
It is so simple that the software package can fit into the read-only memory of a diskless workstation.
Remote Login
Application Layer I Remote Login
Allow the user to log on to a remote computer. After logging on, a user can use the services
available on the remote computer and transfer the results back to the local computer.
TErminaL NETwork (TELNET) is one of such a client-service program. This is the standard TCP/IP
protocol for virtual terminal service.
Example: EOF token in a computer running the DOS is Ctrl+z, while the UNIX recognizes Ctrl+d.
If we want to access any remote computer in the world, we must first know what type of computer we
will be connected to, and we must install the specific terminal emulator used by that computer.
TELNET solves this problem by defining a universal interface called the Network Virtual Terminal
(NVT) character set.
Data Character:
This is an 8-bit character set in which the seven lowest order bits are the same as ASCII and the
highest order bit is 0.
Control Character:
TELNET accomplishes this by embedding the control characters in the data stream. However, to
distinguish data from control characters, each sequence of control characters is preceded by a
special control character called Interpret As Control (IAC).
Example:
Imagine a user wants a server to display a file (named “file1”) on a remote server. Command used is
cat filea.
The user uses the backspace key to correct this situation:
cat filea<backspace>1
User cannot edit locally, the editing is done at the remote server.
The backspace character is translated into two remote characters
(IAC EC), which is embedded in the data and sent to the remote
server.
[IAC – Interpret as Control: 11111111 = 255] [EC – Erase Character Command: 11110111 = 247]
Remote Login| Secure Shell (SSH)
TELNET is vulnerable to hacking because it sends all data including the password in PLAINTEXT (not
encrypted).
A hacker can eavesdrop and obtain the logging name and password.
Remote Login