Unit 2 Application Layer
Unit 2 Application Layer
Types of Sockets: There are two types of Sockets: the datagram socket and the stream socket.
Datagram Socket: This is a type of network which has connection less point for sending and
receiving packets. It is similar to mailbox. The letters (data) posted into the box are collected and
delivered (transmitted) to a letterbox (receiving socket)
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 1
Unit 2 Application Layer
Sockets in computer networks are used for allowing the transmission of information between
two processes of the same machines or different machines in the network. The socket is the
combination of IP address and software port number used for communication between multiple
processes. Socket helps to recognize the address of the application to which data is to be sent
using the IP adder
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.
The transport layer takes services from the Network layer and provides services to the
Application 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 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.
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.
The transport layer is also responsible for creating the end-to-end Connection between hosts for
which it mainly uses TCP and UDP. TCP is a secure, connection-orientated protocol that uses a
handshake protocol to establish a robust connection between two end hosts. TCP ensures reliable
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 2
Unit 2 Application Layer
delivery of messages and is used in various applications. UDP, on the other hand, is a stateless
and unreliable protocol that ensures best-effort delivery. It is suitable for applications that have
little concern with flow or error control and requires sending the bulk of data like video
conferencing. It is often used in multicasting protocols.
Multiplexing(many to one) is when data is acquired from number of processes from the sender
and merged into one packet along with headers and sent as a single packet. Multiplexing allows
simultaneous use of different processes over a network that is running on a host. The processes
are differentiated by their port numbers. Similarly, Demultiplexing(one to many is required at the
receiver side when the message is distributed into different processes. Transport receives the
segments of data from the network layer distributes and delivers it to the appropriate process
running on the receiver’s machine.
Congestion Control:
Congestion is a situation in which too many sources over a network attempt to send data and the
router buffers start overflowing due to which loss of packets occur. As a result retransmission of
packets from the sources increases the congestion further. In this situation, the Transport layer
provides Congestion Control in different ways. It uses open loop congestion control to prevent
the congestion and closed-loop congestion control to remove the congestion in a network once it
occurred. TCP provides AIMD- additive increase multiplicative decrease, leaky bucket technique
for congestion control.
The transport layer checks for errors in the messages coming from the application layer by using
error detection codes, computing checksums, it checks whether the received data is not corrupted
and uses the ACK and NACK services to inform the sender if the data has arrived or not and
checks for the integrity of data.
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.
HTTP Protocol
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 3
Unit 2 Application Layer
The HTTP protocol can be used to transfer the data in the form of plain text, hypertext,
audio, video, and so on.
This protocol is known as HyperText Transfer Protocol because of its efficiency that
allows us to use in a hypertext environment where there are rapid jumps from one
document to another document.
HTTP is similar to the FTP as it also transfers the files from one host to another host. But,
HTTP is simpler than FTP as HTTP uses only one connection, i.e., no control connection
to transfer the files.
HTTP is used to carry the data in the form of MIME-like format.
HTTP is similar to SMTP as the data is transferred between client and server. The HTTP
differs from the SMTP in the way the messages are sent from the client to the server and
from server to the client. SMTP messages are stored and forwarded while HTTP
messages are delivered immediately.
Features of HTTP:
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 4
Unit 2 Application Layer
HTTP Transactions
The above figure shows the HTTP transaction between client and server. The client initiates a
transaction by sending a request message to the server. The server replies to the request message
by sending a response message.
Messages
Request Message: The request message is sent by the client that consists of a request line,
headers, and sometimes a body.
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 5
Unit 2 Application Layer
Response Message: The response message is sent by the server to the client that consists of a
status line, headers, and sometimes a body.
A client that wants to access the document in an internet needs an address and to facilitate the
access of documents, the HTTP uses the concept of Uniform Resource Locator (URL).
The Uniform Resource Locator (URL) is a standard way of specifying any kind of information on
the internet.
The URL defines four parts: method, host computer, port, and path.
SMTP Protocol
SMTP is an application layer protocol. The client who wants to send the mail opens a TCP
connection to the SMTP server and then sends the mail across the connection. The SMTP server
is an always-on listening mode. As soon as it listens for a TCP connection from any client, the
SMTP process initiates a connection through port 25. After successfully establishing a TCP
connection the client process sends the mail instantly.
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 6
Unit 2 Application Layer
1. User-agent (UA)
2. Local MTA
SENDINGE MAIL:
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 as the
body of the message, which is a sequence of ASCII characters. The message body
contains the actual information read by the receipt.
RECEIVING EMAIL:
The user agent at 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.
Advantages of SMTP:
Disadvantages of SMTP:
POP Protocol
The POP protocol stands for Post Office Protocol. As we know that SMTP is used as a
message transfer agent. When the message is sent, then SMPT is used to deliver the
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 7
Unit 2 Application Layer
message from the client to the server and then to the recipient server. But the message is
sent from the recipient server to the actual server with the help of the Message Access
Agent. The Message Access Agent contains two types of protocols, i.e., POP3 and
IMAP.
Suppose sender wants to send the mail to receiver. First mail is transmitted to the sender's
mail server. Then, the mail is transmitted from the sender's mail server to the receiver's
mail server over the internet. On receiving the mail at the receiver's mail server, the mail
is then sent to the user. The whole process is done with the help of Email protocols. The
transmission of mail from the sender to the sender's mail server and then to the receiver's
mail server is done with the help of the SMTP protocol. At the receiver's mail server, the
POP or IMAP protocol takes the data and transmits to the actual user.
Since SMTP is a push protocol so it pushes the message from the client to the server. As we can
observe in the above figure that SMTP pushes the message from the client to the recipient's mail
server. The third stage of email communication requires a pull protocol, and POP is a pull
protocol. When the mail is transmitted from the recipient mail server to the client which mean
that the client is pulling the mail from the server.
To establish the connection between the POP3 server and the POP3 client, the POP3
server asks for the user name to the POP3 client. If the username is found in the POP3
server, then it sends the ok message. It then asks for the password from the POP3 client;
then the POP3 client sends the password to the POP3 server. If the password is matched,
then the POP3 server sends the OK message, and the connection gets established. After
the establishment of a connection, the client can see the list of mails on the POP3 mail
server. In the list of mails, the user will get the email numbers and sizes from the server.
Out of this list, the user can start the retrieval of mail.
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 8
Unit 2 Application Layer
It allows the users to read the email offline. It requires an internet connection only at the
time of downloading emails from the server. Once the mails are downloaded from the
server, then all the downloaded mails reside on our PC or hard disk of our computer,
which can be accessed without the internet. Therefore, we can say that the POP3 protocol
does not require permanent internet connectivity.
It provides easy and fast access to the emails as they are already stored on our PC.
There is no limit on the size of the email which we receive or send.
It requires less server storage space as all the mails are stored on the local machine.
There is maximum size on the mailbox, but it is limited by the size of the hard disk.
It is a simple protocol so it is one of the most popular protocols used today.
It is easy to configure and use.
Disadvantages of POP
If the emails are downloaded from the server, then all the mails are deleted from the
server by default. So, mails cannot be accessed from other machines unless they are
configured to leave a copy of the mail on the server.
Transferring the mail folder from the local machine to another machine can be difficult.
Since all the attachments are stored on your local machine, there is a high risk of a virus
attack if the virus scanner does not scan them. The virus attack can harm the computer.
The email folder which is downloaded from the mail server can also become corrupted.
The mails are stored on the local machine, so anyone who sits on your machine can
access the email folder.
FTP Protocol
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 9
Unit 2 Application Layer
Objectives of FTP
Why FTP?
Although transferring files from one system to another is very simple and straightforward, but
sometimes it can cause problems. For example, two systems may have different file conventions.
Two systems may have different ways to represent text and data. Two systems may have
different directory structures. FTP protocol overcomes these problems by establishing two
connections between hosts. One connection is used for data transfer, and another connection is
used for the control connection.
Control Connection: The control connection uses very simple rules for communication.
Through control connection, we can transfer a line of command or line of response at a
time. The control connection is made between the control processes. The control
connection remains connected during the entire interactive FTP session.
Data Connection: The Data Connection uses very complex rules as data types may vary.
The data connection is made between data transfer processes. The data connection opens
when a command comes for transferring the files and closes when the file is transferred.
FTP Clients
FTP client is a program that implements a file transfer protocol which allows you to transfer files
between two hosts on the internet.
It allows a user to connect to a remote host and upload or download the files.
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 10
Unit 2 Application Layer
It has a set of commands that we can use to connect to a host, transfer the files between you
and your host and close the connection.
The FTP program is also available as a built-in component in a Web browser. This GUI based FTP
client makes the file transfer very easy and also does not require to remember the FTP
commands.
Advantages of FTP:
Speed: One of the biggest advantages of FTP is speed. The FTP is one of the fastest way
to transfer the files from one computer to another computer.
Efficient: It is more efficient as we do not need to complete all the operations to get the
entire file.
Security: To access the FTP server, we need to login with the username and password.
Therefore, we can say that FTP is more secure.
Back & forth movement: FTP allows us to transfer the files back and forth. Suppose
you are a manager of the company, you send some information to all the employees, and
they all send information back on the same server.
Disadvantages of FTP:
The standard requirement of the industry is that all the FTP transmissions should be
encrypted. However, not all the FTP providers are equal and not all the providers offer
encryption. So, we will have to look out for the FTP providers that provides encryption.
FTP serves two operations, i.e., to send and receive large files on a network. However,
the size limit of the file is 2GB that can be sent. It also doesn't allow you to run
simultaneous transfers to multiple receivers.
Passwords and file contents are sent in clear text that allows unwanted eavesdropping.
So, it is quite possible that attackers can carry out the brute force attack by trying to guess
the FTP password.
It is not compatible with every system
DNS Protocol
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 11
Unit 2 Application Layer
Each node in a tree has a domain name, and a full domain name is a sequence of symbols
specified by dots.
DNS is a service that translates the domain name into IP addresses. This allows the users
of networks to utilize user-friendly names when looking for other hosts instead of
remembering the IP addresses.
For example, suppose the FTP site at EduSoft had an IP address of 132.147.165.50, most
people would reach this site by specifying ftp.EduSoft.com. Therefore, the domain name
is more reliable than IP address.
DNS is a TCP/IP protocol used on different platforms. The domain name space is divided into three
different sections: generic domains, country domains, and inverse domain.
Generic Domains
Country Domain
The format of country domain is same as a generic domain, but it uses two-character country
abbreviations (e.g., us for the United States) in place of three character organizational
abbreviations.
Inverse Domain
The inverse domain is used for mapping an address to a name. When the server has received a
request from the client, and the server contains the files of only authorized clients. To determine
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 12
Unit 2 Application Layer
whether the client is on the authorized list or not, it sends a query to the DNS server and ask for
mapping an address to the name.
Working of DNS
TELNET
TELNET stands for Teletype Network. It is a type of protocol that enables one computer to
connect to local computer. It used as a standard TCP/IP protocol for virtual terminal service
which is provided by ISO. The computer which starts the connection is known as the local
computer. The computer which is being connected to i.e. which accepts the connection known
as the remote computer. During telnet operation, whatever is being performed on the remote
computer will be displayed by the local computer. Telnet operates on client/server principle. The
local computer uses telnet client program and the remote computers uses telnet server program.
Default Mode :
Character Mode :
Line Mode :
Line editing like echoing, character erasing etc. is done from the client side.
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 13
Unit 2 Application Layer
A peer-to-peer network is a simple network of computers. It first came into existence in the
late 1970s. Here each computer acts as a node for file sharing within the formed network. Here
each node acts as a server and thus there is no central server in the network. This allows the
sharing of a huge amount of data. The tasks are equally divided amongst the nodes. Each node
connected in the network shares an equal workload. For the network to stop working, all the
nodes need to individually stop working. This is because each node works independently.
These networks do not involve a large number of nodes, usually less than 12. All the
computers in the network store their own data but this data is accessible by the group.
Unlike client-server networks, P2P uses resources and also provides them. This results in
additional resources if the number of nodes increases. It requires specialized software. It
allows resource sharing among the network.
Since the nodes act as clients and servers, there is a constant threat of attack.
Almost all OS today support P2P networks.
Each computer in the network has the same set of responsibilities and capabilities.
Each device in the network serves as both a client and server.
The architecture is useful in residential areas, small offices, or small companies where
each computer act as an independent workstation and stores the data on its hard drive.
Each computer in the network has the ability to share data with other computers in the
network.
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 14
Unit 2 Application Layer
If the peer-to-peer software is not already installed, then the user first has to install the
peer-to-peer software on his computer.
This creates a virtual network of peer-to-peer application users.
The user then downloads the file, which is received in bits that come from multiple
computers in the network that have already that file.
The data is also sent from the user’s computer to other computers in the network that ask
for the data that exist on the user’s computer.
Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 15