0% found this document useful (0 votes)
64 views15 pages

Unit 2 Application Layer

The document summarizes key concepts in the application layer including socket programming, transport layer protocols like HTTP, SMTP, FTP, and DNS. It describes sockets as endpoints for communication between processes, and types of sockets like datagram and stream. It provides an overview of HTTP including its connectionless and stateless nature, and support for different media types. Transport layer responsibilities like process-to-process delivery, end-to-end connections, multiplexing, error handling, and flow control are also summarized.

Uploaded by

PRATHAM DHARMANI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
64 views15 pages

Unit 2 Application Layer

The document summarizes key concepts in the application layer including socket programming, transport layer protocols like HTTP, SMTP, FTP, and DNS. It describes sockets as endpoints for communication between processes, and types of sockets like datagram and stream. It provides an overview of HTTP including its connectionless and stateless nature, and support for different media types. Transport layer responsibilities like process-to-process delivery, end-to-end connections, multiplexing, error handling, and flow control are also summarized.

Uploaded by

PRATHAM DHARMANI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 15

Unit 2 Application Layer

Application Layer: Basics of Socket Programming, Transport layer


applications,Protocols HTTP(overview,Persistant & non Persistant,Message
Format),SMTP(Overview,MessageFormat),FTP,Telnet,DNS,POP,IMAP,Peer-to-
Peer Applications.

Basics of Socket Programming:

A socket is one endpoint of a two way communication link between two


programs running on the network. The socket mechanism provides a means of
inter-process communication (IPC) by establishing named contact points between
which the communication takes place. Like ‘Pipe’ is used to create pipes and sockets is
created using ‘socket’ system call. The socket provides bidirectional FIFO Communication
facility over the network. A socket connecting to the network is created at each end of the
communication. Each socket has a specific address. This address is composed of an IP address
and a port number. Socket is generally employed in client server applications. The server creates
a socket, attaches it to a network port addresses then waits for the client to contact it. The client
creates a socket and then attempts to connect to the server socket. When the connection is
established, transfer of data takes place.

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)

Stream Socket In Computer operating system, a stream socket is type of intercrosses


communications socket or network socket which provides a connection-oriented, sequenced, and
unique flow of data without record boundaries with well-defined mechanisms for creating and
destroying connections and for detecting errors. It is similar to phone. A connection is
established between the phones (two ends) and a conversation (transfer of data) takes place.

unction Call Description


Socket() To create a socket
Bind() It’s a socket identification like a telephone number to contact
Listen() Ready to receive a connection
Connect() Ready to act as a sender
Accept() Confirmation, it is like accepting to receive a call from a sender
Write() To send data
Read() To receive data
Close() To close a connection

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 applications

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

Responsibilities of a Transport Layer:

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.

End-to-end Connection between hosts:

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 and Demultiplexing:

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.

integrity and Error correction:

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

 HTTP stands for HyperText Transfer Protocol.


 It is a protocol used to access the data on the World Wide Web (www).

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:

 Connectionless protocol: HTTP is a connectionless protocol. HTTP client initiates a


request and waits for a response from the server. When the server receives the request,
the server processes the request and sends back the response to the HTTP client after
which the client disconnects the connection. The connection between client and server
exist only during the current request and response time only.
 Media independent: HTTP protocol is a media independent as data can be sent as long
as both the client and server know how to handle the data content. It is required for both
the client and server to specify the content type in MIME-type header.
 Stateless: HTTP is a stateless protocol as both the client and server know each other only
during the current request. Due to this nature of the protocol, both the client and server do
not retain the information between various requests of the web pages.

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.

Uniform Resource Locator (URL)

 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

Both the SMTP-client and SMTP-server should have 2 components:

1. User-agent (UA)
2. Local MTA

Communication between 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
mails, a system must have a client MTA, and to receive mails, a system must have a
server 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:

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

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

Advantages of POP3 protocol

The following are the advantages of a POP3 protocol:

 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

 FTP stands for File transfer protocol.


 FTP is a standard internet protocol provided by TCP/IP used for transmitting the files from one
host to another.
 It is mainly used for transferring the web page files from their creator to the computer that acts
as a server for other computers on the internet.
 It is also used for downloading the files to computer from other servers.

Kavita A Kathane
Dept of CSE ,YCCE Nagpur Page 9
Unit 2 Application Layer

Objectives of FTP

 It provides the sharing of files.


 It is used to encourage the use of remote computers.
 It transfers the data more reliably and efficiently.

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.

There are two types of connections in FTP:

 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

 DNS stands for Domain Name System.


 DNS is a directory service that provides a mapping between the name of a host on the
network and its numerical address.
 DNS is required for the functioning of the internet.

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

 It defines the registered hosts according to their generic behavior.


 Each node in a tree defines the domain name, which is an index to the DNS database.
 It uses three-character labels, and these labels describe the organization type.

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

 DNS is a client/server network communication protocol. DNS clients send requests to


the. server while DNS servers send responses to the client.
 Client requests contain a name which is converted into an IP address known as a forward
DNS lookups while requests containing an IP address which is converted into a name
known as reverse DNS lookups.
 DNS implements a distributed database to store the name of all the hosts available on the
internet.
 If a client like a web browser sends a request containing a hostname, then a piece of
software such as DNS resolver sends a request to the DNS server to obtain the IP address
of a hostname. If DNS server does not contain the IP address associated with a hostname,
then it forwards the request to another DNS server. If IP address has arrived at the
resolver, which in turn completes the request over the internet protocol.

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 :

 If no other modes are invoked then this mode is used.


 Echoing is performed in this mode by the client.
 In this mode, user types a character and client echoes the character on the screen but it
does not send it until whole line is completed.

Character Mode :

 Each character typed in this mode is sent by client to server.


 Server in this type of mode is normally echoes character back to be displayed on the
client’s screen.

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

 Client will send the whole line to the server.

Peer to peer applications

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.

Peer to Peer 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

You might also like