0% found this document useful (0 votes)
25 views

Unit - 6 (Application Layer)

COMPUTER NETWRKS

Uploaded by

Ayush Mishra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Unit - 6 (Application Layer)

COMPUTER NETWRKS

Uploaded by

Ayush Mishra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 98

Computer Networks (CSC305)

Course Outline:

√Overview of Data Communication and Networking


√Physical Layer
√Data Link Layer
- Logical Link Control (LLC)
- Medium Access Control (MAC)
√Network Layer
√Transport Layer
√Application Layer
OSI Reference Model
OSI Reference Model
Application Layer

• Domain Name Server (DNS)

• Simple Mail Transfer Protocol (SMTP)

• Hypertext Transfer Protocol (HTTP)

• File Transfer Protocol (FTP)

• Remote Login
Application Layer

 Domain Name Server (DNS)


• Simple Mail Transfer Protocol (SMTP)

• Hypertext Transfer Protocol (HTTP)

• File Transfer Protocol (FTP)

• 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.

 Store the entire host file in a single computer


and allow access to this centralized information
to every computer that needs mapping.

 Divide the huge amount of 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 used by
the Domain Name System (DNS).
DNS | Name Space
The names of machine should be unique. A name space that maps each address to a unique name
can be organized in two ways:

• Flat Name Space


A name is assigned to an address.
A name in this space is a sequence of characters without structure.
Disadvantage: It cannot be used in a large system such as the Internet because it must be centrally
controlled to avoid any ambiguity and duplication.

• Hierarchical Name Space


Each name is made of several parts [the 1st part can define the nature of the organization, the 2nd
part can define the name of the organization, the 3rd part can define departments in the organization
and so on].

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).

Each node in the tree has a LABEL, which is a


string with a maximum of 63 characters. The
ROOT label is a NULL string (empty string). Full domain name always ends in a null
label, which means the last character is a DOT.
DNS | Domain Name Space
 Full Qualified Domain Name (FQDN):

• A label is terminated by a NULL string.


• Contains the full name of a host.
• Contains all labels, from the most specific to the most
general, that uniquely defines the name of the host.
• Example: challenge.atc.fhda.edu.

 Partially Qualified Domain Name (PQDN):


• A label is not terminated by a NULL string.
• Starts from a node, but it does no reach the root.
• It is used when the name to be resolved belongs to the same site as the client.
• The resolver can supply the missing part, called the SUFFIX, to create an FQDN.
• Example: If an user at the fhda.edu. site wants to get the IP address of the “Challenger”
computer, s/he can define the partial name: challenger.
DNS | Domain Name Space
The information contained in the domain name space must be stored. However, it is very inefficient and
also not reliable to have just one computer store such a huge amount of information.

It is inefficient because responding to requests from all over


the world places a heavy load on the system. It is not
reliable because any failure makes the data inaccessible.

The solution to these problems is to distribute the


information among many computers called DNS
SERVERS. Each server can be responsible for either a large
or small domain. In other words, we have a hierarchy of
servers in the same way that we have a hierarchy of names.

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.
DNS | Domain Name Space
• If a server accepts responsibility for a domain and does not divide the domain into smaller domains,
the “domain” and the “zone” refer to the same thing. The server makes a database called a ZONE
FILE and keeps all the information for every node under that domain.

• 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.

- It is responsible for creating, maintaining, and updating the zone file.

- It stores the zone file on a local disk.

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:

 Generic Domains – Define registered hosts according to their generic behaviour.


com – Commercial Organizations
edu – Educational Institutions
gov – Government Institutions
org – Non-profit Organizations
mil – Military Groups

 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

Generic Domains Country Domains


DNS | Domain Name Space
 Inverse Domain – Is used to map an address to a name.
• This happen when a server has received a request
from a client to do a task. The server has a file that
contains only the IP address of the authorized clients.

• The server asks its resolver to send a query to the DNS


server to map an address to a name to determine if the
client is on the authorized list – Inverse or Pointer
Query.

• The servers that handle the inverse domain are also


hierarchical.

• Netid part of the address should be at a higher level


than the subnetid part, and the subnetid part higher than
the hostid part.

• An IP address such as 132.34.45.121 is read as


121.45.34.132.in-addr.arpa.
DNS | Resolution
Mapping a name to an address or an address to a name is called Name-Address Resolution.

 Resolver

DNS is designed as a client-server application.


A host that needs to map an address to a name or a name to an address calls a DNS client called a
RESOLVER.

The resolver accesses the closest DNS server with


a mapping request.
If the server has the information, it satisfies the
resolver; otherwise, it either refers the resolver to
other servers or asks other servers to provide the
information.
On receipt of the mapping, the resolver interprets the
response to see if it is a real resolution or an error,
and finally delivers the result to the process that
requested it.
DNS | Resolution
Mapping Names to Addresses

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.

Mapping Addresses to Names

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

Domain name sent is 121.45.34.132.in-addr.arpa.


DNS | Resolution
Recursive Resolution Iterative Resolution
DNS | Message
DNS has two types of messages:
• Query
• Response

The query message consists of a HEADER and the Question Records.

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):

• QR (Query/Response) of 1 bit: 0 for Query and 1 for Response

• Opcode of 4 bits: Type of Query or response


0 for Standard
1 for Inverse
2 for Server Status Request
• AA (Authoritative Answer) of 1 bit: Used only in response message. Set (1), if name server is
an Authoritative server.
• TC (TrunCated) of 1 bit: Used when DNS uses the services of UDP. Set (1), if response was
more than 512 bytes and is truncated to 512.
• RD (Recursion Desired) of 1 bit: Set in the query message and repeated in the response
message. Set (1), if client desires a Recursive Answer.
• RA (Recursion Available) of 1 bit: Set in the response message. Set (1), if recursive response
is available.
DNS | Message

• 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:

This is a section consists of one or more question records.

A question record is used by the client to get information from a server.

Query Name: This is a variable length field containing a Domain Name.

Example – admin.atc.fhda.edu
DNS | Message
Query Type: This is a 16 bit field defining the type of query.

Query Class: This is a 16 bit field


defining the specific protocol using DNS.
DNS | Message
 Resource Record:

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.

• TTL: Defines the number of seconds the


answer is valid.
The receiver can cache the answer for
this period of time.

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.

• Resource Data: This field containing the answer to the query


or the domain name of the authoritative server or additional
information.

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

• OpCode: 0000 (Standard Query)


• Recursion is desired (RD = 1)

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

 Domain Name Server (DNS)

 Simple Mail Transfer Protocol (SMTP)


• Hypertext Transfer Protocol (HTTP)

• File Transfer Protocol (FTP)

• 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.

Mail Transfer Agent (MTA) transfers the mail


across the Internet.
Application Layer I Simple Mail Transfer Protocol (SMTP)
The relaying system allows sites that do not use the TCP/IP protocol suite to send email to
users on other sites that may or may not use the TCP/IP protocol suite.

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.

• One-to-Many Expansion is used where the same message is to be sent to different


recipients, the user can create an Alias that is mapped to the list of the recipients.

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.

1. HELO: Sender’s Host Name


Used by client to identify itself.
HELO: iitism.ac.in
2. MAIL FROM: Sender of the Message
Used by client to identify the sender of the message.
MAIL FROM: ck@iitism.ac.in
SMTP | Commands and Responses
3. RCPT TO: Intended recipient of the message
RCPT TO: director@iitk.ac.in
4. DATA: Body of the mail
Used to send the actual message
DATA: Hello! How are you?
5. QUIT
Used to terminate the message
6. VRFY: Name of the recipient to be verified
Used to verify the address of the recipient, which is sent as the argument.
The sender can ask the receiver to confirm that name identifies a valid recipient.
VRFY: director@iitk.ac.in
7. SEND FROM: Sender of the message
The mail is to be delivered to the terminal of the recipient. If the recipient is not logged
in, the mail is bounced back.
SEND FROM: ck@iitism.ac.in
SMTP | Commands and Responses
8. SMOL FROM: Intended recipient of the message
The mail is to be delivered to the terminal or mailbox of the recipient.
If the Recipient logged in: Mail delivered at the Terminal
If the Recipient is logged out: Mail delivered in the Mailbox

9. SMAL FROM: Intended recipient of the message


The mail is to be delivered to the terminal and mailbox of the recipient.
SMTP | Commands and Responses

 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.

 5yz (Permanent Negative Completion reply)


Requested command has been rejected.
The command can not be sent again.
500 – Syntax Error (Unrecognized Command)
501 – Syntax Error in parameter or arguments
503 – Bad sequence of Commands.
554 – Transaction Failed.

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.

How can a user without a permanent connection receive email?


• Each user is assigned a mailbox on a computer that has a permanent Internet connection. The
computer runs a conventional SMTP server, which always remains ready to accept email.
• The user forms a dialup connection, and then runs a protocol that retrieves messages from the
permanent mailbox. The protocol transfers the messages to the user’s computer where they can
be read.

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.

POP Session States:


• Authentication State • Transaction State • Update State
SMTP | Message Access Agent (MAA)

Client: STAT Client: RETR 1


Server: +OK 2 320 Server: +OK 120 octets
Server: …………………..
Client: LIST ……………………………….
Server: +OK 2 mesg (320 octets) ……………………………….
Server: 1 120
Server: 2 200
Server: . Client: DELE 1
Server: +OK mesg 1 deleted
Client: LIST 2
Server: +OK 2 200
SMTP | Message Access Agent (MAA)
 Internet Message Access Protocol (IMAP)

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.

MIME information resides in the mail header, it specifies:


• Version of MIME used • Content-ID
• Type of data being sent • Content Description
• Encoding used to convert the data to ASCII

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

 Domain Name Server (DNS)

 Simple Mail Transfer Protocol (SMTP)

 Hypertext Transfer Protocol (HTTP)

• File Transfer Protocol (FTP)

• 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:

 Operates at Application Level. Uses TCP services (Port no 80).

 Request/Response Based Protocol.

 Stateless Protocol. Request is self-contained.

 Bi-Directional Transfer.

 Capability Negotiation.

 Support for Caching.

 Support for Intermediaries.


HTTP | Transaction
HTTP Request Messages:

Request message consists of a request line, a header and sometimes a body.

 Request Line: Defines the Request Type, Resource (URL) and HTTP Version.

Method (Request Type): Defines several kinds of messages referred to as methods.


The request method is the actual command or request that a client issues to the server.

• 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

• PUT: Used when a client to provide a new or replacement document to


be stored on the server.
The document is included in the body of the request and will be stored in
the location defined by the URL.

• 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.

• COPY: Used to copy a file to another location.

Source File Location – Request Line (URL)


Destination – Entity Header.

• DELETE: Used to remove a document on the server.


HTTP | Transaction

Uniform Resource Locator (URL):

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.

Header_Name: space Header_Value

A header line belongs to one of the four categories:


• General header
• Request Header
• Response Header
• Entity Header

A request message can contain only General, Request


and Entity Header.
HTTP | Transaction
General Headers:
It gives general information about the message.
• Cache-control: Specifies information about caching.
• Connection: Shows whether the connection should
be closed or not.
• Date: Shows the current date.

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:

It gives information about the body of the document.


• Allow: List the valid methods that can be used with a
URL.
• Content-type: Specifies the media type.
• Content-length: Shows the length of the document.
• Expires: Gives the date and time when contents may change.
• Location: Specifies the location of the created or moved document.
HTTP | Transaction
HTTP Response Messages:
Response message consists of a Status line, a header and sometimes a body.
 Status Line: Defines the status of the response message.
It consists of the HTTP Version, Status Code and Status Phrase.

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.

• Age: Shows the age of the document.


• Public: Shows the supported list of methods.
• Server: Shows the server name and version number.
HTTP | Example
Client Server

GET /usr/bin/image1 HTTP/1.1


Accept: image/gif
Accept: image/jpeg

HTTP/1.1 200 OK
Date: Wed, 17-April-2024 9:45:05 GMT
Server: ns3
MIME-version: 1.0
Content-length: 2048

(Body of the Document)


HTTP | Version
 Persistence HTTP (HTTP/1.1)
Server leaves connection open (for some defined time; 125 sec) after sending response.
Server can close the connection at the request of a client or if a time-out has been reached.
Overhead is less.
1 RTT for each referenced object.

 Non-Persistence HTTP (HTTP/1.0)


One TCP connection is made for each request/response.
1. The client opens a TCP connection and sends a request.
2. The server sends the response and closes the connection.
3. The client reads the data until it encounters an EOF marker; it then closes
the connection.
2 RTTs for each referenced object. Imposes high overhead on the server.
Application Layer

 Domain Name Server (DNS)

 Simple Mail Transfer Protocol (SMTP)

 Hypertext Transfer Protocol (HTTP)

 File Transfer Protocol (FTP)


• Remote Login
Application Layer I File Transfer Protocol (FTP)
FTP is the standard mechanism provided by TCP/IP for copying a file from one host to another.

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.

FTP needs two TCP connections. It uses


two well-known TCP ports: Port 20 is used
for the Data Connection and Port 21 is used
for the Control Connection.

The control connection remains connected


during the entire interactive FTP session.

The data connection is opened and then


closed for each file transferred.
FTP | Connections
The two FTP connection, control and data, uses different strategies and different port numbers.

 Control Connection

The connection is created in two steps:


1. The server issues a passive open on the well-known
port 21 and waits for a client.

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 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.

The following shows how FTP creates a data connection:

1. The client issues a passive open using an ephemeral


port.

2. The client sends this port number to the server using


the PORT command.

3. The server receives the port number and issues an


active open using the well-known port 20 and the
received ephemeral port number.
FTP | Communication
The FTP client and server, which run on different computers, must communicate with each other.

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.

 Communication over Control Connection

FTP uses the same approach as SMTP to


communicate across the control connection.
It uses the NVT ASCII character set.

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:

FTP transfer files uses any of the following 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

Commands are divided in to six groups:


• Access Commands
FTP | Command Processing & File Transfer
• File Management Commands

• Data Formatting Commands


FTP | Command Processing & File Transfer
• Port Defining Commands

• File Transferring Commands

• Miscellaneous Commands
FTP | Command Processing & File Transfer
 Command Processing

Responses: A 3 digit number followed by text.


FTP | Command Processing & File Transfer
FTP | Command Processing & File Transfer
 Command Processing

Commands are divided in to six groups:


• Access Commands • Port Defining Commands
• File Management Commands • File Transferring Commands
• Data Formatting Commands • Miscellaneous Commands

Responses: A 3 digit number followed by text.

 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.

TFTP uses the services of UDP on the well-known port 69.


Application Layer

 Domain Name Server (DNS)

 Simple Mail Transfer Protocol (SMTP)

 Hypertext Transfer Protocol (HTTP)

 File Transfer Protocol (FTP)

 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.

TELNET enables the


establishment of a
connection to a remote
system in such a way
that the local terminal
appears to be a
terminal at the remote
system.
TELNET| Network Virtual Terminal (NVT)
The mechanism to access a remote computer is complex. This is because every computer and its
operating system accepts a special combination of characters as tokens.

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.

Via NVT, the client TELNET translates


characters (data or commands) that come
from the local terminal into NVT form and
delivers them to the network.
The server TELNET, on the other hand,
translates data and commands from NVT form
into the form acceptable by the remote
computer.
TELNET| Network Virtual Terminal (NVT)
NVT uses two sets of characters, one for DATA and one for CONTROL. Both are 8-bit bytes.

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:

This is an 8-bit character set in which the highest order bit is 1.


TELNET| Embedding
TELNET uses ONLY ONE TCP connection. Same connection is used for sending both data and
control.
The server uses the WELL-KNOWN PORT 23 and the client uses an ephemeral port.

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.

Secure Shell (SSH) is a secure application program designed to replace TELNET.

SSH is an application layer protocol with three components:


SSH-CONN allows client to create multiple
logical channels over it.

Used to Channels can be used for remote logging, file


Authenticate Client transfer etc.
for the server.
SSH-TRANS creates a secured channel on
top of the TCP.

Exchanges several security parameter to


make insecure connection secure.

Provides Privacy, Data Integrity, Server


Authentication, Message Compression.
Application Layer

 Domain Name Server (DNS)

 Simple Mail Transfer Protocol (SMTP)

 Hypertext Transfer Protocol (HTTP)

 File Transfer Protocol (FTP)

 Remote Login

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy