application layer
application layer
The Principles of Network Applications are fundamental concepts that govern the design and
development of applications that run on a computer network. These principles encompass several
key aspects of network applications, including:
Network Application Architectures
Processes Communicating
The Interface Between the Process and the Computer Network
Transport Services Available to Applications
Transport Services Provided by the Internet
Application-Layer Protocols
1. Network Application Architectures refer to the overall design and structure of a network
application. It encompasses how the application is divided into different components, and how
these components interact with each other. There are several commonly used network
application architectures, including:
Client-Server Architecture: In this architecture, one component acts as a client and makes
requests to a server component, which provides the requested services. This architecture is
commonly used in web applications, where the client is a web browser and the server is a web
server.
Peer-to-Peer Architecture: In this architecture, every component is both a client and a
server, and each component can communicate directly with any other component. This
architecture is commonly used in file-sharing applications, where each user’s device acts as
both a client and a server.
Three-Tier Architecture: In this architecture, the application is divided into three
components: a client component, a middleware component, and a database component. The
client component makes requests to the middleware component, which communicates with
the database component to retrieve or update data. This architecture provides a layer of
abstraction between the client and the database, which can improve performance and
scalability.
Microservices Architecture: In this architecture, the application is divided into a collection
of small, independently deployable components, known as microservices. Each microservice
is responsible for a specific aspect of the application’s functionality, and they communicate
with one another through APIs. This architecture allows for greater flexibility and scalability
compared to other architectures.
The choice of network application architecture depends on several factors, including the
requirements of the application, the scale of the application, and the available resources.
Regardless of the architecture chosen, the design should consider factors such as scalability,
performance, security, and maintainability.
2. Processes Communicating refers to the communication between multiple processes in a
computer network. Processes can be thought of as individual programs or tasks running on a
device, and they may be located on the same device or on different devices connected to the
network.
Communication between processes is facilitated by the use of protocols, which define the
rules and formats for exchanging data. The communication between processes can be either
synchronous or asynchronous, meaning that either both processes must be available to
communicate at the same time or the communication can occur at different times.
In a network application, communication between processes is essential for the application to
function correctly. For example, in a client-server architecture, the client process makes
requests to the server process, and the server process returns the requested information. In a
peer-to-peer architecture, each process can communicate directly with any other process.
It’s important to consider the communication between processes when designing a network
application. Factors such as the reliability of communication, the security of communication,
and the performance of the communication must be taken into account. The choice of
protocols used for communication will depend on the requirements of the application and the
network infrastructure.
3. The Interface between the Process and the Computer Network refers to the connection
between a process running on a device and the underlying computer network. This interface
determines how the process communicates with other processes and with the network itself.
The interface between a process and the computer network is usually provided by a network
stack, which is a collection of protocols and services that handle the communication between the
process and the network. The network stack translates the process’s requests and data into the
appropriate network protocols, and vice versa, allowing the process to communicate over the
network.
The transport Layer is the second layer in the TCP/IP model and the fourth layer in the OSI
model. It is an end-to-end layer used to deliver messages to a host. It is termed an end-to-end
layer because it provides a point-to-point connection rather than hop-to-hop, between the source
host and destination host to deliver the services reliably. The unit of data encapsulation in the
Transport Layer is a segment.
Working of Transport Layer
The transport layer takes services from the Application layer and provides services to
the Network layer.
At the sender’s side: The transport layer receives data (message) from the Application layer and
then performs Segmentation, divides the actual message into segments, adds the source and
destination’s port numbers into the header of the segment, and transfers the message to the
Network layer.
At the receiver’s side: The transport layer receives data from the Network layer, reassembles
the segmented data, reads its header, identifies the port number, and forwards the message to the
appropriate port in the Application layer.
Responsibilities of a Transport Layer
The Process to Process Delivery
End-to-End Connection between Hosts
Multiplexing and Demultiplexing
Congestion Control
Data integrity and Error correction
Flow control
1. The Process to Process Delivery
While Data Link Layer requires the MAC address (48 bits address contained inside the Network
Interface Card of every host machine) of source-destination hosts to correctly deliver a frame and
the Network layer requires the IP address for appropriate routing of packets, in a similar way
Transport Layer requires a Port number to correctly deliver the segments of data to the correct
process amongst the multiple processes running on a particular host. A port number is a 16-bit
address used to identify any client-server program uniquely.
6. Flow Control
The transport layer provides a flow control mechanism between the adjacent layers of the
TCP/IP model. TCP also prevents data loss due to a fast sender and slow receiver by imposing
some flow control techniques. It uses the method of sliding window protocol which is
accomplished by the receiver by sending a window back to the sender informing the size of data
it can receive
1. Control Connection: For sending control information like user identification, password,
commands to change the remote directory, commands to retrieve and store files, etc., FTP makes
use of a control connection. The control connection is initiated on port number 21.
2. Data connection: For sending the actual file, FTP makes use of a data connection. A data
connection is initiated on port number 20.
FTP sends the control information out-of-band as it uses a separate control connection. Some
protocols send their request and response header lines and the data in the same TCP connection.
For this reason, they are said to send their control information in-band. HTTP and SMTP are
such examples.
FTP Session
When an FTP session is started between a client and a server, the client initiates a
control TCP connection with the server side. The client sends control information over this.
When the server receives this, it initiates a data connection to the client side. Only one file can be
sent over one data connection. But the control connection remains active throughout the user
session. As we know HTTP is stateless i.e. it does not have to keep track of any user state. But
FTP needs to maintain a state about its user throughout the session.
FTP Clients
FTP works on a client-server model. The FTP client is a program that runs on the user’s
computer to enable the user to talk to and get files from remote computers. It is a set of
commands that establishes the connection between two hosts, helps to transfer the files, and then
closes the connection.
Some of the commands are:
get the filename(retrieve the file from the server)
get the filename(retrieve multiple files from the server )
ls(list files available in the current directory of the server)
There are also built-in FTP programs, which makes it easier to transfer files and it does not
require remembering the commands.
FTP Data Structures
FTP allows three types of data structures :
1. File Structure: In file structure, there is no internal structure and the file is considered to be a
continuous sequence of data bytes.
2. Record Structure: In record structure, the file is made up of sequential records.
3. Page Structure: In page structure, the file is made up of independent indexed pages.
FTP Commands
Some of the FTP commands are:
USER – This command sends the user identification to the server.
PASS – This command sends the user password to the server.
CWD – This command allows the user to work with a different directory or dataset for file
storage or retrieval without altering his login or accounting information.
RMD – This command causes the directory specified in the path name to be removed as a
directory.
MKD – This command causes the directory specified in the pathname to be created as a
directory.
PWD – This command causes the name of the current working directory to be returned in the
reply.
RETR – This command causes the remote host to initiate a data connection and send the
requested file over the data connection.
STOR – This command causes the storage of a file in the current directory of the remote
host.
LIST – Sends a request to display the list of all the files present in the directory.
ABOR – This command tells the server to abort the previous FTP service command and any
associated transfer of data.
QUIT – This command terminates a USER and if file transfer is not in progress, the server
closes the control connection.
FTP Replies
Some of the FTP replies are :
200 – Command okay.
530 – Not logged in.
331 – User name okay, need a password.
225 – Data connection open; no transfer in progress.
221 – Service closing control connection.
551 – Requested action aborted: page type unknown.
502 – Command not implemented.
503 – Bad sequence of commands.
504 – Command not implemented for that parameter.
Characteristics of FTP
1. FTP uses TCP as a transport layer protocol.
2. It is good for simple file transfers, such as during boot time.
3. Errors in the transmission (lost packets, checksum errors) must be handled by the TFTP
server.
4. It uses only one connection through well-known port 69.
5. TFTP uses a simple lock-step protocol (each data packet needs to be acknowledged). Thus the
throughput is limited.
Advantages of FTP
Speed is one of the advantages of FTP(File Transfer Protocol).
File sharing also comes in the category of advantages of FTP in this between two machines
files can be shared on the network.
Efficiency is more in FTP.
Disadvantages of FTP
File size limit is the drawback of FTP only 2 GB size files can be transferred.
Multiple receivers are not supported by the FTP.
FTP does not encrypt the data this is one of the biggest drawbacks of FTP.
FTP is unsecured we use login IDs and passwords making it secure but they can be attacked
by hackers.
Anonymous FTP
Anonymous FTP is enabled on some sites whose files are available for public access. A user can
access these files without having any username or password. Instead, the username is set to
anonymous, and the password is to the guest by default. Here, user access is very limited. For
example, the user can be allowed to copy the files but not to navigate through directories.
Components of SMTP
1. Mail User Agent (MUA)
2. Mail Submission Agent (MSA)
3. Mail Transfer Agent (MTA)
4. Mail Delivery Agent (MDA)
1. Mail User Agent (MUA): It is a computer application that helps you in sending and retrieving
mail. It is responsible for creating email messages for transfer to the mail transfer agent(MTA).
2. Mail Submission Agent (MSA): It is a computer program that basically receives mail from a
Mail User Agent(MUA) and interacts with the Mail Transfer Agent(MTA) for the transfer of the
mail.
3. Mail Transfer Agent(MTA): It is basically software that has the work to transfer mail from
one system to another with the help of SMTP.
4. Mail Delivery Agent(MDA): A mail Delivery agent or Local Delivery Agent is basically a
system that helps in the delivery of mail to the local system.
Working of SMTP
1. Communication between the sender and the receiver :
The sender’s user agent prepares the message and sends it to the MTA. The MTA’s
responsibility is to transfer the mail across the network to the receiver’s MTA. To send mail, a
system must have a client MTA, and to receive mail, a system must have a server MTA.
2. Sending Emails:
Mail is sent by a series of request and response messages between the client and the server. The
message which is sent across consists of a header and a body. A null line is used to terminate the
mail header and everything after the null line is considered the body of the message, which is a
sequence of ASCII characters. The message body contains the actual information read by the
receipt.
3. Receiving Emails:
The user agent on the server-side checks the mailboxes at a particular time of intervals. If any
information is received, it informs the user about the mail. When the user tries to read the mail it
displays a list of emails with a short description of each mail in the mailbox. By selecting any of
the mail users can view its contents on the terminal.
Working of SMTP
Advantages of SMTP
If necessary, the users can have a dedicated server.
It allows for bulk mailing.
Low cost and wide coverage area.
Offer choices for email tracking.
Reliable and prompt email delivery.
Disadvantages of SMTP
SMTP’s common port can be blocked by several firewalls.
SMTP security is a bigger problem.
Its simplicity restricts how useful it can be.
Just 7-bit ASCII characters can be used.
If a message is longer than a certain length, SMTP servers may reject the entire message.
Delivering your message will typically involve additional back-and-forth processing between
servers, which will delay sending and raise the likelihood that it won’t be sent.
Pre-requisites: SMTP, HTTP
A network protocol is an accepted set of rules that govern data communication between different
devices in the network. In this article, we will see the difference between SMTP and HTTP
protocols.
SMTP
SMTP (Simple Mail Transfer Protocol) is a protocol for managing Internet’s electronic mail. It is
an application layer protocol. It uses TCP due to its reliable data transfer service. TCP
establishes SMTP connections at port 25. SMTP uses persistent connections. The same TCP
connection can be used to send multiple emails, once the connection has been established. Only
7-bit ASCII content is to be directly sent. Other content needs to be encoded to 7-bit ASCII and
then decoded at the receiving end.
DNS uses distributed servers so that data remains distributed in places and per server load
decreases. But SMTP never uses intermediate mail servers. Mail sent by user A to B will go
directly from A’s server to B’s server, and nowhere in between.
HTTP
HTTP is a client-server protocol. It is IP based communication protocol that is used to deliver
data from server to client or vice-versa. Any type of content can be exchanged as long as the
server and client are compatible with it.
Difference between SMTP and HTTP
SMTP HTTP
SMTP is used for mail services. HTTP is mainly used for data and file transfer.
It imposes a 7-bit ASCII restriction on the It does not impose a 7-bit ASCII restriction.
content to be transferred. Can transfer multimedia, hyperlinks, etc.
SMTP is a persistent type of TCP connection. It can use both Persistent and Non-persistent.
Does not support session management or Supports session management and cookies to
cookies. maintain state.
Has a smaller message size limit compared to Has a larger message size limit compared to
HTTP. SMTP.
Supports both plain text and encrypted Supports both plain text and encrypted
communication (SMTPS or STARTTLS). communication (HTTPS).
Domain Name System (DNS) is a hostname for IP address translation service. DNS is
a distributed database implemented in a hierarchy of name servers. It is an application layer
protocol for message exchange between clients and servers. It is required for the functioning of
the Internet.
What is the Need of DNS?
Every host is identified by the IP address but remembering numbers is very difficult for people
also the IP addresses are not static therefore a mapping is required to change the domain name to
the IP address. So DNS is used to convert the domain name of the websites to their numerical IP
address.
Types of Domain
There are various kinds of domain:
1. Generic domains: .com(commercial), .edu(educational), .mil(military), .org(nonprofit
organization), .net(similar to commercial) all these are generic domains.
2. Country domain: .in (India) .us .uk
3. Inverse domain: if we want to know what is the domain name of the website. Ip to domain
name mapping. So DNS can provide both the mapping for example to find the IP addresses
of geeksforgeeks.org then we have to type
nslookup www.geeksforgeeks.org
Types of DNS
Organization of Domain
It is very difficult to find out the IP address associated with a website because there are millions
of websites and with all those websites we should be able to generate the IP address
immediately, there should not be a lot of delays for that to happen organization of the database is
very important.
Name-to-Address Resolution
Hierarchy of Name Servers Root name servers: It is contacted by name servers that can
not resolve the name. It contacts the authoritative name server if name mapping is not
known. It then gets the mapping and returns the IP address to the host.
Top-level domain (TLD) server: It is responsible for com, org, edu, etc, and all top-level
country domains like uk, fr, ca, in, etc. They have info about authoritative domain servers
and know the names and IP addresses of each authoritative name server for the second-level
domains.
Authoritative name servers are the organization’s DNS servers, providing authoritative
hostnames to IP mapping for organization servers. It can be maintained by an organization or
service provider. In order to reach cse.dtu.in we have to ask the root DNS server, then it will
point out to the top-level domain server and then to the authoritative domain name server
which actually contains the IP address. So the authoritative domain server will return the
associative IP address.
Domain Name Server
The client machine sends a request to the local name server, which, if the root does not find the
address in its database, sends a request to the root name server, which in turn, will route the
query to a top-level domain (TLD) or authoritative name server. The root name server can also
contain some hostName to IP address mappings. The Top-level domain (TLD) server always
knows who the authoritative name server is. So finally the IP address is returned to the local
name server which in turn returns the IP address to the host.
Stores the DNS records for Looks up data from other DNS
Data Source
specific domains servers
DNS records (aka zone files) are instructions that live in authoritative DNS servers and provide
information about a domain including what IP address is associated with that domain and how to
handle requests for that domain. These records consist of a series of text files written in what is
known as DNS syntax. DNS syntax is just a string of characters used as commands that tell the
DNS server what to do. All DNS records also have a ‘TTL’, which stands for time-to-live, and
indicates how often a DNS server will refresh that record.
You can think of a set of DNS records like a business listing on Yelp. That listing will give you a
bunch of useful information about a business such as their location, hours, services offered, etc.
All domains are required to have at least a few essential DNS records for a user to be able to
access their website using a domain name, and there are several optional records that serve
additional purposes.
What are the most common types of DNS record?
A record - The record that holds the IP address of a domain. Learn more about the A
record.
AAAA record - The record that contains the IPv6 address for a domain (as opposed to
A records, which list the IPv4 address). Learn more about the AAAA record.
CNAME record - Forwards one domain or subdomain to another domain, does NOT
provide an IP address. Learn more about the CNAME record.
MX record - Directs mail to an email server. Learn more about the MX record.
TXT record - Lets an admin store text notes in the record. These records are often
used for email security. Learn more about the TXT record.
NS record - Stores the name server for a DNS entry. Learn more about the NS record.
SOA record - Stores admin information about a domain. Learn more about the SOA
record.
SRV record - Specifies a port for specific services. Learn more about the SRV record.
PTR record - Provides a domain name in reverse-lookups. Learn more about the PTR
record.